@@ -967,7 +967,7 @@ layout(location = 0) out vec4 diffuse_buffer; //diffuse (rgb) and roughness
967967layout (location = 1 ) out vec4 specular_buffer; // specular and SSS (subsurface scatter)
968968#else
969969
970- layout (location = 0 ) out hvec4 frag_color;
970+ layout (location = 0 ) out vec4 frag_color;
971971#endif // MODE_MULTIPLE_RENDER_TARGETS
972972
973973#endif // RENDER DEPTH
@@ -1481,9 +1481,11 @@ void main() {
14811481#ifdef NORMAL_USED
14821482 if (sc_scene_roughness_limiter_enabled()) {
14831483 // https://www.jp.square-enix.com/tech/library/pdf/ImprovedGeometricSpecularAA.pdf
1484+ // SPIR-V Validation claims that derivatives of FP16 vectors are not valid code generation (see #108009).
1485+ vec3 dn = vec3 (normal);
1486+ vec3 dndu = dFdx (dn), dndv = dFdy (dn);
14841487 half roughness2 = roughness * roughness;
1485- hvec3 dndu = dFdx (normal), dndv = dFdy (normal);
1486- half variance = half(scene_data.roughness_limiter_amount) * (dot (dndu, dndu) + dot (dndv, dndv));
1488+ half variance = half(scene_data.roughness_limiter_amount) * half(dot (dndu, dndu) + dot (dndv, dndv));
14871489 half kernelRoughness2 = min (half(2.0 ) * variance, half(scene_data.roughness_limiter_limit));
14881490 half filteredRoughness2 = min (half(1.0 ), roughness2 + kernelRoughness2);
14891491 roughness = sqrt (filteredRoughness2);
@@ -2182,23 +2184,25 @@ void main() {
21822184#else // MODE_MULTIPLE_RENDER_TARGETS
21832185
21842186#ifdef MODE_UNSHADED
2185- frag_color = hvec4(albedo, alpha);
2187+ hvec4 out_color = hvec4(albedo, alpha);
21862188#else // MODE_UNSHADED
2187- frag_color = hvec4(emission + ambient_light + diffuse_light + direct_specular_light + indirect_specular_light, alpha);
2189+ hvec4 out_color = hvec4(emission + ambient_light + diffuse_light + direct_specular_light + indirect_specular_light, alpha);
21882190#endif // MODE_UNSHADED
21892191
21902192#ifndef FOG_DISABLED
21912193 // Draw "fixed" fog before volumetric fog to ensure volumetric fog can appear in front of the sky.
2192- frag_color .rgb = mix (frag_color .rgb, fog.rgb, fog.a);
2194+ out_color .rgb = mix (out_color .rgb, fog.rgb, fog.a);
21932195#endif // !FOG_DISABLED
21942196
21952197 // On mobile we use a UNORM buffer with 10bpp which results in a range from 0.0 - 1.0 resulting in HDR breaking
21962198 // We divide by sc_luminance_multiplier to support a range from 0.0 - 2.0 both increasing precision on bright and darker images
2197- frag_color .rgb = frag_color .rgb / sc_luminance_multiplier();
2199+ out_color .rgb = out_color .rgb / sc_luminance_multiplier();
21982200#ifdef PREMUL_ALPHA_USED
2199- frag_color .rgb *= premul_alpha;
2201+ out_color .rgb *= premul_alpha;
22002202#endif
22012203
2204+ frag_color = out_color;
2205+
22022206#endif // MODE_MULTIPLE_RENDER_TARGETS
22032207
22042208#endif // MODE_RENDER_DEPTH
@@ -2207,10 +2211,10 @@ void main() {
22072211 // These motion vectors are in NDC space (as opposed to screen space) to fit the OpenXR XR_FB_space_warp specification.
22082212 // https://registry.khronos.org/OpenXR/specs/1.0/html/xrspec.html#XR_FB_space_warp
22092213
2210- hvec3 ndc = hvec3( screen_position.xyz / screen_position.w) ;
2214+ vec3 ndc = screen_position.xyz / screen_position.w;
22112215 ndc.y = - ndc.y;
2212- hvec3 prev_ndc = hvec3( prev_screen_position.xyz / prev_screen_position.w) ;
2216+ vec3 prev_ndc = prev_screen_position.xyz / prev_screen_position.w;
22132217 prev_ndc.y = - prev_ndc.y;
2214- frag_color = hvec4 (ndc - prev_ndc, half( 0.0 ) );
2218+ frag_color = vec4 (ndc - prev_ndc, 0.0 );
22152219#endif
22162220}
0 commit comments