Multitexturing/splattering 

Texture splattering, I think this is called. I use three standard textures (e.g. grass, mud, gravel). A fourth stencil texture specifies the amount at which each of these textures is to be used (in the red/green/blue channels).

The pixel shader code is pretty simple:

vec4 stencil = texture2D(texture0, texCoord1);
gl_FragColor = texture2D(texture1, texCoord0) * stencil.r
+ texture2D(texture2, texCoord0) * stencil.g
+ texture2D(texture3, texCoord0) * stencil.b;


What did however take some time was writing a XML material loading system.



These screenshots are from the third person action game engine I'm working on. What you see is just a test environment, although I am planning a game. But that's top secret :)

The white arrow thing represents the ray with which the player can select an object to carry (i.e. those wood blocks).

The engine uses my (possibly incorrect) interpretation of what a component system is. That is, an entity in the engine is not a solid class, but just a collection of components with a common ID. Components could be character physics, box physics, an animated mesh, a third person camera... All these communicate with each other by sending messages.
So the physics object can transmit its position and both the mesh object and the third person camera object can receive it. Or any other components added in the future would be able to. That sort of thing...

And of *course*, all component parameters are read from xml files.

A nice article can be found here: http://cowboyprogramming.com/2007/01/05 ... -heirachy/



And here's the stencil map! Pure red/green/blue gives just a single texture. Pure white would be all textures added together.


This particular shader will be for terrain. There are still a lot of improvements to make, such as detail maps, normal maps... But the 3D engine I'm using, Irrlicht, seems to support a maximum of only 4 textures. Hmm.

Au revoir!
[ add comment ] ( 290 views ) permalink

<<First <Back | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Next> Last>>