Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

[FIXED] Hue filter issue
Started by Reaver Apr 24 2014 02:59 AM

32 replies to this topic
hue photoshop graphics2.0 filter
[TOPIC CONTROLS]
Page 1 of 2 1 2
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

Reaver

[GLOBAL: userInfoPane.html]
Reaver
  • Enthusiast

  • 87 posts
  • Corona SDK

Hi!

 

We are trying to use the hue filter on a uniform color image in order to add some color customization to our game. We have used photoshop to find wanted hue values for the image. The problem is that there seems to be a slight problem with the colors when they are in the app. It looks like some of the colors are darker than we expect them to be when finding the values in photoshop. We can reproduce this effect in photoshop by also turning the lightness of the image down when adjusting the hue.

 

We also noticed that the corona hue filter will change the color of white in images while the photoshop hue filter does not tune the color of black or white in images. Though we solved this by using the hue filter on a uniform color image.

 

Does anyone have an explanation for this or have experienced something similar? Is this even a good way of doing this? Is this a known issue that different programs have differently behaving hue functions?

 

Thanks!

 

EDIT: The corona hue filter changes the color of the white in an image, not that black as I first stated.



[TOPIC: post.html]
#2

bjsorrentino

[GLOBAL: userInfoPane.html]
bjsorrentino
  • Veteran

  • 8,506 posts
  • Corona SDK

Hi @Reaver,

Are you seeing these differences on a device or on the Simulator? Can you post some screenshots to compare?

 

Thanks,

Brent



[TOPIC: post.html]
#3

Reaver

[GLOBAL: userInfoPane.html]
Reaver
  • Enthusiast

  • 87 posts
  • Corona SDK

Hi Brent!

 

I tested on the device and simulator and the results look the same. I have also a couple of images for you.

 

This is the image as it appears in GIMP with hue set to -170.

cvTpn2f.png

 

This is the image of how it is displayed with Corona with the same hue value.

7bqbGf8.png

 

As you can see the Image has a different color and the parts of the image that were white are effected by the hue filter which it does not do in GIMP and Photoshop.

 

Original Image: 

8ATxKch.png

 

Code:

local image = display.newImage("hue.png")
image.x = 150
image.y = 350

local hueValue = -170

image.fill.effect = "filter.hue"
image.fill.effect.angle = hueValue


[TOPIC: post.html]
#4

bjsorrentino

[GLOBAL: userInfoPane.html]
bjsorrentino
  • Veteran

  • 8,506 posts
  • Corona SDK

Hi @Reaver,

Engineering is taking a look at this. Thanks for posting the screenshots.

 

Brent



[TOPIC: post.html]
#5

albert90

[GLOBAL: userInfoPane.html]
albert90
  • Enthusiast

  • 82 posts
  • Corona Staff

@Reaver: Tomorrow's daily build (CoronaSDK 2014.2298) will include a fix for filter.hue that will bring our results closer to GIMP and Photoshop.

 

Thanks for reporting this problem!

 

Albert



[TOPIC: post.html]
#6

Reaver

[GLOBAL: userInfoPane.html]
Reaver
  • Enthusiast

  • 87 posts
  • Corona SDK

Thanks for looking into this!



[TOPIC: post.html]
#7

Reaver

[GLOBAL: userInfoPane.html]
Reaver
  • Enthusiast

  • 87 posts
  • Corona SDK

Hi again.

 

I just had a look at this and it seems that the colors match better but that the sign needs to be switched for the hue value found in photoshop and GIMP. So if a specific color has hue value 50 in PS or Gimp then the color can be found by using -50 as the hue value in corona.



[TOPIC: post.html]
#8

Dotnaught

[GLOBAL: userInfoPane.html]
Dotnaught
  • Contributor

  • 370 posts
  • Corona SDK

Using build 2393, the "filter.hue" produces substantially different colors for iOS (7.1, iPhone 5) and for Android. fill.effect.angle = 200 produces red on iOS and army green on Android (4.4.3, Nexus 7).

 

Are colors supposed to be consistent across platforms?



[TOPIC: post.html]
#9

albert90

[GLOBAL: userInfoPane.html]
albert90
  • Enthusiast

  • 82 posts
  • Corona Staff

@Dotnaught: The result of the hue filter should be the same across platforms. Can you file a bug with a simple sample? Please make sure your sample uses the texture giving you the incorrect result. Having a bug on file will help us track the issue and schedule some time to fix it. Thanks!



