Results 1 to 3 of 3

Thread: Stencil shadows + Per pixel lighting in shader

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2009
    Posts
    10

    Stencil shadows + Per pixel lighting in shader

    Hello,

    this will be very silly question indeed, but I've been looking on the internet for about week now, without any success...

    I've got stencil shadows implemented (without shaders) and per pixel lighting shader implemented. And I want to put it all together...but my problem is that I don't know how to acess stencil buffer in my lighting shader and I don't want to pass it as some texture, or do I have to ?

    Or is there some way to bypass stencil buffer and use the shadow volumes in my per pixel lighting sgader ?

    So can someone please explain this to me or point me to some sources where it is.
    Thanks !

  2. #2
    Member Contributor
    Join Date
    Jul 2009
    Location
    Buenos Aires
    Posts
    67

    Re: Stencil shadows + Per pixel lighting in shader

    With stencil shadows normally you do two passes:

    One pass with the light off, then enable stencil test and do a second pass with the light on.

    Another tecnhique is to do the first pass with the light on, enable stencil and draw a translucent quad with a hardcoded "shadow color".

    AFAIK you cannot directly access the stencil buffer from a fragment shader.

  3. #3
    Junior Member Newbie
    Join Date
    Oct 2009
    Posts
    10

    Re: Stencil shadows + Per pixel lighting in shader

    I can't access stencil buffer in fragment shader...so how do I get information from it in my lightin shader?

    With that second idea you mean something like:
    Create a shadow mask -> grey where the shadow is (or shade of grey depending on number of shadows from multiple lights) and white where the light is supposed to be and then blend it over lighted scene...perhaps by passing it to shader...

Similar Threads

  1. Stencil bitplanes/glReadPixels() - pixel per byte or pixel per bit ?
    By Jon Mc Jon in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 10-09-2006, 08:24 PM
  2. optimising per-pixel lighting shader
    By supagu in forum OpenGL: GLSL
    Replies: 5
    Last Post: 12-29-2004, 03:42 AM
  3. Replies: 2
    Last Post: 08-17-2003, 01:57 AM
  4. Check out my dot3 pixel lights and stencil shadows
    By JD in forum OpenGL: Advanced Coding
    Replies: 0
    Last Post: 07-17-2003, 02:25 AM
  5. Per-Pixel Lighting + Soft Shadows Demo
    By Sundy in forum OpenGL: Advanced Coding
    Replies: 17
    Last Post: 05-12-2002, 10:18 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean