# Is there any documents or examples for Custom shader / Shader Replacement?

**URL:** https://discourse.paraview.org/t/is-there-any-documents-or-examples-for-custom-shader-shader-replacement/1423
**Category:** ParaView Support
**Tags:** opengl
**Created:** [March 8, 2019, 9:25am UTC](https://discourse.paraview.org/t/is-there-any-documents-or-examples-for-custom-shader-shader-replacement/1423 "2019-03-08T09:25:09Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![ymjia](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/y/ccd318/32.png) [@ymjia](https://discourse.paraview.org/u/ymjia)
#### Post date: [March 8, 2019, 9:25am UTC](https://discourse.paraview.org/t/is-there-any-documents-or-examples-for-custom-shader-shader-replacement/1423/1 "2019-03-08T09:25:09Z")

</div>

I am trying to shading a point cloud in point gaussian representation.  
But I cannot figure out how to get vertex normal or how to get camera position through shader replacement/ custom shader.

Could someone give me some hints? Thanks!

---

<div class="post-metadata">

### Author: ![Michael](https://discourse.paraview.org/user_avatar/discourse.paraview.org/michael/32/16_2.png) [@Michael](https://discourse.paraview.org/u/Michael)
#### Post date: [March 8, 2019, 10:02am UTC](https://discourse.paraview.org/t/is-there-any-documents-or-examples-for-custom-shader-shader-replacement/1423/2 "2019-03-08T10:02:31Z")

</div>

Hi,  
The spheres displayed by the Point Gaussian representation are fake spheres, it is is actually quads facing the camera, so getting the normal and camera position to compute shading would be useless (the normal is always pointing to the camera).

The default shading is computed this way:

```
float dist = dot(offsetVCGSOutput.xy,offsetVCGSOutput.xy);
if (dist > 1.0) {
  discard;
} else {
  float scale = (1.0 - dist);
  ambientColor *= scale;
  diffuseColor *= scale;
}

```

If the fragment of the quad is outside the unit circle, it is discarded.  
Otherwise, the color is scaled down with the distance from the fragment to the center of the quad.

---

<div class="post-metadata">

### Author: ![aron.helser](https://discourse.paraview.org/user_avatar/discourse.paraview.org/aron.helser/32/13_2.png) [@aron.helser](https://discourse.paraview.org/u/aron.helser)
#### Post date: [March 8, 2019, 1:46pm UTC](https://discourse.paraview.org/t/is-there-any-documents-or-examples-for-custom-shader-shader-replacement/1423/3 "2019-03-08T13:46:11Z")

</div>

The VTK shader examples also might help: [https://lorensen.github.io/VTKExamples/site/Cxx/#shaders](https://lorensen.github.io/VTKExamples/site/Cxx/#shaders)

---

<div class="post-metadata">

### Author: ![tjggriffin](https://discourse.paraview.org/user_avatar/discourse.paraview.org/tjggriffin/32/11986_2.png) [@tjggriffin](https://discourse.paraview.org/u/tjggriffin)
#### Post date: [June 28, 2023, 7:05pm UTC](https://discourse.paraview.org/t/is-there-any-documents-or-examples-for-custom-shader-shader-replacement/1423/4 "2023-06-28T19:05:03Z")

</div>

Current URL: [https://examples.vtk.org/site/](https://examples.vtk.org/site/)
