+ | Texture better coede

This commit is contained in:
TheRedShip
2025-01-28 22:28:35 +01:00
parent ae83d7d9f1
commit 23f2a9a5c6
5 changed files with 5 additions and 9 deletions

View File

@ -24,8 +24,8 @@ pl 0 -2 0 0 1 0 2 // floor
qu -1 1.999 -1 2 0 0 0 0 2 6
OBJ obj/Dragon_800K.obj -0.5 0 0.55 5 0 90 0
OBJ obj/Dragon_800K.obj 0.5 0 -0.55 5 0 -90 0
OBJ scenes/obj/Dragon_800K.obj -0.5 0 0.55 5 0 90 0
OBJ scenes/obj/Dragon_800K.obj 0.5 0 -0.55 5 0 -90 0
# OBJ obj/Model.obj

View File

@ -91,8 +91,8 @@ bool intersectTriangle(Ray ray, GPUTriangle obj, out hitInfo hit)
hit.v = v;
hit.t = t;
hit.position = ray.origin + ray.direction * t;
// hit.normal = vec3(u, v, 1 - (u + v)); //texture mapping
hit.normal = obj.normal * sign(-dot(ray.direction, obj.normal));
// hit.normal = vec3(u, v, 1 - (u + v)); //texture mapping
return (valid);
}

View File

@ -113,9 +113,7 @@ vec3 getTextureColor(int texture_index, hitInfo hit)
void calculateLightColor(GPUMaterial mat, hitInfo hit, inout vec3 color, inout vec3 light, inout uint rng_state)
{
if (mat.texture_index != -1)
color *= getTextureColor(mat.texture_index, hit);
color *= mat.texture_index == -1 ? vec3(1.0) : getTextureColor(mat.texture_index, hit);
color *= mat.color;
light += mat.emission * mat.color;
// light += sampleLights(hit.position, rng_state);

View File

@ -80,10 +80,8 @@ Ray transparencyRay(hitInfo hit, Ray ray, GPUMaterial mat, inout uint rng_state)
Ray newRay(hitInfo hit, Ray ray, inout uint rng_state)
{
GPUObject obj;
GPUMaterial mat;
obj = objects[hit.obj_index];
mat = materials[hit.mat_index];
if (mat.type == 0)

View File

@ -67,7 +67,7 @@ Shader::Shader(std::string vertexPath, std::string fragmentPath, std::string com
const char *fragmentCode = loadFileWithIncludes(fragmentPath);
const char *computeCode = loadFileWithIncludes(computePath);
// printWithLineNumbers(computeCode);
printWithLineNumbers(computeCode);
_vertex = glCreateShader(GL_VERTEX_SHADER);