Giter VIP home page Giter VIP logo

godot-texture-painter's Introduction

Godot Texture Painter

This is a prototype for a PBR texture painter in Godot 3.0. It's meant to be mostly a proof-of-concept, to show that it's possible at all - but I might turn it into a full blown application one day (but no promises!).

Paint

The painting algorithm is GPU-accelerated, so you can paint on extremely large textures with huge brushes on very high poly models without lag.

You can paint albedo, roughness, metalness and emission. Also, you can right click to place decals, and use the slider on the top right to change the brush softness. Other controls are displayed on the GUI.

Here's a video of it in action.

Note: requires Godot 3.1.1 Mono edition. Older versions probably won't work.

How it works

The program works using two kinds of textures: mesh and paint textures. They are organized in the scene tree like this:

Tree

Mesh textures store information about triangle position and normal on a per-pixel basis, which is used as input for the paint shader to do GPU accelerated painting. This already reveals a fundamental limitation of the algorithm, though: since a texture can store only one value per pixel, a texel can only be at 1 point in space at the same time. As such, the algorithm only works for models that have non-overlapping UVs (so every texel appears exactly once on the model).

Paint textures store the actual texture you see on the model, and it is generated by mixing the output from the paint shader with the previous frame. There are 4 of them: albedo, roughness, metalness and emission. I might make a 5th one, for painting normals, although that will be a little more difficult to implement.

Limitations/Known Issues

  • You can only paint on models that have non-overlapping UVs.

godot-texture-painter's People

Contributors

bauxitedev avatar dependabot[bot] avatar karroffel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

godot-texture-painter's Issues

Implement zoom, panning and rotation (via mouse/graphics tablet)

Applications like Blender and Godot let the user zoom into the currently edited model as well as panning around to see different angles.

Many applications allow rotating around the view-point by using the middle mouse button. Right now, only WASD can be used to change rotation and there is no way to zoom or pan at all.

add subsurface texture painting

A new paint "channel" for subsurface scatter maps could be useful in many situations, it would be awesome if this supported painting of that.

Shader Android support

Hello,

I am currently porting your app to Android, and planing to make a PR if I succeed.
Unfortunate what seems to be blocking me are the shaders.

Using GLES3 works fine on desktop (Ubuntu 22.04), while it causes the Suzanne mesh to disappear on Android.
Strangely, I can see the texture being drawn on the albedo texture, so It's not an issue with loading the mesh.

Using GLES2 shown the mesh on both desktop and Android, but causes the texture painting to break because the shaders rely on textureSize, texelFetch and maybe some other logic which is GLES3 specific.

I've read the official docs for conversions between GLES2 and GLES3, but did not have much success.
https://docs.godotengine.org/en/stable/tutorials/rendering/gles2_gles3_differences.html
You can see a code snippet of my attempt to port the sahder to GLES2:

			//Skip pixels outside bounds (TODO ensure this actually makes it faster)
			// if (point.x < 0 || point.x >= textureSize(SCREEN_TEXTURE, 0).x || point.y < 0 || point.y >= textureSize(SCREEN_TEXTURE, 0).y)
			if (point.x < 0 || float(point.x) >= SCREEN_PIXEL_SIZE.x || point.y < 0 || float(point.y) >= SCREEN_PIXEL_SIZE.y)
				continue;
			
			//Okay, fixed it, must use SCREEN_TEXTURE instead of meshtex_pos here
			// vec4 pos_col = texelFetch(SCREEN_TEXTURE, point, 0);
			vec4 pos_col = texture(SCREEN_TEXTURE, UV);

Could you please provide me some hints on how to handle these shader issues?

Request: Material paint

Having an option to use a material as a brush (painting to it's defined channels) would be amazing

Godot freezes while starting the project

It's also lagging when starting the editor.

Godot version:
master (godotengine/godot@228b09b)

OS/device including version:
Antergos (Arch Linux)

Output:

Godot Engine v3.1.dev.custom_build (c) 2007-2018 Juan Linietsky, Ariel Manzur & Godot Contributors.
Switch Scene Tab
 drivers/gles3/rasterizer_storage_gles3.cpp:1093 - Condition ' p_width <= 0 || p_width > 16384 ' is true.
 Node not found: textures/mesh/position
 ViewportTexture: Path to node is invalid
 Node not found: textures/mesh/normal
 ViewportTexture: Path to node is invalid
Set hint_tooltip
Set hint_tooltip
Set hint_tooltip
Set hint_tooltip
 drivers/gles3/rasterizer_storage_gles3.cpp:888 - Condition ' !texture->active ' is true. returned: Ref<Image>()
 drivers/gles3/rasterizer_storage_gles3.cpp:888 - Condition ' !texture->active ' is true. returned: Ref<Image>()
 drivers/gles3/rasterizer_storage_gles3.cpp:888 - Condition ' !texture->active ' is true. returned: Ref<Image>()
 drivers/gles3/rasterizer_storage_gles3.cpp:888 - Condition ' !texture->active ' is true. returned: Ref<Image>()
 drivers/gles3/rasterizer_storage_gles3.cpp:888 - Condition ' !texture->active ' is true. returned: Ref<Image>()
...

undo/redo is missing

It would be cool if there was a way to go back to the last state before the brush was "set on the mesh" the last time.

Not sure how that can be done efficiently, I guess storing images to which the program can revert to would work just fine, it would just take quite some memory, but maybe there's another way.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.