Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


zetwalnwar

Member Since 18 Jul 2011
Offline Last Active Mar 05 2012 07:04 PM

Posts I've Made

In Topic: Fragment Depth in glsl

23 February 2012 - 05:10 PM

Thanks for the replies Posted Image

I am currently working in the eye space. In this space, the camera is at (0,0,0) and we are looking towards the negative z.

The only thing that seems to be giving me something which looks correct is:

// in the vertex shader
eyeVec = vec3(gl_ModelViewMatrix * gl_Vertex);


// in the fragment shader
depth = -1.0/((eyeVec.z-gl_DepthRange.near)/(gl_DepthRange.far-gl_DepthRange.near));

or

depth = -1.0/eyeVec.z;

I am not satisfied with the range of z that I am getting though
cube.png
though it looks reasonable correct.

This is my perspective projection setup:
gluPerspective(45, (width/height), 1, 10.0);
and I do several other translations and rotations too.

My question is: how do I get the value of my near plane and far plane in the fragment shader while working in eyespace. Is gl_DepthRange.near correct ?

OpenGL version used:
OpenGL Version: 4.2.0 NVIDIA 290.10
OpenGL Shading Language Version: 4.20 NVIDIA via Cg compiler

In Topic: front to back blending issues on Linux

02 August 2011 - 06:15 PM

"GL_ONE_MINUS_DST_ALPHA"

Is it perhaps because you have not requested an alpha buffer? And on Mac you get one by default but on Linux you don't?


It seems so. The glGetIntegerv(GL_ALPHA_BITS, alphabits); was returning 0!!!

In Topic: pinpong issues in opengl

19 July 2011 - 08:10 AM

Got the answer!. There was a typo in my code

glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, tex_id[readTex]); glUniform1iARB(buf_Out, 0);
glActiveTexture(GL_TEXTURE2); should have been glActiveTexture(GL_TEXTURE0); :angry:

PARTNERS