Archived

This topic is now archived and is closed to further replies.

not draw a vertex in a vertex shader

This topic is 4946 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

There is a way to not draw a vertex in a vertex shader, so you can do a simple backface culling ? I have tried to do this float4 def_vtx = float4(0.0f, 0.0f, 0.0f, 1.0f); if (dot(IN.Normal,normalize(view_direction)) < 0) OUT.Pos = mul(view_proj_matrix,IN.Pos); else OUT.Pos = def_vtx; but the results are bad.

Share this post


Link to post
Share on other sites
Is there some reason you can''t just turn on backface culling?

Because that method there doesn''t work so well, since some vertices (the ones facing away) are going to be placed in a bad place, and the others will. Problem is, you get triangles that connect the "bad place" vertices to the normal ones, so your model will look very odd indeed, I bet.

Just use built-in backface culling. It''s faster and it actually works, to boot.

Share this post


Link to post
Share on other sites
I know that I must use standart backface culling, its fast and good, I am only trying to do it in a shader only to learn if its posible to eliminate vertex and/or faces with a vertex shader, I am begining in shader world.

Share this post


Link to post
Share on other sites
You can''t discard faces or vertices in a shader. The card will discard the faces that are backfacing AFTER the shader runs, and the faces are built with the transformed faces.

A vertex is not enough information to backface cull. On a curved surface, imagine a point at the edge. Along the edge, the same vertex that will be used in a face that''s culled will be used in another face that isn''t culled. Your code is cause all faces using such vertices are horribly distorted.

Share this post


Link to post
Share on other sites
you can''t place some vertices in a way that later the card discard it, for example creating zero-area triangles ? although you have information of only the actual vertex

Share this post


Link to post
Share on other sites