| 90 | } |
| 91 | |
| 92 | float 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 | |
| 115 | Vec3fa getTextureTexel3f(const Texture* texture, float s, float t) |
| 116 | { |
no test coverage detected