This commit is contained in:
owner committed 2026-03-15 22:03:30 -04:00
1 parent cea633d5ba
commit 6eca497b1f
16 files changed
+649

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
# VR Model Viewer configuration
# Lines starting with # are comments.
[ui]
# Path to a TTF/OTF font file with CJK coverage.
# Kochi Gothic is a good choice on Gentoo:
# /usr/share/fonts/kochi-substitute/kochi-gothic-subst.ttf
# Leave blank to use ImGui's built-in ASCII-only font.
font_path = /usr/share/fonts/kochi-substitute/kochi-gothic-subst.ttf
# Font size in pixels
font_size = 14
# Starting width of the morph panel in pixels
panel_width = 380
[model]
# Initial scale applied to the loaded model.
# FBX exports from Blender are often 100x too large (cm vs m units).
# Try 0.01 if your model appears huge, 1.0 if it looks correct.
scale = 0.01
+37
View File
@@ -0,0 +1,37 @@
#version 130
varying vec3 v_normalVS;
varying vec3 v_posVS;
varying vec2 v_uv;
varying vec4 v_color;
uniform sampler2D osg_Sampler0;
uniform bool u_hasTexture;
uniform vec3 u_lightDirVS;
uniform vec3 u_lightColor;
uniform vec3 u_ambientColor;
uniform int u_bands;
uniform float u_bandSharpness;
float celQuantise(float value, int bands) {
float b = float(bands);
return floor(value * b + 0.5) / b;
}
void main() {
vec3 N = normalize(v_normalVS);
vec3 L = normalize(u_lightDirVS);
// Half-lambert so shadows aren't pitch black
float NdL = dot(N, L) * 0.5 + 0.5;
float celVal = celQuantise(NdL, u_bands);
vec4 baseColor = u_hasTexture
? texture2D(osg_Sampler0, v_uv)
: v_color;
vec3 diffuse = baseColor.rgb * u_lightColor * celVal;
vec3 ambient = baseColor.rgb * u_ambientColor;
gl_FragColor = vec4(ambient + diffuse, baseColor.a);
}
+19
View File
@@ -0,0 +1,19 @@
#version 130
// OSG binds these automatically via Program::addBindAttribLocation
// or via the fixed-function compatibility aliases in core profile.
// Using built-in compatibility varyings is the safest approach with OSG 3.6.
varying vec3 v_normalVS;
varying vec3 v_posVS;
varying vec2 v_uv;
varying vec4 v_color;
void main() {
vec4 posVS = gl_ModelViewMatrix * gl_Vertex;
v_posVS = posVS.xyz;
v_normalVS = normalize(gl_NormalMatrix * gl_Normal);
v_uv = gl_MultiTexCoord0.xy;
v_color = gl_Color;
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}
+56
View File
@@ -0,0 +1,56 @@
#version 130
varying vec3 v_normalVS;
varying vec3 v_posVS;
varying vec2 v_uv;
varying vec4 v_color;
uniform sampler2D osg_Sampler0;
uniform bool u_hasTexture;
uniform vec3 u_lightDirVS;
uniform vec3 u_lightColor;
uniform vec3 u_ambientColor;
uniform vec3 u_outlineColor;
uniform bool u_outlinePass;
uniform int u_bands;
uniform float u_specularThreshold;
uniform float u_specularIntensity;
uniform float u_rimThreshold;
uniform float u_rimIntensity;
uniform vec3 u_rimColor;
float celStep(float value, int bands) {
return floor(value * float(bands) + 0.5) / float(bands);
}
void main() {
if (u_outlinePass) {
gl_FragColor = vec4(u_outlineColor, 1.0);
return;
}
vec3 N = normalize(v_normalVS);
vec3 L = normalize(u_lightDirVS);
vec3 V = normalize(-v_posVS);
// Cel diffuse
float NdL = dot(N, L) * 0.5 + 0.5;
float celDif = celStep(NdL, u_bands);
// Snap specular
vec3 H = normalize(L + V);
float NdH = max(dot(N, H), 0.0);
float spec = step(u_specularThreshold, NdH) * u_specularIntensity;
// Rim light
float rim = 1.0 - max(dot(N, V), 0.0);
rim = step(u_rimThreshold, rim) * u_rimIntensity;
vec4 base = u_hasTexture ? texture2D(osg_Sampler0, v_uv) : v_color;
vec3 ambient = base.rgb * u_ambientColor;
vec3 diffuse = base.rgb * u_lightColor * celDif;
vec3 specCol = u_lightColor * spec;
vec3 rimCol = u_rimColor * rim;
gl_FragColor = vec4(ambient + diffuse + specCol + rimCol, base.a);
}
+25
View File
@@ -0,0 +1,25 @@
#version 130
uniform bool u_outlinePass;
uniform float u_outlineWidth;
varying vec3 v_normalVS;
varying vec3 v_posVS;
varying vec2 v_uv;
varying vec4 v_color;
void main() {
vec3 pos = gl_Vertex.xyz;
if (u_outlinePass) {
pos += gl_Normal * u_outlineWidth;
}
vec4 posVS = gl_ModelViewMatrix * vec4(pos, 1.0);
v_posVS = posVS.xyz;
v_normalVS = normalize(gl_NormalMatrix * gl_Normal);
v_uv = gl_MultiTexCoord0.xy;
v_color = gl_Color;
gl_Position = gl_ModelViewProjectionMatrix * vec4(pos, 1.0);
}