Skip to content

Commit

Permalink
Outline Shader Drifting
Browse files Browse the repository at this point in the history
  • Loading branch information
GMatrixGames committed May 29, 2024
1 parent eb3f302 commit 631530d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
15 changes: 8 additions & 7 deletions FModel/Resources/outline.vert
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,18 @@ vec2 unpackBoneIDsAndWeights(int packedData)
return vec2(float((packedData >> 16) & 0xFFFF), float(packedData & 0xFFFF));
}

vec4 calculateScale(vec4 bindPos, vec4 bindNormal)
{
vec4 worldPos = vInstanceMatrix * bindPos;
float scaleFactor = length(uViewPos - worldPos.xyz) * 0.0035;
return transpose(inverse(vInstanceMatrix)) * bindNormal * scaleFactor;
}

void main()
{
vec4 bindPos = vec4(mix(vPos, vMorphTargetPos, uMorphTime), 1.0);
vec4 bindNormal = vec4(vNormal, 1.0);
bindPos.xyz += calculateScale(bindPos, bindNormal).xyz;

vec4 finalPos = vec4(0.0);
vec4 finalNormal = vec4(0.0);
Expand All @@ -53,19 +61,12 @@ void main()
finalNormal += transpose(inverse(boneMatrix)) * bindNormal * weight;
}
}
finalPos = normalize(finalPos);
finalNormal = normalize(finalNormal);
}
else
{
finalPos = bindPos;
finalNormal = bindNormal;
}

vec4 worldPos = vInstanceMatrix * finalPos;
float scaleFactor = length(uViewPos - worldPos.xyz) * 0.0035;
vec4 nor = transpose(inverse(vInstanceMatrix)) * finalNormal * scaleFactor;
finalPos.xyz += nor.xyz;

gl_Position = uProjection * uView * vInstanceMatrix * finalPos;
}
2 changes: 1 addition & 1 deletion FModel/Views/Snooper/Shading/Material.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void Setup(Options options, int uvCount)
}

{ // ambient occlusion + color boost
if (Parameters.TryGetTexture2d(out var original, "M", "AEM", "AO", "Mask") &&
if (Parameters.TryGetTexture2d(out var original, "M", "AEM", "AO") &&
!original.Name.Equals("T_BlackMask") && options.TryGetTexture(original, false, out var transformed))
{
HasAo = true;
Expand Down
1 change: 1 addition & 0 deletions FModel/Views/Snooper/Shading/TextureHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public static void FixChannels(string game, Texture texture)
case "COSMICSHAKE":
case "PHOENIX":
case "ATOMICHEART":
case "MULTIVERSUS":
{
texture.SwizzleMask =
[
Expand Down

0 comments on commit 631530d

Please sign in to comment.