2014-09-19 48 views
2

我想通過結合現有的和Corona模擬器崩潰來創建新的效果。Corona SDK崩潰時試圖結合過濾器/效果

這裏是我的代碼

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"; 

還質疑有關過濾器參數。如何在此示例中爲過濾器對比指定參數?

謝謝

回答

1

這最近給我帶來了麻煩。我發現它可以通過在節點表中聲明效果的圖形定義來解決。

我在下面列出瞭解決方案和更正的語法。

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"; 

關於對比度的問題,原諒我,如果我誤解了,但是這應該是一個可行的解決方案

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 

一個很好的介紹,這是Tutorial: Multi-Pass Shaders in Graphics 2.0 by Bryan Smith

+0

謝謝回答。我試過你編寫的第二個代碼,它可以工作,但形狀是紅色而不是灰色。 – iBad 2014-09-28 06:29:54

+0

這是打算。嘗試將對比度更改爲0以無效看到它。 這回答了你爲什麼崩潰以及如何更改節點過濾器中的對比度參數的問題。爲了獲得理想的效果,你將不得不在實施中稍微玩一下。現在,您可能會遇到另一個問題,即您的工作目前爲止。 – 2014-09-28 08:48:53