Shader Integration

advanced tasks

Cloud Shadows FX · Common Tasks

Shader Integration

Cloud Shadows FX exposes a shadow sampling function that you can call from your own shaders to apply cloud shadows to custom materials.

Step 1 — Include the HLSL files

Add the following includes to your shader. Adjust the path if your shader is in a different folder.

#include "CloudShadowsInput.hlsl"
#include "CloudShadowsCommon.hlsl"

Step 2 — Sample the shadow attenuation

Call GetShadowAttenuation() in your fragment shader:

half4 GetShadowAttenuation(float3 wpos, float depth01, float3 normalWS);
ParameterDescription
wposWorld-space position of the pixel.
depth01Linear depth in the 0–1 range.
normalWSWorld-space surface normal. Used to avoid shadows on ceilings. Pass float3(0,1,0) if not needed.

Step 3 — Pass shader variables from C#

In your script, call UpdateMaterialProperties() on the CloudShadows component, passing your material, so the required shader variables are set:

CloudShadows cs = GetComponent<CloudShadows>();
cs.UpdateMaterialProperties(myMaterial);
Note: You must call UpdateMaterialProperties() whenever profile values change so the shader receives updated data.
Was this page helpful?