3D Grass and Depth Problem

Started by
3 comments, last by Medo Mex 8 years, 2 months ago

I have a transparent image that I'm using as a texture for many billboards to draw 3D grasses

Instead of getting the results expected, here is what I get:

[attachment=30443:grass.png]

The grass billboards are hiding each others, so I tried to disable the depth buffer when drawing the billboards and I got this problem fixed but I run into another problem, I see grasses I'm not supposed to see as the following:

[attachment=30444:grass 2.png]

How do I fix this problem?

Thanks,

Advertisement

Instead of alpha blending, you probably want alpha testing for the grass billboards so that no depth value is written for the transparent pixels.

You can do something like this in your pixel shader:


float4 texture = ...

if(texture.a < 0.5)
   discard;

current project: Roa

@lwm: That can fix the problem, but the same problem can occur with particles.

In D3D9 I used to enable the depth buffer and disable writing to the depth buffer when drawing particles.

How can I do the same in D3D11?

You can do this by setting the Depth-Stencil-State to

DepthEnable = true

DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ZERO

current project: Roa

@lwm: Thanks, one last problem is that when I look at the grass from above, most of the grasses disappear, I also run into performance problem when I try to make the terrain have a lot of grasses (even when I'm using instancing).

This topic is closed to new replies.

Advertisement