godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.12k stars 69 forks source link

Display a checkerboard pattern on the fallback 3D material #6138

Open Calinou opened 1 year ago

Calinou commented 1 year ago

Describe the project you are working on

The Godot editor :slightly_smiling_face:

Describe the problem or limitation you are having in your project

While Godot 4 has made a lot of progress on the default appearance of 3D scenes, there's still room for improvement.

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

Display a checkerboard pattern on the fallback 3D material. This has two benefits over a plain untextured surface:

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

This shader is based on @CptPotato's procedural checker shader. Since it performs triplanar mapping in local (object) space, it does not require meshes to have UV. It also doesn't use a texture, but renders the checkerboard procedurally. The checkerboard's lines are always sharp but antialiased.

The checkerboard's average albedo and roughness levels are tuned to match the previous untextured material, with parts of the material being brighter and other parts being darker.

Screenshots have SDFGI and glow enabled.

On the 3rd test case, some of the cubes have default StandardMaterial3D/ORMMaterial3D/ShaderMaterials attached as a comparison. These are expected to be brighter and rougher than the fallback material.

Daytime

Current fallback material With checkerboard material
Screenshot_20230121_014105 webp Screenshot_20230121_014057 webp
Screenshot_20230121_014158 webp Screenshot_20230121_014152 webp
Screenshot_20230121_014223 webp Screenshot_20230121_014215 webp

Nighttime

Current fallback material With checkerboard material
Screenshot_20230121_013636 webp Screenshot_20230121_013603 webp
Screenshot_20230121_013813 webp Screenshot_20230121_013804 webp
Screenshot_20230121_013926 webp Screenshot_20230121_013918 webp

Regarding performance, this shader makes the 2nd test scene 0.05 mspf slower to render in 4K on a GeForce RTX 4090 (measured with SDFGI and glow disabled). Slower GPUs will be more impacted at similar resolutions, but it may also be argued that the performance of the fallback material should be representative of final materials you'd typically use in a finished project. There may be ways to optimize the shader too – I haven't looked extensively.

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

No.

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

This is about improving the out-of-the-box user experience.

Lielay9 commented 1 year ago

Such a missed opportunity :shakes head: 😔

image

yosoyfreeman commented 1 year ago

I personally think that the current material is better suited for prototyping and and looks more cohesive and less noisy.

Also, a checkerboard only helps with scale and prototyping if it have the proper subdivisions (With the proposed one it would only be helpful modelling in a grid of 25 cm), in practise a developer could be using 3x3 pieces that would need a corresponding meters and subdivisions. This could be adjustable, but i think is over complicated.

CptPotato commented 1 year ago

I personally think that the current material is better suited for prototyping and and looks more cohesive and less noisy.

Also, a checkerboard only helps with scale and prototyping if it have the proper subdivisions (With the proposed one it would only be helpful modelling in a grid of 25 cm), in practise a developer could be using 3x3 pieces that would need a corresponding meters and subdivisions. This could be adjustable, but i think is over complicated.

It's not for me to decide, but in my opinion the main benefit such a material provides is giving important visual cues to judge the depth and shape of the geometry. Especially on large surfaces that are common in rough blockouts it's otherwise hard or impossible to tell how close you actually are to the surface.

Whether or not the grid actually lines up with the objects themselves is secondary I think, but I do get the point.

Calinou commented 1 year ago

After discussing this with reduz, we decided to go with a different implementation instead:

It may also be worth having a project setting to override the fallback material, in case you want the checkerboard (or any other texture) to be applied everywhere.

yosoyfreeman commented 1 year ago

Super nice solution.

Anyway, i think changing the current super white color to something more gray and reflective would achieve a similar result of improving first impressions and would still be a good solution.

Calinou commented 1 year ago

Anyway, i think changing the current super white color to something more gray and reflective would achieve a similar result of improving first impressions and would still be a good solution.

The fallback material's albedo and roughness were already tweaked in 4.0 to be less bright and slightly more reflective. There is a PR that further tweaks it, but it won't be merged for 4.0: https://github.com/godotengine/godot/pull/62756

yosoyfreeman commented 1 year ago

You are always two steps ahead haha

Thank you for your work Calinou!

Zireael07 commented 1 year ago

Closed PR is https://github.com/godotengine/godot/pull/71774, no new PR yet

Calinou commented 1 year ago

It may also be worth having a project setting to override the fallback material, in case you want the checkerboard (or any other texture) to be applied everywhere.

I made a branch adding such a project setting: https://github.com/Calinou/godot/tree/add-3d-fallback-material-shader-override

It overrides the shader and not the material though, as I couldn't figure out how to override the material. This would be preferable as it's much more flexible.

Testing project: test_custom_default_material.zip