Jump to content
  • Advertisement
Sign in to follow this  

GLSL - Storing custom data into texture.

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

[font="Calibri"]Greetings,

[/font]
[font="Calibri"]In the making of an Indexed Lighting shader, each sampler's pixel contains a light color. I’m wondering what would be the correct syntax to retrieve a single pixel color using a texture 1d.[/font]

uniform sampler1D u_LightColors;

void main(void)
{
vec4 l_lightColor;

for (int i = 0; i< 8; ++i)
{
l_lightColor = texture(u_LightColors, i);
…SNIP

[font="Calibri"]It does not seems to work so far, what am I missing?[/font]

Share this post


Link to post
Share on other sites
Advertisement
dunno if there is an exception with 1d textures you are using, but aren't texcoords in the intervall [0, 1] ?
also u have to be carefull about texture filtering at look(use linear and offset the texcoords by half an pixel)


const float texsize = 8;
const halfpixel = 1./texsize * 0.5;
for (int i = 0; i< 8; ++i){

l_lightColor = texture(u_LightColors, i/texsize + halfpixel)

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!