• Advertisement
Sign in to follow this  

fragment texture sampler for vector3 field

This topic is 1321 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Heyup guys, 

 

I was wondering if there is an efficient way to use a texture sampler to sample through a vector3 2-dimensional array, from within a GLSL fragment shader.

 

A bit of background :

 

I'm looking at ray marching algorithms (a-la ShaderToy), while using an Oculus DK1. 

 

I want to sample an 2D array of 3D vectors (representing the screen space 960 x 800, 2D will be enough, although will require a re-normalisation), to quickly look up the ray direction (and position, although the computation is trivial enough) for each fragment, taking into account the barrel correction required. I'm not sure if that is feasible with current tech.

 

The advantage is it does away with the need to create a large back buffer, applying a large post-process distortion mesh, and wasting a whole lot of fragment computations in the process. 

Edited by 0BZEN

Share this post


Link to post
Share on other sites
Advertisement

hmm might be able to use float components in my texture

 

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, 960, 800, 0, GL_RGBA, GL_FLOAT, data)

 

something like that.

 

16mb texture, for fragment ray directions.

 

32mb if I also want to map the fragment ray origins.

 

ouch!

Edited by 0BZEN

Share this post


Link to post
Share on other sites


16mb texture, for fragment ray directions.

Do you really need 32-bit precision to represent direction vectors?

 

I'd honestly be surprised if 8-bit textures weren't sufficient, and there are always half floats if you really need them...

Share this post


Link to post
Share on other sites

 

Do you really need 32-bit precision to represent direction vectors?

 

I'd honestly be surprised if 8-bit textures weren't sufficient, and there are always half floats if you really need them...

 

 

I think so. This is for ray-marching, so accuracy is pretty critical. I suppose I can experiment a little on that front. 

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement