mirror of
https://github.com/TheRedShip/RT_GPU.git
synced 2025-09-27 18:48:36 +02:00
~ | Fixing emissive texture
This commit is contained in:
@ -202,8 +202,8 @@ vec3 pathtrace(Ray ray, inout uint rng_state)
|
||||
GPUMaterial mat = materials[hit.mat_index];
|
||||
calculateLightColor(mat, hit, color, light, rng_state);
|
||||
|
||||
if (mat.emission > 0.0)
|
||||
break;
|
||||
// if (mat.emission > 0.0 && mat.emission_texture_index == -1)
|
||||
// break;
|
||||
|
||||
ray = newRay(hit, ray, rng_state);
|
||||
ray.inv_direction = 1.0 / ray.direction;
|
||||
|
@ -2,7 +2,7 @@ hitInfo traceRay(Ray ray);
|
||||
|
||||
vec3 GetEnvironmentLight(Ray ray)
|
||||
{
|
||||
return vec3(0.);
|
||||
// return vec3(0.);
|
||||
vec3 sun_pos = vec3(-0.5, 0.5, 0.5);
|
||||
float SunFocus = 1.5;
|
||||
float SunIntensity = 1.;
|
||||
@ -101,8 +101,8 @@ vec2 getSphereUV(vec3 surfacePoint)
|
||||
return vec2(u, v);
|
||||
}
|
||||
|
||||
uniform sampler2D textures[32];
|
||||
uniform sampler2D emission_textures[32];
|
||||
uniform sampler2D textures[64];
|
||||
uniform sampler2D emissive_textures[64];
|
||||
|
||||
vec2 getTextureColor(hitInfo hit)
|
||||
{
|
||||
@ -130,11 +130,14 @@ void calculateLightColor(GPUMaterial mat, hitInfo hit, inout vec3 color, inou
|
||||
if (mat.emission_texture_index != -1)
|
||||
{
|
||||
vec2 uv = getTextureColor(hit);
|
||||
light += mat.emission * texture(emission_textures[mat.emission_texture_index], uv).rgb;
|
||||
vec3 emission = mat.emission * texture(emissive_textures[mat.emission_texture_index], uv).rgb;
|
||||
|
||||
light += mat.emission * emission;
|
||||
}
|
||||
else
|
||||
{
|
||||
light += mat.emission * mat.color;
|
||||
|
||||
color *= mat.color;
|
||||
color *= mat.color;
|
||||
}
|
||||
// light += sampleLights(hit.position, rng_state);
|
||||
}
|
@ -141,22 +141,21 @@ hitInfo traverseBVHs(Ray ray)
|
||||
|
||||
hitInfo temp_hit = traceBVH(transformedRay, BvhData[i]);
|
||||
|
||||
|
||||
float transformed_t = temp_hit.t / bvh_data.scale;
|
||||
if (transformed_t < hit.t)
|
||||
{
|
||||
GPUTriangle triangle = triangles[temp_hit.obj_index];
|
||||
GPUTriangle triangle = triangles[temp_hit.obj_index];
|
||||
|
||||
hit.u = temp_hit.u;
|
||||
hit.v = temp_hit.v;
|
||||
hit.t = transformed_t;
|
||||
hit.obj_index = temp_hit.obj_index;
|
||||
hit.mat_index = triangle.mat_index;
|
||||
|
||||
|
||||
vec3 position = transformedRay.origin + transformedRay.direction * temp_hit.t;
|
||||
hit.position = inverseTransformMatrix * position + bvh_data.offset;
|
||||
|
||||
vec3 based_normal = triangle.normal; // * sign(-dot(transformedRay.direction, triangle.normal));
|
||||
vec3 based_normal = triangle.normal * sign(-dot(transformedRay.direction, triangle.normal));
|
||||
hit.normal = normalize(inverseTransformMatrix * based_normal);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user