Jump to content

  • Log In with Google      Sign In   
  • Create Account

Marcel Stockli

Member Since 04 Mar 2012
Offline Last Active Jun 20 2013 05:05 PM

Posts I've Made

In Topic: LogLUV conversion now working

03 January 2013 - 12:40 PM

No problem! Cool you fixed it, that kind of errors are very annoying.

In Topic: Reconstructing World Position from Depth

03 January 2013 - 12:23 PM

You can use both (far and near plane), but you need to transform the depth in a different way for each one. If CameraRay is a normalized vector then you can use any one.




vec3 WorldPosition = CameraPosition + ( CameraRay * (LinearDepth*ViewClipFar ) ) ;


You have (LinearDepth*ViewClipFar ) so I think LinearDepth is in [0,1] and (LinearDepth*ViewClipFar ) should be in [0,ViewClipFar], then CameraRay needs to be a normalized vector. (I don't know if it is)


Did you checked if FrustumPoints are correct? You can also unproject them if you have the model matrix and projection matrix (an easy way to do it http://www.opengl.org/sdk/docs/man2/xhtml/gluUnProject.xml).

In Topic: LogLUV conversion now working

02 January 2013 - 04:22 PM

Did you checked the matrix order? (row major, column major). Your matrix constructor should have the same order than the HLSL Matrix constructor because the code you are usin, originally was HLSL. The same with the vector-matrix multiplication.

In Topic: Reconstructing World Position from Depth

02 January 2013 - 04:01 PM

Hi Davidtse, your scene is projected on the near quad but you are computing the far quad:

  1. FrustumPoints[0] = cml::normalize(FarCenterPosition - Right*(FarWidth/2) - Up*(FarHeight/2));
  2. FrustumPoints[1] = cml::normalize(FarCenterPosition - Right*(FarWidth/2) + Up*(FarHeight/2));
  3. FrustumPoints[2] = cml::normalize(FarCenterPosition + Right*(FarWidth/2) - Up*(FarHeight/2));
  4. FrustumPoints[3] = cml::normalize(FarCenterPosition + Right*(FarWidth/2) + Up*(FarHeight/2));

It should be:


  1. FrustumPoints[0] = cml::normalize(NearCenterPosition - Right*(NearWidth/2) - Up*(NearHeight/2));
  2. FrustumPoints[1] = cml::normalize(NearCenterPosition- Right*(NearWidth/2) + Up*(NearHeight/2));
  3. FrustumPoints[2] = cml::normalize(NearCenterPosition+ Right*(NearWidth/2) - Up*(NearHeight/2));
  4. FrustumPoints[3] = cml::normalize(NearCenterPosition+ Right*(NearWidth/2) + Up*(NearHeight/2));


I am not sure if you have more errors but this one is an important error, don't forget to add the cameraPosition at the end (not substract).