Simple solution to flip normals on materials?

Hey folks,

I know we have Mesh.flipFaces(true) working on meshes to flip faces and normals.

On material we have sideOrientation to doing similar things but this feature doesn’t flip normals at all.

Just wondering is there a similar function but only filp normals on material end? Or at least flip faces and normals together like what Mesh.flipFaces(true) does. Or any quick approaches doing sth similar.

Many thanks,

No, there’s no existing option to just negate the normal in the shader code. What is your use case for this?

What you can do is to create a material plugin and negate vNormalW at the CUSTOM_VERTEX_UPDATE_WORLDPOS injection point.

@Evgeni_Popov Thank you for the response!

Can you provide a PG for this material plug in?

I actually asked a follow up question here 1 day ago:

My follow up question is related to this topic.

You can use the solution PG as a starting point in the link above. From my understanding, in the solution PG, there just need one more “flip normal at shader” step added after sideOrientation, the rendering result should look correct.

Hope this makes sense.

Many thanks,

You can enable two sided lighting and disable back face culling. This way, you don’t need to call makeGeometryUnique:

Using a material plugin, you can avoid cloning the mesh by simply updating the diffuse color for the back faces:


Thank you for the PGs!

Actually can you give me an example of Material plug in that only flip normal at render time?
I know I can use twoSidedLighting but ran into some issues when I use it in practice. So for my case just trying to find a way enabling the material to flip normal at render time.

Many thanks!

Here it is:

1 Like


Yes!! that’s it! And its awesome it works for both PBR and Standard materials!
Thank you so much again!

@Evgeni_Popov @sebavan Btw do you guys think this function it’s worth to be promoted to an official feature?

This sounds really edge case to be a general feature and easy enough to deploy as part of the app itself. Let s integrate as soon as it gets more traction.