Jump to content
  • Advertisement
Sign in to follow this  
denisve

OpenGL Passing massive arrays of data as uniform texture

This topic is 1165 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

Hi, all.

 

I need to pass a large lookup table to fragment shader (large enough to not be able to pass it as array). The lookup table basically maps uv coordinates to texture location in texture atlas, which needs to be used at current uv coordinates.

 

Problem is, functions like texelFetch are not supported for OpenGL ES, so I can't really access the pixels as data. Is there any workaround for this? Basically what I need is a way to fetch any pixel from texture, avoiding filters.

 

Also, if there are better ways of passing data, except for textures, I'd love suggestions.

 

Thanks.

Edited by denisve

Share this post


Link to post
Share on other sites
Advertisement

I suppose you could just not use texture filtering, use point sampling (nearest), dont mipmap, and make sure your texture coordinates (table lookup indices?) fall exactly on texel centers.

Edited by NumberXaero

Share this post


Link to post
Share on other sites

What version of OpenGL ES are you targeting? The texelFetch function is supported from ES 3.0 onwards.

Edited by Xycaleth

Share this post


Link to post
Share on other sites

I suppose you could just not use texture filtering, use point sampling (nearest), dont mipmap, and make sure your texture coordinates (table lookup indices?) fall exactly on texel centers.

 

So I just sample for 1/x and 1/y? Will that cover for both min and mag filters?

Share this post


Link to post
Share on other sites

What version of OpenGL ES are you targeting? The texelFetch function is supported from ES 3.0 onwards.

 

I use WebGL, so that's 2.0.

Share this post


Link to post
Share on other sites

I suppose you could just not use texture filtering, use point sampling (nearest), dont mipmap, and make sure your texture coordinates (table lookup indices?) fall exactly on texel centers.

 
So I just sample for 1/x and 1/y? Will that cover for both min and mag filters?
Yeah use nearest for both, and no mipmaps.
Texcoords for texel centres are (0.5+index)/size.
e.g. for a 256 wide texture,
the rightmost texel is (0.5+255)÷256=0.998046875

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!