Viewport does not update custom shader

Viewport does not update custom shader

jesusbERX5T
Observer Observer
599 Views
0 Replies
Message 1 of 1

Viewport does not update custom shader

jesusbERX5T
Observer
Observer

I'm working on a HLSL lens effect shader that depends on the camera location in world space. The camera location is being passed as a parameter to the shader.

 

1. The first problem I'm encountering is that the shader does not refresh the viewport with changes in the scene unless the camera position changes. If the camera moves around an object that has the custom shader applied, it works great. However, if the same object is moving and the camera is still, then the shader does not update until the camera is somehow updated by movement or refocused. How can I get the viewport to update and match the changes in the scene?

 

2. The perspective camera is the one being passed into the shader. Ideally, any camera that's viewing the object with the custom shader applied, would pass in its location (or camera direction to the pixel) into the shader. This would allow the lens effect to look correct from that camera's viewpoint. So if the layout has four viewports looking at the object from different positions in space, the lensing effect would be correct for each camera. Is there a general way to get the camera position (or camera direction to the pixel) that is responsible for a given viewport?

 

Thank in advance for your help,

0 Likes
600 Views
0 Replies
Replies (0)