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

Update multisplat16.shader #301

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

QbieShay
Copy link

@QbieShay QbieShay commented Feb 3, 2022

My own attempt at more organic blending for the multisplat plugin and preventing hard cuts when painting with low opacity

Copy link
Owner

@Zylann Zylann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs explanation because I have no clue how this works^^"

Also you updated that shader but it's not the only one using that technique (there is a fair amount of copypasta to make once this is finalized)

@@ -25,6 +25,9 @@ uniform bool u_depth_blending = true;
uniform float u_globalmap_blend_start;
uniform float u_globalmap_blend_distance;
uniform bool u_tile_reduction = false;
uniform float low_edge = 0.1;
uniform float smoothness = 0.2;
uniform float height_boost = 0.1;
Copy link
Owner

@Zylann Zylann Feb 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should respect naming convention, uniforms start with u_ (I wish I could use _ only but Godot reserves that).
Also I have no idea what these do just from the name. I see they all affect how textures are blended (when depth blending is on) but their name alone doesnt reflect that either.

float dh = 0.2;

float dh = height_boost;
bumps.r = 1.0 - pow(1.0 - bumps.r, 0.5);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Careful with pow, it's a transcendental math function, it's expensive. Here you raise to power 0.5, which is actually square root, so maybe use sqrt instead?
Not sure what this formula does


float dh = height_boost;
bumps.r = 1.0 - pow(1.0 - bumps.r, 0.5);
bumps.g = pow(bumps.g, 2.0);
Copy link
Owner

@Zylann Zylann Feb 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pow again, prefer squaring by multiplying by itself. Are GLSL compilers smart enough to replace the call with that? Still no idea why you do this though, it's like some textures are more important than others or something

@Calinou
Copy link
Contributor

Calinou commented Feb 3, 2022

Could you add comparison screenshots between the old and new shader?

@QbieShay
Copy link
Author

QbieShay commented Feb 4, 2022

The pow in the function is to alleviate issues when there are more than 4 textures blending at the same time. If you paint with low opacity brushes with more than 4 textures you'll see abrupt cuts starting to show.

I can't show the assets i tested with but I can show in a clean project later.

As for the names, i have no idea either exactly what they do :D that's why they are not very descriptive. I'm open to any name you will propose ^^

@TokisanGames
Copy link
Contributor

When I have 5+ textures in one area, I often get lines like the dashed line across textures as you can see on the rock faces on the right and left (not the rock cracks). By pushing around the textures more I can eventually brush these out.

image

I inserted the changes to bump into my get_depth_blended_weights() function, however none of them, nor any other parameter in that function affected those line artifacts. They did change other blended edges, but I have no issue with the default blend.

Regarding the functions:

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

Successfully merging this pull request may close these issues.

None yet

4 participants