Hey guys!
I’m trying to get this (https://forums.unrealengine.com/deve…-world-normals) tutorial working in 4.19.2, and while the changes to the code make it not give anymore errors, it flat-out doesn’t work.
Here’s the material and the result, and the code as well
//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;
Thanks!
EDIT: I’m stupid, accidentally put a 9 in the code where an 8 should’ve been facedesk
However, it crashes with 8 in the code, so now I’m more confused lol