Skip to content

Commit

Permalink
Fixed stupid bug in 3d texture projection for Dat models and added a …
Browse files Browse the repository at this point in the history
…test covering this.
  • Loading branch information
MeltyPlayer committed Oct 28, 2023
1 parent 6f28f85 commit e7440a2
Show file tree
Hide file tree
Showing 273 changed files with 2,392 additions and 218 deletions.
10 changes: 9 additions & 1 deletion FinModelUtility/Fin/Fin/src/shaders/glsl/GlslUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,14 @@ struct Texture {
mat2x3 transform2d;
mat4 transform3d;
};
vec2 transformUv3d(mat4 transform3d, vec2 inUv) {
vec4 rawTransformedUv = (transform3d * vec4(inUv, 0, 1));
// We need to manually divide by w for perspective correction!
return rawTransformedUv.xy / rawTransformedUv.w;
}
""";
}

Expand All @@ -187,7 +195,7 @@ public static string ReadColorFromTexture(
if (!(finTexture?.IsTransform3d ?? false)) {
transformedUv = $"({textureName}.transform2d * {rawUvName}).xy";
} else {
transformedUv = $"({textureName}.transform3d * vec4({rawUvName}, 0, 1)).xy";
transformedUv = $"transformUv3d({textureName}.transform3d, {rawUvName})";
}
return
$"texture({textureName}.sampler, " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ struct Texture {
mat2x3 transform2d;
mat4 transform3d;
};

vec2 transformUv3d(mat4 transform3d, vec2 inUv) {
vec4 rawTransformedUv = (transform3d * vec4(inUv, 0, 1));

// We need to manually divide by w for perspective correction!
return rawTransformedUv.xy / rawTransformedUv.w;
}

uniform Texture texture0;

in vec3 vertexNormal;
Expand All @@ -44,7 +52,7 @@ void main() {
individualLightColors[i] = lightColor;
}

vec3 colorComponent = texture(texture0.sampler, clamp((texture0.transform3d * vec4(uv0, 0, 1)).xy, texture0.clampMin, texture0.clampMax)).rgb*(vec3(0.501960813999176) + individualLightColors[0].rgb*vec3(0.7019608020782471,0.7019608020782471,0.501960813999176));
vec3 colorComponent = texture(texture0.sampler, clamp(transformUv3d(texture0.transform3d, uv0), texture0.clampMin, texture0.clampMax)).rgb*(vec3(0.501960813999176) + individualLightColors[0].rgb*vec3(0.7019608020782471,0.7019608020782471,0.501960813999176));

float alphaComponent = 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ struct Texture {
mat2x3 transform2d;
mat4 transform3d;
};

vec2 transformUv3d(mat4 transform3d, vec2 inUv) {
vec4 rawTransformedUv = (transform3d * vec4(inUv, 0, 1));

// We need to manually divide by w for perspective correction!
return rawTransformedUv.xy / rawTransformedUv.w;
}

uniform Texture texture0;

in vec3 vertexNormal;
Expand All @@ -44,7 +52,7 @@ void main() {
individualLightColors[i] = lightColor;
}

vec3 colorComponent = texture(texture0.sampler, clamp((texture0.transform3d * vec4(uv0, 0, 1)).xy, texture0.clampMin, texture0.clampMax)).rgb*(vec3(0.501960813999176) + individualLightColors[0].rgb*vec3(0.7019608020782471,0.7019608020782471,0.501960813999176));
vec3 colorComponent = texture(texture0.sampler, clamp(transformUv3d(texture0.transform3d, uv0), texture0.clampMin, texture0.clampMax)).rgb*(vec3(0.501960813999176) + individualLightColors[0].rgb*vec3(0.7019608020782471,0.7019608020782471,0.501960813999176));

float alphaComponent = 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ struct Texture {
mat2x3 transform2d;
mat4 transform3d;
};

vec2 transformUv3d(mat4 transform3d, vec2 inUv) {
vec4 rawTransformedUv = (transform3d * vec4(inUv, 0, 1));

// We need to manually divide by w for perspective correction!
return rawTransformedUv.xy / rawTransformedUv.w;
}

uniform Texture texture0;

in vec3 vertexNormal;
Expand All @@ -44,7 +52,7 @@ void main() {
individualLightColors[i] = lightColor;
}

vec3 colorComponent = texture(texture0.sampler, clamp((texture0.transform3d * vec4(uv0, 0, 1)).xy, texture0.clampMin, texture0.clampMax)).rgb*(vec3(0.501960813999176) + individualLightColors[0].rgb*vec3(0.7019608020782471,0.7019608020782471,0.501960813999176));
vec3 colorComponent = texture(texture0.sampler, clamp(transformUv3d(texture0.transform3d, uv0), texture0.clampMin, texture0.clampMax)).rgb*(vec3(0.501960813999176) + individualLightColors[0].rgb*vec3(0.7019608020782471,0.7019608020782471,0.501960813999176));

float alphaComponent = 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ struct Texture {
mat2x3 transform2d;
mat4 transform3d;
};

vec2 transformUv3d(mat4 transform3d, vec2 inUv) {
vec4 rawTransformedUv = (transform3d * vec4(inUv, 0, 1));

// We need to manually divide by w for perspective correction!
return rawTransformedUv.xy / rawTransformedUv.w;
}

uniform Texture texture0;

in vec3 vertexNormal;
Expand All @@ -44,7 +52,7 @@ void main() {
individualLightColors[i] = lightColor;
}

vec3 colorComponent = texture(texture0.sampler, clamp((texture0.transform3d * vec4(uv0, 0, 1)).xy, texture0.clampMin, texture0.clampMax)).rgb*(vec3(0.501960813999176) + individualLightColors[0].rgb*vec3(0.7019608020782471,0.7019608020782471,0.501960813999176));
vec3 colorComponent = texture(texture0.sampler, clamp(transformUv3d(texture0.transform3d, uv0), texture0.clampMin, texture0.clampMax)).rgb*(vec3(0.501960813999176) + individualLightColors[0].rgb*vec3(0.7019608020782471,0.7019608020782471,0.501960813999176));

float alphaComponent = 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ struct Texture {
mat2x3 transform2d;
mat4 transform3d;
};

vec2 transformUv3d(mat4 transform3d, vec2 inUv) {
vec4 rawTransformedUv = (transform3d * vec4(inUv, 0, 1));

// We need to manually divide by w for perspective correction!
return rawTransformedUv.xy / rawTransformedUv.w;
}

uniform Texture texture0;

in vec3 vertexNormal;
Expand All @@ -44,7 +52,7 @@ void main() {
individualLightColors[i] = lightColor;
}

vec3 colorComponent = texture(texture0.sampler, clamp((texture0.transform3d * vec4(uv0, 0, 1)).xy, texture0.clampMin, texture0.clampMax)).rgb*(vec3(0.501960813999176) + individualLightColors[0].rgb*vec3(0.7019608020782471,0.7019608020782471,0.501960813999176));
vec3 colorComponent = texture(texture0.sampler, clamp(transformUv3d(texture0.transform3d, uv0), texture0.clampMin, texture0.clampMax)).rgb*(vec3(0.501960813999176) + individualLightColors[0].rgb*vec3(0.7019608020782471,0.7019608020782471,0.501960813999176));

float alphaComponent = 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ struct Texture {
mat2x3 transform2d;
mat4 transform3d;
};

vec2 transformUv3d(mat4 transform3d, vec2 inUv) {
vec4 rawTransformedUv = (transform3d * vec4(inUv, 0, 1));

// We need to manually divide by w for perspective correction!
return rawTransformedUv.xy / rawTransformedUv.w;
}

uniform Texture texture0;

in vec3 vertexNormal;
Expand All @@ -44,7 +52,7 @@ void main() {
individualLightColors[i] = lightColor;
}

vec3 colorComponent = texture(texture0.sampler, clamp((texture0.transform3d * vec4(uv0, 0, 1)).xy, texture0.clampMin, texture0.clampMax)).rgb*(vec3(0.501960813999176) + individualLightColors[0].rgb*vec3(0.7019608020782471,0.7019608020782471,0.501960813999176));
vec3 colorComponent = texture(texture0.sampler, clamp(transformUv3d(texture0.transform3d, uv0), texture0.clampMin, texture0.clampMax)).rgb*(vec3(0.501960813999176) + individualLightColors[0].rgb*vec3(0.7019608020782471,0.7019608020782471,0.501960813999176));

float alphaComponent = 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ struct Texture {
mat2x3 transform2d;
mat4 transform3d;
};

vec2 transformUv3d(mat4 transform3d, vec2 inUv) {
vec4 rawTransformedUv = (transform3d * vec4(inUv, 0, 1));

// We need to manually divide by w for perspective correction!
return rawTransformedUv.xy / rawTransformedUv.w;
}

uniform Texture texture0;

in vec3 vertexNormal;
Expand All @@ -44,7 +52,7 @@ void main() {
individualLightColors[i] = lightColor;
}

vec3 colorComponent = texture(texture0.sampler, clamp((texture0.transform3d * vec4(uv0, 0, 1)).xy, texture0.clampMin, texture0.clampMax)).rgb*(vec3(0.501960813999176) + individualLightColors[0].rgb*vec3(0.7019608020782471,0.7019608020782471,0.501960813999176));
vec3 colorComponent = texture(texture0.sampler, clamp(transformUv3d(texture0.transform3d, uv0), texture0.clampMin, texture0.clampMax)).rgb*(vec3(0.501960813999176) + individualLightColors[0].rgb*vec3(0.7019608020782471,0.7019608020782471,0.501960813999176));

float alphaComponent = 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ struct Texture {
mat2x3 transform2d;
mat4 transform3d;
};

vec2 transformUv3d(mat4 transform3d, vec2 inUv) {
vec4 rawTransformedUv = (transform3d * vec4(inUv, 0, 1));

// We need to manually divide by w for perspective correction!
return rawTransformedUv.xy / rawTransformedUv.w;
}

uniform Texture texture0;

in vec3 vertexNormal;
Expand All @@ -44,7 +52,7 @@ void main() {
individualLightColors[i] = lightColor;
}

vec3 colorComponent = texture(texture0.sampler, clamp((texture0.transform3d * vec4(uv0, 0, 1)).xy, texture0.clampMin, texture0.clampMax)).rgb*(vec3(0.501960813999176) + individualLightColors[0].rgb*vec3(0.7019608020782471,0.7019608020782471,0.501960813999176));
vec3 colorComponent = texture(texture0.sampler, clamp(transformUv3d(texture0.transform3d, uv0), texture0.clampMin, texture0.clampMax)).rgb*(vec3(0.501960813999176) + individualLightColors[0].rgb*vec3(0.7019608020782471,0.7019608020782471,0.501960813999176));

float alphaComponent = 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ struct Texture {
mat2x3 transform2d;
mat4 transform3d;
};

vec2 transformUv3d(mat4 transform3d, vec2 inUv) {
vec4 rawTransformedUv = (transform3d * vec4(inUv, 0, 1));

// We need to manually divide by w for perspective correction!
return rawTransformedUv.xy / rawTransformedUv.w;
}

uniform Texture texture0;

in vec3 vertexNormal;
Expand All @@ -44,7 +52,7 @@ void main() {
individualLightColors[i] = lightColor;
}

vec3 colorComponent = texture(texture0.sampler, clamp((texture0.transform3d * vec4(uv0, 0, 1)).xy, texture0.clampMin, texture0.clampMax)).rgb*(vec3(0.501960813999176) + individualLightColors[0].rgb*vec3(0.7019608020782471,0.7019608020782471,0.501960813999176));
vec3 colorComponent = texture(texture0.sampler, clamp(transformUv3d(texture0.transform3d, uv0), texture0.clampMin, texture0.clampMax)).rgb*(vec3(0.501960813999176) + individualLightColors[0].rgb*vec3(0.7019608020782471,0.7019608020782471,0.501960813999176));

float alphaComponent = 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ struct Texture {
mat2x3 transform2d;
mat4 transform3d;
};

vec2 transformUv3d(mat4 transform3d, vec2 inUv) {
vec4 rawTransformedUv = (transform3d * vec4(inUv, 0, 1));

// We need to manually divide by w for perspective correction!
return rawTransformedUv.xy / rawTransformedUv.w;
}

uniform Texture texture0;

in vec3 vertexNormal;
Expand All @@ -44,7 +52,7 @@ void main() {
individualLightColors[i] = lightColor;
}

vec3 colorComponent = texture(texture0.sampler, clamp((texture0.transform3d * vec4(uv0, 0, 1)).xy, texture0.clampMin, texture0.clampMax)).rgb*(vec3(0.501960813999176) + individualLightColors[0].rgb*vec3(0.7019608020782471,0.7019608020782471,0.501960813999176));
vec3 colorComponent = texture(texture0.sampler, clamp(transformUv3d(texture0.transform3d, uv0), texture0.clampMin, texture0.clampMax)).rgb*(vec3(0.501960813999176) + individualLightColors[0].rgb*vec3(0.7019608020782471,0.7019608020782471,0.501960813999176));

float alphaComponent = 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ struct Texture {
mat2x3 transform2d;
mat4 transform3d;
};

vec2 transformUv3d(mat4 transform3d, vec2 inUv) {
vec4 rawTransformedUv = (transform3d * vec4(inUv, 0, 1));

// We need to manually divide by w for perspective correction!
return rawTransformedUv.xy / rawTransformedUv.w;
}

uniform Texture texture0;

in vec3 vertexNormal;
Expand All @@ -44,7 +52,7 @@ void main() {
individualLightColors[i] = lightColor;
}

vec3 colorComponent = texture(texture0.sampler, clamp((texture0.transform3d * vec4(uv0, 0, 1)).xy, texture0.clampMin, texture0.clampMax)).rgb*(vec3(0.501960813999176) + individualLightColors[0].rgb*vec3(0.7019608020782471,0.7019608020782471,0.501960813999176));
vec3 colorComponent = texture(texture0.sampler, clamp(transformUv3d(texture0.transform3d, uv0), texture0.clampMin, texture0.clampMax)).rgb*(vec3(0.501960813999176) + individualLightColors[0].rgb*vec3(0.7019608020782471,0.7019608020782471,0.501960813999176));

float alphaComponent = 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ struct Texture {
mat2x3 transform2d;
mat4 transform3d;
};

vec2 transformUv3d(mat4 transform3d, vec2 inUv) {
vec4 rawTransformedUv = (transform3d * vec4(inUv, 0, 1));

// We need to manually divide by w for perspective correction!
return rawTransformedUv.xy / rawTransformedUv.w;
}

uniform Texture texture0;

in vec3 vertexNormal;
Expand All @@ -44,7 +52,7 @@ void main() {
individualLightColors[i] = lightColor;
}

vec3 colorComponent = texture(texture0.sampler, clamp((texture0.transform3d * vec4(uv0, 0, 1)).xy, texture0.clampMin, texture0.clampMax)).rgb*(vec3(0.501960813999176) + individualLightColors[0].rgb*vec3(0.7019608020782471,0.7019608020782471,0.501960813999176));
vec3 colorComponent = texture(texture0.sampler, clamp(transformUv3d(texture0.transform3d, uv0), texture0.clampMin, texture0.clampMax)).rgb*(vec3(0.501960813999176) + individualLightColors[0].rgb*vec3(0.7019608020782471,0.7019608020782471,0.501960813999176));

float alphaComponent = 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ struct Texture {
mat2x3 transform2d;
mat4 transform3d;
};

vec2 transformUv3d(mat4 transform3d, vec2 inUv) {
vec4 rawTransformedUv = (transform3d * vec4(inUv, 0, 1));

// We need to manually divide by w for perspective correction!
return rawTransformedUv.xy / rawTransformedUv.w;
}

uniform Texture texture0;

in vec3 vertexNormal;
Expand All @@ -44,7 +52,7 @@ void main() {
individualLightColors[i] = lightColor;
}

vec3 colorComponent = texture(texture0.sampler, clamp((texture0.transform3d * vec4(uv0, 0, 1)).xy, texture0.clampMin, texture0.clampMax)).rgb*(vec3(0.501960813999176) + individualLightColors[0].rgb*vec3(0.7019608020782471,0.7019608020782471,0.501960813999176));
vec3 colorComponent = texture(texture0.sampler, clamp(transformUv3d(texture0.transform3d, uv0), texture0.clampMin, texture0.clampMax)).rgb*(vec3(0.501960813999176) + individualLightColors[0].rgb*vec3(0.7019608020782471,0.7019608020782471,0.501960813999176));

float alphaComponent = 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ struct Texture {
mat2x3 transform2d;
mat4 transform3d;
};

vec2 transformUv3d(mat4 transform3d, vec2 inUv) {
vec4 rawTransformedUv = (transform3d * vec4(inUv, 0, 1));

// We need to manually divide by w for perspective correction!
return rawTransformedUv.xy / rawTransformedUv.w;
}

uniform Texture texture0;

in vec3 vertexNormal;
Expand All @@ -44,7 +52,7 @@ void main() {
individualLightColors[i] = lightColor;
}

vec3 colorComponent = texture(texture0.sampler, clamp((texture0.transform3d * vec4(uv0, 0, 1)).xy, texture0.clampMin, texture0.clampMax)).rgb*(vec3(0.501960813999176) + individualLightColors[0].rgb*vec3(0.7019608020782471,0.7019608020782471,0.501960813999176));
vec3 colorComponent = texture(texture0.sampler, clamp(transformUv3d(texture0.transform3d, uv0), texture0.clampMin, texture0.clampMax)).rgb*(vec3(0.501960813999176) + individualLightColors[0].rgb*vec3(0.7019608020782471,0.7019608020782471,0.501960813999176));

float alphaComponent = 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ struct Texture {
mat2x3 transform2d;
mat4 transform3d;
};

vec2 transformUv3d(mat4 transform3d, vec2 inUv) {
vec4 rawTransformedUv = (transform3d * vec4(inUv, 0, 1));

// We need to manually divide by w for perspective correction!
return rawTransformedUv.xy / rawTransformedUv.w;
}

uniform Texture texture0;

in vec3 vertexNormal;
Expand All @@ -44,7 +52,7 @@ void main() {
individualLightColors[i] = lightColor;
}

vec3 colorComponent = texture(texture0.sampler, clamp((texture0.transform3d * vec4(uv0, 0, 1)).xy, texture0.clampMin, texture0.clampMax)).rgb*(vec3(0.501960813999176) + individualLightColors[0].rgb*vec3(0.7019608020782471,0.7019608020782471,0.501960813999176));
vec3 colorComponent = texture(texture0.sampler, clamp(transformUv3d(texture0.transform3d, uv0), texture0.clampMin, texture0.clampMax)).rgb*(vec3(0.501960813999176) + individualLightColors[0].rgb*vec3(0.7019608020782471,0.7019608020782471,0.501960813999176));

float alphaComponent = 1;

Expand Down
Loading

0 comments on commit e7440a2

Please sign in to comment.