Advertisement Jump to content
Sign in to follow this  
takis

texture coordinate to texel

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

Hello, I have a texture atlas for an object in my scene. If i search the pixel in my texture that corresponds to my texture coordinate and i change its color, i get a strange result. While in my texture only one pixel is change from color, i get after texture mapping more changes. Here is the link to the screenshots of my problem, that makes my problem more clearly. http://lumumba.luc.ac.be/~takis187/blaai/ void Texture::adjust(const Vector2D& texcoord, const Vector3D& color, float alpha) { float u=texcoord.getU(); float v=texcoord.getV(); float x = (u-floorf(u))*m_width; float y = (v-floorf(v))*m_height; float i = floorf(x); float j = floorf(y); unsigned char* pix=lookup_raw((int)i,(int)j); pix[0]=(unsigned char)(color.getR()<0.f ? 0.f: color.getR()>1.f ? 255.f : color.getR()*255.f); pix[1]=(unsigned char)(color.getG()<0.f ? 0.f: color.getG()>1.f ? 255.f : color.getG()*255.f); pix[2]=(unsigned char)(color.getB()<0.f ? 0.f: color.getB()>1.f ? 255.f : color.getB()*255.f); if(m_channels==4) pix[3]=(unsigned char)(alpha<0.f ? 0.f: alpha>1.f ? 255.f : alpha*255.f); } inline unsigned char* Texture::lookup_raw(int col, int row) { return m_map + m_channels * (m_width*row + col); }

Share this post


Link to post
Share on other sites
Advertisement
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!