Skip to content

Commit

Permalink
Merge pull request #21 from hborchardt/hborchardt/3dsurface_offset_pr…
Browse files Browse the repository at this point in the history
…ecision

Improve precision of surface3d worldPosition calculation
  • Loading branch information
archmoj authored May 16, 2024
2 parents 682e1a2 + 6c75a5b commit 4f7404e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion shaders/contour-vertex.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ varying vec4 vColor;
void main() {
vec3 dataCoordinate = permutation * vec3(uv.xy, height);
worldCoordinate = objectOffset + dataCoordinate;
vec4 worldPosition = model * vec4(worldCoordinate, 1.0);
mat4 objectOffsetTranslation = mat4(1.0) + mat4(vec4(0), vec4(0), vec4(0), vec4(objectOffset, 0));
vec4 worldPosition = (model * objectOffsetTranslation) * vec4(dataCoordinate, 1.0);

vec4 clipPosition = projection * (view * worldPosition);
clipPosition.z += zOffset;
Expand Down
3 changes: 2 additions & 1 deletion shaders/vertex.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ varying vec4 vColor;
void main() {
vec3 localCoordinate = vec3(uv.zw, f.x);
worldCoordinate = objectOffset + localCoordinate;
vec4 worldPosition = model * vec4(worldCoordinate, 1.0);
mat4 objectOffsetTranslation = mat4(1.0) + mat4(vec4(0), vec4(0), vec4(0), vec4(objectOffset, 0));
vec4 worldPosition = (model * objectOffsetTranslation) * vec4(localCoordinate, 1.0);
vec4 clipPosition = projection * (view * worldPosition);
gl_Position = clipPosition;
kill = f.y;
Expand Down

0 comments on commit 4f7404e

Please sign in to comment.