• News

• Industries

• Learning & Support

• Community

• Marketplace

# Help with HLSL

Hello! I don’t know anything about HLSL and I really want some help with it!

First of All: I have a code here that creates a Blur around the character and with that I can create a nice Glow effect around the character. I took it fro this tutorial:

Ok, now is the problem: I need to occlude the effect when an object or anything that blocks the camera from viewing the character.

Some people in the comments made the statement that I can multiply something by something but I really don’t know anything about it! Where to put it, how to put it when to put it, can someone give me a resolution?

Here’s the code inside the custom node:

``````static const float PI2 = 3.14159265359f * 2;
int CDIndex = 13;
int CSIndex = 25;
Steps = clamp(floor(Steps), 1, 128);
float stepSize = Radius / Steps;
float result = 0.0f;
float stencil = 0.0f;

for (int i = 1; i <= Steps; ++i)
{
float currStep = i * stepSize;
for (int j = 0; j < RadialSteps; ++j)
{
float angle = j * radialStepSize;
float2 coord = float2(cos(angle), sin(angle)) * currStep + UV;
float sample = SceneTextureLookup(ViewportUVToSceneTextureUV(coord, CDIndex), CDIndex, false);
result += (MaxDistance - clamp(sample, 0, MaxDistance)) / MaxDistance;
stencil = max(stencil, SceneTextureLookup(ViewportUVToSceneTextureUV(coord, CSIndex), CSIndex, false));
}
}
return float2(result / (RadialSteps * Steps), stencil);
``````

The creator said this:

You can compare the scene depth to the object’s custom depth and if the custom depth is higher than the scene depth, it means it’s behind something.

Something like ((SceneDepth + 0.1) - CustomDepth)->Ceil->Saturate should give you either 0 or 1. 0 if it’s behind something and 1 otherwise. Than you multiply that by the effect intensity or something to have it nullified when behind stuff.

I tried something with nodes, multiplying the output with the Custom Depth + SceneDepth, and got the occlusion by doing it, but that didn’t influenced a thing with the Custom Node. Thanks.