nV News Forums

 
 

nV News Forums (http://www.nvnews.net/vbulletin/index.php)
-   NVIDIA Linux (http://www.nvnews.net/vbulletin/forumdisplay.php?f=14)
-   -   GLSL shadow2D() problem (http://www.nvnews.net/vbulletin/showthread.php?t=86316)

oc2k1 02-14-07 01:37 PM

GLSL shadow2D() problem
 
I don't know if that is GLSL compiler bug. My driver version is 1.0.9746:

My thextur is generated by:
glTexImage2D (GL_TEXTURE_2D, 0,GL_DEPTH_COMPONENT , w, h, 0, GL_DEPTH_COMPONENT , GL_UNSIGNED_BYTE, NULL);
Bind as FBO with:
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,GL_DE PTH_ATTACHMENT_EXT,GL_TEXTURE_2D,texture, 0);

uniform sampler2DShadow Shadowmap;
shadow2D(Shadowmap, vec3(parabol,0.0));

returns the same value than:

uniform sampler2D Shadowmap;
texture2D(Shadowmap, parabol));

The 3rd vec3 component of shadow2Ds firsts argument is always ignored. The shadow2D function shouldn't return something other than 0.0 or 1.0 (except for PCF) (or not?)

squeen 02-15-07 05:24 AM

Re: GLSL shadow2D() problem
 
This function works consistently for me (several cards, several drivers)

Code:

float lookupShadow(in sampler2DShadow dmap, in vec3 coord, in vec2 offset, const float size)
{
  float depth = shadow2D(dmap, coord + vec3( offset.x,  offset.y, 0.0)*size).r;
  return(depth);
}

where dmap is the shadowmap (don't forget to set the uniform to the right texture image unit, bind it in code etc.), and size is the shadowmap size in pixels (e.g. 2048). Coord comes from the vertex shader
Code:

gl_TexCoord[1] = gl_TextureMatrix[1] * gl_ModelViewMatrix * gl_Vertex;
But you have to have the TextureMatrix for the shadows populated by the eye space->light space transformation, just like with hardware shadow maps.

Hope that helps. Shadows are tricky.

oc2k1 02-15-07 07:28 AM

Re: GLSL shadow2D() problem
 
1 Attachment(s)
My shadows are working with a own comparison function. The problem is that I can't use the hardware PCF with that emulation.

And I don't know why the shadow2D() returns the value from the shadowmap instead the comparison with the 3rd value.

http://www.nvnews.net/vbulletin/atta...1&d=1171542959
That are dualparabolic shadows rendered with 16x AA and two shadowsamples per fragment (efective 8 samples per lightsource, because the 16x MSAA includes a 4x SSAA). With hardware PCF I could get 16 samples per pixel with only one lookup per fragment. (PS: 5 lights are switched off)

oc2k1 02-16-07 11:18 AM

Re: GLSL shadow2D() problem
 
I have forgot that line:
Code:

glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE_ARB );


Please move that Topic to the developer section.


All times are GMT -5. The time now is 12:45 AM.

Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright 1998 - 2014, nV News.