Hello Ventuzians!
THE FORUMS ARE CLOSED!

Please join our discord server HERE!! << click me :D

We are shutting our Ventuz Forum, but don't worry, it will all be archived for you to search in if you have a query. From now on, please add all your comments, questions or observations into our Discord Server

Thanks for the great time - see you on discord!!
Dee, Karol, Daniel and the whoooole Product and Support team!

How to obtain eyeposition in shaders?

Q and A about functionality and how to solve a special task for your application.

Moderator: Support

Post Reply
lukeNeo

How to obtain eyeposition in shaders?

Post by lukeNeo » 04 Oct 2015, 10:31

Hi to all,
I'm trying to do some porting from GLSL shaders to HLSL in Ventuz. One problem I have is: how can I know my eyeposition (camera position) into the shader code?
For example, even to compute specular lighting effect, I need the eye position to calculate the specular reflection..

I can't find the right constant for "eyeposition" in the documentation:
http://www.ventuz.com/support/help/V4_0 ... hader.html

Anyone can help?
Thank you!

TVM Cracklings
Posts: 33
Joined: 30 Sep 2015, 10:49

Re: How to obtain eyeposition in shaders?

Post by TVM Cracklings » 05 Oct 2015, 12:55

Method 1: Use viewspace to compute lighting. This would probably make your program run faster as well.

Method 2: The hard way. Getting Camera position through view matrix. Check out this post on SO.

Hope this helps.
-C

TVM Cracklings
Posts: 33
Joined: 30 Sep 2015, 10:49

Re: How to obtain eyeposition in shaders?

Post by TVM Cracklings » 06 Oct 2015, 08:17

Oh, and you can always pass your camera position in world space as uniform variables if everythings else fails.

Or take a look at the glm::lookAt() function and implement it directly in your shader. This would even save you a camera node. :lol:

Post Reply