Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Black artifacts on snapshot canvas mode with alpha texture
Started by david.ciaudo Dec 01 2018 11:21 AM

2 replies to this topic
snapshot alpha canvas painting
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

david.ciaudo

[GLOBAL: userInfoPane.html]
david.ciaudo
  • Enthusiast

  • 50 posts
  • Corona SDK

Hi everybody, today I'm trying to make a simple painting app and I found some interesting code on the corona blog:

local w = display.viewableContentWidth
local h = display.viewableContentHeight

local bg = display.newRect(0,0,w,h)
bg.anchorX = 0
bg.anchorY = 0

local snapshot = display.newSnapshot(w,h)
snapshot:translate(w*0.5, h*0.5)
snapshot.canvasMode = "discard"

function listener(event)
	local x,y = event.x - snapshot.x, event.y - snapshot.y

	if event.phase == "began" or event.phase == "moved" then
		local o = display.newImage("brush.png", x, y)
		o:setFillColor(1,0,0)
		snapshot.canvas:insert( o )
		snapshot:invalidate("canvas")
	end
end

Runtime:addEventListener("touch", listener)

This sample is working nicely on the simulator but when I build it on my android device (galaxy s7) there are black artifacts all around my brush when I try to draw slowly as you see in the screenshot linked on this post.

 

While I concede this is an interesting effect it is very annoying for the goal of my app.

 

Do you know how I can fix this issue?

 

I've linked everything in the post to reproduce this bug.

 

Attached Files



[TOPIC: post.html]
#2

david.ciaudo

[GLOBAL: userInfoPane.html]
david.ciaudo
  • Enthusiast

  • 50 posts
  • Corona SDK

I changed the texture of my brush removing alpha nuance and it removes the black contouring, but I really want the anti-aliasing around my circle. Any idea of what is happening?



[TOPIC: post.html]
#3

vlads

[GLOBAL: userInfoPane.html]
vlads
  • Contributor

  • 577 posts
  • Corona Staff

Try setting up high-precision shaders in your config.lua: https://docs.coronalabs.com/guide/basics/configSettings/index.html#shader-precision




[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: snapshot, alpha, canvas, painting