Blit with shader?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Ronja

Is there a way of copying one texture into another one using a shader? The same way unitys Graphics.Blit allows you to pass in a material that takes in the source texture as a uniform parameter and its result is written to the target texture.

Alternatively is there a lowlevel graphics API I’m missing that allows me to set the render target and render meshes immediately so I can implement blit functionality myself?

I looked around in the examples and stumbled upon the postprocessing docs which told me to implement a multipass postprocessing effect via the scene hierarchy which seems like design hostile to the flexibility I’m looking for?

My direct usecase is that I’m looking to make a pixel art program where I have a rendertexture for each layer and I need custom shaders both for using tools/brushes on it as well as combining it with previously rendered layers and its child layers. In some cases those tools also need textures to remember a state while drawing and all of that drawing is highly order specific, something I don’t feel secure of when letting a viewport in the hieararchy render “whenever”.

I think you might want to [look into how it’s done in/ask the creator of] Material Maker: https://www.materialmaker.org/

It’s a PBR procedural material authoring tool built with Godot Engine (currently still version 3.x). It has tools to bake textures and do texture painting in the viewport with procedural shader-defined brushes. I think it should cover your needs.

There’s a Discord server where you can ask the author (Rodzilla) or just open the Godot project and look at it yourself - the software is MIT-licensed (same as Godot) so you could reuse parts of it even in commercial, proprietary projects.

unfa | 2023-04-05 09:18