Horde3D http://www.horde3d.org/forums/ |
|
How to get light position in NDC and clip coordinates.... http://www.horde3d.org/forums/viewtopic.php?f=1&t=2295 |
Page 1 of 1 |
Author: | Almahmudrony [ 21.12.2016, 07:34 ] |
Post subject: | How to get light position in NDC and clip coordinates.... |
Hi i having problem to get world space light position on clip space and Normalized Device Coordinates.... i have tried this to get clip coordinates in shader, vec3(-10,90,100) is the light position on world space.... Code: vec4 v = projMat * viewMat *vec4(-10,90,100,1); vec3 lpos = v.xyz/v.w; but it's not resulting the exact projection location of light on screen ![]() any advice could be highly appreciate.... |
Author: | Irdis [ 21.12.2016, 21:19 ] |
Post subject: | Re: How to get light position in NDC and clip coordinates... |
I don't know exactly how to solve your problem, but take a look how engine calculates the aabb of the screen that is influenced by light source: https://github.com/horde3d/Horde3D/blob ... gLight.cpp - calcScreenSpaceAABB Also, check functions in files in utilityLib folder. For example: Code: vec4 calcViewPos( const vec4 pos ) { return viewMat * pos; } Maybe quad drawing shader can give you a hint: Code: [[VS_FSQUAD]] uniform mat4 projMat; attribute vec3 vertPos; varying vec2 texCoords; void main( void ) { texCoords = vertPos.xy; gl_Position = projMat * vec4( vertPos, 1 ); } You can also check this link: https://www.khronos.org/opengl/wiki/Com ... ndow_space |
Page 1 of 1 | All times are UTC + 1 hour |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |