Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Sprite:setEffectStack — Gideros Forum

Sprite:setEffectStack

Can someone tell me whats wrong with this code:
local blur = Shader.new("Vertex", "fBlur", 0, {
		{name="vMatrix", type=Shader.CMATRIX, sys=Shader.SYS_WVP, vertex=true},
		{name="fColor", type=Shader.CFLOAT4, sys=Shader.SYS_COLOR, vertex=false},
		{name="fTexture", type=Shader.CTEXTURE, vertex=false},
		{name="fDir", type=Shader.CFLOAT2, vertex=false},
		{name="fResolution", type=Shader.CFLOAT2, vertex=false},
	}, {
		{name="vVertex", type=Shader.DFLOAT, mult=3, slot=0, offset=0},
		{name="vColor", type=Shader.DUBYTE, mult=4, slot=1, offset=0},
		{name="vTexCoord", type=Shader.DFLOAT, mult=2, slot=2, offset=0},
	}
)
local texture = Texture.new("image.png")
local tw = texture:getWidth()
local th = texture:getHeight()
stage:addChild(Pixel.new(0xff00ff, 1, tw, th)) -- bg image
 
local image = Bitmap.new(texture)
local rt = RenderTarget.new(tw, th)
rt:draw(image)
local render = Bitmap.new(rt)
 
-- does NOT work ???
render:setEffectStack{{buffer = rt, shader = blur}}
render:setEffectConstant(1, "fDir", Shader.CFLOAT2, 1, 1,0)
render:setEffectConstant(1, "fResolution", Shader.CFLOAT2, 1, 512,512)
 
stage:addChild(render)
But if do it manualy:
blur:setConstant("fDir", Shader.CFLOAT2, 1, 1,0)
blur:setConstant("fResolution", Shader.CFLOAT2, 1, 512,512)
render:setShader(blur)
then it works.
Tagged:

Comments

Sign In or Register to comment.