# CustomVertexShaderCode

**URL:** https://discourse.vtk.org/t/customvertexshadercode/15106
**Category:** Support
**Created:** [January 3, 2025, 3:45am UTC](https://discourse.vtk.org/t/customvertexshadercode/15106 "2025-01-03T03:45:54Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![1078586743](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/1/838e76/32.png) [@1078586743](https://discourse.vtk.org/u/1078586743)
#### Post date: [January 3, 2025, 3:45am UTC](https://discourse.vtk.org/t/customvertexshadercode/15106/1 "2025-01-03T03:45:54Z")

</div>

Hi  
I’m newer to vtk, when i use SetVertexShaderCode of vtkShaderProperty, the model will disappear.But if i remove SetVertexShaderCode and only use SetFragmentShaderCode, it can work.Following is my VertexShader code

````auto
const char* vertexShaderCode = R"(
#version 330 core

in vec3 normalMC;
in vec3 vertexVC;
in mat4 MCVCMatrix;

out vec3 myNormalMCVSOutput;
out vec3 camPosition;

void main() {
    myNormalMCVSOutput = normalMC;
    camPosition = -vec3(MCVCMatrix[3].x, MCVCMatrix[3].y, MCVCMatrix[3].z) * mat3(MCVCMatrix);
	gl_Position = MCVCMatrix * vec4(vertexVC, 1.0);
}
)";```
````

---

<div class="post-metadata">

### Author: ![jaswantp](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jaswantp/32/10046_2.png) [@jaswantp](https://discourse.vtk.org/u/jaswantp)
#### Post date: [January 3, 2025, 1:53pm UTC](https://discourse.vtk.org/t/customvertexshadercode/15106/2 "2025-01-03T13:53:11Z")

</div>

> [@1078586743](#):
>
> ```auto
> gl_Position = MCVCMatrix * vec4(vertexVC, 1.0);
> 
> ```

Multiply with `MCDCMatrix` instead of `MCVCMatrix`

---

<div class="post-metadata">

### Author: ![1078586743](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/1/838e76/32.png) [@1078586743](https://discourse.vtk.org/u/1078586743)
#### Post date: [January 6, 2025, 12:59am UTC](https://discourse.vtk.org/t/customvertexshadercode/15106/3 "2025-01-06T00:59:32Z")

</div>

Thanks for your reply, i try it and it could work.
