godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.13k stars 92 forks source link

Improve scene thumbnails #7232

Open JoNax97 opened 1 year ago

JoNax97 commented 1 year ago

Describe the project you are working on

Evaluating Godot for a content-heavy 3D project. (This proposal will focus entirely on 3D as I don't have much experience with the 2D side of the editor)

Describe the problem or limitation you are having in your project

This is an alternative take to the issue described in #4759. Many of the details of this proposal are taken from the discussion there.

Right now, the editor uses the current camera position in the viewport to generate thumbnails. This is user-dependent and non-deterministic, which heavily limits the usefulness of the generated thumbnails.

There's no universal solution that would automatically generate good thumbnails for every scene. However, the problem can be scoped to work with "single object" scenes. In a project, most scenes will often be small, like a piece of furniture, a power-up, a character, etc that can easily be previewed automatically.

I think users should not need to always configure thumbnails manually. For a large scene it may be needed, but small scenes should pretty much always give good thumbnails automatically.

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

I'd approach the issue in 3 stages:

The first stage would be to have a default camera placement that is consistent and works for most cases. A sensible option is to have a 3/4, low FOV camera that frames the whole scene, like in these examples taken from Unity and the Sims: image image

The second stage would be a simple tool to override the camera for a given scene, with the current location of the editor camera. This would mostly solve the problem for big scenes (mostly levels) where a full, zoomed out view would not be very useful, and a shot of a landmark within the scene would work better.

Then a third stage would be more advanced options to customise either the default settings or the override for a given scene. Options like default angle, FOV, background color, etc.

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

Minimum features:

Nice-to-have features:

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

This will be used often, every 3D project would benefit from this.

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

Editor thumbnails are a core feature.

josefalanga commented 1 year ago

I love the idea. Having a deterministic way of generating thumbnails would be very cool.

Indeed, as the linked proposal mentions, It's very hard to generate a solution that fits every case, but giving some control on how to tweak settings should work for most cases.

It would be cool to have a little preview of the thumbnail, to tinker with the settings you mention, like FOV and distance. Something like Photoshop's Navigator feature. Here is a video demoing on how it works. It can be hidden by default, and shown only if you need/want a preview or adjust the thumbnail settings. It has the side effect for 2D scenes and UI to be able to evaluate the composition and hierarchy of your scene without having to zoom out, like having a minimap. It's useful beyond thumbnail generating.

In general I like this proposal more than the linked one because feels a little less hacky/manual than having a dedicated node to place in the scene if you wanted the benefits. IMO, something automated than can be tweaked is better UX.

This proposal skips discussing a solution for 2D/UI scenes, but probably can be extended there too.

SeanRamey commented 1 year ago

For 2D I think this will work pretty well if you just have the "default thumbnail camera" be centered on coordinates (0,0). I definitely think this proposal is much better than the alternative proposal. The largest reason I want something to fix this is because the Scene Collections in the 2D TileSet are absolutely horrible. You can't just look for a picture of what you want, you need to scroll through a big list (and that's another problem, can't change the layout of the list to not show thumbnails, or view in a grid) and actually read all the names to find what you want.

eddieataberk commented 10 months ago

Have you found any solution or workaround for it?

JoNax97 commented 10 months ago

Have you found any solution or workaround for it?

I haven't found the time to work on this, sadly

Wokarol commented 10 months ago

For 2D I think this will work pretty well if you just have the "default thumbnail camera" be centered on coordinates (0,0)

@SeanRamey, I think the AABB approach, like with the 3D scenes would work better than a centered camera. That way, the camera should always capture the whole scene no matter the origin placement

Bat-Computer commented 9 months ago

I worry that due to some users wanting extra features I've seen recently instead instead of just showing thumbnail previews of models, that it will put off devs attempting to add this feature due to time constraints.

Looking at Unreal and Unity in these screenshots, the whole model is taken into account no matter how large it is. It is in perspective and not orthographic, which to me looks better. Unreal has a grid floor, where Unity does not. Both engines take a three-quarter shot of the model (aprroximately). Additonally each engine has a basic directional light with shadow.

Unreal Engine Screenshot 2024-01-01 173158

Unity Screenshot 2024-01-01 175015

In Godot 4.2.1 We already have the 'Advanced Import Settings' window, which does the majority of what is required. The main difference is that it uses an orthographic view instead of perspective one. Screenshot 2024-01-01 175936

Rather writting complete new code, could this be adapted in some way and a screenshot be taken from this?

In my proposal 'Display scene resource thumbnails in the FileSystem dock' (https://github.com/godotengine/godot-proposals/issues/8760) I suggested that it might be useful to keep the FileSystem dock as is, but have another tab added to the foot of the UI window similar to Unreal Engines Content drawer. Would there be any drawbacks to this for usability? 293510599-7095a6c8-bda1-4304-8a19-b691a20e21a7

Calinou commented 9 months ago

I suggested that it might be useful to keep the FileSystem dock as is, but have another tab added to the foot of the UI window similar to Unreal Engines Content drawer. Would there be any drawbacks to this for usability?

This is off-topic for this particular proposal. Please continue the discussion in https://github.com/godotengine/godot-proposals/issues/1508 :slightly_smiling_face:

4d49 commented 7 months ago

I made an addon that performs similar functionality as a separate dock.

Nodragem commented 5 months ago

I have been using the Gridmap node and it seems that it already creates thumbnail for 3d objects, in a pretty useful way. Could we reuse the code of the Gridmap thumbnail generator?

smix8 commented 1 month ago

The GridMap does not directly create these thumbnails. This is done as part of the MeshLibary Resource and its export plugin and MeshLibraryEditor::_import_scene() function. It is limited to a single Mesh Resource per thumbnail so it can not render an entire complex scene.

For more generic Resources the previews are created in the editor/plugins/editor_preview_plugins.cpp. The PackedScene has handling there but no generator code, it just adds an empty Texture.

Nodragem commented 1 month ago

I think we can start simple, and "copy/paste" the method used in MeshLibrary in editor/plugins/editor_preview_plugins.cpp. Then we try to improve it from there? I might have a go, although I have no idea what I am doing 😄

I also need to check if there is an issue already opened for GLB/FBX files preview.

smix8 commented 1 month ago

Scenes thumbnails are currently generated when the scene is opened and saved. That is why you have thumbnail if you already did that once while else you just have an empty texture. It is also why the thumbnail has all the editor gizmos included as it just takes a screenshot of the editor camera the moment the scene is saved.

The code that I mentioned is for actual Resource preview handler that works independent from opening or saving a scene. It tries to find a thumbnail from cache or generates a new preview as soon as the Resource needs to be displayed somewhere, e.g. filesystem, inspector export variable or somewhere else.

The issue is instancing entire PackedScene files for rendering a thumbnail is non-trivial compared to just simple static resources. When we only take screenshots from already loaded and working scenes that is a kind of firewall against these problems else the user wouldn't be able to even open that scene.

Scene files can include a lot, including scripts and other stuff that gets fired that can mess with the engine stability. Doing scene thumbnail rendering in a controlled environment for your project is one thing as many addons demonstrate. The core engine needs to assume always the worst data input. Adding it just for the most naive cases will do no good. The preview generator is already one of the top bug and crash sources in Godot because it was build in a very hacky way, e.g. it has regularly issues with threading, let's not repeat such mistakes.

The preview generator is due for a rework as it has been a thorn in the editor's side for a while. I remember just for Godot version 4.3 it was the culprit for multiple random user crash reports. The instability of the preview generator has been known for a while, there are even old code comments like this

Wow it generated a preview...

... as the devs likely couldn't believe that the code even worked ;)

That said I don't want to discourage anyone from taking a shot on solving this, it may take a while until core devs find time for this, just be aware that this is not as simple for the core engine as just writing a thumbnail render addon for your own project.

Nodragem commented 1 month ago

I see, thank you for explaining!

In terms of adding preview for GLB/GLTF/FBX files, there should be less issues, as there is no scripts. This would already be a big step forward (but I guess we can discuss it in a different issue).

Concerning the scene previews, we could have a solution where the user can select multiple .tscn files, right-click and mark them as "preview as 3D asset". This will search for the Mesh resources used in the scene and their relative location, and preview them together. It would NOT open the scene, nor run its scripts. It would just open the meshes for the preview.

For .tscn, it can be done by just reading the text file. For .scn, not sure how it would work.

Following this idea, we could mark automatically a file as "preview as 3D asset" when the root node is a mesh. And have a "preview as 3D asset" tickbox in the Import dock and Advanced Import.

By preview generator, do you mean the code that takes a screenshot when we save a scene?

EDIT: we could show the icon of the root node in one corner of the preview. Could be useful.

smix8 commented 1 month ago

By preview generator, do you mean the code that takes a screenshot when we save a scene?

Godot has different preview generators to create thumbnails for a variety of things. Some create textures procedual like those for Audio or Curve files, some have their own Viewports and instance Resources in prebuild rendering scenes to take a screenshot. Some do even live rendering like the inspector preview for meshes.

Nodragem commented 1 month ago

Which one do you mean when you say "The preview generator is due for a rework"?

I am looking at the file editor\plugins\editor_preview_plugins.cpp and editor\editor_node.cpp at the moment.

For future reference (for myself and whoever wants to have a look !):