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:
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
jit.gl.slabs 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 jit.gl.sketch 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
> 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
> 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 jit.gl.slab 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.