How to find and fix shader's errors?

Hello. I’m trying to use free forward shader from here:

But I’m getting errors:

[SM6] /Engine/Generated/Material.ush:2843:20: error: expected ‘)’
[unroll(CelSamples / 2)]
^
[SM6] )
[SM6] /Engine/Generated/Material.ush:2843:20: error: expected ‘]’
[unroll(CelSamples / 2)]
^
[SM6] ]
[SM6] /Engine/Generated/Material.ush:2843:24: error: expected expression
[unroll(CelSamples / 2)]
^
[SM6] /Engine/Generated/Material.ush:2843:25: error: expected expression
[unroll(CelSamples / 2)]
^
[SM6] /Engine/Generated/Material.ush:2919:20: error: expected ‘)’
[unroll(CelSamples / 2)]
^
[SM6] /Engine/Generated/Material.ush:2919:20: error: expected ‘]’
[unroll(CelSamples / 2)]
^
[SM6] /Engine/Generated/Material.ush:2919:24: error: expected expression
[unroll(CelSamples / 2)]
^
[SM6] /Engine/Generated/Material.ush:2919:25: error: expected expression
[unroll(CelSamples / 2)]
^
[SM6] D3DCompileToDxil failed. Error code: Неопознанная ошибка (0x80004005).

I don’t understand how to fix it and I don’t even know how to find nodes with that errors. I think the problem should be in material function or in custom node with HLSL but I found only two custom MF and seems like everything is ok with it.
Can somebody help me with it?

Update: I think I found HLSL code with that errors but still don’t know how to fix it:
EdgeDetectDepthForward function:

UV = ScreenAlignedUV(UV);

float4 output = float4(0, 0, 0, 0);
float2 Samples[8] = { float2(0, -1), float2(0, 1), float2(-1, 0), float2(1, 0), float2(-1, -1), float2(-1, 1), float2(1, -1), float2(1, 1) };
float4 Tex = clamp(SceneTextureLookup(UV, 1, true), 0, 50000);

for (int y = 1; y <= Smoothing; y++)
{
	[unroll(4)]
	for (int x = 0; x < 4; x++)
	{
		float4 Tex2 = clamp(SceneTextureLookup(UV + (Samples[x] * y * OffsetAmount * PixelSize), 1, true), 0, 50000);
		output +=
		abs(
			float4(
				saturate(Tex.r / DepthScale - 
				Tex2.r / DepthScale),

				saturate(Tex.r / (DepthScale * 3) - 
				Tex2.r / (DepthScale * 3)),

				saturate(Tex.r / (DepthScale * 10) - 
				Tex2.r / (DepthScale * 10)),
			0)
		) / y;
	}
	[unroll(CelSamples / 2)]
	for (int x = 4; x < CelSamples; x++)
	{
		float4 Tex2 = clamp(SceneTextureLookup(UV + (Samples[x] * y * OffsetAmount * PixelSize), 1, true), 0, 50000);
		output +=
		abs(
			float4(
				saturate(Tex.r / DepthScale - 
				Tex2.r / DepthScale),

				saturate(Tex.r / (DepthScale * 3) - 
				Tex2.r / (DepthScale * 3)),

				saturate(Tex.r / (DepthScale * 10) - 
				Tex2.r / (DepthScale * 10)),
			0)
		) / 2 / y;
	}
}

return output / (Reduction * Smoothing);

EdgeDetectColourForward function:

UV = ScreenAlignedUV(UV);

float4 output = float4(0, 0, 0, 0);
float2 Samples[8] = { float2(0, -1), float2(0, 1), float2(-1, 0), float2(1, 0), float2(-1, -1), float2(-1, 1), float2(1, -1), float2(1, 1) };
float4 base = saturate(clamp(SceneTextureLookup(UV, 14, true), 0, LightnessThreshold));


for (int y = 1; y <= Smoothing; y++)
{
	[unroll(4)]
	for (int x = 0; x < 4; x++) {
		output += abs(
			base - 
			saturate(clamp(SceneTextureLookup(UV + (Samples[x] * y * OffsetAmount * PixelSize), 14, true), 0, LightnessThreshold))
		) / y;
	}
	[unroll(CelSamples / 2)]
	for (int x = 4; x < CelSamples; x++) {
		output += abs(
			base - 
			saturate(clamp(SceneTextureLookup(UV + (Samples[x] * y * OffsetAmount * PixelSize), 14, true), 0, LightnessThreshold))
		) / 2 / y;
	}
}

return output / (Reduction * Smoothing);

Solution: for a quick and easy fix remove every [unroll] line.
Thanks to Laura from Unreal Slackers discord.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.