Multipass Shaders

    Apr 05 2006 | 9:40 pm
    Hi, Is it possible to do multipass shading on an object? I was thinking something like contect @shader pass1 pass2
    Or, is there another method that I'm not aware of for processing geometry in this way.
    thanks, wes

    • Apr 05 2006 | 10:11 pm
      Hi Wes,
      Unfortunately not in as easy a fashion as you describe below. You'll need to set up a render chain which draws multiple passes of the object and for each pass changes the shader attribute of said object. Note that this can be done with sketch, overriding the ob3d attributes (drawraw), something similar to the following:
      reset, glbindprogram shader1, drawobject modelname 1, glunbindprogram shader1, glbindprogram shader2, drawobject modelname 1, glunbindprogram shader2
    • Apr 11 2006 | 11:24 am
      hi, i almost missed this post.
      can you explain a bit what binding/unbind shaders in a chain like this do? is that was slab does, if you have a chain of slabs?
      i bring this up because i've written patches where multiple working on large textures (2048x1024) seems to eat up all of the GPU, whereas writing a single shader that combines all of the operations of the slab, and then binding it using really makes huge performance difference for the better. of course, conceptually it would be nicer to split out all of my shading functions into discrete shader objects, instead of lumping them together. is that what's going on here?
      let's say i wanted to use the contrast shader, then pipe the output into the scalebias shader. normally i'd use slabs, patches together sequentially. does this shader method in sketch achieve the same result?
      thanks, evan
    • Apr 11 2006 | 11:07 pm
      On Apr 11, 2006, at 4:24 AM, evan.raskob wrote:
      > can you explain a bit what binding/unbind shaders in a chain like > this do?
      It is just like binding a shader for use in an object with the @shader attribute.
      > is that was slab does, if you have a chain of slabs?
      This is what slab does on a *per pass* basis. Slabs do *not* concatenate the programs, recompiling into a single program (would be nice, but this is not the case). So, this would not change your strategy whatsoever. You will need to build your own "meta" shaders rather than using many instances of to gain optimum performance when working with large textures.
      Note that you can use subroutines in GLSL. So you might just want to build up a library of subroutines which you could more easily mix and match as necessary in your shader source.
      Best, Joshua
    • Apr 12 2006 | 8:55 am
      Thanks for the info Joshua, I will need to read more about subroutines in GLSL it looks like.
      Best, Evan