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

ogre <-> Polyvox (cg shader problems)
http://www.volumesoffun.com/phpBB3/viewtopic.php?f=14&t=398
Page 2 of 2

Author:  gamer8o4 [ Sun Jun 03, 2012 7:14 pm ]
Post subject:  Re: ogre <-> Polyvox (cg shader problems)

@david: i got it, texturing works :D

And about the atlas, i thought it would be easier.
The uv variable is just a float2, but for the atlas i need a float4
(i have to save these coordinates: startx, endx, starty, endy).
how can i change the shader to implement a float4 variable?

Author:  David Williams [ Mon Jun 04, 2012 12:19 pm ]
Post subject:  Re: ogre <-> Polyvox (cg shader problems)

gamer8o4 wrote:
The uv variable is just a float2, but for the atlas i need a float4
(i have to save these coordinates: startx, endx, starty, endy).
how can i change the shader to implement a float4 variable?


The texture atlas is just a 2D texture which means you have to use a 2D position (float2) to sample it. The tex2D function can only sample one particular point in the texture, it cannot sample a 'range'.

Your startx, endx, starty, endy can indeed be stored in a float4 if you wish, and you can compute these values from the material id which PolyVox provides. You then need to combine these startx, endx, starty, endy with the texture coordinates for the particular fragment you are currently rendering, and this gives you the 2D position where you should sample the texture.

I don't have any code for this as I'm not using texture atlases myself, but if you search around this forum you might find something. But this isn't really a PolyVox issue, so you should also have a look elsewhere for any information you can find about implementing texture atlases. They are complex though. I'd still recommend you start by passing the textures through different texture units.

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