+ | Texture working finally !

This commit is contained in:
TheRedShip
2025-01-28 23:08:37 +01:00
parent 23f2a9a5c6
commit c59a9c037f
10 changed files with 142175 additions and 1300 deletions

View File

@ -105,9 +105,16 @@ uniform sampler2D textures[32];
vec3 getTextureColor(int texture_index, hitInfo hit)
{
GPUTriangle tri = triangles[hit.obj_index];
vec2 uv = hit.u * tri.texture_vertex2 + hit.v * tri.texture_vertex3 + (1 - (hit.u + hit.v)) * tri.texture_vertex1;
vec2 uv = vec2(0.0);
if (hit.obj_type == 0)
uv = getSphereUV(hit.normal);
else if (hit.obj_type == 3)
{
GPUTriangle tri = triangles[hit.obj_index];
uv = hit.u * tri.texture_vertex2 + hit.v * tri.texture_vertex3 + (1 - (hit.u + hit.v)) * tri.texture_vertex1;
}
return (texture(textures[texture_index], uv).rgb);
}