Page 1 of 1

How to obtain eyeposition in shaders?

Posted: 04 Oct 2015, 10:31
by lukeNeo
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!

Re: How to obtain eyeposition in shaders?

Posted: 05 Oct 2015, 12:55
by TVM Cracklings
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

Re: How to obtain eyeposition in shaders?

Posted: 06 Oct 2015, 08:17
by TVM Cracklings
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: