| 113 | } |
| 114 | |
| 115 | Vec3fa 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 |
no test coverage detected