+ | Parsing textures

This commit is contained in:
TheRedShip
2025-01-27 23:56:32 +01:00
parent 6b64d2188e
commit e9c77cfdd4
12 changed files with 92 additions and 94 deletions

View File

@ -38,6 +38,7 @@ struct GPUMaterial
float metallic; // 4
float refraction; // 4
int type; // 4
int texture_index; // 4
};
struct GPUCamera

View File

@ -103,15 +103,18 @@ vec2 getSphereUV(vec3 surfacePoint)
uniform sampler2D textures[16];
vec3 getTextureColor(int texture_index, hitInfo hit)
{
vec2 uv = getSphereUV(hit.normal);
return (texture(textures[texture_index], uv).rgb);
}
void calculateLightColor(GPUMaterial mat, hitInfo hit, inout vec3 color, inout vec3 light, inout uint rng_state)
{
if (objects[hit.obj_index].type == 0)
{
vec2 uv = getSphereUV(hit.normal);
color *= texture(textures[0], uv).rgb;
}
else
color *= mat.color;
if (mat.texture_index != -1)
color *= getTextureColor(mat.texture_index, hit);
color *= mat.color;
light += mat.emission * mat.color;
// light += sampleLights(hit.position, rng_state);
}