Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


fragment texture sampler for vector3 field


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 0BZEN   Crossbones+   -  Reputation: 2025

Like
0Likes
Like

Posted 11 June 2014 - 04:17 PM

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, 11 June 2014 - 04:19 PM.

Everything is better with Metal.


Sponsor:

#2 0BZEN   Crossbones+   -  Reputation: 2025

Like
0Likes
Like

Posted 11 June 2014 - 04:39 PM

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, 11 June 2014 - 04:47 PM.

Everything is better with Metal.


#3 swiftcoder   Senior Moderators   -  Reputation: 10242

Like
1Likes
Like

Posted 11 June 2014 - 07:15 PM


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...


Tristam MacDonald - Software Engineer @Amazon - [swiftcoding]


#4 0BZEN   Crossbones+   -  Reputation: 2025

Like
0Likes
Like

Posted 12 June 2014 - 01:32 AM

 

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. 


Everything is better with Metal.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS