Advertisement

ddx/ddy (mip selection) for decals in tiled forward render

Started by May 04, 2019 10:41 PM
0 comments, last by Nikita Sidorenko 5 years, 6 months ago

I have a loop through the decals like this:


    [loop] 
    for (int i = 0; i < projectorCount; i++) {
        uint currentOffset = lightOffset + i + pointLightCount + spotLightCount;
        uint projectorIndex = lightIndicesBuffer[currentOffset];

        float4 projectedTextureUV = mul(projectors[projectorIndex].projectionMatrix, float4(input.position_worldspace.xyz, 1));
        projectedTextureUV /= projectedTextureUV.w;
        projectedTextureUV = (projectedTextureUV + 1.0) / 2.0;
        float2 spritesheetUV = projectedTextureUV.xy * projectors[projectorIndex].scale + projectors[projectorIndex].offset;
        float4 projectedTexture = projectorTexture.SampleGrad(projectorSampler, spritesheetUV, uvDDX, uvDDY);
        //.....
    }

I need to get uvDDX and uvDDY somehow. I can't use ddx(projectedTextureUV.xy) inside the loop.

So what is the common approach to get the decal's mip?

This topic is closed to new replies.

Advertisement