godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.15k stars 97 forks source link

Allow BaseMaterial3D Roughness values above `1.0` when using a roughness image map #9176

Open Ahem-008 opened 8 months ago

Ahem-008 commented 8 months ago

Describe the project you are working on

A 3d game with PBR.

Describe the problem or limitation you are having in your project

When you add a roughness texture and have roughness value at 1 that is the intended effect by the map on the material, you can reduce the roughness value to make the material more glossy/smooth but you cannot increase it to make it more rougher/less glossy than it is intended to be.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

It would be nice have the roughness value go upto 2 instead of 1.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

github_roughness

If this enhancement will not be used often, can it be worked around with a few lines of script?

No, this enhancement will help everybody making 3d games and it will be used often.

Is there a reason why this should be core and not an add-on in the asset library?

This is a very core functionality!

Calinou commented 8 months ago

This makes sense (also for metallic), but if we do this, we need to make sure the final value is always clamped to 1.0 as values above will look broken.

Also, I wouldn't show values above 1.0 in the slider but only allow manually entering them with the keyboard (using the or_greater property hint).

Ahem-008 commented 8 months ago

Maybe the editor value can go from -1 to 1 because it makes sense for the roughness value to be at 0 when you add a texture map. you make the material more or less glossy only in the context of the texture.

Calinou commented 8 months ago

Maybe the editor value can go from -1 to 1 because it makes sense for the roughness value to be at 0 when you add a texture map. you make the material more or less glossy only in the context of the texture.

Changing the way the roughness/metallic values are interpreted would break compatibility with existing projects, not to mention it would deviate from the standard that all other engines follow.

Ahem-008 commented 8 months ago

Changing the way the roughness/metallic values are interpreted would break compatibility with existing projects, not to mention it would deviate from the standard that all other engines follow.

True, but its more cleaner and understandable for the user, the alternative would be not knowing you can set the value to more than 1 and using a image editor, come back to Godot and check result, if not satisfied repeat these steps a few time - this wouldn't be the case if we have a nice slider that goes from -1 to 1. This is a great QoL improvement for the long run and who knows other engines might follow Godot's example in the future.

twoco commented 2 months ago

My solution is to use following in a shader:

uniform float test_roughness : hint_range(-1.0, 1.0) = 0.0;
// ...
ROUGHNESS = clamp(test_arm.g + test_roughness, 0, 1);

I don't see any difference if I remove clamp. Maybe ROUGHNESS does that internally or does not matter.

You need to use "add" instead of "multiply". Because 0 (of the texture) multiplied x times is still 0. With the Add operator you can turn it completely off or on. But you get a clipping effect. Otherwise you need other image filters. But then you could just edit your roughness texture. Multiplication only makes sense if you want to reduce the roughness. Or did I miss something?