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

Function getTextureTexel1f

tutorials/common/tutorial/tutorial_device.cpp:92–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

90}
91
92float getTextureTexel1f(const Texture* texture, float s, float t)
93{
94 if (!texture) return 0.0f;
95
96 int iu = (int)floor(s * (float)(texture->width));
97 iu = iu % texture->width; if (iu < 0) iu += texture->width;
98 int iv = (int)floor(t * (float)(texture->height));
99 iv = iv % texture->height; if (iv < 0) iv += texture->height;
100
101 if (texture->format == Texture::FLOAT32)
102 {
103 float *data = (float *)texture->data;
104 return data[iv*texture->width + iu];
105 }
106 else if (texture->format == Texture::RGBA8)
107 {
108 const int offset = (iv * texture->width + iu) * 4;
109 unsigned char * t = (unsigned char*)texture->data;
110 return t[offset+0]*(1.0f/255.0f);
111 }
112 return 0.0f;
113}
114
115Vec3fa getTextureTexel3f(const Texture* texture, float s, float t)
116{

Callers 1

OBJMaterial__preprocessFunction · 0.85

Calls 1

floorFunction · 0.50

Tested by

no test coverage detected