MCPcopy Create free account
hub / github.com/RenderKit/embree / getTextureTexel3f

Function getTextureTexel3f

tutorials/common/tutorial/tutorial_device.cpp:115–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

113}
114
115Vec3fa getTextureTexel3f(const Texture* texture, float s, float t)
116{
117 if (!texture) return Vec3fa(0.0f,0.0f,0.0f);
118
119 int iu = (int)floor(s * (float)(texture->width));
120 iu = iu % texture->width; if (iu < 0) iu += texture->width;
121 int iv = (int)floor(t * (float)(texture->height));
122 iv = iv % texture->height; if (iv < 0) iv += texture->height;
123
124 if (texture->format == Texture::RGBA8)
125 {
126 const int offset = (iv * texture->width + iu) * 4;
127 unsigned char * t = (unsigned char*)texture->data;
128 const unsigned char r = t[offset+0];
129 const unsigned char g = t[offset+1];
130 const unsigned char b = t[offset+2];
131 return Vec3fa( (float)r * 1.0f/255.0f, (float)g * 1.0f/255.0f, (float)b * 1.0f/255.0f );
132 }
133 return Vec3fa(0.0f,0.0f,0.0f);
134}
135
136} // namespace embree

Callers 1

OBJMaterial__preprocessFunction · 0.85

Calls 2

Vec3faClass · 0.50
floorFunction · 0.50

Tested by

no test coverage detected