Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Ants with Alpha or Shaders with Strokes
Started by paul04 Feb 28 2019 07:17 AM

4 replies to this topic
shader marchingants generator effects
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

paul04

[GLOBAL: userInfoPane.html]
paul04
  • Observer

  • 3 posts
  • Corona SDK

Hi,

 

Sorry, I guess this is kind of two questions...

 

 

** Marching Ants Effect

 

The 'Marching Ants' effect as defined here gives a black/white effect.

https://docs.coronalabs.com/guide/graphics/effects.html#generator.marchingants

 

The effect I would like to achieve is a white/alpha effect.

 

The link referred to on this post, is dead - https://forums.coronalabs.com/topic/62537-marching-ants-configurability/

 

I assume it's supposed to point to the link above, but there's no configurability documented there?

 

 

 

** Shaders on strokes

 

I've come up with this (likely terrible) shader - https://f25j6.app.goo.gl/LyEM - black/alpha for testing

 

 

I don't know a lot about shaders - and I'm having a hell of a time getting it to apply to a newRoundedRect stroke.

local ants = {}
ants.category = "generator"
ants.name = "antspantz"
ants.isTimeDependent = true
ants.fragment = [[
P_COLOR vec4 FragmentKernel( P_UV vec2 texCoord ){
  vec4 CoronaVertexUserData = vec4(0,0,0,0);
  P_COLOR vec4 ret = vec4(0, 0, 0,
    sin((CoronaTotalTime*5.)+(texCoord.x*50.)+(texCoord.y*50.))
  );
  return CoronaColorScale(ret);
}
]]
graphics.defineEffect( ants )

-- 

display.setDefault("background", .7, .7, .7)
obj = display.newRoundedRect( 200, 200, 320, 320, 20 )
obj.fill = { 1,0,0,1 }
obj.stroke = { 0,1,1,1 }
obj.strokeWidth = 20
obj.stroke.effect = "generator.custom.antspantz"
 

 

produces different results in the simulator every time you run it ?!

change that last line to fill instead of stroke and it works - so I guess strokes are broken?  :(



[TOPIC: post.html]
#2

davebollinger

[GLOBAL: userInfoPane.html]
davebollinger
  • Corona Geek

  • 1,373 posts
  • Corona SDK

are you aware that the source is available?  i think if you simply replace the constant "1.0" alpha value of the returned color with the variable "gray" then it'll effectively be a strokecolor-or-transparent effect (which seems like what you're after).



[TOPIC: post.html]
#3

paul04

[GLOBAL: userInfoPane.html]
paul04
  • Observer

  • 3 posts
  • Corona SDK

Ahh, I was not aware, that will be useful thanks!



[TOPIC: post.html]
#4

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 26,697 posts
  • Enterprise

FYI: https://forums.coronalabs.com/topic/62537-marching-ants-configurability/ seems to work for me. It may have been a temporary outage.

 

Rob



[TOPIC: post.html]
#5

paul04

[GLOBAL: userInfoPane.html]
paul04
  • Observer

  • 3 posts
  • Corona SDK

FYI: https://forums.coronalabs.com/topic/62537-marching-ants-configurability/ seems to work for me. It may have been a temporary outage.

 

Rob

 

Hi Rob, yes that page works - but the link referred to on that page, doesn't.

 

i.e. how is the generator effect configurable?




[topic_controls]
[/topic_controls]