Horde3D

Next-Generation Graphics Engine
It is currently 22.12.2024, 02:17

All times are UTC + 1 hour




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

Joined: 02.12.2016, 12:30
Posts: 23
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 :cry: ...

any advice could be highly appreciate....

_________________
~@AlmahmudRony@~


Top
 Profile  
Reply with quote  
PostPosted: 21.12.2016, 21:19 
Offline

Joined: 17.11.2009, 17:00
Posts: 205
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:

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


Top
 Profile  
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 13 guests


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