gltf_factors reads pbrMetallicRoughness.baseColorFactor, metallicFactor, roughnessFactor and the emissiveFactor into the primitive (pr.fac), and prim_factors hands them to every program that draws its textures (actors, the scatter's meshes and levels, the impostor bake) as 1 - factor, so a program never given them - or a material that gives none (pr.fac null) - multiplies by 1 and draws as before. An untextured material with a colour (or a metal/roughness) samples a pure white for it, so the factor is exactly what it draws: horse_cornea is its own colour, not the 200 grey every untextured part had. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
30 lines
1.2 KiB
GLSL
30 lines
1.2 KiB
GLSL
// impostor bake: albedo + coverage, and the model-frame normal
|
|
in vec3 v_wpos;
|
|
in vec3 v_nrm;
|
|
in vec2 v_uv;
|
|
in float v_seed;
|
|
layout(location = 0) out vec4 o_albedo;
|
|
layout(location = 1) out vec4 o_normal;
|
|
uniform sampler2D u_diff;
|
|
uniform vec4 u_fac_base_inv; // a glTF material's base colour factor, as 1 - factor
|
|
uniform sampler2D u_arm;
|
|
void main() {
|
|
vec4 d = texture(u_diff, v_uv) * (vec4(1.0) - u_fac_base_inv);
|
|
if (d.a < 0.5) discard; // cut-out cards (needles, blades, leaves) bake with their shape
|
|
vec3 N = normalize(v_nrm);
|
|
if (!gl_FrontFacing) N = -N;
|
|
#ifdef FLOWER
|
|
float vy = clamp(v_uv.y, 0.0, 1.0);
|
|
if (v_uv.x >= 2.0) d.rgb = vec3(0.035, 0.09, 0.02) * (0.7 + 0.6 * vy);
|
|
else if (v_uv.x >= 1.0) {
|
|
float f = fract(v_uv.x);
|
|
vec3 violet = vec3(0.06, 0.03, 0.3);
|
|
vec3 lip = vec3(0.4, 0.3, 0.68);
|
|
// each floret: a dark keel at the base, a pale standard at the top edge
|
|
d.rgb = mix(violet, lip, smoothstep(0.35, 1.0, vy) * 0.6 + 0.25 * smoothstep(0.3, 0.0, abs(f - 0.5)));
|
|
d.rgb *= 0.85 + 0.15 * vy;
|
|
} else d.rgb = vec3(0.08, 0.17, 0.03);
|
|
#endif
|
|
o_albedo = vec4(d.rgb, 1.0);
|
|
o_normal = vec4(N * 0.5 + 0.5, texture(u_arm, v_uv).r);
|
|
}
|