diff --git a/Assets/Shaders/DeferredComposite_CS.glsl b/Assets/Shaders/DeferredComposite_CS.glsl index 833180e7..5af585ba 100644 --- a/Assets/Shaders/DeferredComposite_CS.glsl +++ b/Assets/Shaders/DeferredComposite_CS.glsl @@ -57,25 +57,34 @@ void main() // normal of fragment vec3 normalView = imageLoad(normals, globalThread).rgb; + // light layer index + uint lightLayer = imageLoad (lightLayerData, globalThread).r; + vec3 fragColor = vec3 (0.0f); for (int i = 0; i < lightCounts.directionalLights; ++i) { - // get normalized direction of light - vec3 dLightNormalized = normalize (DirLightData.dLightData[i].direction); + if ((lightLayer & DirLightData.dLightData[i].cullingMask) != 0) + { + // get normalized direction of light + vec3 dLightNormalized = normalize (DirLightData.dLightData[i].direction); - // Get diffuse strength - float diffuseStrength = max (0, dot (dLightNormalized, normalView)); + // Get diffuse strength + float diffuseStrength = max (0, dot (dLightNormalized, normalView)); - // Calculate the fragment color - fragColor += DirLightData.dLightData[i].diffuseColor.rgb * diffuseStrength.rrr * pixelDiffuse; + // Calculate the fragment color + fragColor += DirLightData.dLightData[i].diffuseColor.rgb * diffuseStrength.rrr * pixelDiffuse; + } } for (int i = 0; i < lightCounts.ambientLights; ++i) { - // Just do some add - //fragColor += pixelDiffuse.rgb * AmbLightData.aLightData[i].ambientColor.rgb * vec3 (0.5f); - fragColor += pixelDiffuse.rgb * AmbLightData.aLightData[i].ambientColor.rgb * vec3 (AmbLightData.aLightData[i].strength); + if ((lightLayer & AmbLightData.aLightData[i].cullingMask) != 0) + { + // Just do some add + //fragColor += pixelDiffuse.rgb * AmbLightData.aLightData[i].ambientColor.rgb * vec3 (0.5f); + fragColor += pixelDiffuse.rgb * AmbLightData.aLightData[i].ambientColor.rgb * vec3 (AmbLightData.aLightData[i].strength); + } } float ssaoVal = imageLoad (ssaoBlurredImage, globalThread).r; diff --git a/Assets/Shaders/DeferredComposite_CS.shshaderb b/Assets/Shaders/DeferredComposite_CS.shshaderb index 8d7a8327..6e0ff2a4 100644 Binary files a/Assets/Shaders/DeferredComposite_CS.shshaderb and b/Assets/Shaders/DeferredComposite_CS.shshaderb differ