Last active
January 2, 2022 13:49
-
-
Save cecilemuller/47d3cf126c4377df119a221abf1b8b64 to your computer and use it in GitHub Desktop.
Marmoset Toolbag 4: Albedo Transition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "../state.frag" | |
#include "../other/customExtras.sh" | |
#define MARGIN 0.05 | |
#define RANGE 1.05 | |
uniform float uStartTime; // name "Start time (in seconds)" min 0 max 60 default 0 | |
uniform float uDurationTime; // name "Duration (in seconds)" min 0 max 60 default 10 | |
USE_TEXTURE2D(tTransitionMap); // name "Transition" | |
USE_TEXTURE2D(tAlbedoMap2); // name "Albedo" | |
float getLerpFactor(in FragmentState s) { | |
float blendFraction = textureMaterial(tTransitionMap, s.vertexTexCoord).r; | |
float timeFraction = max(0, (uCustomAnimationTime - uStartTime)) / uDurationTime; | |
float minValue = (timeFraction * RANGE) - MARGIN; | |
return clamp((blendFraction - minValue) / MARGIN, 0.0, 1.0); | |
} | |
void CustomAlbedo(inout FragmentState s) { | |
vec4 color1 = textureMaterial(tAlbedoMap, s.vertexTexCoord); | |
color1 = uAlbedoMapGrayscale ? color1.rrra : color1; | |
color1.xyz *= uAlbedoMapColor; | |
vec4 color2 = textureMaterial(tAlbedoMap2, s.vertexTexCoord); | |
color2 = uAlbedoMapGrayscale ? color2.rrra : color2; | |
color2.xyz *= uAlbedoMapColor; | |
vec4 result = lerp(color2, color1, getLerpFactor(s)); | |
s.albedo = result; | |
s.baseColor = result.xyz; | |
} | |
#ifdef Albedo | |
#undef Albedo | |
#endif | |
#define Albedo CustomAlbedo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment