Skip to content

Add vertex color support to dissolve module #88

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

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
_DissolveCutoff("Cutoff", Range(0,1)) = 0.04
_DissolveCutoffRangeMin("Cutoff Range Min %CombineWith(_DissolveCutoffRangeMax)", Float) = -0.1
[HideInInspector]_DissolveCutoffRangeMax("Max", Float) = 1.1
[Enum(Local Position, 0, UV, 1, Texture, 2)]_DissolveSource("Fade Based On", Int) = 0
[Enum(Local Position, 0, UV, 1, Texture, 2, Vertex Colors, 3)]_DissolveSource("Fade Based On", Int) = 0
_DissolveTexture("Fade Texture %ShowIf(_DissolveSource == 2)", 2D) = "grayscaleRamp" {}
UI_DissolveTextureNote("> This texture will be used as a base of fade progression. Generally expected to be some kind of gradient, sometimes multiplied by a pattern %ShowIf(_DissolveSource == 2)", Int) = 0
[Enum(X, 0, Y, 1, Z, 2, Negative X, 3, Negative Y, 4, Negative Z, 5)]_DissolveDirection("Fade Direction", Int) = 1
Expand Down Expand Up @@ -85,6 +85,12 @@
gradSource = SAMPLE_TEXTURE2D(_DissolveTexture, sampler_DissolveTexture, uv)[(_DissolveDirection % totalChannels)] * (_DissolveDirection > 2 ? -1 : 1);
break;
}
case 3: {
half isReverse = _DissolveDirection > 2 ? 0 : 1;
gradSource = d.vertexColor[(_DissolveDirection % totalChannels)];
gradSource = ((1 - gradSource) * (1 - isReverse)) + (gradSource * isReverse);
break;
}
}
half grad = lerp(1 - (gradSource + 0.5), gradSource, saturate(_DissolveSource));
#if DISSOLVE_SHOW_FADE_GRAD
Expand Down