“s” is the output struct from a Surface shader, such as SurfaceOutputStandard, when you’re assigning all those o.Albedo, o.Normal, etc… properties in the surface shader surf function. But I believe that part isn’t important anyways for the emission unless you want to perfectly replicate unity’s lighting model in your shader, otherwise all that’s important is for you to take your current lighting/shading calculation and add it to your emission and have this last part: csharp~~ ~~#ifndef UNITY_HDR_ON emissiveColor.rgb = exp2(-emissiveColor.rgb); #endif~~ ~~ If that still doesn’t fix the result, then you can do a search for BRDF1_Unity_PBS in UnityStandardBRDF.cginc to see all the calculations on those inputs Unity is doing.
That same shader code is used by the surface shader already. If you look at the generated shader code from your surface shader you’ll find the same “exp2()” line. That’s not the problem.
I think the problem stems from the Standard shader using a custom editor vs just using the [HDR] flag on the color property, but I don’t know for sure. There’s nothing obvious in the editor code for why they should produce different results.
I would check with the frame debugger to see if the color values both shaders are receiving are the same, but I highly suspect they will not and the Standard shader is for some reason getting a much brighter color value.
Thank you for the information, Its great to hear that my shader doesn’t need to worry about that code because it does it already.
Thanks for the advice of using framedebugger, I was searching for a way to see the shader varibles values. From that I discovered that the values where infact different! - Despite being the same in the color picker!
After some digging, it does infact seem to be because of the [HDR] flag vs custom material editor!
(editor code is more my thing, over shaders)
Writing a custom GUI for my shader (/copying from the standsharderGUI) does infact solve this issue! and the outputted values are the same. I am still somewhat unsure as to Why though, i’ll keep digging.
Also, just to note, that unity has confirmed my bug report - so this does infact seem to be a bug
–Update–
I have found the cause of the issue, simply its the HDR tag on the color. If I have a custom editor replicating what the StandardShaderGUI does but my color field does not have the [HDR] tag, the emissive value color will be the same as the standard shader.