55 ADDRESS_CLAMP_TO_EDGE , BLENDEQUATION_ADD , BLENDMODE_ONE_MINUS_SRC_ALPHA , BLENDMODE_SRC_ALPHA ,
66 CULLFACE_NONE ,
77 FILTER_LINEAR , FILTER_LINEAR_MIPMAP_LINEAR , PIXELFORMAT_SRGBA8 ,
8- SEMANTIC_POSITION ,
9- SHADERLANGUAGE_GLSL
8+ SEMANTIC_POSITION
109} from '../../platform/graphics/constants.js' ;
1110import { DepthState } from '../../platform/graphics/depth-state.js' ;
1211import { RenderTarget } from '../../platform/graphics/render-target.js' ;
@@ -15,7 +14,6 @@ import { drawQuadWithShader } from '../../scene/graphics/quad-render-utils.js';
1514import { QuadRender } from '../../scene/graphics/quad-render.js' ;
1615import { StandardMaterialOptions } from '../../scene/materials/standard-material-options.js' ;
1716import { StandardMaterial } from '../../scene/materials/standard-material.js' ;
18- import { ShaderChunks } from '../../scene/shader-lib/shader-chunks.js' ;
1917import { ShaderUtils } from '../../scene/shader-lib/shader-utils.js' ;
2018
2119/**
@@ -60,6 +58,46 @@ const shaderOutlineExtendPS = /* glsl */ `
6058 }
6159` ;
6260
61+ // WGSL version of the outline extend shader
62+ const shaderOutlineExtendWGSL = /* wgsl */ `
63+
64+ varying vUv0: vec2f;
65+
66+ uniform uOffset: vec2f;
67+ uniform uSrcMultiplier: f32;
68+ var source: texture_2d<f32>;
69+ var sourceSampler: sampler;
70+
71+ @fragment
72+ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
73+ var output: FragmentOutput;
74+
75+ var pixel: vec4f;
76+ var texel = textureSample(source, sourceSampler, input.vUv0);
77+ let firstTexel = texel;
78+ var diff = texel.a * uniform.uSrcMultiplier;
79+
80+ pixel = textureSample(source, sourceSampler, input.vUv0 + uniform.uOffset * -2.0);
81+ texel = max(texel, pixel);
82+ diff = max(diff, length(firstTexel.rgb - pixel.rgb));
83+
84+ pixel = textureSample(source, sourceSampler, input.vUv0 + uniform.uOffset * -1.0);
85+ texel = max(texel, pixel);
86+ diff = max(diff, length(firstTexel.rgb - pixel.rgb));
87+
88+ pixel = textureSample(source, sourceSampler, input.vUv0 + uniform.uOffset * 1.0);
89+ texel = max(texel, pixel);
90+ diff = max(diff, length(firstTexel.rgb - pixel.rgb));
91+
92+ pixel = textureSample(source, sourceSampler, input.vUv0 + uniform.uOffset * 2.0);
93+ texel = max(texel, pixel);
94+ diff = max(diff, length(firstTexel.rgb - pixel.rgb));
95+
96+ output.color = vec4f(texel.rgb, min(diff, 1.0));
97+ return output;
98+ }
99+ ` ;
100+
63101const _tempFloatArray = new Float32Array ( 2 ) ;
64102const _tempColor = new Color ( ) ;
65103
@@ -119,8 +157,9 @@ class OutlineRenderer {
119157 this . shaderExtend = ShaderUtils . createShader ( device , {
120158 uniqueName : 'OutlineExtendShader' ,
121159 attributes : { vertex_position : SEMANTIC_POSITION } ,
122- vertexGLSL : ShaderChunks . get ( device , SHADERLANGUAGE_GLSL ) . get ( 'fullscreenQuadVS' ) ,
123- fragmentGLSL : shaderOutlineExtendPS
160+ vertexChunk : 'fullscreenQuadVS' ,
161+ fragmentGLSL : shaderOutlineExtendPS ,
162+ fragmentWGSL : shaderOutlineExtendWGSL
124163 } ) ;
125164
126165 this . shaderBlend = ShaderUtils . createShader ( device , {
0 commit comments