I just finished my first trivial Irrlicht demo: a fully UV-mapped and textured cube. Thanks to all who answered my noob questions! I'm a long way from writing a game (actually, my goal is just a UI mockup for a game) but I'm having fun learning stuff.
My next step will be writing functions to generate all the regular polyhedra inscribed within spheres of a given radius. As I do this, I want to make sure that my meshes will be suitable for texture blending, which I totally don't understand yet. For example, I want to be able to have an icosahedron with some of its points splatted with a different texture. Do I need to do anything special with the meshes to make this possible (or easier)?
Making meshes suitable for texture blending
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Well, points are actually not textured at all - at least it's hard to say how their texture looks like. But areas can be textured differently. In general you have to put all the points belonging to that area into a different mesh buffer with different material and textures. Another way would be to use a second texture coord set (with EVT_2TCOORDS) and use an overlay texture. Depends on your application.
[complete edit]
Turns out it is, in fact, working more or less how I expected. I just didn't expect it to blend all the way across the poly. The two textures I was using had very different amounts of contrast, so the blending was difficult to see. It's more clear with different textures:
http://www.flickr.com/photos/76481772@N00/4474248559/
I still don't understand how the color attributes affect which texture is shown. I expected it to work like this:
But changing the r,g,b values only desaturates the texture. So... how do I do this with 4 or 8 textures? I found the place in the code where max textures is defined as 4. Just change that to 8 and recompile? And is there a way I can alter the blending behavior so the texture transition occurs in about the middle third of the triangle rather than across the entire surface?
Hybrid, I hope you're not getting a notification every time I edit this comment. If you are, I'm terribly sorry for the spam.
Turns out it is, in fact, working more or less how I expected. I just didn't expect it to blend all the way across the poly. The two textures I was using had very different amounts of contrast, so the blending was difficult to see. It's more clear with different textures:
http://www.flickr.com/photos/76481772@N00/4474248559/
Code: Select all
video::SColor clr0(255,255,255,255);
video::SColor clr1(0,255,255,255);
buffer->Vertices.push_back(video::S3DVertex(xyz[0], norm, clr0, uv[0]));
buffer->Vertices.push_back(video::S3DVertex(xyz[1], norm, clr0, uv[1]));
buffer->Vertices.push_back(video::S3DVertex(xyz[2], norm, clr1, uv[2]));
buffer->Vertices.push_back(video::S3DVertex(xyz[3], norm, clr1, uv[3]));
node->setMaterialType( video::EMT_SOLID_2_LAYER );
node->setMaterialTexture(0, driver->getTexture("red.png"));
node->setMaterialTexture(1, driver->getTexture("blue.png"));
Code: Select all
video::SColor clr0(255,0,0,0); // all texture 0
video::SColor clr1(0,255,0,0); // all texture 1
Hybrid, I hope you're not getting a notification every time I edit this comment. If you are, I'm terribly sorry for the spam.
To blend more than two textures, do I need to do something like what arras describes here?
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=37696
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=37696