Volumes Of Fun
http://www.volumesoffun.com/phpBB3/

Handling rotated meshes with a texture atlas
http://www.volumesoffun.com/phpBB3/viewtopic.php?f=2&t=196
Page 1 of 1

Author:  Googolplexed [ Wed Apr 13, 2011 5:16 am ]
Post subject:  Handling rotated meshes with a texture atlas

Well, I'm currently experimenting with polyvox, and I've gotten my basic mesh stuff working (using cubic-surface-extractor).
As you could probably tell from the choice of extractor, I'm aiming for a minecraft-ish style of utilizing voxels using Ogre3d

My current issue, is that unlike most projects using voxels, my generated mesh will be rotated in-game (customized voxel spaceship)

I've mostly constructed all the basics for a non-rotated mesh, however when rotated, the textures come out of alignment.

Considering that each face of a voxel might need to have a different texture, does anyone have suggestions on the best way to texture the faces, independent of rotation ?

(I'm still quite new to working with the graphics pipeline, so any suggestions on what to start working on would be appreciated)

Author:  Shanee [ Wed Apr 13, 2011 7:29 am ]
Post subject:  Re: Handling rotated meshes with a texture atlas

Are you calculating the normals in shader to create texture coordinates? Try to apply texture coordinates before applying world matrix, the normals for this use should give the same results I believe.

Author:  David Williams [ Wed Apr 13, 2011 8:29 pm ]
Post subject:  Re: Handling rotated meshes with a texture atlas

Ok, let's leave aside the issue of having a diffent texture on each face and focus first on handling the local transformation.

You say you already have the system working without a local transformation, and so this implies that you have managed to generate UV coordinates (for sampling the textures) and normals (for blending the textures) based on the final world space position of the vertices?

In this case you should be able to transform your world space positions and normals back to local space. In your Ogre .program or .material you are probably using something like:

Code:
param_named_auto world world_matrix
param_named_auto viewProj viewproj_matrix


to pass these values to the vertex shader? If so, you can try passing the following matrix to the pixel shader: 'inverse_world_matrix'. I think that's the one you want, but have a look at this page to see your options. You can then use it to transform you normal back to local space, and also your positions (probably before you turn them into UV coordinates).

The above is untested... fingers crossed :)

Author:  Googolplexed [ Fri Apr 15, 2011 9:57 pm ]
Post subject:  Re: Handling rotated meshes with a texture atlas

Thanks, just the hint I needed to get it working

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/