[TOPIC: post.html]
#10

playthisstudios

[GLOBAL: userInfoPane.html]
playthisstudios
  • Enthusiast

  • 71 posts
  • Corona SDK

Was there ever a bug filed for this? We were just about to launch an update to our app that included hue adjustment of images. Worked great on iOS, nexus4, nexus 5, nexus 7 gen 2, but doesn't work as expected on Nexus 7 gen 1. (Even setting hue to 0 on nexus 7 gen 1 results in a green image from a base orange one). This is preventing us from adding this required feature and I am worried this could happen randomly on any of the other many types of Android devices. Could we get an update please?



[TOPIC: post.html]
#11

playthisstudios

[GLOBAL: userInfoPane.html]
playthisstudios
  • Enthusiast

  • 71 posts
  • Corona SDK

Posted Bug (Case 35892) for this.

Easiest reproducable case is to load an image, set hue filter to it and set the hue angle to 0.

On Nexus 4,5, 2nd gen 7 and iphone ipad etc works as expected (image looks "normal")

On Nexus 1st gen the image has a hue adjustment to it.

Not sure how many other devices would be affected, but assuming it would not just be isolated to Nexus7 1st Gen.



[TOPIC: post.html]
#12

playthisstudios

[GLOBAL: userInfoPane.html]
playthisstudios
  • Enthusiast

  • 71 posts
  • Corona SDK

Any further updates on this issue? The bug (Case 35892) was filed over 6 weeks ago?

 

Thanks

 

David



[TOPIC: post.html]
#13

playthisstudios

[GLOBAL: userInfoPane.html]
playthisstudios
  • Enthusiast

  • 71 posts
  • Corona SDK

I have been more than patient on this issue - I posted the  bug (Case 35892) 10 weeks ago - I joined the discussion here http://forums.coronalabs.com/topic/52957-getting-odd-results-with-filterhue/?hl=filter

where another user was having problems with it.

 

I added a check for system.getInfo( "gpuSupportsHighPrecisionFragmentShaders" ) so the hue filter is only available on supported devices (which blocked it on 1st gen Nexus 7, although users will complain why they don't get the hue feature)

I was just about to submit the update to app store - thought I would try on iphone4 to do a final test, and it PASSES the test above, but setting the hue to 0 makes the image have a hue adjustment, which makes a photo app useless to a user with an iphone4.

 

Could I PLEASE have someone from engineering look at this and tell me what can be done?

 

 

David



[TOPIC: post.html]
#14

bjsorrentino

[GLOBAL: userInfoPane.html]
bjsorrentino
  • Veteran

  • 8,506 posts
  • Corona SDK

Hi David,

I've once again urged the engineers to look into this a.s.a.p. Sorry for the lack of action on this… I'll keep you posted.

 

Thanks,

Brent



[TOPIC: post.html]
#15

playthisstudios

[GLOBAL: userInfoPane.html]
playthisstudios
  • Enthusiast

  • 71 posts
  • Corona SDK

Thanks Brent.

At this point we are using that check on android, and are going to have to restrict to iOS8+ on apple devices (to ensure user has 4S or above).

Not a great solution, but if engineering fix it, we can remove those restrictions.

David



[TOPIC: post.html]
#16

bjsorrentino

[GLOBAL: userInfoPane.html]
bjsorrentino
  • Veteran

  • 8,506 posts
  • Corona SDK

Hi David,

Does the issue mostly occur when the angle is set to 0? Or any angle?

 

Brent



[TOPIC: post.html]
#17

playthisstudios

[GLOBAL: userInfoPane.html]
playthisstudios
  • Enthusiast

  • 71 posts
  • Corona SDK

Hi Brent,

0 or any angle (on 1st gen Nexus) it is as if it is offset. An orange image with angle 0 (or 360) will appear green.

 

David



[TOPIC: post.html]
#18

bjsorrentino

[GLOBAL: userInfoPane.html]
bjsorrentino
  • Veteran

  • 8,506 posts
  • Corona SDK

Hi David,

Just to be 100% clear, any angle? So like 90, 180, 172, or anything? Not just 0 or 360?

 

Brent



[TOPIC: post.html]
#19

playthisstudios

[GLOBAL: userInfoPane.html]
playthisstudios
  • Enthusiast

  • 71 posts
  • Corona SDK

Yep, any angle is wrong. I set it up with a slider to adjust the angle (I was thinking of getting the user to do an initial adjustment on platform), and on the Nexus 1st gen, to get the orange image back to "orange", it required it to be set to about 57. But, the image didn't quite look right (the color wasn't exactly the same). ie it wasn't the same as setting to 0 on another device/simulator.

