mirror of
https://github.com/TheRedShip/RT_GPU.git
synced 2025-09-27 10:48:34 +02:00
~ | Small fix
This commit is contained in:
42
scenes/colored_light2.rt
Normal file
42
scenes/colored_light2.rt
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
CAM -1.96358 -1.9992 7.56063 1.4 -70.8 0.142 4.412 90 10
|
||||||
|
|
||||||
|
# TEX skymap.hdr
|
||||||
|
# MAT 255 255 255 1.0 0.0 0.0 LAM 0 // 0
|
||||||
|
# sp 0 2 0 150 0
|
||||||
|
|
||||||
|
MAT 90 200 250 1.0 0.0 0.0 // 0
|
||||||
|
MAT 140 160 250 1.0 0.0 0.0 // 1
|
||||||
|
MAT 200 100 250 1.0 0.0 0.0 // 2
|
||||||
|
MAT 240 70 230 1.0 0.0 0.0 // 3
|
||||||
|
MAT 250 130 180 1.0 0.0 0.0 // 4
|
||||||
|
MAT 250 180 120 1.0 0.0 0.0 // 5
|
||||||
|
MAT 240 230 60 1.0 0.0 0.0 // 6
|
||||||
|
MAT 200 250 100 1.0 0.0 0.0 // 7
|
||||||
|
MAT 150 250 150 1.0 0.0 0.0 // 8
|
||||||
|
MAT 90 250 200 1.0 0.0 0.0 // 9
|
||||||
|
|
||||||
|
MAT 200 200 200 0.0 0.0 0.0 // 10
|
||||||
|
MAT 200 200 200 0.0 1.25 0.0 DIE -1 // 11
|
||||||
|
|
||||||
|
qu -5 -5 0.01 0 10 0 0.5 0 0 1 0
|
||||||
|
qu -4 -5 0.01 0 10 0 0.5 0 0 1 1
|
||||||
|
qu -3 -5 0.01 0 10 0 0.5 0 0 1 2
|
||||||
|
qu -2 -5 0.01 0 10 0 0.5 0 0 1 3
|
||||||
|
qu -1 -5 0.01 0 10 0 0.5 0 0 1 4
|
||||||
|
qu 0 -5 0.01 0 10 0 0.5 0 0 1 5
|
||||||
|
qu 1 -5 0.01 0 10 0 0.5 0 0 1 6
|
||||||
|
qu 2 -5 0.01 0 10 0 0.5 0 0 1 7
|
||||||
|
qu 3 -5 0.01 0 10 0 0.5 0 0 1 8
|
||||||
|
qu 4 -5 0.01 0 10 0 0.5 0 0 1 9
|
||||||
|
|
||||||
|
cu 0 0 5 10 10 10 10
|
||||||
|
# sp 0 -2 5 3 11
|
||||||
|
|
||||||
|
OBJ obj/Dragon_800K.obj 0 -2.75 7.5 30 0 0 0 11
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,7 +1,4 @@
|
|||||||
#CAM 18.9143 1.24843 -5.48951 8.5 -200 0.04 14.829 45 2
|
CAM 18.9143 1.24843 -5.48951 8.5 -200 0.04 14.829 45 5
|
||||||
#CAM -30.2582 13.4046 6.92082 9.69999 -61.2004 0.04 14.829 45 2
|
|
||||||
#CAM 3.05548 13.1494 -6.01793 9.44218 18.2879 0.00 14.829 45 2
|
|
||||||
CAM 17.5213 11.4943 -1.28202 -36.7578 -904.112 0 14.829 45 2
|
|
||||||
|
|
||||||
MAT 255 255 255 0.0 1.0 0.5 // dragon 0
|
MAT 255 255 255 0.0 1.0 0.5 // dragon 0
|
||||||
MAT 255 220 50 0.0 1.0 0.5 // dragon 1
|
MAT 255 220 50 0.0 1.0 0.5 // dragon 1
|
||||||
|
@ -34,7 +34,6 @@ void main()
|
|||||||
float totalWeight = 0.;
|
float totalWeight = 0.;
|
||||||
vec4 light = vec4(vec3(0.), 1.0);
|
vec4 light = vec4(vec3(0.), 1.0);
|
||||||
|
|
||||||
|
|
||||||
for (int x = -2; x <= 2; x++)
|
for (int x = -2; x <= 2; x++)
|
||||||
{
|
{
|
||||||
for (int y = -2; y <= 2; y++)
|
for (int y = -2; y <= 2; y++)
|
||||||
@ -72,7 +71,7 @@ void main()
|
|||||||
if (u_pass == u_pass_count - 1)
|
if (u_pass == u_pass_count - 1)
|
||||||
{
|
{
|
||||||
vec4 color = light * imageLoad(color_texture, pixel_coords);
|
vec4 color = light * imageLoad(color_texture, pixel_coords);
|
||||||
imageStore(output_texture, pixel_coords, color);
|
imageStore(output_texture, pixel_coords, sqrt(color));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ bool intersectTriangle(Ray ray, GPUTriangle obj, out hitInfo hit)
|
|||||||
vec3 pvec = cross(ray.direction, vertex2);
|
vec3 pvec = cross(ray.direction, vertex2);
|
||||||
float det = dot(vertex1, pvec);
|
float det = dot(vertex1, pvec);
|
||||||
|
|
||||||
if (abs(det) < 1e-8)
|
if (abs(det) < 1e-10)
|
||||||
return (false);
|
return (false);
|
||||||
|
|
||||||
vec3 tvec = ray.origin - obj.position;
|
vec3 tvec = ray.origin - obj.position;
|
||||||
|
@ -68,24 +68,18 @@ vec3 sampleQuadLight(vec3 position, GPUObject obj, int light_index, GPUMaterial
|
|||||||
return mat.emission * mat.color / (light_dist * light_dist) * pdf;
|
return mat.emission * mat.color / (light_dist * light_dist) * pdf;
|
||||||
}
|
}
|
||||||
|
|
||||||
vec3 sampleLights(vec3 position, inout uint rng_state)
|
vec3 sampleLights(in vec3 position, inout uint rng_state)
|
||||||
{
|
{
|
||||||
vec3 light = vec3(0.0);
|
int light_list_index = int(floor(randomValue(rng_state) * float(u_lightsNum)));
|
||||||
|
int light_index = lightsIndex[light_list_index];
|
||||||
|
|
||||||
|
GPUObject light_obj = objects[light_index];
|
||||||
|
GPUMaterial lightMat = materials[light_obj.mat_index];
|
||||||
|
|
||||||
for (int i = 0; i < u_lightsNum; i++)
|
if (light_obj.type == 0)
|
||||||
{
|
return float(u_lightsNum) * sampleSphereLight(position, light_obj, light_index, lightMat, rng_state);
|
||||||
int light_index = lightsIndex[i];
|
else if (light_obj.type == 2)
|
||||||
|
return float(u_lightsNum) * sampleQuadLight(position, light_obj, light_index, lightMat, rng_state);
|
||||||
GPUObject obj = objects[light_index];
|
|
||||||
GPUMaterial mat = materials[obj.mat_index];
|
|
||||||
|
|
||||||
if (obj.type == 0)
|
|
||||||
light += sampleSphereLight(position, obj, light_index, mat, rng_state);
|
|
||||||
else if (obj.type == 2)
|
|
||||||
light += sampleQuadLight(position, obj, light_index, mat, rng_state);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (light);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vec2 getSphereUV(vec3 surfacePoint)
|
vec2 getSphereUV(vec3 surfacePoint)
|
||||||
@ -134,6 +128,7 @@ void calculateLightColor(GPUMaterial mat, hitInfo hit, inout vec3 color, inou
|
|||||||
{
|
{
|
||||||
color *= mat.color;
|
color *= mat.color;
|
||||||
light += mat.emission * mat.color;
|
light += mat.emission * mat.color;
|
||||||
// light += sampleLights(hit.position, rng_state);
|
// if (mat.emission == 0.0)
|
||||||
|
// light += sampleLights(hit.position, rng_state);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -204,6 +204,8 @@ vec3[2] pathtrace(Ray ray, inout uint rng_state)
|
|||||||
{
|
{
|
||||||
imageStore(normal_texture, ivec2(gl_GlobalInvocationID.xy), vec4(normalize(hit.normal), 1.0));
|
imageStore(normal_texture, ivec2(gl_GlobalInvocationID.xy), vec4(normalize(hit.normal), 1.0));
|
||||||
imageStore(position_texture, ivec2(gl_GlobalInvocationID.xy), vec4(normalize(hit.position), 1.0));
|
imageStore(position_texture, ivec2(gl_GlobalInvocationID.xy), vec4(normalize(hit.position), 1.0));
|
||||||
|
// vec4 accum_normal = accumulate(normal_texture, accum_normal, normalize(hit.normal));
|
||||||
|
// vec4 accum_position = accumulate(position_texture, accum_position, normalize(hit.position));
|
||||||
}
|
}
|
||||||
|
|
||||||
float p = max(color.r, max(color.g, color.b));
|
float p = max(color.r, max(color.g, color.b));
|
||||||
@ -269,11 +271,10 @@ void main()
|
|||||||
vec3[2] color_light = pathtrace(ray, rng_state);
|
vec3[2] color_light = pathtrace(ray, rng_state);
|
||||||
vec3 color = color_light[0] * color_light[1];
|
vec3 color = color_light[0] * color_light[1];
|
||||||
|
|
||||||
vec4 accum_color = accumulate(color_texture, accum_color, sqrt(color_light[0]));
|
vec4 accum_color = accumulate(color_texture, accum_color, (color_light[0]));
|
||||||
|
|
||||||
vec4 accum_light = accumulate(light_accum_texture, accum_light, color_light[1]);
|
vec4 accum_light = accumulate(light_accum_texture, accum_light, color_light[1]);
|
||||||
vec4 final_light = sqrt(accum_light);
|
|
||||||
imageStore(light_texture, pixel_coords, final_light);
|
imageStore(light_texture, pixel_coords, accum_light);
|
||||||
|
|
||||||
vec4 accum = accumulate(output_accum_texture, accum, color);
|
vec4 accum = accumulate(output_accum_texture, accum, color);
|
||||||
vec4 final_output_color = sqrt(accum);
|
vec4 final_output_color = sqrt(accum);
|
||||||
|
@ -35,9 +35,9 @@ Scene::Scene(std::string &name)
|
|||||||
|
|
||||||
_gpu_denoise.enabled = 0;
|
_gpu_denoise.enabled = 0;
|
||||||
_gpu_denoise.pass = 0;
|
_gpu_denoise.pass = 0;
|
||||||
_gpu_denoise.c_phi = 0.1f;
|
_gpu_denoise.c_phi = 0.4f;
|
||||||
_gpu_denoise.p_phi = 0.1f;
|
_gpu_denoise.p_phi = 0.01f;
|
||||||
_gpu_denoise.n_phi = 0.1f;
|
_gpu_denoise.n_phi = 0.01f;
|
||||||
|
|
||||||
if (!file.is_open())
|
if (!file.is_open())
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user