Sign in to follow this  

alpha test objects at distance

Recommended Posts

I am using instancing to render grass on my terrain, but distant grass objects sort of disappear especially if they are with thin leaves.
What is the common way to handle this problem?

Currently i do this in gbuffer pixel shader:

static const float maxDist    = 7.0f;// max dist from cam
    static const float aRefRange  = 0.392f;
    static const float aRefToAdd  = 0.47f;
    float dstTo      = length(posVS); //cam is at 0,0,0
    dstTo            = clamp(dstTo, 0.0f, maxDist);
    float inRange    = (1.0f - (dstTo / maxDist)) * aRefRange;
    float aRefVal    = inRange + aRefToAdd;
    clip(diff.w - aRefVal);

Share this post

Link to post
Share on other sites

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

Sign in to follow this