mirror of
https://github.com/TheRedShip/RT_GPU.git
synced 2025-09-27 10:48:34 +02:00
~ | Some map changing
This commit is contained in:
@ -19,5 +19,5 @@ pl -3 0 0 1 0 0 3
|
||||
pl 0 0 -3 0 0 1 4
|
||||
pl 0 0 3 0 0 -1 2
|
||||
|
||||
po -0.5 -0.5 -1 0 1 0 1 1 0 0 2
|
||||
po -0.5 -0.5 1 0 1 0 1 0 0 1 4
|
||||
po -0.33 -0.66 -1 -0.25 1 0 1 0.25 0 0 2
|
||||
po -0.5 -0.5 1 0 1 0 1 0 0 1 4
|
20
scenes/test.rt
Normal file
20
scenes/test.rt
Normal file
@ -0,0 +1,20 @@
|
||||
CAM 0 1 3
|
||||
|
||||
MAT 200 200 200 0.0 0.0 0.0 //white
|
||||
MAT 255 50 50 0.0 0.0 0.0 //red
|
||||
MAT 50 255 50 0.0 0.0 0.0 //green
|
||||
MAT 100 100 255 0.0 0.0 0.0 //blue
|
||||
MAT 255 100 255 0.0 0.0 0.0 //purple
|
||||
MAT 30 30 30 0.0 0.0 0.0 //black
|
||||
|
||||
MAT 255 255 255 5.0 0.0 0.0 //light
|
||||
|
||||
# sp -100 30 50 50 6
|
||||
|
||||
sp 0 -25 0 50 4
|
||||
|
||||
sp 1 1 -0.5 2 0
|
||||
sp -0.8 0.8 0 1.5 1
|
||||
sp -2.2 0.4 0.25 1 2
|
||||
sp -3 0.2 0.50 0.75 3
|
||||
sp -3.8 -0.1 0.60 0.5 5
|
@ -135,7 +135,8 @@ vec3 pathtrace(Ray ray, inout uint rng_state)
|
||||
hitInfo hit = traceRay(ray);
|
||||
if (hit.obj_index == -1)
|
||||
{
|
||||
light += vec3(0); //ambient color
|
||||
light += GetEnvironmentLight(ray);
|
||||
// light += vec3(135 / 255.0f, 206 / 255.0f, 235 / 255.0f); //ambient color
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -29,28 +29,21 @@ vec3 randomHemisphereDirection(vec3 normal, inout uint rng_state)
|
||||
return (direction * sign(dot(normal, direction)));
|
||||
}
|
||||
|
||||
vec3 GetEnvironmentLight(Ray ray)
|
||||
{
|
||||
vec3 sun_pos = vec3(-0.5, 0.5, 0.5);
|
||||
float SunFocus = 1.5;
|
||||
float SunIntensity = 1;
|
||||
|
||||
// vec3 randomHemisphereDirection(vec3 normal, inout uint rng_state)
|
||||
// {
|
||||
// float r1 = randomValue(rng_state);
|
||||
// float r2 = randomValue(rng_state);
|
||||
|
||||
// float phi = 2.0 * M_PI * r1;
|
||||
// float cos_theta = sqrt(1.0 - r2);
|
||||
// float sin_theta = sqrt(r2);
|
||||
|
||||
// // Create orthonormal basis
|
||||
// vec3 tangent, bitangent;
|
||||
// if (abs(normal.x) > abs(normal.z)) {
|
||||
// tangent = normalize(vec3(-normal.y, normal.x, 0.0));
|
||||
// } else {
|
||||
// tangent = normalize(vec3(0.0, -normal.z, normal.y));
|
||||
// }
|
||||
// bitangent = cross(normal, tangent);
|
||||
|
||||
// return normalize(
|
||||
// tangent * (cos(phi) * sin_theta) +
|
||||
// bitangent * (sin(phi) * sin_theta) +
|
||||
// normal * cos_theta
|
||||
// );
|
||||
// }
|
||||
vec3 GroundColour = vec3(0.5, 0.5, 0.5);
|
||||
vec3 SkyColourHorizon = vec3(135 / 255.0f, 206 / 255.0f, 235 / 255.0f);
|
||||
vec3 SkyColourZenith = SkyColourHorizon / 2.0;
|
||||
|
||||
float skyGradientT = pow(smoothstep(0, 0.4, ray.direction.y), 0.35);
|
||||
float groundToSkyT = smoothstep(-0.01, 0, ray.direction.y);
|
||||
vec3 skyGradient = mix(SkyColourHorizon, SkyColourZenith, skyGradientT);
|
||||
float sun = pow(max(0, dot(ray.direction, sun_pos.xyz)), SunFocus) * SunIntensity;
|
||||
// Combine ground, sky, and sun
|
||||
vec3 composite = mix(GroundColour, skyGradient, groundToSkyT) + sun * int(groundToSkyT >= 1);
|
||||
return composite;
|
||||
}
|
@ -7,31 +7,11 @@ Ray lambertRay(hitInfo hit, Ray ray, GPUMaterial mat, uint rng_state)
|
||||
bool is_specular = (mat.metallic >= randomValue(rng_state));
|
||||
|
||||
ray.origin = hit.position + hit.normal * 0.001;
|
||||
ray.direction = mix(diffuse_dir, specular_dir, mat.roughness * float(is_specular));
|
||||
ray.direction = normalize(mix(diffuse_dir, specular_dir, mat.roughness * float(is_specular)));
|
||||
|
||||
return (ray);
|
||||
}
|
||||
|
||||
// Ray dieletricRay(hitInfo hit, Ray ray, GPUMaterial mat)
|
||||
// {
|
||||
// float refraction_ratio;
|
||||
// vec3 unit_direction;
|
||||
|
||||
// refraction_ratio = 1.0f / mat.roughness; //mat.roughness = refraction (saving memory)
|
||||
|
||||
// if (dot(ray.direction, hit.normal) > 0.0f)
|
||||
// {
|
||||
// hit.normal = -hit.normal;
|
||||
// refraction_ratio = mat.roughness;
|
||||
// }
|
||||
|
||||
// unit_direction = normalize(ray.direction);
|
||||
// ray.origin = hit.position + hit.normal * -0.0001f;
|
||||
// ray.direction = refract(unit_direction, hit.normal, refraction_ratio);
|
||||
|
||||
// return (ray);
|
||||
// }
|
||||
|
||||
Ray dieletricRay(hitInfo hit, Ray ray, GPUMaterial mat)
|
||||
{
|
||||
float refraction_ratio;
|
||||
@ -39,19 +19,20 @@ Ray dieletricRay(hitInfo hit, Ray ray, GPUMaterial mat)
|
||||
|
||||
refraction_ratio = 1.0f / mat.roughness; //mat.roughness = refraction (saving memory)
|
||||
|
||||
float d = dot(ray.direction, hit.normal);
|
||||
hit.normal *= sign(d);
|
||||
|
||||
if (d > 0.0f)
|
||||
if (dot(ray.direction, hit.normal) > 0.0f)
|
||||
{
|
||||
hit.normal = -hit.normal;
|
||||
refraction_ratio = mat.roughness;
|
||||
}
|
||||
|
||||
unit_direction = normalize(ray.direction);
|
||||
ray.origin = hit.position + hit.normal * 0.0001f;
|
||||
ray.direction = refract(unit_direction, -hit.normal, refraction_ratio);
|
||||
ray.origin = hit.position + hit.normal * -0.0001f;
|
||||
ray.direction = refract(unit_direction, hit.normal, refraction_ratio);
|
||||
|
||||
return (ray);
|
||||
}
|
||||
|
||||
|
||||
Ray newRay(hitInfo hit, Ray ray, uint rng_state)
|
||||
{
|
||||
GPUObject obj;
|
||||
|
Reference in New Issue
Block a user