Jump to content
  • Advertisement
Nikita Sidorenko

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

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!