# Scenelight + GPU Volume Rendering - incorrect & inconsistent lighting

**URL:** https://discourse.vtk.org/t/scenelight-gpu-volume-rendering-incorrect-inconsistent-lighting/1454
**Category:** Support
**Created:** [July 30, 2019, 4:03pm UTC](https://discourse.vtk.org/t/scenelight-gpu-volume-rendering-incorrect-inconsistent-lighting/1454 "2019-07-30T16:03:18Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![gw99](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/g/ce7236/32.png) [@gw99](https://discourse.vtk.org/u/gw99)
#### Post date: [July 30, 2019, 4:03pm UTC](https://discourse.vtk.org/t/scenelight-gpu-volume-rendering-incorrect-inconsistent-lighting/1454/1 "2019-07-30T16:03:18Z")

</div>

Hi,

I’m trying to set up volume rendering with Scene Lights rather than using the default Head Light. This is part of a larger project, where I am using vtk external rendering. I was getting significantly different rendering results in my application compared to e.g. paraview - I am using Scenelights in my application rather than Headlights. So I modified the VTK GPURenderDemo.cxx to try and recreate my problems, and find a solution. I’m not at the bottom yet, but even within an entirely VTK environment…

…the volume renders produced with a scenelight differs significantly from the volume renders produced with a headlight with the same parameters when the camera position is the same in both instances.

For instance

- Scenelight renders may have a much darker diffuse render (but they may not be)
- Scenelight renders may have no specular highlights (but the diffuse render looks OK)
- Scenelight ‘shadows’ may noticably differ from those produced by a headlight
- **Scenelight appears to light the volume from completely the wrong direction**

NB - I am using GPU rendering, Windows 10, Visual Studio.

The data I have used in this example may be downloaded from:

[http://www.pcir.org/researchers/54879843\_20060101.html](http://www.pcir.org/researchers/54879843_20060101.html)

My modification of the GPURenderDemo code, uploaded to PasteBin:

[PasteBin of modified GPURenderDemo source code](https://pastebin.com/x8szmRvb).

These images were taken using VTK 8.2.0 (clean on today!)

 ![Skull_GPU_Scene_p00p00p00](https://discourse.vtk.org/uploads/default/original/1X/4d0c9a2b265a402e31f67abcd7664cb0d3964831.png)

Here…

- Light is a scenelight at (0, 0, -400) looking at (0, 0, 0), default parameters
- Camera is at (0, 0, -400) looking at (0, 0, 0)
- Model is at (0, 0, 0) and its rotation is (0, 0, 0)

Bit dark, but doesn’t look too bad.

 ![Skull_GPU_Scene_p00p90m90](https://discourse.vtk.org/uploads/default/original/1X/c88a9fec35533e499f9e89c23ec5a38803cf0802.png)

But if i rotate the skull, it all goes a wrong…

- Light is a scenelight at (0, 0, -400) looking at (0, 0, 0), default parameters
- Camera is at (0, 0, -400) looking at (0, 0, 0)
- Model is at (0, 0, 0) and its rotation is **(0, 90, -90)**

The lighting should light up the side of the skull I am looking at - but instead lights up the front an back of the skull.

 ![Skull_CPU_Scene_p00p90m90](https://discourse.vtk.org/uploads/default/original/1X/2ffc877fe7d4473d74b60ade6e868b0745326df0.png)

If I switch to **CPU** rendering the lighting looks correct (even though the skull has lines through it) The birghtness is also much better.

Light, camera, model is as above.

 ![Skull_GPU_Headl_p00p90m90](https://discourse.vtk.org/uploads/default/original/1X/67bb76d32e5932e5bdaece4cb72cfee4e84dc6d4.png)

Now switching back to GPU Rendering, but changing the light to a headlight (in the same place as the scenelight)

- Light is a **Headlight** at (0, 0, -400) looking at (0, 0, 0), default parameters
- Camera is at (0, 0, -400) looking at (0, 0, 0)
- Model is at (0, 0, 0) and its rotation is (0, 90, -90)

A couple of final points, if I move the camera for the **CPU** render with the scenelight, the skull is nicely shadowed on the dark side…

[I cannot upload the image because of stupid discourse]

But the moving the camera in the **GPU** render with the scenelight it is clear that both sides of the skull are lit (and from the wrong direction)

[I cannot upload the image because of stupid discourse]

So…

- What lighting does and doesn’t work in GPU rendering?  
\*\* Do scenelights work at all? (These are the ones I most want to use)  
\*\* Is the headlight the only light I can use? (This seems to be the case, which is quite limiting)
- If scenelights + GPU will work - how do I get them to work?
- If scenelights + GPU won’t work - why not? And what plans are there to fix them?

I have the debug output of the camera, volume and lighting settings to show that they are the same, if anyone is interested I can upload them.

Many thanks for your help - this has taken some digging into.

Gavin
