Skip to content

Commit

Permalink
Fix shader compilation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
BarthPaleologue committed Feb 17, 2025
1 parent 0bd294e commit 10ab9b0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
10 changes: 6 additions & 4 deletions src/shaders/mandelbox.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,15 @@ float distanceEstimator(vec3 position) {
void main() {
vec4 screenColor = texture2D(textureSampler, vUV);// the current screen color

vec3 pixelWorldPosition = worldFromUV(vUV, camera_inverseProjection, camera_inverseView);// the pixel position in world space (near plane)
vec3 rayDir = normalize(pixelWorldPosition - camera_position);// normalized direction of the ray

float depth = texture2D(depthSampler, vUV).r;// the depth corresponding to the pixel in the depth map

vec3 pixelWorldPosition = worldFromUV(vUV, depth, camera_inverseProjectionView);// the pixel position in world space (near plane)

// actual depth of the scene
float maximumDistance = length(pixelWorldPosition - camera_position) * remap(depth, 0.0, 1.0, camera_near, camera_far);
float maximumDistance = length(pixelWorldPosition - camera_position);

vec3 rayDir = normalize(worldFromUV(vUV, 1.0, camera_inverseProjectionView) - camera_position);

float impactPoint, escapePoint;
if (!(rayIntersectSphere(camera_position, rayDir, object_position, object_radius * object_scaling_determinant, impactPoint, escapePoint))) {
gl_FragColor = screenColor;
Expand Down
10 changes: 6 additions & 4 deletions src/shaders/mengerSponge.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,15 @@ float distanceEstimator( in vec3 p ) {
void main() {
vec4 screenColor = texture2D(textureSampler, vUV);// the current screen color

vec3 pixelWorldPosition = worldFromUV(vUV, camera_inverseProjection, camera_inverseView);// the pixel position in world space (near plane)
vec3 rayDir = normalize(pixelWorldPosition - camera_position);// normalized direction of the ray

float depth = texture2D(depthSampler, vUV).r;// the depth corresponding to the pixel in the depth map

vec3 pixelWorldPosition = worldFromUV(vUV, depth, camera_inverseProjectionView);// the pixel position in world space (near plane)

// actual depth of the scene
float maximumDistance = length(pixelWorldPosition - camera_position) * remap(depth, 0.0, 1.0, camera_near, camera_far);
float maximumDistance = length(pixelWorldPosition - camera_position);

vec3 rayDir = normalize(worldFromUV(vUV, 1.0, camera_inverseProjectionView) - camera_position);

float impactPoint, escapePoint;
if (!(rayIntersectSphere(camera_position, rayDir, object_position, object_radius * object_scaling_determinant, impactPoint, escapePoint))) {
gl_FragColor = screenColor;
Expand Down
3 changes: 2 additions & 1 deletion src/shaders/sierpinski.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,11 @@ void main() {
float depth = texture2D(depthSampler, vUV).r;// the depth corresponding to the pixel in the depth map

vec3 pixelWorldPosition = worldFromUV(vUV, depth, camera_inverseProjectionView);// the pixel position in world space (near plane)
vec3 rayDir = normalize(pixelWorldPosition - cameraPosition);// normalized direction of the ray

// actual depth of the scene
float maximumDistance = length(pixelWorldPosition - camera_position);

vec3 rayDir = normalize(worldFromUV(vUV, 1.0, camera_inverseProjectionView) - camera_position);

float impactPoint, escapePoint;
if (!(rayIntersectSphere(camera_position, rayDir, object_position, object_radius * object_scaling_determinant, impactPoint, escapePoint))) {
Expand Down

0 comments on commit 10ab9b0

Please sign in to comment.