Skip to content

Commit

Permalink
fixed(display): Ensure the strokeWidth of Boxes is correctly rendered…
Browse files Browse the repository at this point in the history
… in all cases

Signed-off-by: Tim Deubler <[email protected]>
  • Loading branch information
TerminalTim committed Aug 23, 2024
1 parent 58c1f0a commit 19fa268
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
13 changes: 3 additions & 10 deletions packages/display/src/displays/webgl/glsl/box_fragment.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,9 @@ void main(void){
normal = normalize(surfacePos - v_worldPos);
#else

vec3 size = vSize;
// size.z *= u_zMeterToPixel;
vec3 pos = vPosition;
// vec3 pos = vec3(vPosition.xy,vPosition.z*u_zMeterToPixel);



float a = smoothstep(v_strokeWidth, v_strokeWidth + smoothness, length(abs(pos.xy) - size.xy));
a *= smoothstep(v_strokeWidth, v_strokeWidth + smoothness, length(abs(pos.yz) - size.yz));
a *= smoothstep(v_strokeWidth, v_strokeWidth + smoothness, length(abs(pos.xz) - size.xz));
float a = smoothstep(v_strokeWidth, v_strokeWidth + smoothness, length(abs(vPosition.xy) - vSize.xy));
a *= smoothstep(v_strokeWidth, v_strokeWidth + smoothness, length(abs(vPosition.yz) - vSize.yz));
a *= smoothstep(v_strokeWidth, v_strokeWidth + smoothness, length(abs(vPosition.xz) - vSize.xz));
color = mix(u_stroke, u_fill, a);

// interpolated varying -> unit vector
Expand Down
2 changes: 1 addition & 1 deletion packages/display/src/displays/webgl/glsl/box_vertex.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void main(void){
#else
// vPosition = vertexOffset;
vPosition = vec3(vertexOffset.xy, vertexOffset.z * u_zMeterToPixel);
v_strokeWidth = u_strokeWidth / u_scale;
v_strokeWidth = u_strokeWidth / u_scale * scaleDZ;
#endif

vSize = size;
Expand Down

0 comments on commit 19fa268

Please sign in to comment.