Skip to content

Commit 8a59d96

Browse files
authored
AlphaToCoverage Example: Make wireframe thickness consistent (#21389)
* make ATC wireframe lines a consistent thickness * Add spacing, variable rename * fix screenshot
1 parent a529689 commit 8a59d96

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed
2.74 KB
Loading

examples/webgl_materials_wireframe.html

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,13 @@
7575
in vec3 vCenter;
7676
out vec4 outColor;
7777

78-
float aastep( float threshold, float dist ) {
79-
80-
float afwidth = fwidth( dist ) * 0.5;
81-
return smoothstep( threshold - afwidth, threshold + afwidth, dist );
82-
83-
}
84-
8578
void main() {
8679

87-
float d = min( min( vCenter.x, vCenter.y ), vCenter.z );
80+
vec3 afwidth = fwidth( vCenter.xyz );
8881

89-
float edge = 1.0 - aastep( thickness, d );
82+
vec3 edge3 = smoothstep( thickness * afwidth, ( thickness + 1.0 ) * afwidth, vCenter.xyz );
83+
84+
float edge = 1.0 - min( min( edge3.x, edge3.y ), edge3.z );
9085

9186
outColor.rgb = gl_FrontFacing ? vec3( 0.9, 0.9, 1.0 ) : vec3( 0.4, 0.4, 0.5 );
9287
outColor.a = edge;
@@ -196,7 +191,7 @@
196191
gui.add( API, 'thickness', 0.4, 4 ).onChange( function () {
197192

198193
mesh2.material.uniforms.thickness.value = API.thickness;
199-
mesh3.material.uniforms.thickness.value = API.thickness * 0.01;
194+
mesh3.material.uniforms.thickness.value = API.thickness;
200195

201196
} );
202197

0 commit comments

Comments
 (0)