Here I want to achieve double render back and front, At the back it should be red color and in the front it should be green color. Currently only green color is shown .
Hello
Seems normal to be, since your cube is closed, no matter at what angle you see it, you only see front faces… If you comment front face render :
// Custom render loop
engine.runRenderLoop(() => {
renderBackfaces(); // First pass for backfaces
//renderFrontfaces(); // Second pass for front faces
});
Then indeed it’s red… But since frontface comes later, it overrides the backface render.
Or am I missing something ?
++
Tricotou
@Tricotou you are correct , so how can i acheive the red at the back and green at the front
As I said, on a cube, it will always be one color, since it’s closed.
Instead of working with 2 materials, since you are defining a custom shader, you can work with gl_FrontFacing
and set the material to backFaceCulling = false
to make sure it renders both sides :
As you can see it works on an open mesh (plane) but won’t work on a cube since any face is front facing, unless you go INSIDE the cube…
thanks for the help, understood the concept @Tricotou