Shader passes in ISF

Post your awesome Wire patches here, share tutorials
Post Reply
cat
Posts: 151
Joined: Fri Oct 08, 2004 11:03

Shader passes in ISF

Post by cat »

I've been trying work on some passes in isf and it seems a bit odd.
I have 2 passes, the first one works when set to 0, that seems as it should be, but I would expect the 2nd pass to be 1, but it only works when set to 2.
So what am I missing in my understanding of what is going on? I'm coming from hlsl shading so I'm still trying to get to grips with the oddities on glsl, and isf in particular
I'm missing being able to SamplerStates for example, mirror, wrap etc for texcoords, is that possible?

Thanks

Code: Select all

/*{
    "CREDIT": "",
    "DESCRIPTION": "",
    "CATEGORIES": [ "generator" ],
    "INPUTS": 
    [
	
	            {
               "NAME": "inputImage",
                "TYPE": "image"
                },
	
              	    {
                    "NAME": "threshold",
                    "TYPE": "float",
                    "DEFAULT": 0.99,         
                     "MIN": 0,
            		 "MAX": 1
                    }
    ],
	
	"PASSES": 
    [
		  {
  			"TARGET": "P01"
  		},
  	
  		{
  			"TARGET": "P02"
  		}
	   ]
	
}*/

void main() 
{
			if (PASSINDEX == 0)	{
		                        //Threshold
		                        vec4 colBuf = IMG_NORM_PIXEL(inputImage, isf_FragNormCoord);
		                        float thresh= float(((colBuf.r+colBuf.g+colBuf.b)/3.0) > threshold);
				                gl_FragColor = vec4(thresh,thresh,thresh,thresh) ;
	                            }
	
            if (PASSINDEX == 2)	{	// Why does this pass need to be 2, surely it should be 1?
                                gl_FragColor = IMG_NORM_PIXEL(P01, isf_FragNormCoord)*vec4(1,1,0,1); 
		                        }
	
}

cat
Posts: 151
Joined: Fri Oct 08, 2004 11:03

Re: Shader passes in ISF

Post by cat »

So having added another pass, it seems to be that the shader automatically writes into the next pass so in my third pass I am sampling for P03 my 2rd renderpass declaration, not as would have expected, P02 should be my 2nd. Seems weird, but I can work with it I guess.

Next question, I want my 3rd pass to be optional so I tried if (PASSINDEX == 3 && myBool) but if this pass isn't called I get no output rather than the 2 pass I expected. How do I solve this?

cat
Posts: 151
Joined: Fri Oct 08, 2004 11:03

Re: Shader passes in ISF

Post by cat »

While I'm posting weird shader things
void main() {
vec4 colBuf = IMG_NORM_PIXEL(inputImage, isf_FragNormCoord);
gl_FragColor = colorInput*colBuf;
}

is colorInput has 0 in the alpha, I would expect to set the alpha to 0 in the output, ie the image should fade out, but it seems you need to multiply the rgb data as well. I guess its premult, never quite understood that, when is an alpha not an alpha?

Post Reply