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

Automate channel packing for faster texture authoring #473

Open
Radivarig opened this issue Aug 31, 2024 · 5 comments
Open

Automate channel packing for faster texture authoring #473

Radivarig opened this issue Aug 31, 2024 · 5 comments
Labels
enhancement New feature or request idea Just an idea, may or may not be implemented low priority Low Priority
Milestone

Comments

@Radivarig
Copy link

Description

Texture authoring is a bit slow as channel packing is required in Terrain3D (unless using only albedo/normal rgb) so my suggestion is to automate it.

Ideally for each Texture in the edit inspector there would be inputs for separate albedo/height/normal/roughness and all of the Texture Packer tab checkboxes, then the rest would be handled in the background.

Another way of automating it could be to convert the Channel Packer tab content into a list, one item for each Texture that would be setup once and persist the values, then have the option to auto update when the textures change and the output textures would be assigned to Terrain3D Texture inputs (or elsewhere in custom shaders with the same expected packing).

Third could be a tool that would call the Channel Packer API:

@tool
extends Resource
class_name AutoChannelPacker

# detect changes and re-export when either of the texture files update
@export var auto_export_on_changes: bool
# auto set properties needed for terrain3d based on the extension
@export var auto_set_terrain3d_properties: bool

@export_group("Albedo & Height")
@export var albedo_texture: Texture2D
@export var height_texture: Texture2D
@export_enum("r", "g", "b", "a") var height_channel = "r"
# {filename} would be replaced with albedo_texture file name
@export var albedo_height_output: String = "{filename}_albedo_height"
# the rest of the options

@export_group("Normal & Roughness")
@export var normal_texture: Texture2D
@export var roughness_texture: Texture2D
@export_enum("r", "g", "b", "a") var roughness_channel = "r"
# {filename} would be replaced with normal_texture file name
@export var normal_roughness_output: String = "{filename}_normal_roughness"
# the rest of the options

# on file change
func merge_channel_into_alpha():
	# call channel packer api
	pass
@TokisanGames
Copy link
Owner

I assume you've already seen #471. Some of these comments could have been made there.

Texture authoring is a bit slow as channel packing is required in Terrain3D

What part of the process is slow? Drag 4 textures in or select them, check the boxes, click the pack button, save the two files one after the other. All of those need to happen per texture set.

Ideally for each Texture in the edit inspector there would be inputs for separate albedo/height/normal/roughness and all of the Texture Packer tab checkboxes, then the rest would be handled in the background.

All of these inputs are there, then processing occurs when the pack button is pressed and the files are named and saved. I'm not sure what you don't like. Do you not want the file dialogs mid process and want output file path selectable on the first screen?

Another way of automating it could be to convert the Channel Packer tab content into a list, one item for each Texture that would be setup once and persist the values

If you're describing a UI layout, a picture would help. If not I don't understand. Keeping values across opening the packer window is the only thing I understand so far. If we do that, we also need a clear all button.

then have the option to auto update when the textures change

When the user selects different texture files to pack next, what specifically will be auto updated?

and the output textures would be assigned to Terrain3D Texture inputs

You mean upon saving the packed files, you want them to be inserted into the asset dock as a TextureAsset? hmmm for someone who knows what they're doing, yes. For a new person, this will break their terrain as they mix and match sizes and formats. It's better to not break it as a secondary result from saving a file. Better to break it as a primary result from dragging the texture file into the dock, or normal slot.

I'm sorry, I do not understand your requests, except persistent values in the packer. Please try and clarify your points.

cc: @Xtarsia

@Radivarig
Copy link
Author

I've seen #471, good stuff.
I started this as a comment there and concluded that it's more of a reuse of the Channel Packer rather than the improvement of its functionality and possibly changes needed elsewhere so I wanted to discuss it separately without interfering with the PR.

In short I would like to automate channel packing after the first setup when the textures change.

The ideal case:
Let's say there is only rgb, the process of assigning the albedo/normal is dragging them once into the Texture set edit section and that's it. When the textures are updated externally and Godot reimports them I can see the changes right after, having done zero additional steps. This is the desired workflow which I'd like to have with all of the separate textures.

The slow part:
The above is currently not the case with composite textures where 3 + 1 channels form rgba and need to be re-packed on every change, and this is what I would like to get automated. It is hard to update rgba in external software because alpha makes the texture transparent. What works better for authoring is to separate the drawing of only the rgb albedo and separately height. The same goes for normals with roughness.

Clarification:

  1. First case is about allowing Terrain3D > Texture set: Edit inspector to take in additional height and roughness and auto pack in the background
    • I guess this can be ignored for now
  2. Second case is about rendering the current content of the Channel Picker tab multiple times in a list while persisting the values, having +/- buttons and adding the auto pack option
    • basically the same as 3. case below but with a different UI
  3. Third case is the editor tool currently most approachable to me so I started buthering that

For case 3. I've further divided it into channel_packer_options and channel_packers_handler which would:
- hold a list of channel packer options
- handle the texture change detection
- call the existing Channel Packer through code

This would then produce the packed textures that the users would manually assign into Terrain3D > Texture set: Edit inspector, and would then auto update on changes.

Hope this portrays it better now.

image

@Xtarsia
Copy link
Contributor

Xtarsia commented Sep 1, 2024

A different solution to this would be to hook up a check_flat_alpha type function to signals sent from set_albedo and set_normal.
(Would have to connect/disconnect said signals when_edit() is called in editor.gd i think)

So in the editor, whenever albedo or normal are set, a check occurs to determine if the textures are packed, and if not we can invoke a popup with a message such as "Texture Alpha Channel is white, do you want to open the channel packer?" and proceed from there. (load the image into the packer, set resize resolution & import setings, have it auto load the new image into the TextureAsset etc)

Definitley seperate PR for that tho.

@Radivarig
Copy link
Author

That would help with the 1. case, to bring the packer to attention of new users, but the main point is the continuous auto repacking.

For example after Texture set packed_albedo_height is assigned and I update either the original albedo or the original height texture, I don't want to need to repack it, I want it to repack itself automatically.

The trigger for it is detecting when Godot reimports a texture, and the data for packing is the content of the Channel Packer tab.

Anyways, apologies for being unable to explain it better. I'm working on implementing the 3. case which will demonstrate a solution.

@TokisanGames
Copy link
Owner

The only use case I see for this is if someone is a texture artist working in something like substance designer (which can already saved packed textures) and are continuously modifying and saving their textures and want to see it on the terrain. I assume this is you, Op. Most users are downloading a texture, setting it up once, then not touching the files again.

I'd accept a PR on this if it is laid out in a way that is very clearly and understandable what it's for. I don't want to merge or maintain code that one person is going to use. Given the rare need, my personal efforts are better spent on the many priorities most people need.

This prototype screenshot conveys the functionality, but it takes some thinking to figure out what is going on. Instead, how it should probably work is an alternate screen in the current packer, where tracked textures can be registered and modified. Ultimately, I want to have a single tools panel where all tools are integrated together. #81, and this would be two of those screens.

@TokisanGames TokisanGames added enhancement New feature or request low priority Low Priority labels Sep 4, 2024
@TokisanGames TokisanGames added this to the Future milestone Sep 4, 2024
@TokisanGames TokisanGames moved this to Future Ideas in Terrain3D Roadmap Sep 4, 2024
@TokisanGames TokisanGames added the idea Just an idea, may or may not be implemented label Dec 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request idea Just an idea, may or may not be implemented low priority Low Priority
Projects
Status: Future Ideas
Development

No branches or pull requests

3 participants