Here’s an example of a composite shader used to generate custom fades.
You supply the front image and the fade image (a greyscale image that should contain all values from black to white), and can set the fade percentage.
This cycles through 7 or so different fade images, none of which are interesting because I knocked them up quickly in photoshop, but hopefully you get the idea.
https://www.dropbox.com/s/vm8noo52lj554uy/Shader_Fader.apk?dl=0
Needless to say this would be much much cooler being able to work with snapshots *hint hint*
Note that this changes the *alpha* of the top layer image, so whatever is behind (in this case the purpley mountains) can be animated or whatever, it isn’t tied into the actual composite filter at all, I just had to stick something behind to make it more interesting. Only the foresty image is part of the shader, so that (for now…? ) must be static, same with the fade image itself.
Here’s the shader code, since it doesn’t make sense to show this in the playground:
[lua]local kernel = {}
kernel.language = “glsl”
kernel.category = “composite”
kernel.group = “playlevel”
kernel.name = “fade”
– Expose effect parameters using vertex data
kernel.vertexData =
{
{
name = “fadePercent”,
default = 50,
min = 0,
max = 100,
index = 0,
},
}
kernel.fragment =
[[
P_COLOR vec4 FragmentKernel( P_UV vec2 texCoord )
{
P_RANDOM float fadeBoundary = CoronaVertexUserData.x;
P_COLOR vec4 fadeTexCol = texture2D( CoronaSampler1, texCoord );
P_COLOR vec4 baseTexCol = texture2D( CoronaSampler0, texCoord );
if ( fadeBoundary == 100. )
baseTexCol = vec4( 0., 0., 0., 0. );
else if ( fadeTexCol.x * 100.0 < fadeBoundary )
baseTexCol = vec4( 0., 0., 0., 0. );
return CoronaColorScale( baseTexCol );
}
]]
return kernel[/lua]