It looks like you're new here. If you want to get involved, click one of these buttons!
local nmrt = RenderTarget.new(xp2, hh, true) --xp2 is the powerof2 size of the double texture (allTextures) nmrt:draw(allTextures) if self.tilemapmesh then --update texture --Remove mesh and create a new one, works but it's "slow" self.tilemapmesh:removeFromParent() self.tilemapmesh = nil collectgarbage() end --create mesh self.tilemapmesh = Mesh.new() self.tilemapmesh:setVertexArray(x, y, x+w, y, x+w, y+h, x, y+h) self.tilemapmesh:setTextureCoordinateArray(x, y, x + w, y, x + w, y + h, x, y + h) self.tilemapmesh:setIndexArray(1, 2, 3, 1, 3, 4) self.tilemapmesh:setTexture(nmrt) self.tilemapmesh:setShader(self.effect) self:addChild(self.tilemapmesh) |
local nmrt = RenderTarget.new(xp2, hh, true) --xp2 is the powerof2 size of the double texture (allTextures) nmrt:draw(allTextures) if self.tilemapmesh then --update texture --just update mesh texture self.tilemapmesh:clearTexture() self.tilemapmesh:setTexture(nmrt) else --create mesh self.tilemapmesh = Mesh.new() self.tilemapmesh:setVertexArray(x, y, x+w, y, x+w, y+h, x, y+h) self.tilemapmesh:setTextureCoordinateArray(x, y, x + w, y, x + w, y + h, x, y + h) self.tilemapmesh:setIndexArray(1, 2, 3, 1, 3, 4) self.tilemapmesh:setTexture(nmrt) self.tilemapmesh:setShader(self.effect) self:addChild(self.tilemapmesh) end |
Dislikes: Yan
Comments
I have to collectgarbage() after setTexture(), and of course you're right I don't need clearTexture()
FPS is still lower than expected, from my past experience I think it's collectgarbage's fault but it's needed here, I can't do without it unless I want to see my texture memory double at each passage. Can you think of any alternative?
Thank you
Likes: SinisterSoft, pie
I think I am doing something wrong, but if I look at the whole texture (classic+normal) I'd say it's fine.
The shader works well on the layer below, but on the top layer the normal map is "white", I see it change its nuance when I move the lights but I am unable to understand what's happening: any suggestion on what could be the problem? It seems that it's not blending with the "classic texture".
thank you
[edit: fixed with a dirty delay: I was rendering the texture BEFORE all the objects were placed on the "classic side"]
Likes: hgy29