Hope that helps,

 

David



[TOPIC: post.html]
#20

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,376 posts
  • Enterprise

Can you add this line to your config.lua:

 

shaderPrecision = "highp",

 

This tells your app to use high precision calculations which apparently the hue filter needs.  I've tested it on my Kindle Fire Gen 1 and my Nexus 7 Gen 1 and the FilterViewer for Hue now matches the simulator.  This is a short term fix because it's causing any other shaders to use more math than needed.  Engineering will get this fixed in an upcoming daily build, but for now, this should work around the issue.

 

Rob



[TOPIC: post.html]
#21

playthisstudios

[GLOBAL: userInfoPane.html]
playthisstudios
  • Enthusiast

  • 71 posts
  • Corona SDK

Hi Brent,

 

So I saw that there was a note in release 2522 about this being enabled for hue only.

 

Tested on Nexus 7 1st gen and another low end android tab that it didn't work on before. And if you set hue angle to 0 it does indeed match the original image.

 

BUT! If I try to adjust the hue after that (for instance on a slider as the basic example code below shows), then it doesn't update. Tried same build on a Nexus 2nd gen  and it updates correctly on changing the hue angle.

 

So we are close, but not quite there. Could you ask engineering to try adjusting the hue value after creation and see if they can repro the issue?

local widget = require( "widget" )

local snapshot1 = display.newSnapshot(400,400)
snapshot1.x = 200

local base = display.newImageRect ("Icon@2x.png",200,200)
base.x = 50
base.y = 50

local test = display.newImageRect ("Icon@2x.png",200,200)
test.y = 100

snapshot1.group:insert(test)

test.fill.effect = "filter.hue"
test.fill.effect.angle = 0

local myText = display.newText( "0", 100, 350, native.systemFont, 16 )


-- Slider listener
local function sliderListener( event )
    print( "Slider at " .. event.value .. "%" )
    test.fill.effect.angle = event.value 
    myText.text = event.value 
    snapshot1:invalidate()
end

-- Create the widget
local slider = widget.newSlider
{
    top = 400,
    left = 50,
    width = 400,
    value = 0,  -- Start slider at 10% (optional)
    listener = sliderListener
}

David



[TOPIC: post.html]
#22

bjsorrentino

[GLOBAL: userInfoPane.html]
bjsorrentino
  • Veteran

  • 8,506 posts
  • Corona SDK

Hi David,

This might be a snapshot issue, not a hue filter issue. What happens if you try this code on the test image but don't involve any of the snapshot stuff?

 

Brent



[TOPIC: post.html]
#23

playthisstudios

[GLOBAL: userInfoPane.html]
playthisstudios
  • Enthusiast

  • 71 posts
  • Corona SDK

Hi Brent, tried without the snapshot as well, and no different.

That code works fine on 2nd gen Nexus, so not sure how the hue could now be set, but not able to be changed.

Did you try that code on your nexus 7 gen 1?

David



[TOPIC: post.html]
#24

bjsorrentino

[GLOBAL: userInfoPane.html]
bjsorrentino
  • Veteran

  • 8,506 posts
  • Corona SDK

Hi David,

I'm not in the office at the moment so I don't have an older device to test on. In any case, does merely setting the value to (say) 50 now work, or not work, on the 1st-gen Nexus? Meaning, simplifying this without the slider code, what happens when you set angles? Do different devices now basically sync in hue behavior or not?

 

Did you remove the "highp" thing from your config.lua once you upgraded to 2522?

 

Thanks,

Brent



[TOPIC: post.html]
#25

playthisstudios

[GLOBAL: userInfoPane.html]
playthisstudios
  • Enthusiast

  • 71 posts
  • Corona SDK

Hi Brent, on further investigation, setting the angle to 50 or 90 results in the same as setting it to 0. Which is probably why the slider doesn't do anything. It would appear that setting it to anything on Nexus 7 1st gen results in a hue of 0.

Can you confirm when you are in again and pass back to engineering?

 

David




[topic_controls]
Page 1 of 2 1 2
 
[/topic_controls]