[TUTORIAL] Edge Detection Post Process Effect using World Normals

you need to replace the “SceneTextureLookup(UV, 8);” in the custom node with “SceneTextureLookup(UV, 8,true);” (or use a false if you don’t want filtering (got this from the HLSL output of another shader))
It would be better to provide the scene lookups as input parameters, but the second one may not be easy.
Does anybody know that the node version of the lookup is?

I made a slight improvement, I added the unroll specifier to the loops:


//kernel size
int sizeX = 5;
int sizeY = 5;

//offset added to all uvs to get from the center to the corner
MaterialFloat2 baseOffset = MaterialFloat2(-sizeX/2.0f, -sizeY/2.0f) * offset.rg;
//sample the world normal from the GBuffer
float4 baseNormal = SceneTextureLookup(UV, 8,true);
//dot product for two normalized vectors ranges between -1.0f to 1.0f
//we're going to search the smallest value so initialize to something larger
float minDot = 10.0f;

[unroll]
for (int i = 0; i < sizeX; ++i)
{
	[unroll]
	for (int j = 0; j < sizeY; ++j)
	{
		//calucalte clamped uvs
		float2 uvs = min(max(UV + baseOffset * scale + i * offset.r * scale.r * float2(1.0, 0.0f) + j * offset.g * scale.g * float2(0.0, 1.0f), float2(0.0f, 0.0f)), float2(1.0f, 1.0f));
		//sample world normal from the GBuffer at the new position
		float newDot = dot(baseNormal, SceneTextureLookup(uvs, 8,true));
		//if smaller than our current value
		if (newDot < minDot)
		{
			//use the new value
			minDot = newDot;
		}
	}
}

//return smallest dot product in this region
return minDot;