Can't replicate Metallic Alpha from Standard Shader

Node-based Shader Editor

Can't replicate Metallic Alpha from Standard Shader

Postby elamhut » Sat Oct 06, 2018 1:14 am

Hey guys, I'm trying to replicate the standard shader here with some very small modifications (mainly a gradient texture that fills in the emissive so I can animate it turning on, but that's besides the point), but I can't manage to replicate the Metallic value sampling from the Metallic Alpha.

Left is standard, right is my custom.

When I set everything up with the same values on Color, Metallic and Smoothness I get almost perfect results.

Image

When I try sampling my Metallic from a Texture's Metallic Alpha (just like Standard Does). I get some crazy weird result like this:

Image

They are both using the same texture, sampling from Metallic Alpha.

I don't really know what to do, I just need a near-perfect replica of the Standard Shader with Metallic Alpha working :/
elamhut
 
Posts: 3
Joined: Fri Oct 05, 2018 10:33 pm

Re: Can't replicate Metallic Alpha from Standard Shader

Postby Ricardo Teixeira » Sat Oct 06, 2018 3:21 pm

Hey there, can you share the standard material, the ASE shader and the texture used?

We would be happy to examine it, the results should be identical.

Thanks!
Sales & 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
Ricardo Teixeira
 
Posts: 954
Joined: Fri Aug 09, 2013 2:26 pm

Re: Can't replicate Metallic Alpha from Standard Shader

Postby elamhut » Sun Oct 07, 2018 8:25 pm

Hey!

Here's a Unity Package with the models, textures, shaders and a prefab with everything already set up.

We use:
Color
Albedo
Metallic Alpha
Normal Map
Emissive
Detail Albedo
Detail Normal

I tried replicating each one of these in the new shader, only adding a clamped Black and White gradient that I use to fill the emissive from bottom to top in order for me to be able to animate it.

https://www.dropbox.com/s/8rwtu6j5j4a4a ... ckage?dl=0

Also,

Thanks a lot for the reply and the support :)
elamhut
 
Posts: 3
Joined: Fri Oct 05, 2018 10:33 pm

Re: Can't replicate Metallic Alpha from Standard Shader

Postby Ricardo Teixeira » Mon Oct 08, 2018 2:37 pm

elamhut wrote:Hey!

Here's a Unity Package with the models, textures, shaders and a prefab with everything already set up.

We use:
Color
Albedo
Metallic Alpha
Normal Map
Emissive
Detail Albedo
Detail Normal
I tried replicating each one of these in the new shader, only adding a clamped Black and White gradient that I use to fill the emissive from bottom to top in order for me to be able to animate it.
https://www.dropbox.com/s/8rwtu6j5j4a4a ... ckage?dl=0
Also,
Thanks a lot for the reply and the support :)


Hey there,

Thank you for the sample, we really appreciate it. It seems to be working as expected provided that you compare the same exact values. The Metallic texture shared is used by the Unity counterpart as 0(black) for the metallic while the Alpha is used in the Smoothness channel, in the ASE sample you're using the Alpha as the metallic value.

We would be happy to guide you here, how exactly do you want to use the Texture to drive your Metallic and Smoothness values?

Do note that:

You don't need to use the Alpha channel of the metallic texture as you would in a standard material. If you're only using one channel you could store it pretty much anywhere. Why not combine the Emissive texture and the Metallic + Smoothness in the same file? 1 texture per-channel(RGBA) saves you quite a lot.

The Normal textures are not used correctly, you can't simply add them. I recommend using the Blend Normals node or the Lerp node followed by a normalize.

It's definitely possible to implement a detail mask that behaves the same way as Unity standard shader detail mask, for that you need to replicate exactly what Unity is doing by using their one of their functions through a Custom Expression node.

There are several methods available, which you can examine for yourself in the "UnityStandardInput.cginc" file, for example:

#if _DETAIL_MULX2
albedo *= LerpWhiteTo (detailAlbedo * unity_ColorSpaceDouble.rgb, mask);
#elif _DETAIL_MUL
albedo *= LerpWhiteTo (detailAlbedo, mask);
#elif _DETAIL_ADD
albedo += detailAlbedo * mask;
#elif _DETAIL_LERP
albedo = lerp (albedo, detailAlbedo, mask);
#endif

I'm sending you a shader sample which implements the first calculation, DETAIL_MULX2, in attachement with this email.

In any case, for most cases you will likely only need to Lerp or Multiply your textures to achieve similar effects.

Looking forward your reply.
Attachments
Sample.zip
(1.36 KiB) Downloaded 260 times
Sales & 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
Ricardo Teixeira
 
Posts: 954
Joined: Fri Aug 09, 2013 2:26 pm

Re: Can't replicate Metallic Alpha from Standard Shader

Postby elamhut » Tue Oct 09, 2018 4:03 am

Hey Ricardo,

Again thanks for the AMAZING support!

Oh, I know about the not-so-optimized stuff. I was just prototyping stuff first so I was trying to get to the final result before thinking of ways to optimize the Shader.

What you made me realize was that the Metallic was using the Alpha in the Smoothness input instead of the Metallic input, and that it uses the Red channel for that. Unity's documentation is not really straightforward about that and, in fact, is wrong in some ways about how its own Shader works :/ So I did try a bunch of stuff before giving up.

On the other hand I was extremely stupid because if you just hover your mouse on the metallic material this appears:
Image

But nonetheless your help was invaluable.

Also thanks for helping me with how to apply the Detail map, for this I had to ask a programmer to give me a hand since I'm not a coder myself. But everything is fine now and we got that expression working properly :)

This shader is going to be used through our entire game :) Thanks a lot for helping me achieve this result, we were having a ton of headaches trying to program it by hand before getting Amplify (I used to use Shaderforge, but it's now dead so we migrated and I'm loving it way more).


Thanks!
elamhut
 
Posts: 3
Joined: Fri Oct 05, 2018 10:33 pm

Re: Can't replicate Metallic Alpha from Standard Shader

Postby Amplify_Borba » Tue Oct 09, 2018 7:46 am

No problem, we're happy to know that you're enjoying using our tool!

Have you had the chance to rate and review Amplify Shader Editor? It would be awesome if you could share your experience with the Unity community, the Unity Asset Store thrives on user interaction and direct feedback.
Every bit helps, your feedback is extremely valuable to us!

Feel free to get back in touch if you have further issues or 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


Return to Amplify Shader Editor

Who is online

Users browsing this forum: No registered users and 11 guests