+ | Small tweaks

This commit is contained in:
TheRedShip
2025-01-09 00:03:33 +01:00
parent ff3af20e13
commit dbdd08f3ec
4 changed files with 24 additions and 20 deletions

View File

@ -1,4 +1,5 @@
TEX checker
MAT 255 255 255 4.0 0.0 0.0 //light MAT 255 255 255 4.0 0.0 0.0 //light
MAT 255 255 255 0.0 0.0 0.0 //white MAT 255 255 255 0.0 0.0 0.0 //white

View File

@ -19,6 +19,9 @@ struct GPUObject {
int mat_index; // 4 int mat_index; // 4
int type; // 4 int type; // 4
vec3 cube_size() { return (vertex1); }
int portal_index() { return (int(radius)); }
}; };
struct GPUMaterial struct GPUMaterial
@ -28,6 +31,7 @@ struct GPUMaterial
float roughness; // 4 float roughness; // 4
float metallic; // 4 float metallic; // 4
int type; // 4 int type; // 4
int texture_index; // 4
}; };
layout(std430, binding = 1) buffer ObjectBuffer layout(std430, binding = 1) buffer ObjectBuffer
@ -72,7 +76,7 @@ Ray portalRay(Ray ray, hitInfo hit)
vec3 relative; vec3 relative;
portal_1 = objects[hit.obj_index]; portal_1 = objects[hit.obj_index];
portal_2 = objects[int(portal_1.radius)]; // saving memory radius = portal_index portal_2 = objects[portal_1.portal_index()]; // saving memory radius = portal_index
relative = hit.position - portal_1.position; relative = hit.position - portal_1.position;
@ -171,7 +175,7 @@ Ray initRay(vec2 uv, inout uint rng_state)
vec3 ray_direction = normalize((inverse(u_viewMatrix) * vec4(view_space_ray, 0.0)).xyz); vec3 ray_direction = normalize((inverse(u_viewMatrix) * vec4(view_space_ray, 0.0)).xyz);
float focus_distance = 4.5; float focus_distance = 4.5;
float aperture = 0; float aperture = 0.1;
vec3 right = vec3(u_viewMatrix[0][0], u_viewMatrix[1][0], u_viewMatrix[2][0]); vec3 right = vec3(u_viewMatrix[0][0], u_viewMatrix[1][0], u_viewMatrix[2][0]);
vec3 up = vec3(u_viewMatrix[0][1], u_viewMatrix[1][1], u_viewMatrix[2][1]); vec3 up = vec3(u_viewMatrix[0][1], u_viewMatrix[1][1], u_viewMatrix[2][1]);

View File

@ -115,8 +115,7 @@ bool intersectTriangle(Ray ray, GPUObject obj, out hitInfo hit)
bool intersectCube(Ray ray, GPUObject obj, out hitInfo hit) bool intersectCube(Ray ray, GPUObject obj, out hitInfo hit)
{ {
vec3 obj_size = obj.vertex1; vec3 halfSize = obj.cube_size() * 0.5;
vec3 halfSize = obj_size * 0.5;
vec3 rayOriginLocal = ray.origin - obj.position; vec3 rayOriginLocal = ray.origin - obj.position;
vec3 invDir = 1.0 / ray.direction; vec3 invDir = 1.0 / ray.direction;

View File

@ -36,21 +36,21 @@ vec3 randomHemisphereDirection(vec3 normal, inout uint rng_state)
return (direction * sign(dot(normal, direction))); return (direction * sign(dot(normal, direction)));
} }
// vec3 GetEnvironmentLight(Ray ray) vec3 GetEnvironmentLight(Ray ray)
// { {
// vec3 sun_pos = vec3(-0.5, 0.5, 0.5); vec3 sun_pos = vec3(-0.5, 0.5, 0.5);
// float SunFocus = 1.5; float SunFocus = 1.5;
// float SunIntensity = 1; float SunIntensity = 1;
// vec3 GroundColour = vec3(0.5, 0.5, 0.5); vec3 GroundColour = vec3(0.5, 0.5, 0.5);
// vec3 SkyColourHorizon = vec3(135 / 255.0f, 206 / 255.0f, 235 / 255.0f); vec3 SkyColourHorizon = vec3(135 / 255.0f, 206 / 255.0f, 235 / 255.0f);
// vec3 SkyColourZenith = SkyColourHorizon / 2.0; vec3 SkyColourZenith = SkyColourHorizon / 2.0;
// float skyGradientT = pow(smoothstep(0, 0.4, ray.direction.y), 0.35); float skyGradientT = pow(smoothstep(0.0, 0.4, ray.direction.y), 0.35);
// float groundToSkyT = smoothstep(-0.01, 0, ray.direction.y); float groundToSkyT = smoothstep(-0.01, 0.0, ray.direction.y);
// vec3 skyGradient = mix(SkyColourHorizon, SkyColourZenith, skyGradientT); vec3 skyGradient = mix(SkyColourHorizon, SkyColourZenith, skyGradientT);
// float sun = pow(max(0, dot(ray.direction, sun_pos.xyz)), SunFocus) * SunIntensity; float sun = pow(max(0, dot(ray.direction, sun_pos.xyz)), SunFocus) * SunIntensity;
// // Combine ground, sky, and sun // Combine ground, sky, and sun
// vec3 composite = mix(GroundColour, skyGradient, groundToSkyT) + sun * int(groundToSkyT >= 1); vec3 composite = mix(GroundColour, skyGradient, groundToSkyT) + sun * int(groundToSkyT >= 1);
// return composite; return composite;
// } }