# vtkShaderProperty::AddFragmentShaderReplacement behaves differently in WebAssembly (VTK 9.5.2) compared to native OpenGL

**URL:** https://discourse.vtk.org/t/vtkshaderproperty-addfragmentshaderreplacement-behaves-differently-in-webassembly-vtk-9-5-2-compared-to-native-opengl/16513
**Category:** vtk.wasm
**Created:** [August 17, 2026, 6:28pm UTC](https://discourse.vtk.org/t/vtkshaderproperty-addfragmentshaderreplacement-behaves-differently-in-webassembly-vtk-9-5-2-compared-to-native-opengl/16513 "2026-08-17T18:28:25Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![HST](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/h/b38774/32.png) [@HST](https://discourse.vtk.org/u/HST)
#### Post date: [August 17, 2026, 6:28pm UTC](https://discourse.vtk.org/t/vtkshaderproperty-addfragmentshaderreplacement-behaves-differently-in-webassembly-vtk-9-5-2-compared-to-native-opengl/16513/1 "2026-08-17T18:28:25Z")

</div>

Hi,

I use `vtkShaderProperty::AddFragmentShaderReplacement()` to modify the fragment shader.

The following shader replacement works correctly in the native OpenGL build, the actor is red. But it has no visible effect in a WebAssembly/WebGL2 build. The actor itself is rendered correctly in both builds.  
The shader replacement is installed without compile or runtime errors.

auto shaderProperty =

actor-\>GetShaderProperty();

shaderProperty-\>AddFragmentShaderReplacement(  
“//VTK::Light::Impl”,  
false,  
R"glsl(  
//VTK::Light::Impl  
fragOutput0.rgb =  
vec3(1.0, 0.0, 0.0);  
)glsl",  
false);

# Expected Result:

Both builds render the actor completely red.

# Actual Result

### Native OpenGL

The actor becomes red as expected.

### WebAssembly / WebGL2

The actor keeps its original color.

The replacement appears to have no visible effect.

Environment:

VTK Version: 9.5.2

Native:

- Windows 11

- RenderingOpenGL2

- MSVC 2022

Web:

- Emscripten

- WebGL2

- VTK built from source

VTK configuration:

VTK\_ENABLE\_WEBGPU=OFF

VTK\_OPENGL\_HAS\_EGL=OFF

VTK\_OPENGL\_USE\_GLES=ON

VTK\_MODULE\_ENABLE\_VTK\_RenderingOpenGL2=DEFAULT

VTK\_WEBASSEMBLY\_64\_BIT=OFF
