Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

[FIXED] Graphics 2.0, Filters, and Alpha Channels: Supported?
Started by gullie667 Jan 02 2014 02:15 PM

15 replies to this topic
graphics 2.0 alpha alpha channel filters 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

gullie667

[GLOBAL: userInfoPane.html]
gullie667
  • Contributor

  • 185 posts
  • Corona SDK

Is there any way to get the graphics 2.0 filter effects to work with alpha channels? I love the feature set but my entire game is built around .pngs with masks. Currently, anytime I add an effect the image it turns to a square :(

 

Am I missing something?

 

Thanks!

 

Gullie



[TOPIC: post.html]
#2

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,786 posts
  • Enterprise

Can you provide some code?

 

Thanks

Rob



[TOPIC: post.html]
#3

gullie667

[GLOBAL: userInfoPane.html]
gullie667
  • Contributor

  • 185 posts
  • Corona SDK

Any display object using a newImageRect / imageSheet  with any .png that has an alpha channel to create a transparent object does this with filter.colorMatrix. 

 

The parts that should be transparent ( black in alpha) are not. They become visible.

 

For example:

 

object.fill.effect = "filter.colorMatrix"

object.fill.effect.coefficients =
{
    1, 0, 0, 0,  --red coefficients
    0, 1, 0, 0,  --green coefficients
    0, 0, 1, 0,  --blue coefficients
    0, 0, 0, 1   --alpha coefficients
}
object.fill.effect.bias = { 0.6, 0.1, 0, 0 }


[TOPIC: post.html]
#4

bjsorrentino

[GLOBAL: userInfoPane.html]
bjsorrentino
  • Veteran

  • 8,506 posts
  • Corona SDK

Hi Gullie,

Have you considered using something like "filter.monotone" instead of colorMatrix? Monotone respects alpha channels, and gives you a fair amount of color control (RGBA) on an image.

 

Best regards,

Brent



[TOPIC: post.html]
#5

gullie667

[GLOBAL: userInfoPane.html]
gullie667
  • Contributor

  • 185 posts
  • Corona SDK

monsterObject.fill.effect = "filter.scatter" does the same thing... the otherwise transparent parts become black... IE a black box around my object becomes visible.



[TOPIC: post.html]
#6

jacques1

[GLOBAL: userInfoPane.html]
jacques1
  • Contributor

  • 318 posts
  • Corona SDK

Any word on this issue be solved?



[TOPIC: post.html]
#7

gullie667

[GLOBAL: userInfoPane.html]
gullie667
  • Contributor

  • 185 posts
  • Corona SDK

So Brent, Rob, 

 

With respect to a filter like scatter, is this as designed, to be implemented, a bug, or something I need to fix on my end?

 

Thanks!

 

Gullie



[TOPIC: post.html]
#8

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,786 posts
  • Enterprise

There is one of two possible conditions.  1. Filters/Shaders are supposed to support Alpha channels and if it's not, its a bug.  2. They don't support alpha channels, in which chase this needs to be a feature request.  Now this is a pair of conditions that could happen on any given filter.  I've asked engineering to clarify their intent.

 

If its #1, then I'll need you to file a bug report. If it's #2, then there will need to be a feature request added to the feedback site.  Once I hear back from Engineering, I'll update this thread on how to proceed.  Now if it's a case that some are and dont, and some are not supposed to, I'll work with the team to get the docs updated to clearly state which ones support alpha channels and which ones don't.

 

And while we try to monitor the forums on the weekends, the engineer's are on a more of a Monday-Friday work scheduled. 

 

Rob



[TOPIC: post.html]
#9

gullie667

[GLOBAL: userInfoPane.html]
gullie667
  • Contributor

  • 185 posts
  • Corona SDK

I appreciate your attention! Let me know...

 

Also and while I'm at it, is .alpha or transitionTo supposed to be supported? transitionTo and .aphla don't seem to be working with some of the filters.

 

See my code:

 

THANKS!

 

--Function kills the current monster
local function killMonster( transitionTime )

    local tmr
    local counter = 0
    local timeInc
    local intensityInc

    local function scatterObject( object )

        if timeInc * counter < transitionTime then

            counter = counter + 1

            object.fill.effect = "filter.scatter"
            object.fill.effect.intensity = intensityInc * counter

            print( "Time, Intensity = " .. timeInc * counter .. ", " .. intensityInc * counter )

        else

            Runtime:removeEventListener( tmr )

        end
    end

    timeInc =  ( transitionTime / 30 )
    intensityInc =  .5 / ( transitionTime / 30 )

    hideMonsterHealth()

    transition.to( monsterObject, { time = transitionTime, alpha = 0 } )

    ---CODE REMOVED AND REPLACED WITH ENTER FRAME LISTENER
    --monsterObject.fill.effect = "filter.scatter"
    --transition.to( monsterObject.fill.effect, { time = transitionTime, intensity = .5 } )
    
    --Transition out monster
    tmr = Runtime:addEventListener( "enterFrame", function() return scatterObject( monsterObject ) end )
end


[TOPIC: post.html]
#10

bjsorrentino

[GLOBAL: userInfoPane.html]
bjsorrentino
  • Veteran

  • 8,506 posts
  • Corona SDK

Hi @gullie667,

The "alpha" parameter in regards to a filter (not the alpha of the actual object) is only supported if the filter has that as one of its internal parameters. Only then can you point to that property and adjust it or transition it. A complete list of the filters and supported parameters is available here:

 

http://docs.coronalabs.com/guide/graphics/effects.html

 

Best regards,

Brent



[TOPIC: post.html]
#11

gullie667

[GLOBAL: userInfoPane.html]
gullie667
  • Contributor

  • 185 posts
  • Corona SDK

Brent / Rob,

 

Just to be clear, in this specific case, I am trying to fade out (remove a monster that has been killed)  a display object. A display object created with newImageRect, using an imageSheet, and being made from a .png with an embedded transparency.

 

The goal is to simultaneously:

A)fade out the monster by using a transitionTo and adjusting the alpha = 1 to 0 over 1 sec. 

