Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


alpha test objects at distance


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 belfegor   Crossbones+   -  Reputation: 2722

Like
0Likes
Like

Posted 07 February 2013 - 05:32 PM


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);


Sponsor:

#2 MJP   Moderators   -  Reputation: 11786

Like
3Likes
Like

Posted 07 February 2013 - 06:06 PM

This is a problem common  with alpha testing using mipmapped textures. You can read through this article for more info.



#3 belfegor   Crossbones+   -  Reputation: 2722

Like
0Likes
Like

Posted 13 February 2013 - 08:25 AM

I finally managed to compile nvcompress utility from code sample from article you have provided.
Result is amazing. Thank you greatly MJP.

Before:
bad.png

After:
ok.png


Edited by belfegor, 13 February 2013 - 09:11 AM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS