Skip to content

Commit

Permalink
Slightly cleaned up reflection mapping logic by moving reflection UV …
Browse files Browse the repository at this point in the history
…calculation into the vertex shader.
  • Loading branch information
MeltyPlayer committed Nov 28, 2024
1 parent a7acbbd commit 6f37952
Show file tree
Hide file tree
Showing 153 changed files with 202 additions and 216 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -832,14 +832,12 @@ private string GetTextureValue_(int textureIndex,
=> GlslUtil.ReadColorFromTexture(
textureName,
GlslConstants.IN_SPHERICAL_REFLECTION_UV_NAME,
uv => $"asin({uv}) / 3.14159 + 0.5",
texture,
this.animations_),
UvType.LINEAR
=> GlslUtil.ReadColorFromTexture(
textureName,
GlslConstants.IN_LINEAR_REFLECTION_UV_NAME,
uv => $"acos({uv}) / 3.14159",
texture,
this.animations_),
};
Expand Down
30 changes: 9 additions & 21 deletions FinModelUtility/Fin/Fin/src/shaders/glsl/GlslUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@ void main() {
binormal = cross(vertexNormal, tangent);");

if (shaderRequirements.UsesSphericalReflectionMapping) {
vertexSrc.AppendLine($" {GlslConstants.IN_SPHERICAL_REFLECTION_UV_NAME} = normalize(projectionVertexModelMatrix * vec4(in_Normal, 0)).xy;");
vertexSrc.AppendLine($" {GlslConstants.IN_SPHERICAL_REFLECTION_UV_NAME} = asin(normalize(projectionVertexModelMatrix * vec4(in_Normal, 0)).xy) / 3.14159 + .5;");
}
if (shaderRequirements.UsesLinearReflectionMapping) {
vertexSrc.AppendLine($" {GlslConstants.IN_LINEAR_REFLECTION_UV_NAME} = normalize(projectionVertexModelMatrix * vec4(in_Normal, 0)).xy;");
vertexSrc.AppendLine($" {GlslConstants.IN_LINEAR_REFLECTION_UV_NAME} = acos(normalize(projectionVertexModelMatrix * vec4(in_Normal, 0)).xy) / 3.14159;");
}
} else {
vertexSrc.AppendLine($@"
Expand All @@ -176,10 +176,10 @@ void main() {
binormal = cross(vertexNormal, tangent);");

if (shaderRequirements.UsesSphericalReflectionMapping) {
vertexSrc.AppendLine($" {GlslConstants.IN_SPHERICAL_REFLECTION_UV_NAME} = normalize(mvpMatrix * vec4(in_Normal, 0)).xy;");
vertexSrc.AppendLine($" {GlslConstants.IN_SPHERICAL_REFLECTION_UV_NAME} = asin(normalize(mvpMatrix * vec4(in_Normal, 0)).xy) / 3.14159 + .5;");
}
if (shaderRequirements.UsesLinearReflectionMapping) {
vertexSrc.AppendLine($" {GlslConstants.IN_LINEAR_REFLECTION_UV_NAME} = normalize(mvpMatrix * vec4(in_Normal, 0)).xy;");
vertexSrc.AppendLine($" {GlslConstants.IN_LINEAR_REFLECTION_UV_NAME} = acos(normalize(mvpMatrix * vec4(in_Normal, 0)).xy) / 3.14159;");
}
}

Expand Down Expand Up @@ -429,34 +429,22 @@ public static string GetTypeOfTexture(

public static string ReadColorFromTexture(
string textureName,
string rawUvName,
IReadOnlyTexture? finTexture,
IReadOnlyList<IReadOnlyModelAnimation> animations)
=> ReadColorFromTexture(textureName,
rawUvName,
t => t,
finTexture,
animations);

public static string ReadColorFromTexture(
string textureName,
string rawUvName,
Func<string, string> uvConverter,
string uvName,
IReadOnlyTexture? finTexture,
IReadOnlyList<IReadOnlyModelAnimation> animations) {
var needsClamp = finTexture.UsesShaderClamping();
var textureTransformType = finTexture.GetTextureTransformType_(animations);

if (!needsClamp && textureTransformType == TextureTransformType.NONE) {
return $"texture({textureName}, {uvConverter(rawUvName)})";
return $"texture({textureName}, {uvName})";
}

var transformedUv = textureTransformType switch {
TextureTransformType.TWO_D =>
$"{textureName}.transform2d * vec3(({uvConverter(rawUvName)}).x, ({uvConverter(rawUvName)}).y, 1)",
$"{textureName}.transform2d * vec3(({uvName}).x, ({uvName}).y, 1)",
TextureTransformType.THREE_D =>
$"transformUv3d({textureName}.transform3d, {uvConverter(rawUvName)})",
_ => uvConverter(rawUvName)
$"transformUv3d({textureName}.transform3d, {uvName})",
_ => uvName
};

if (needsClamp) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ void main() {

vec3 colorComponent = clamp(texture(texture1, uv0).rgb*mergedLightSpecularColor.rgb*vec3(1.4980392158031464) + clamp((ambientLightColor.rgb*vec3(0.800000011920929) + mergedLightDiffuseColor.rgb)*texture(texture1, uv0).rgb, 0, 1), 0, 1);

float alphaComponent = (vertexColor0.a*texture(texture2, asin(sphericalReflectionUv) / 3.14159 + 0.5).a + scalar_3dsAlpha0)*scalar_3dsAlpha1;
float alphaComponent = (vertexColor0.a*texture(texture2, sphericalReflectionUv).a + scalar_3dsAlpha0)*scalar_3dsAlpha1;

fragColor = vec4(colorComponent, alphaComponent);
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void main() {
vertexNormal = normalize(modelMatrix * vec4(in_Normal, 0)).xyz;
tangent = normalize(modelMatrix * vec4(in_Tangent)).xyz;
binormal = cross(vertexNormal, tangent);
sphericalReflectionUv = normalize(mvpMatrix * vec4(in_Normal, 0)).xy;
sphericalReflectionUv = asin(normalize(mvpMatrix * vec4(in_Normal, 0)).xy) / 3.14159 + .5;
uv0 = in_Uvs[0];
vertexColor0 = in_Colors[0];
}
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ void main() {

vec3 colorComponent = clamp(texture(texture1, uv0).rgb*mergedLightSpecularColor.rgb*vec3(2) + clamp((ambientLightColor.rgb*vec3(0.800000011920929) + mergedLightDiffuseColor.rgb)*texture(texture1, uv0).rgb, 0, 1), 0, 1);

float alphaComponent = (vertexColor0.a*texture(texture2, asin(sphericalReflectionUv) / 3.14159 + 0.5).a + scalar_3dsAlpha0)*scalar_3dsAlpha1;
float alphaComponent = (vertexColor0.a*texture(texture2, sphericalReflectionUv).a + scalar_3dsAlpha0)*scalar_3dsAlpha1;

fragColor = vec4(colorComponent, alphaComponent);
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void main() {
vertexNormal = normalize(modelMatrix * vec4(in_Normal, 0)).xyz;
tangent = normalize(modelMatrix * vec4(in_Tangent)).xyz;
binormal = cross(vertexNormal, tangent);
sphericalReflectionUv = normalize(mvpMatrix * vec4(in_Normal, 0)).xy;
sphericalReflectionUv = asin(normalize(mvpMatrix * vec4(in_Normal, 0)).xy) / 3.14159 + .5;
uv0 = in_Uvs[0];
vertexColor0 = in_Colors[0];
}
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ void main() {
vec4 mergedLightSpecularColor = vec4(0);
getMergedLightColors(vertexPosition, fragNormal, shininess, mergedLightDiffuseColor, mergedLightSpecularColor);

vec3 colorComponent = clamp(clamp((color_3dsColor3 + vec3(texture(texture0, uv0).rgb.g)), 0, 1)*clamp(clamp((vec3(texture(texture1, uv0).rgb.b)*texture(texture2, asin(sphericalReflectionUv) / 3.14159 + 0.5).rgb + clamp(color_3dsColor2*vec3(1 + -1*vertexColor0.rgb.r*vertexColor0.rgb.r*2) + clamp(vertexColor0.rgb, 0, 1), 0, 1)), 0, 1)*texture(texture1, uv0).rgb*vec3(2)*(ambientLightColor.rgb + mergedLightDiffuseColor.rgb), 0, 1), 0, 1);
vec3 colorComponent = clamp(clamp((color_3dsColor3 + vec3(texture(texture0, uv0).rgb.g)), 0, 1)*clamp(clamp((vec3(texture(texture1, uv0).rgb.b)*texture(texture2, sphericalReflectionUv).rgb + clamp(color_3dsColor2*vec3(1 + -1*vertexColor0.rgb.r*vertexColor0.rgb.r*2) + clamp(vertexColor0.rgb, 0, 1), 0, 1)), 0, 1)*texture(texture1, uv0).rgb*vec3(2)*(ambientLightColor.rgb + mergedLightDiffuseColor.rgb), 0, 1), 0, 1);

float alphaComponent = vertexColor0.a*texture(texture1, uv0).a*scalar_3dsAlpha1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void main() {
vertexNormal = normalize(modelMatrix * vec4(in_Normal, 0)).xyz;
tangent = normalize(modelMatrix * vec4(in_Tangent)).xyz;
binormal = cross(vertexNormal, tangent);
sphericalReflectionUv = normalize(mvpMatrix * vec4(in_Normal, 0)).xy;
sphericalReflectionUv = asin(normalize(mvpMatrix * vec4(in_Normal, 0)).xy) / 3.14159 + .5;
uv0 = in_Uvs[0];
vertexColor0 = in_Colors[0];
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ void main() {
vec4 mergedLightSpecularColor = vec4(0);
getMergedLightColors(vertexPosition, fragNormal, shininess, mergedLightDiffuseColor, mergedLightSpecularColor);

vec3 colorComponent = clamp(clamp((texture(texture0, uv0).rgb + texture(texture1, asin(sphericalReflectionUv) / 3.14159 + 0.5).rgb), 0, 1)*(ambientLightColor.rgb*vec3(0.4000000059604645) + mergedLightDiffuseColor.rgb*vec3(0.49803921580314636))*vec3(2), 0, 1);
vec3 colorComponent = clamp(clamp((texture(texture0, uv0).rgb + texture(texture1, sphericalReflectionUv).rgb), 0, 1)*(ambientLightColor.rgb*vec3(0.4000000059604645) + mergedLightDiffuseColor.rgb*vec3(0.49803921580314636))*vec3(2), 0, 1);

float alphaComponent = vertexColor0.a*texture(texture0, uv0).a*scalar_3dsAlpha3;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void main() {
vertexNormal = normalize(modelMatrix * vec4(in_Normal, 0)).xyz;
tangent = normalize(modelMatrix * vec4(in_Tangent)).xyz;
binormal = cross(vertexNormal, tangent);
sphericalReflectionUv = normalize(mvpMatrix * vec4(in_Normal, 0)).xy;
sphericalReflectionUv = asin(normalize(mvpMatrix * vec4(in_Normal, 0)).xy) / 3.14159 + .5;
uv0 = in_Uvs[0];
vertexColor0 = in_Colors[0];
}
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ void main() {
vec4 mergedLightSpecularColor = vec4(0);
getMergedLightColors(vertexPosition, fragNormal, shininess, mergedLightDiffuseColor, mergedLightSpecularColor);

vec3 colorComponent = clamp(clamp(vertexColor0.rgb*(ambientLightColor.rgb*vec3(0.4000000059604645) + mergedLightDiffuseColor.rgb*vec3(0.49803921580314636) + mergedLightSpecularColor.rgb)*texture(texture0, uv0).rgb*vec3(2), 0, 1) + texture(texture1, asin(sphericalReflectionUv) / 3.14159 + 0.5).rgb, 0, 1);
vec3 colorComponent = clamp(clamp(vertexColor0.rgb*(ambientLightColor.rgb*vec3(0.4000000059604645) + mergedLightDiffuseColor.rgb*vec3(0.49803921580314636) + mergedLightSpecularColor.rgb)*texture(texture0, uv0).rgb*vec3(2), 0, 1) + texture(texture1, sphericalReflectionUv).rgb, 0, 1);

float alphaComponent = vertexColor0.a*texture(texture0, uv0).a;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void main() {
vertexNormal = normalize(modelMatrix * vec4(in_Normal, 0)).xyz;
tangent = normalize(modelMatrix * vec4(in_Tangent)).xyz;
binormal = cross(vertexNormal, tangent);
sphericalReflectionUv = normalize(mvpMatrix * vec4(in_Normal, 0)).xy;
sphericalReflectionUv = asin(normalize(mvpMatrix * vec4(in_Normal, 0)).xy) / 3.14159 + .5;
uv0 = in_Uvs[0];
vertexColor0 = in_Colors[0];
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ in vec2 uv0;
out vec4 fragColor;

void main() {
vec3 colorComponent = texture(texture0, asin(sphericalReflectionUv) / 3.14159 + 0.5).rgb;
vec3 colorComponent = texture(texture0, sphericalReflectionUv).rgb;

float alphaComponent = 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ void main() {
vertexNormal = normalize(modelMatrix * vec4(in_Normal, 0)).xyz;
tangent = normalize(modelMatrix * vec4(in_Tangent)).xyz;
binormal = cross(vertexNormal, tangent);
sphericalReflectionUv = normalize(mvpMatrix * vec4(in_Normal, 0)).xy;
sphericalReflectionUv = asin(normalize(mvpMatrix * vec4(in_Normal, 0)).xy) / 3.14159 + .5;
uv0 = in_Uvs[0];
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ in vec2 uv0;
out vec4 fragColor;

void main() {
vec3 colorComponent = texture(texture0, asin(sphericalReflectionUv) / 3.14159 + 0.5).rgb;
vec3 colorComponent = texture(texture0, sphericalReflectionUv).rgb;

float alphaComponent = 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ void main() {
vertexNormal = normalize(modelMatrix * vec4(in_Normal, 0)).xyz;
tangent = normalize(modelMatrix * vec4(in_Tangent)).xyz;
binormal = cross(vertexNormal, tangent);
sphericalReflectionUv = normalize(mvpMatrix * vec4(in_Normal, 0)).xy;
sphericalReflectionUv = asin(normalize(mvpMatrix * vec4(in_Normal, 0)).xy) / 3.14159 + .5;
uv0 = in_Uvs[0];
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ void main() {
vec4 mergedLightSpecularColor = vec4(0);
getMergedLightColors(vertexPosition, fragNormal, shininess, mergedLightDiffuseColor, mergedLightSpecularColor);

vec3 colorComponent = mergedLightDiffuseColor.rgb*vec3(2)*vec3(0.6509804129600525)*vec3(0.30000001192092896) + texture(texture0, asin(sphericalReflectionUv) / 3.14159 + 0.5).rgb*vec3(0.699999988079071);
vec3 colorComponent = mergedLightDiffuseColor.rgb*vec3(2)*vec3(0.6509804129600525)*vec3(0.30000001192092896) + texture(texture0, sphericalReflectionUv).rgb*vec3(0.699999988079071);

float alphaComponent = 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ void main() {
vertexNormal = normalize(modelMatrix * vec4(in_Normal, 0)).xyz;
tangent = normalize(modelMatrix * vec4(in_Tangent)).xyz;
binormal = cross(vertexNormal, tangent);
sphericalReflectionUv = normalize(mvpMatrix * vec4(in_Normal, 0)).xy;
sphericalReflectionUv = asin(normalize(mvpMatrix * vec4(in_Normal, 0)).xy) / 3.14159 + .5;
uv0 = in_Uvs[0];
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ void main() {
vec4 mergedLightSpecularColor = vec4(0);
getMergedLightColors(vertexPosition, fragNormal, shininess, mergedLightDiffuseColor, mergedLightSpecularColor);

vec3 colorComponent = (mergedLightDiffuseColor.rgb*vec3(2)*vec3(0.7019608020782471) + mergedLightSpecularColor.rgb)*texture(texture0, asin(sphericalReflectionUv) / 3.14159 + 0.5).rgb;
vec3 colorComponent = (mergedLightDiffuseColor.rgb*vec3(2)*vec3(0.7019608020782471) + mergedLightSpecularColor.rgb)*texture(texture0, sphericalReflectionUv).rgb;

float alphaComponent = 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ void main() {
vertexNormal = normalize(modelMatrix * vec4(in_Normal, 0)).xyz;
tangent = normalize(modelMatrix * vec4(in_Tangent)).xyz;
binormal = cross(vertexNormal, tangent);
sphericalReflectionUv = normalize(mvpMatrix * vec4(in_Normal, 0)).xy;
sphericalReflectionUv = asin(normalize(mvpMatrix * vec4(in_Normal, 0)).xy) / 3.14159 + .5;
uv0 = in_Uvs[0];
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ void main() {
vec4 mergedLightSpecularColor = vec4(0);
getMergedLightColors(vertexPosition, fragNormal, shininess, mergedLightDiffuseColor, mergedLightSpecularColor);

vec3 colorComponent = (mergedLightDiffuseColor.rgb*vec3(2)*vec3(0.7019608020782471) + mergedLightSpecularColor.rgb)*texture(texture0, asin(sphericalReflectionUv) / 3.14159 + 0.5).rgb;
vec3 colorComponent = (mergedLightDiffuseColor.rgb*vec3(2)*vec3(0.7019608020782471) + mergedLightSpecularColor.rgb)*texture(texture0, sphericalReflectionUv).rgb;

float alphaComponent = 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ void main() {
vertexNormal = normalize(modelMatrix * vec4(in_Normal, 0)).xyz;
tangent = normalize(modelMatrix * vec4(in_Tangent)).xyz;
binormal = cross(vertexNormal, tangent);
sphericalReflectionUv = normalize(mvpMatrix * vec4(in_Normal, 0)).xy;
sphericalReflectionUv = asin(normalize(mvpMatrix * vec4(in_Normal, 0)).xy) / 3.14159 + .5;
uv0 = in_Uvs[0];
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ void main() {
vec4 mergedLightSpecularColor = vec4(0);
getMergedLightColors(vertexPosition, fragNormal, shininess, mergedLightDiffuseColor, mergedLightSpecularColor);

vec3 colorComponent = (mergedLightDiffuseColor.rgb*vec3(2)*vec3(0.7019608020782471,0.501960813999176,0) + vec3(1,1,0.5490196347236633)*mergedLightSpecularColor.rgb)*vec3(0.5) + texture(texture0, asin(sphericalReflectionUv) / 3.14159 + 0.5).rgb*vec3(0.5);
vec3 colorComponent = (mergedLightDiffuseColor.rgb*vec3(2)*vec3(0.7019608020782471,0.501960813999176,0) + vec3(1,1,0.5490196347236633)*mergedLightSpecularColor.rgb)*vec3(0.5) + texture(texture0, sphericalReflectionUv).rgb*vec3(0.5);

float alphaComponent = 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ void main() {
vertexNormal = normalize(modelMatrix * vec4(in_Normal, 0)).xyz;
tangent = normalize(modelMatrix * vec4(in_Tangent)).xyz;
binormal = cross(vertexNormal, tangent);
sphericalReflectionUv = normalize(mvpMatrix * vec4(in_Normal, 0)).xy;
sphericalReflectionUv = asin(normalize(mvpMatrix * vec4(in_Normal, 0)).xy) / 3.14159 + .5;
uv0 = in_Uvs[0];
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ void main() {
vec4 mergedLightSpecularColor = vec4(0);
getMergedLightColors(vertexPosition, fragNormal, shininess, mergedLightDiffuseColor, mergedLightSpecularColor);

vec3 colorComponent = (mergedLightDiffuseColor.rgb*vec3(2)*vec3(0.7019608020782471,0.501960813999176,0) + vec3(1,1,0.5490196347236633)*mergedLightSpecularColor.rgb)*vec3(0.5) + texture(texture0, asin(sphericalReflectionUv) / 3.14159 + 0.5).rgb*vec3(0.5);
vec3 colorComponent = (mergedLightDiffuseColor.rgb*vec3(2)*vec3(0.7019608020782471,0.501960813999176,0) + vec3(1,1,0.5490196347236633)*mergedLightSpecularColor.rgb)*vec3(0.5) + texture(texture0, sphericalReflectionUv).rgb*vec3(0.5);

float alphaComponent = 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ void main() {
vertexNormal = normalize(modelMatrix * vec4(in_Normal, 0)).xyz;
tangent = normalize(modelMatrix * vec4(in_Tangent)).xyz;
binormal = cross(vertexNormal, tangent);
sphericalReflectionUv = normalize(mvpMatrix * vec4(in_Normal, 0)).xy;
sphericalReflectionUv = asin(normalize(mvpMatrix * vec4(in_Normal, 0)).xy) / 3.14159 + .5;
uv0 = in_Uvs[0];
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ void main() {
vec4 mergedLightSpecularColor = vec4(0);
getMergedLightColors(vertexPosition, fragNormal, shininess, mergedLightDiffuseColor, mergedLightSpecularColor);

vec3 colorComponent = (mergedLightDiffuseColor.rgb*vec3(2)*vec3(0.7019608020782471,0.501960813999176,0) + vec3(1,1,0.5490196347236633)*mergedLightSpecularColor.rgb)*vec3(0.5) + texture(texture0, asin(sphericalReflectionUv) / 3.14159 + 0.5).rgb*vec3(0.5);
vec3 colorComponent = (mergedLightDiffuseColor.rgb*vec3(2)*vec3(0.7019608020782471,0.501960813999176,0) + vec3(1,1,0.5490196347236633)*mergedLightSpecularColor.rgb)*vec3(0.5) + texture(texture0, sphericalReflectionUv).rgb*vec3(0.5);

float alphaComponent = 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ void main() {
vertexNormal = normalize(modelMatrix * vec4(in_Normal, 0)).xyz;
tangent = normalize(modelMatrix * vec4(in_Tangent)).xyz;
binormal = cross(vertexNormal, tangent);
sphericalReflectionUv = normalize(mvpMatrix * vec4(in_Normal, 0)).xy;
sphericalReflectionUv = asin(normalize(mvpMatrix * vec4(in_Normal, 0)).xy) / 3.14159 + .5;
uv0 = in_Uvs[0];
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ void main() {
vec4 mergedLightSpecularColor = vec4(0);
getMergedLightColors(vertexPosition, fragNormal, shininess, mergedLightDiffuseColor, mergedLightSpecularColor);

vec3 colorComponent = (mergedLightDiffuseColor.rgb*vec3(2)*vec3(0.7019608020782471,0.501960813999176,0) + vec3(1,1,0.5490196347236633)*mergedLightSpecularColor.rgb)*vec3(0.5) + texture(texture0, asin(sphericalReflectionUv) / 3.14159 + 0.5).rgb*vec3(0.5);
vec3 colorComponent = (mergedLightDiffuseColor.rgb*vec3(2)*vec3(0.7019608020782471,0.501960813999176,0) + vec3(1,1,0.5490196347236633)*mergedLightSpecularColor.rgb)*vec3(0.5) + texture(texture0, sphericalReflectionUv).rgb*vec3(0.5);

float alphaComponent = 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ void main() {
vertexNormal = normalize(modelMatrix * vec4(in_Normal, 0)).xyz;
tangent = normalize(modelMatrix * vec4(in_Tangent)).xyz;
binormal = cross(vertexNormal, tangent);
sphericalReflectionUv = normalize(mvpMatrix * vec4(in_Normal, 0)).xy;
sphericalReflectionUv = asin(normalize(mvpMatrix * vec4(in_Normal, 0)).xy) / 3.14159 + .5;
uv0 = in_Uvs[0];
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ void main() {
vec4 mergedLightSpecularColor = vec4(0);
getMergedLightColors(vertexPosition, fragNormal, shininess, mergedLightDiffuseColor, mergedLightSpecularColor);

vec3 colorComponent = (mergedLightDiffuseColor.rgb*vec3(2)*vec3(0.7019608020782471,0.501960813999176,0) + vec3(1,1,0.5490196347236633)*mergedLightSpecularColor.rgb)*vec3(0.5) + texture(texture0, asin(sphericalReflectionUv) / 3.14159 + 0.5).rgb*vec3(0.5);
vec3 colorComponent = (mergedLightDiffuseColor.rgb*vec3(2)*vec3(0.7019608020782471,0.501960813999176,0) + vec3(1,1,0.5490196347236633)*mergedLightSpecularColor.rgb)*vec3(0.5) + texture(texture0, sphericalReflectionUv).rgb*vec3(0.5);

float alphaComponent = 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ void main() {
vertexNormal = normalize(modelMatrix * vec4(in_Normal, 0)).xyz;
tangent = normalize(modelMatrix * vec4(in_Tangent)).xyz;
binormal = cross(vertexNormal, tangent);
sphericalReflectionUv = normalize(mvpMatrix * vec4(in_Normal, 0)).xy;
sphericalReflectionUv = asin(normalize(mvpMatrix * vec4(in_Normal, 0)).xy) / 3.14159 + .5;
uv0 = in_Uvs[0];
}
Loading

0 comments on commit 6f37952

Please sign in to comment.