B)apply a filter.scatter and gradually increase the "intensity" parameter from 0 to .5 over 1 sec.

 

The "transitionTo / alpha" works fine alone.

 

When the filter.scatter effect is applied alone the object's embedded transparency goes to a visible black. When the filter.scatter effect is applied in conjunction with the "transitionTo / alpha" the display object's embedded transparency goes to a visible black and the "transitionTo / alpha" no longer functions.

 

The filter.scatter documentation mentions nothing of an alpha parameter.

 

So, the question: If the filter.scatter effect where to maintain the embedded .png's transparaency the "transitonTo / alpha" effect would still be unsupported? That's what you are saying right?

 

Thanks!



[TOPIC: post.html]
#12

bjsorrentino

[GLOBAL: userInfoPane.html]
bjsorrentino
  • Veteran

  • 8,506 posts
  • Corona SDK

Hi @gullie667,

I asked the engineers if core alpha could be supported in the "scatter" filter or not.

 

In the meantime, would you be able to achieve a similar effect using the "dissolve" filter? This one respects core alpha in my testing.

 

Brent



[TOPIC: post.html]
#13

albert90

[GLOBAL: userInfoPane.html]
albert90
  • Enthusiast

  • 82 posts
  • Corona Staff

I fixed the "scatter" filter transparency problem in the next daily build. Thanks for reporting this issue!



[TOPIC: post.html]
#14

jacques1

[GLOBAL: userInfoPane.html]
jacques1
  • Contributor

  • 318 posts
  • Corona SDK

@Albert90 - is that build .2123 that it's fixed in or the build coming after that?



[TOPIC: post.html]
#15

bjsorrentino

[GLOBAL: userInfoPane.html]
bjsorrentino
  • Veteran

  • 8,506 posts
  • Corona SDK

Hi @jacques1,

It's build 2125 of later for that feature.

 

Brent



[TOPIC: post.html]
#16

gullie667

[GLOBAL: userInfoPane.html]
gullie667
  • Contributor

  • 185 posts
  • Corona SDK

Thanks Guys




[topic_controls]
[/topic_controls]