[code]local eff="ripple1" -- effect name-- the following lines are to make sure the shader is compiled, -- a shader is mini program, that needs to be compiled to use itshaderAddEffect(eff)shaderRemoveEffect(eff)-- this is a standard setting, the shader has a variable that is called strength, we set that to 1shader_effects[eff].num.strength=1-- also for any animation inside the shader, it needs the time, -- so we bind the variable time in the shader to our timebind(eff, "time", field("shader_iTime"))--[[ that is tricky, it contains the settings for something we could call "effect channel", like in an audio mixer, send to channel 1 or such. So we say use the shader "eff" and composition method 5 and 4, list of methods here:0 GL_ZERO1 GL_ONE2 GL_SRC_COLOR3 GL_ONE_MINUS_SRC_COLOR4 GL_SRC_ALPHA5 GL_ONE_MINUS_SRC_ALPHA6 GL_DST_ALPHA7 GL_ONE_MINUS_DST_ALPHA8 GL_DST_COLOR9 GL_ONE_MINUS_DST_COLOR10 GL_SRC_ALPHA_SATURATEthe comp dst means what of the destination goes into the equationand comp src the same for source. So we use the alpha channel of the source image (GL_SRC_ALPHA) and for the destination the inverse (GL_ONE_MINUS_SRC_ALPHA).Destination means our surface, source is the image we are drawing.If we use GL_ONE, GL_ONE you will see that image is like blended onto the surface because the colors are added. ]]shaderSetOptions({{shader = shader_effects[eff].num(), comp_dst=5, comp_src=4 }}, 1)-- simplest thing of them, set the object "target_object" to the effect channel 1Objects.target_object.ShaderSet = 1[/code]
by SimonS, 11 years ago