Skip to content
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

Improve material preview in the inspector #11259

Open
lander-vr opened this issue Nov 29, 2024 · 10 comments · May be fixed by godotengine/godot#99927
Open

Improve material preview in the inspector #11259

lander-vr opened this issue Nov 29, 2024 · 10 comments · May be fixed by godotengine/godot#99927

Comments

@lander-vr
Copy link

lander-vr commented Nov 29, 2024

Describe the project you are working on

Art UX improvements

Describe the problem or limitation you are having in your project

The material preview window is not representative of what materials look like in the average scene.
The lack of environment/reflections makes materials hard to read, and makes it so some materials, particularly metals and materials involving transparency, are not adequately represented. This essentially makes it so users are unable to rely on this preview, and are forced to make their own preview scene in order to get a representative preview, which entirely negates the purpose of the preview window.

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

Visualize materials in a basic scene with a cubemap and a grid floor to accentuate reflective details.

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

Current Proposal
Image Image
Image Image

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?

Material preview is core.

@passivestar
Copy link

grid floor could use a procedural texture #5294 🙂

@Calinou
Copy link
Member

Calinou commented Nov 29, 2024

For generated images, we could either use a ReflectionProbe with the Always update mode (so it renders in a single frame), or use a PanoramaSkyMaterial that provides the reflection (even if we still have a grid floor below the object). The latter would require increasing the editor binary size somewhat to include the sky texture1, but it would speed up preview rendering by not needing to perform another render of the scene for the ReflectionProbe.

For the real-time preview, we can keep the ReflectionProbe at its default Once update mode or use the prerendered sky as mentioned above.

Footnotes

  1. I expect a 1024×512 OpenEXR image with lossless compression to give good results here, maybe even 512×256 given the preview is quite small.

@Calinou Calinou changed the title Improve material preview Improve material preview in the inspector Nov 29, 2024
@lander-vr
Copy link
Author

lander-vr commented Nov 29, 2024

I'm a fan of using a cubemap for this, this would allow not just having a gradient, but including clouds/environment in the cubemap which would add more variation and details in reflections. (Similar to Unreals preview environments)
Example using an HDRI from Polyhaven1:
Image

The slightly overexposed look here may not seem ideal initially, but the value of this material was set to 100, which is extremely bright and doesn't exist in the real world, so this preview setup actually communicates that brightness quite well.

Which environment texture is being referenced in the preview could be exposed as a project setting, so the user could choose a custom one which would align better with the visual direction/lighting of their project.

Are previews in other places, such as the 3D importer, visual shader graph in 4.4, MeshInstances, ..., rendered with the same logic as the material preview? I think all 3D previews would benefit from this setup, so if this preview logic is already something that's unified, I don't think this is a change that should be separated from those other places.
To add to that, I'm not sure of how these previews are made internally, but if these would be scenes with an environment node inside I think it would make sense to allow access to that environments post processing and compositor effects to give the user flexibility, e.g. for stylized projects using global effects.
A default (toggleable) camera attributes could also deal with auto-exposure for high contrast effects (e.g. emmissive stuff), which, combined with having glow enabled, is good for communicating that contrast, as well as adjusting exposure depending on the HDRI. As well as for example previewing values extending above 1 in the visual shader graph.

Footnotes

  1. https://polyhaven.com/a/buikslotermeerplein

@ydeltastar
Copy link

I think it would make sense to allow access to that environments post processing and compositor effects to give the user flexibility, e.g. for stylized projects using global effects.

It would be an editor setting so the environment can't depend on project-specific files. We should be able to set a path to an HDRI outside the project and be applied on every instance of the editor, for example.
Resources don't work in this case and we would have to provide every setting manually. Better add only the most relevant settings like HDRI path, sky rotation, sky energy, and glow.

@Calinou
Copy link
Member

Calinou commented Nov 30, 2024

It would be an editor setting so the environment can't depend on project-specific files. We should be able to set a path to an HDRI outside the project and be applied on every instance of the editor, for example.

I would say it has to be a project setting, so that all team members see the preview the same way.

Different projects may also warrant a different look for their previews (e.g. a project taking place exclusively at nighttime warrants darker lighting for its previews).

The Default Environment project setting is already an example of a resource that is defined in the project settings and can reference other files.

@IsaacMarovitz
Copy link

Would be nice as well to be able to toggle through multiple preview meshes (sphere, cube, plane, etc) like Unity and Blender allow you to do.

@lander-vr
Copy link
Author

Would be nice as well to be able to toggle through multiple preview meshes (sphere, cube, plane, etc) like Unity and Blender allow you to do.

Currently this is already possible (Though there's only a sphere and cube), however there's a lot of value in providing more options since certain shaders can require different preview needs than what a cube or sphere can offer. Particularly a more complex mesh with a variety of sharp and soft edges (Which could be something fun like a 3D version of the Godot logo, or something the the logo embedded into it) would be useful. There would also be value in allowing custom meshes to be used.

@tetrapod00
Copy link

Though there's only a sphere and cube

There is a quad now too :) godotengine/godot#97030

Particularly a more complex mesh with a variety of sharp and soft edges (Which could be something fun like a 3D version of the Godot logo, or something the the logo embedded into it)

I thought the exact same thing, after a quad mesh preview was added I thought to myself that this is the only major thing missing (after four preview meshes, we should probably add a custom mesh preview instead of adding more and more specific meshes).

@ydeltastar
Copy link

Metallic materials are impossible to preview currently and I started using them a lot so I did a pass at implementing this proposal on my custom build.

Before

Image

After

An Environment path can be configured in rendering/environment/defaults/material_preview_environment.

Image

I'm not sure what to do about the floor.
Since we can rotate the preview, the floor could get in the way. It can be toggleable. But then does it stay static or does it rotate too with the mesh?

@lander-vr
Copy link
Author

Since we can rotate the preview, the floor could get in the way. It can be toggleable. But then does it stay static or does it rotate too with the mesh?

As long as the floors backface gets culled, this shouldn't be a problem. I imagine expected behavior of moving the view would be orbiting your camera around the object, not just spinning the object. This allows you to see how the object interacts with different parts of the HDRI reflecting onto it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants