It is currently Sat Aug 22, 2020 4:14 am


All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Handling rotated meshes with a texture atlas
PostPosted: Wed Apr 13, 2011 5:16 am 

Joined: Tue Apr 12, 2011 1:32 am
Posts: 2
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)


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Handling rotated meshes with a texture atlas
PostPosted: Wed Apr 13, 2011 7:29 am 

Joined: Fri Feb 18, 2011 8:41 pm
Posts: 173
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.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Handling rotated meshes with a texture atlas
PostPosted: Wed Apr 13, 2011 8:29 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
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 :)


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Handling rotated meshes with a texture atlas
PostPosted: Fri Apr 15, 2011 9:57 pm 

Joined: Tue Apr 12, 2011 1:32 am
Posts: 2
Thanks, just the hint I needed to get it working


Top
Offline Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Theme created StylerBB.net