Skip to content

Commit

Permalink
Merge pull request #148 from brown-ccv/fix-precision-opengles
Browse files Browse the repository at this point in the history
Fix float precision for OpenglES
  • Loading branch information
kmilo9999 authored Jun 12, 2023
2 parents 5f451de + 9afd393 commit 3347754
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 8 deletions.
Binary file modified example/public/assets/models/summer-high-salt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified example/public/assets/models/summer-high-temp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified example/public/assets/models/summer-low-salt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified example/public/assets/models/summer-low-temp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified example/public/assets/models/winter-high-salt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified example/public/assets/models/winter-high-temp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified example/public/assets/models/winter-low-salt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified example/public/assets/models/winter-low-temp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 11 additions & 8 deletions src/aframe/fragment-shader.frag
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ v_: Data for the entire volume
*/

// Clip the volume between clip_min and clip_max
vec2 intersectBox(vec3 camera, vec3 direction, vec3 clip_min, vec3 clip_max ) {
vec3 direction_inverse = 1.0 / direction;
vec3 bmin_direction = (clip_min - camera) * direction_inverse;
vec3 bmax_direction = (clip_max - camera) * direction_inverse;
vec3 tmin = min(bmin_direction, bmax_direction);
vec3 tmax = max(bmin_direction, bmax_direction);
vec2 intersectBox(highp vec3 camera, highp vec3 direction, vec3 clip_min, vec3 clip_max ) {
highp vec3 direction_inverse = 1.0 / direction;
highp vec3 bmin_direction = (clip_min - camera) * direction_inverse;
highp vec3 bmax_direction = (clip_max - camera) * direction_inverse;
highp vec3 tmin = min(bmin_direction, bmax_direction);
highp vec3 tmax = max(bmin_direction, bmax_direction);
float t_start = max(tmin.x, max(tmin.y, tmin.z));
float t_end = min(tmax.x, min(tmax.y, tmax.z));
return vec2(t_start, t_end);
Expand All @@ -54,6 +54,9 @@ vec4 sample_model(ModelStruct model, vec2 start_position, vec2 end_position, flo
model_sample.a = max(model_sample.r, max(model_sample.g, model_sample.b));
if(model_sample.a < 0.20) model_sample.a *= 0.1;

// uncomment next line and comment next return statement to render basic volume cube
// return vec4(1.0,0.0,0.0,1.0);

// Sample transfer texture
return texture(
model.transfer_texture,
Expand All @@ -71,8 +74,8 @@ void main() {

// Get the t values for the intersection with the clipping values
vec2 t_hit = intersectBox(camPos, ray_direction, clip_min, clip_max);
float t_start = t_hit.x;
float t_end = t_hit.y;
highp float t_start = t_hit.x;
highp float t_end = t_hit.y;

/*
We dont want to sample voxels behind the eye if its inside the volume,
Expand Down

0 comments on commit 3347754

Please sign in to comment.