-
-
Notifications
You must be signed in to change notification settings - Fork 21.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix emission calculation for spatial shader #10441
Fix emission calculation for spatial shader #10441
Conversation
and here I was wondering why my emission mask does nothing in 3.0, thanks man! |
Excellent! I have been meaning to create an issue for this. Look forward to trying it out :) |
I thought it might be more useful the current way, but if you prefer this way I'm fine too. PR looks perfect. |
I was thinking about it, and I'm not sure if this proposal is better. The rationale is the following:
So I think after thinking about it for a while, that this PR is a bad idea, it just makes emission more restricted. |
Isn't the current behavior similar to how emission map works in Unity? |
@reduz, I think the main benefit of multiplying is ability to change Color of emission using texture as mask. And other engines works this way. |
I was mostly talking about being able to use black/white masks to control which parts of the mesh do emission (eg. only a lamp or a decorative border) |
@Zireael07 yes, but to have control on light color of that emission you need multiplication of emission texture and emission color |
47470a8
to
b95da29
Compare
Then this would also mean that's how it works with Substance, right? |
I'm still not convinced that it's more intuitive, I would probably just add an option to select the behavior.. |
I'm not exactly sure how this works with Unity or Substance (is there an official doc about it?), but based on this discussion, the current behavior in Godot apparently matches Khronos shader in their gltf exporter repo. |
The current Godot implementation is also the one that physically makes more sense: in the absence of emission you should only get albedo (which is the reflected environmental light), and when you turn on an additional light source (which is the emission) it should just add to albedo.(electromagnetic waves add without interacting, neglecting quantum mechanical effects for bosons. also in reality, when you turn on the light source it will heat the object up changing transport properties a little such that the albedo will be slightly different but shouldn't be much.) |
@reduz, I really don't know in what case it is convinient to have sum of emission color and texture. Maybe you can give an example of such use case? If it can be helpful in some situation, maybe to have an option is better idea. Because with current implementation it is impossible to do coloring of emission with mask. @tagcup About Unity you can see here |
I don't know whick picture you're referring to exactly but this one (from that page) is mostly black: https://docs.unity3d.com/uploads/Main/StandardShaderEmissiveMaterialInspector.png |
@tagcup: That's because it's partially a mask. Now if I were to apply this same picture as emission texture in Godot, the whole mesh would be emissive right now in 3.0 (and properly masked in 2.1.3). |
Given there are good reasons for both use cases, I will do the following
|
@Zireael07 I must've misunderstood what Godot is currently doing then. So according to what you're saying, Godot is currently adding albedo as emissive color on top of the given emissive texture |
@tagcup, as @Zireael07 sad, result is almost black. But on the right side you can see almost black texture with small green and orange squares, and to the left you will see white color @tagcup, in current implementation Godot use color from texture plus emission color (and maybe plus Albedo). So when you are using emission texture, you can left emission color black. But in Unity you must set it to white, or other color to do coloring. @reduz, good to know, that there will be an option to select behavior. Thanks. Also I could do this option in this PR. Or do you want to do it yourself? |
b95da29
to
304bc80
Compare
@reduz , I have just added flag to select to use multiplication or not. Could you see is it good enough option to accept? |
e27aefd
to
5290acd
Compare
Can you please squash the clang-format commit? It doesn't make much sense for the public git history. Other than that, @reduz is the multiplication flag that was implemented after your comment a good fix, should this be merged in this form? |
5290acd
to
94e20e0
Compare
What are we doing with this? Still unable to mask my emissions as of alpha 2... |
I think this will be merged eventually since it adds a flag for users to choose whether they want additive or multiplicative mode. |
I think, that current emission calculation is incorrect, or at least not convenient.
Current logic sums color and value from texture. That means, that you can't use texture as mask to make some parts of mesh emitting. Or you can use black color on texture to not emit, but color become useless. And you can't use it as tint to colorize emission.
I suggest to use texture as mask by multiplying it with color instead of summation.
Also I changed hint color for case, when you don't need a texture.