Hi guys,
I am totally new to shaders and have been banging my head for several hours now. I followed the documentation from Corona, found some examples and even managed to create a simple image with shader.
My nightmare, however, started when I decided to use this specific shader ( which I found in another topic ) : https://goo.gl/kpaqiK
When I follow the tutorials from Corona to implement this shader I get a black rectangle and nothing happens in the simulator.
Here is my code so far:
-- generator.custom.portal local kernel = {} kernel.category = "generator" kernel.isTimeDependent = true kernel.name = "portal" kernel.fragment = [[P\_COLOR vec4 FragmentKernel( P\_UV vec2 texCoord ) { P\_UV vec2 center = vec2(0.5,0.5); P\_UV float speed = 0.035; P\_UV float invAr = CoronaVertexUserData.y / CoronaVertexUserData.x; P\_UV vec2 uv = texCoord.xy / CoronaVertexUserData.xy; P\_COLOR vec3 col = vec4(uv,0.5+0.5\*sin(CoronaTotalTime),1.0).xyz; P\_COLOR vec3 texcol; P\_UV float x = (center.x-uv.x); P\_UV float y = (center.y-uv.y) \*invAr; P\_UV float r = -(x\*x + y\*y); P\_UV float z = 1.0 + 0.5\*sin((r+CoronaTotalTime\*speed)/0.013); texcol.x = z; texcol.y = z; texcol.z = z; return CoronaColorScale(vec4(texture2D(CoronaSampler0, texCoord).rgb \* col\*texcol,1.0)); }]] return kernel
And then in another place:
local k1 = require("generator\_portal") graphics.defineEffect( k1 ) local object = display.newImageRect("images/rainbow.png",160, 160) object.x = \_W/2 object.y = \_H/2 object.fill.effect = "generator.custom.portal"
What I get in the simulator is just a black rectangle. Am I doing something wrong? Any help will be greatly appreciated.