bjornbytes / lovr

Lua Virtual Reality Framework
https://lovr.org
MIT License
2k stars 138 forks source link

How to remove membrane from grass #778

Closed WOLFxxxxxx closed 6 months ago

WOLFxxxxxx commented 6 months ago

Capture

bjornbytes commented 6 months ago

Transparent objects needs to be drawn back-to-front. The objects in front are getting drawn first and writing to the depth buffer, and the objects behind them are getting drawn later and depth testing against the transparent pixels.

You can put objects into a table with their distance to the camera and sort based on that.

In the future LÖVR may be able to do this automatically.

jmiskovic commented 6 months ago

You can achieve a lot with this line at the start of lovr.draw function:

pass:setAlphaToCoverage(true)

It won't solve all issues with complex overlaps but it should fix the situation in your screenshot. There's a great article that covers a more advanced technique for foliage: Anti-aliased Alpha Test: The Esoteric Alpha To Coverage