how do i fix - Shader warning in 'Hidden/SSAO' error message?

Hi there

I just recently came across this issue which is preventing me from playing my scene.

{ Shader warning in ‘Hidden/SSAO’: ‘s’: loop control variable conflicts with a previous declaration in the outer scope; most recent declaration will be used at line 228 (on d3d11)

Compiling Vertex program }

I have never heard of seen this before and I cannot find anything online.

Does anyone know a way around this?

I would be very grateful for any help…

Thanks

Ben,

i would like to know that too.

Basically the problem is that it thinks the shader is redeclaring ‘s’ because it’s declared twice like so:

    for (int s = 0; s < NUM_BLUR_SAMPLES; ++s) // declared once
    {
        float2 nuv = i.uv + o * (s+1);
        half4 ngeom = tex2D (_CameraDepthNormalsTexture, nuv.xy);
        half coef = (NUM_BLUR_SAMPLES - s) * CheckSame (geom, ngeom);
        sum += tex2D (_SSAO, nuv.xy).r * coef;
        denom += coef;
    }
    for (int s = 0; s < NUM_BLUR_SAMPLES; ++s) // declared twice
    {
        float2 nuv = i.uv - o * (s+1);
        half4 ngeom = tex2D (_CameraDepthNormalsTexture, nuv.xy);
        half coef = (NUM_BLUR_SAMPLES - s) * CheckSame (geom, ngeom);
        sum += tex2D (_SSAO, nuv.xy).r * coef;
        denom += coef;
    }

If you change it so you don’t declare ‘s’ twice like the following, then it will know that you mean to used the same variable but reset it to 0 each time.

    int s = 0; // only declared once
    for (s = 0; s < NUM_BLUR_SAMPLES; ++s)
    {
        float2 nuv = i.uv + o * (s+1);
        half4 ngeom = tex2D (_CameraDepthNormalsTexture, nuv.xy);
        half coef = (NUM_BLUR_SAMPLES - s) * CheckSame (geom, ngeom);
        sum += tex2D (_SSAO, nuv.xy).r * coef;
        denom += coef;
    }
    for (s = 0; s < NUM_BLUR_SAMPLES; ++s)
    {
        float2 nuv = i.uv - o * (s+1);
        half4 ngeom = tex2D (_CameraDepthNormalsTexture, nuv.xy);
        half coef = (NUM_BLUR_SAMPLES - s) * CheckSame (geom, ngeom);
        sum += tex2D (_SSAO, nuv.xy).r * coef;
        denom += coef;
    }

Really it should be fixed in the source asset. Is there a bug that someone has filed that we can suggest a fix?

1 Like

[código = CSharp] int _LastMip;

float4 fragMin (v2f i): SV_Target
{
float2 tsP = i.uv2.xy;
float2 lastTexSize = mipToSize (_LastMip);
float2 lastTexSizeInv = 1.0 / lastTexSize;
float2 p00 = snapToTexelCenter (tsP, lastTexSize, lastTexSizeInv);
float2 p11 = p00 + lastTexSizeInv;

retorno min
min (tex2D (_MainTex, p00), tex2D (_MainTex, p11)),
min (tex2D (_MainTex, float2 (p00.x, p11.y)), tex2D (_MainTex, float2 (p11.x, p00.y)))
);
}

float4 fragResolveHitPoints (v2f i): SV_Target
{
float2 tsP = i.uv2.xy;
float4 temp = tex2D (_HitPointTexture, tsP);
float2 hitPoint = temp.xy;
confianza flotante = temp.w;
float3 colorResult = confianza> 0.0? tex2D (_MainTex, hitPoint) .rgb: tex2D (_CameraReflectionsTexture, tsP) .rgb;

si (cualquiera (isnan (colorResult)))
colorResult = float3 (0.0, 0.0, 0.0);

// A partir del 29/11/2015, en Unity 5.3 en una computadora con Windows 8.1 con NVIDIA GeForce 980,
// con el controlador 347.62, la comprobación anterior no funciona para deshacerse de los NaN.
// Entonces agregamos esta verificación “redundante”.
if (! all (isfinite (colorResult)))
colorResult = float3 (0.0, 0.0, 0.0);

return float4 (colorResult, confianza);
}

float4 fragBilatKeyPack (v2f i): SV_Target
{
float2 tsP = i.uv2.xy;
float3 csN = tex2D (_CameraGBufferTexture2, tsP) .xyz;
rugosidad flotante = tex2D (_CameraGBufferTexture1, tsP) .a;
return float4 (csN, rugosidad);
}

float4 fragDepthToCSZ (v2f i): SV_Target
{
profundidad de flotación = SAMPLE_DEPTH_TEXTURE (_CameraDepthTexture, i.uv2.xy);
return float4 (-LinearEyeDepth (profundidad), 0.0, 0.0, 0.0);

Tengo problemas con este lineas de codigo me podrian ayudar me sale esto ?
Shader warning in ‘Hidden/Post FX/Screen Space Reflection’: value cannot be NaN, isnan() may not be necessary. /Gis may force isnan() to be performed at line 753 (on d3d11)

Compiling Fragment program
Platform defines: SHADER_API_DESKTOP UNITY_COLORSPACE_GAMMA UNITY_ENABLE_DETAIL_NORMALMAP UNITY_ENABLE_REFLECTION_BUFFERS UNITY_LIGHTMAP_FULL_HDR UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BLENDING UNITY_SPECCUBE_BOX_PROJECTION UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS
Disabled keywords: SHADER_API_GLES30 UNITY_ASTC_NORMALMAP_ENCODING UNITY_ENABLE_NATIVE_SHADOW_LOOKUPS UNITY_HALF_PRECISION_FRAGMENT_SHADER_REGISTERS UNITY_HARDWARE_TIER1 UNITY_HARDWARE_TIER2 UNITY_HARDWARE_TIER3 UNITY_LIGHTMAP_DLDR_ENCODING UNITY_LIGHTMAP_RGBM_ENCODING UNITY_METAL_SHADOWS_USE_POINT_FILTERING UNITY_NO_DXT5nm UNITY_NO_FULL_STANDARD_SHADER UNITY_NO_SCREENSPACE_SHADOWS UNITY_PBS_USE_BRDF2 UNITY_PBS_USE_BRDF3 UNITY_PRETRANSFORM_TO_DISPLAY_ORIENTATION UNITY_VIRTUAL_TEXTURING