Next-Generation Graphics Engine
It is currently 16.07.2019, 00:21

All times are UTC + 1 hour

Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: 21.12.2016, 07:34 

Joined: 02.12.2016, 12:30
Posts: 23

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....
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 :cry: ...

any advice could be highly appreciate....


Reply with quote  
PostPosted: 21.12.2016, 21:19 

Joined: 17.11.2009, 17:00
Posts: 194
Location: Russia, Moscow
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:

vec4 calcViewPos( const vec4 pos )
   return viewMat * pos;

Maybe quad drawing shader can give you a hint:

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

Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group