What is the best way to make grass shader only effective where near the camera?
I followed this tutorial to learn about grass shader. Now I'd like to apply that shader into my own mesh, which is a massive unity terrain. Even though my pc can handle that many vertexes, I still want to try some optimization. My idea is to only render the grass within a certain distance from the camera, and the current implementation is using if-else, which is not the best choice in a GPU.
float dist = length(ObjSpaceViewDir(v.vertex)); if (dist > 100) { return; }
My question is:
I add the if condition in geometry shader, since it returns void
void geo(triangle vertexOutput IN[3], inout TriangleStream<geometryOutput> triStream)
I wonder if it's possible to exclude some vertexes from a vertex shader, which doesn't return void?
2.Is it possible to replace the if-else using some math magic?
3.If I set the alpha of a vertex to transparent, will it still cost GPU resources?
Your answer
Follow this Question
Related Questions
Shadowcaster Fragment Shader Discard 0 Answers
CG >shadow catcher< shader not showing in iOS 0 Answers
Blur shader that works with Vive 0 Answers
How to make a shader run at a certain point in time? 0 Answers