Phase 4.2: match grass blade colors to voxel faces + stronger translucency

Use same ambient (0.15, 0.18, 0.25) as voxel PS instead of greener
tint. Increase translucency (0.6) to reduce contrast when orbiting
around grass. Wrap at 0.85 for balanced lit-side brightness.
This commit is contained in:
Samuel Bouchet 2026-03-26 19:07:04 +01:00
parent 9086a794a8
commit 36b8de9285

View file

@ -53,17 +53,18 @@ float4 main(PSInput input) : SV_TARGET0 {
float wrap = halfLambert * halfLambert; // squared for falloff shape
// Translucency: thin blades let light through from behind
// Simple SSS approximation: light arriving from the back side
// Stronger effect to reduce contrast when orbiting around grass
float3 V = normalize(cameraPosition.xyz - input.worldPos);
float backLight = saturate(dot(V, L)); // view aligned with light = backlit
float transAmount = (1.0 - saturate(rawNdotL)) * 0.4; // stronger when facing away from light
float backLight = saturate(dot(V, L));
float transAmount = (1.0 - saturate(rawNdotL)) * 0.8;
float translucency = backLight * transAmount;
// Warm vegetation ambient (higher than stone, slightly green-tinted)
float3 vegAmbient = float3(0.22, 0.28, 0.20);
// Same ambient as voxel faces for color consistency
float3 ambient = float3(0.15, 0.18, 0.25);
float3 diffuse = sunColor.rgb * (wrap * 0.7 + translucency * 0.5);
lit = texColor * (diffuse + vegAmbient);
// Wrap + strong translucency to minimize light/dark contrast
float3 diffuse = sunColor.rgb * (wrap * 0.85 + translucency * 0.6);
lit = texColor * (diffuse + ambient);
}
return float4(lit, 1.0);