Generating terrain with different textures

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.
Steel Style
Posts: 168
Joined: Sun Feb 04, 2007 3:30 pm
Location: France

Post by Steel Style »

Try this in your shader;

Code: Select all

if ( pos.y >= 0 && pos.y < 90)
	gl_FragColor = mix(col1,col0,pos.y*0.11111f);// Note : 0.111f = 1/90
else if ( pos.y >= 90 && pos.y < 160)
	gl_FragColor = mix(col2,col1,(pos.y-90)*0.014286f);
else
	gl_FragColor = mix(col3,col2,(pos.y-160)/95.0f);
badday
Posts: 102
Joined: Mon Aug 16, 2010 1:14 pm

Post by badday »

@Steel Style: Applying your advice results in:
Image

There is a nice transition between the brown and the green one, but the other seem to be not alright. I played around with the values, but didn´t get a useful result. Maybe you can tell me, how that mix-function works.

Thanks a lot.


Greetings,

badday
Steel Style
Posts: 168
Joined: Sun Feb 04, 2007 3:30 pm
Location: France

Post by Steel Style »

I made a mistake you should invert the color col0,col1 instead of col1,col0 and so on...
The mix function is a GLSL function blending the color with an alpha value.

Code: Select all

if ( pos.y >= 0 && pos.y < 90)
	gl_FragColor = mix(col0,col1,pos.y*0.11111f);// Note : 0.111f = 1/90
else if ( pos.y >= 90 && pos.y < 160)
	gl_FragColor = mix(col1,col2,(pos.y-90)*0.014286f);
else
	gl_FragColor = mix(col2,col3,(pos.y-160)/95.0f);
badday
Posts: 102
Joined: Mon Aug 16, 2010 1:14 pm

Post by badday »

Alright, but there is still a problem between 0 and 1. Here´s a screenshot:

Image

Thanks a lot.

badday
Steel Style
Posts: 168
Joined: Sun Feb 04, 2007 3:30 pm
Location: France

Post by Steel Style »

Okay I get it 1/90 = 0.0111111f and I forget the 0 after the point.

Also I suggest you to make some change for exemple for the snow and the ground, if you want quick reponse comme to the irrlicht irc channel : #irrlicht at irc.freenode.net
badday
Posts: 102
Joined: Mon Aug 16, 2010 1:14 pm

Post by badday »

Hey, you´re right, I didn´t notice that either ;)
Thanks a lot. Works great.

Well, yes I´ll visit the IRC channel if I´ve got another questions, thanks for your advice.

Greetings,

badday
Post Reply