Reputation: 286
I am trying to create new effect by combining existing ones and Corona Simulator crashes.
Here is my code
graphics.defineEffect({
language = "glsl",
category = "filter",
name = "myEffect",
graph = {
gray = { effect = "filter.grayscale", input1 = "paint1" },
--final = { effect = "filter.contrast", input1 = "gray" },
},
output = "gray"
});
local rect = display.newRect(100, 100, 100, 100);
rect:setFillColor(1, 0, 0);
rect.fill.effect = "filter.myEffect";
Also question about arguments for filter. How can I specify arguments for filter contrast in this sample?
Thank you
Upvotes: 2
Views: 340
Reputation: 6337
This was recently bringing trouble to me too. I found it to be solvable by declaring the graph definitions of the effects in a nodes table.
I included the solution and corrected syntax below.
graphics.defineEffect({
language = "glsl",
category = "filter",
name = "myEffect",
graph = {
nodes = {
gray = { effect = "filter.grayscale", input1 = "paint1" }
--final = { effect = "filter.contrast", input1 = "gray" },
},
output = "gray"
}
})
local rect = display.newRect(100, 100, 100, 100);
rect:setFillColor(1, 0, 0);
rect.fill.effect = "filter.myEffect";
Regarding the contrast questions, excuse me if I misunderstood but this should be a viable solution
graphics.defineEffect({
language = "glsl",
category = "filter",
name = "myEffect",
graph = {
nodes = {
gray = { effect = "filter.grayscale", input1 = "paint1" },
final = { effect = "filter.contrast", input1 = "gray" }
},
output = "final"
}
})
local rect = display.newRect(100, 100, 100, 100);
rect:setFillColor(1, 0, 0);
rect.fill.effect = "filter.myEffect";
rect.fill.effect.final.contrast = 2
A good introduction to this is Tutorial: Multi-Pass Shaders in Graphics 2.0 by Bryan Smith
Upvotes: 1