colors for front / backside

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
AReichl
Posts: 270
Joined: Wed Jul 13, 2011 2:34 pm

colors for front / backside

Post by AReichl »

Hi,

i am using Irrlicht for a visualisation tool for CAD data (believe it or not, but besides OpenSceneGraph no other library could load or even handle these data - with Irrlicht i made some small changes to the STL-loader and all was fine).

Now i would like to display my objects with different colors (or white intensity) on the front and backside.

How could i do that?
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: colors for front / backside

Post by CuteAlien »

Easiest solution I can think of is to make a copy of the meshbuffer. Then loop over all the indices and flip the 1st and 3rd index for each triangle. Give that meshbuffer another material (or the vertices in it another vertex-color). Keep backface culling enabled.

Unless someone knows a trick avoid the copy...
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: colors for front / backside

Post by hendu »

I'd use a shader. You have access to whether it's front or back via a built-in variable, then you can color as you wish.
AReichl
Posts: 270
Joined: Wed Jul 13, 2011 2:34 pm

Re: colors for front / backside

Post by AReichl »

Aha - good idea. I would say it's the OBVIOUS idea, but i wanted to avoid shaders as much as possible. This would be a good reason to start with it.
Post Reply