mirror of
https://github.com/KillzXGaming/Switch-Toolbox
synced 2025-02-16 13:58:26 +00:00
Improve gfbmdl UV transformation for diffuse textures
This commit is contained in:
parent
43d0a498b5
commit
e5f0745818
4 changed files with 25 additions and 10 deletions
|
@ -549,6 +549,10 @@ namespace FirstPlugin
|
|||
param.Value.Value = 1;
|
||||
if (param.Key.Contains("UVTranslate"))
|
||||
param.Value.Value = 0;
|
||||
if (param.Key.Contains("ColorBaseU"))
|
||||
param.Value.Value = 0;
|
||||
if (param.Key.Contains("ColorBaseV"))
|
||||
param.Value.Value = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -385,9 +385,14 @@ namespace FirstPlugin
|
|||
ScaleY = ValueParams["ColorUVScaleV"].Value;
|
||||
|
||||
if (ValueParams.ContainsKey("ColorUVTranslateU"))
|
||||
TransX = ValueParams["ColorUVTranslateU"].Value;
|
||||
TransX += ValueParams["ColorUVTranslateU"].Value;
|
||||
if (ValueParams.ContainsKey("ColorUVTranslateV"))
|
||||
TransY = ValueParams["ColorUVTranslateV"].Value;
|
||||
TransY += ValueParams["ColorUVTranslateV"].Value;
|
||||
|
||||
if (ValueParams.ContainsKey("ColorBaseU"))
|
||||
TransX += ValueParams["ColorBaseU"].Value;
|
||||
if (ValueParams.ContainsKey("ColorBaseV"))
|
||||
TransY += ValueParams["ColorBaseV"].Value;
|
||||
}
|
||||
if (matTexture.Type == STGenericMatTexture.TextureType.Normal)
|
||||
{
|
||||
|
|
|
@ -242,6 +242,8 @@ namespace FirstPlugin
|
|||
SetUniformData(mat, shader, "ColorUVScaleV");
|
||||
SetUniformData(mat, shader, "ColorUVTranslateU");
|
||||
SetUniformData(mat, shader, "ColorUVTranslateV");
|
||||
SetUniformData(mat, shader, "ColorBaseU");
|
||||
SetUniformData(mat, shader, "ColorBaseV");
|
||||
}
|
||||
|
||||
private static void SetUniformData(GFLXMaterialData mat, ShaderProgram shader, string propertyName)
|
||||
|
|
|
@ -67,6 +67,8 @@ uniform float ColorUVScaleU;
|
|||
uniform float ColorUVScaleV;
|
||||
uniform float ColorUVTranslateU;
|
||||
uniform float ColorUVTranslateV;
|
||||
uniform float ColorBaseU;
|
||||
uniform float ColorBaseV;
|
||||
|
||||
uniform float NormalMapUVScaleU;
|
||||
uniform float NormalMapUVScaleV;
|
||||
|
@ -137,11 +139,12 @@ void main()
|
|||
vec3 albedo = vec3(1);
|
||||
if (HasDiffuse == 1)
|
||||
{
|
||||
vec2 colorUV = f_texcoord0;
|
||||
colorUV.x *= ColorUVScaleU + ColorUVTranslateU;
|
||||
colorUV.y *= ColorUVScaleV + ColorUVTranslateV;
|
||||
vec2 uvScale = vec2(ColorUVScaleU, ColorUVScaleV);
|
||||
vec2 uvTranslate = vec2(ColorUVTranslateU, ColorUVTranslateV);
|
||||
vec2 shift = vec2(ColorBaseU, ColorBaseV);
|
||||
vec2 texCoord0 = shift + uvScale * (f_texcoord0.xy + (uvTranslate));
|
||||
|
||||
vec4 DiffuseTex = pow(texture(DiffuseMap, colorUV).rgba, vec4(gamma));
|
||||
vec4 DiffuseTex = pow(texture(DiffuseMap, texCoord0).rgba, vec4(gamma));
|
||||
|
||||
//Comp Selectors
|
||||
albedo.r = GetComponent(RedChannel, DiffuseTex);
|
||||
|
@ -271,12 +274,13 @@ void main()
|
|||
}
|
||||
else if (renderType == 3) //DiffuseColor
|
||||
{
|
||||
vec2 colorUV = displayTexCoord;
|
||||
colorUV.x *= ColorUVScaleU + ColorUVTranslateU;
|
||||
colorUV.y *= ColorUVScaleV + ColorUVTranslateV;
|
||||
vec2 uvScale = vec2(ColorUVScaleU, ColorUVScaleV);
|
||||
vec2 uvTranslate = vec2(ColorUVTranslateU, ColorUVTranslateV);
|
||||
vec2 shift = vec2(ColorBaseU, ColorBaseV);
|
||||
vec2 texCoord0 = shift + uvScale * (displayTexCoord.xy + (uvTranslate));
|
||||
|
||||
//Comp Selectors
|
||||
vec4 diffuseMapColor = vec4(texture(DiffuseMap, colorUV).rgb, 1);
|
||||
vec4 diffuseMapColor = vec4(texture(DiffuseMap, texCoord0).rgb, 1);
|
||||
diffuseMapColor.r = GetComponent(RedChannel, diffuseMapColor);
|
||||
diffuseMapColor.g = GetComponent(GreenChannel, diffuseMapColor);
|
||||
diffuseMapColor.b = GetComponent(BlueChannel, diffuseMapColor);
|
||||
|
|
Loading…
Add table
Reference in a new issue