Different colors when using constant or property values

Node-based Shader Editor

Different colors when using constant or property values

Postby Jono00 » Tue Oct 09, 2018 11:19 am

Hi!

I just made a new, empty shader. I use 2 colors to define the albedo of a mesh. For some reason, I get different results when the colors are constant or property!

Results when the colors are constants.
Results when the colors are properties.

To reiterate, the only thing I changed is the color type (Constant to Property). Am I misunderstanding something here?

I'm using unity 2018.2.9f1

Thanks!
Jono00
 
Posts: 2
Joined: Tue Oct 09, 2018 11:11 am

Re: Different colors when using constant or property values

Postby Amplify_Borba » Tue Oct 09, 2018 2:11 pm

Hello, thank you for getting in touch and for your support!

This behavior is expected and it only happens in Linear color space, which is due to Unity trying to convert the property's value. It won't happen if the value is a constant, since the value is directly specified in the shader, or if you work in Gamma color space, which hopefully are valid workarounds.

Please let me know if you have any further questions, thanks!
Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Amplify_Borba
 
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am

Re: Different colors when using constant or property values

Postby Jono00 » Tue Oct 09, 2018 2:27 pm

Oh! I actually did not know that.

Thank you for the swift and kind reply :)
Jono00
 
Posts: 2
Joined: Tue Oct 09, 2018 11:11 am

Re: Different colors when using constant or property values

Postby Amplify_Borba » Tue Oct 09, 2018 3:06 pm

No problem, please don't hesitate to get in touch if you have any further questions, we'll be happy to help!
Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Amplify_Borba
 
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am

Re: Different colors when using constant or property values

Postby JohnnyFactor » Sat Jan 05, 2019 10:59 am

I'm encountering the same thing and it's causing issues when building to mobile, so how do we use Property mode in linear color space?

EDIT: I'll be more specific here. The color nodes work fine when working in linear space, but the floats do not. I've been replacing floats with greyscale color nodes but I would really like to understand what's going on.
JohnnyFactor
 
Posts: 9
Joined: Thu Aug 16, 2018 2:43 pm

Re: Different colors when using constant or property values

Postby Amplify_Borba » Mon Jan 07, 2019 3:45 pm

Hello, the conversion between linear and gamma is expected to only occur in color properties.

However, the float node does have a Gamma attribute that, according to Unity's documentation, might perform the necessary conversion.

Please let us know if the above does work, otherwise you'll likely have to use the color node rather than the float node.
Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Amplify_Borba
 
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am

Re: Different colors when using constant or property values

Postby JohnnyFactor » Mon Jan 07, 2019 8:50 pm

Yes, that worked! Thanks for finding this, now it's clear. A build to iOS with a float node with the Gamma attribute is identical to a color node. I found the same info on a link from the page you posted, worded slightly differently:

https://docs.unity3d.com/Manual/SL-Properties.html:
"For properties that are marked as Float or Vector type, no color space conversions are done by default; it is assumed that they contain non-color data. It is possible to add [Gamma] attribute for float/vector properties to indicate that they are specified in sRGB space, just like colors."
JohnnyFactor
 
Posts: 9
Joined: Thu Aug 16, 2018 2:43 pm

Re: Different colors when using constant or property values

Postby Amplify_Borba » Tue Jan 08, 2019 12:24 pm

No problem, thank you for letting us know this worked out for you!
Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Amplify_Borba
 
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am


Return to Amplify Shader Editor

Who is online

Users browsing this forum: Bing [Bot] and 8 guests