I’ve been searching for hours on how to implement two sided texture on
polys but found nothing of good use. Anyone have done this before?
Please log in or register to post a reply.
I draw my scene twice and this works. But, is that the right way to do
that? Doesn’t OpenGL support texturing both side of a poly?
could you set the cullmode to none, that should make the texture visible
on both sides of the poly. not sure if it will give the effect you
desire but should work.
Yes I did that, but It doesn’t look like we can set a texture for each
side of a poly. Is there?
no i don’t think so, the way you described looks like the best way if
wanting a unique texture on both sides.
you can do it with shaders, just take use the angle between the surface
normal and the camera/pixel ray to swap between textures.
Or if you want a simple solution, just create two polygons a tiny amount
Why would they need to be a tiny amount apart? They can share vertices.
Just make sure you use the appropriate backface culling mode so at any
given time only one of the two polygons will render.
It’s pretty common to actually have two polygons when rendering
doublesided materials anyway. The cost of that couple of extra indices
outweighs the cost of the culling mode state change and extra drawprim
You can determine back/front facing in shader (gl_FrontFacing in
OpenGL) and then sample different textures.
Yes. A similar flag exists in HLSL. Don’t forget to negate the normal on
the back side as well, to get correct lighting. (Or light from both
sides, if you want the impression of a translucent surface.)
Normally I would create two polygons in this instance and let the cull
mode determine which one gets drawn in a lazy render. I’m not sure how
important it is for you to have a double sided polygon, but I would
pretty much do what .oisyn mentioned, although without sharing vertices.
I would split the texture coordinates so that the front face maps to the
left side of the texture and the back face maps to the right side of the
texture (assuming this texture or purpose is specific here). No need for
special logic and dot products in the shader. Just race it through the
pipeline in a quick and simple draw and let the cull mode do its thing.
This is also backwards compatible with ancient hardware.
I would try it out and look at what you get, sharing verts can produce z
fighting on some platforms from some view angles.
Thanks guys for the tips. What I ended up doing is to cull the back
faces, draw the front ones, then cull the front and draw the back ones.