Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: texture2D/texture2DProj

  1. #1
    Member Regular Contributor
    Join Date
    Jul 2005
    Location
    Germany
    Posts
    311

    texture2D/texture2DProj

    shouldn't this:

    Code :
    float GetShadow( sampler2D shadowmap, vec4 projection )
    {
    	return texture2DProj( shadowmap, projection ).r;
    }
    give the same result as this?

    Code :
    float GetShadow( sampler2D shadowmap, vec4 projection )
    {
    	return texture2D( shadowmap, projection.xy /projection.w ).r;
    }
    first one works fine for my shadow mapping shader, second one does not.

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    May 2005
    Location
    Prague, Czech Republic
    Posts
    924

    Re: texture2D/texture2DProj

    If you are trying to use builtin shadowmap comparisons (TEXTURE_COMPARE_MODE) then both functions are wrong because they are using incorrect sampler type and sampling instruction (the correct are sampler2DShadow and shadow2D(Proj)) so theirs results are undefined. This is likely what you are seeing. In the first case the hw will by accident get correct data (the depth coordinate from projection.z) to perform the comparison. (I assume that you have Nvidia cards which supports that comparison in hw).

    If you really use ordinary textures, both functions should give the same result.

  3. #3
    Senior Member OpenGL Pro
    Join Date
    Sep 2004
    Location
    Prombaatu
    Posts
    1,401

    Re: texture2D/texture2DProj

    My guess is that he's using VSMs and just looking for a sample from a depthmap for debugging purposes; or perhaps he's trying to perform his own PCF. Heck, maybe he's just rendering a spotlight and has a strange function naming convention, or he's cleverly generalized his shadow and projective texture functionality.

    Perhaps it's something far more vexing ;-)

    I guess we'll never really know for sure until he's good enough to volunteer with some more information.

  4. #4
    Member Regular Contributor
    Join Date
    Jul 2005
    Location
    Germany
    Posts
    311

    Re: texture2D/texture2DProj

    komat is right, i forgot to switch to sampler2DShadow and shadow2DProj as it was working anyway. thank you guys.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •