mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 13:30:02 +00:00
Fix additional minor differences
This commit is contained in:
parent
a8f4a4d749
commit
7532116b69
@ -196,7 +196,7 @@ bool GenerateVertexShaderGLSL(const VShaderID &id, char *buffer, const GLSLShade
|
||||
|
||||
int numBoneWeights = 0;
|
||||
int boneWeightScale = id.Bits(VS_BIT_WEIGHT_FMTSCALE, 2);
|
||||
bool texcoordVec3In = false;
|
||||
bool texcoordInVec3 = false;
|
||||
|
||||
if (compat.vulkan) {
|
||||
if (enableBones) {
|
||||
@ -213,7 +213,6 @@ bool GenerateVertexShaderGLSL(const VShaderID &id, char *buffer, const GLSLShade
|
||||
if (useHWTransform && hasNormal)
|
||||
WRITE(p, "layout (location = %d) in vec3 normal;\n", (int)PspAttributeLocation::NORMAL);
|
||||
|
||||
bool texcoordInVec3 = false;
|
||||
if (doTexture && hasTexcoord) {
|
||||
if (!useHWTransform && doTextureTransform && !isModeThrough) {
|
||||
WRITE(p, "layout (location = %d) in vec3 texcoord;\n", (int)PspAttributeLocation::TEXCOORD);
|
||||
@ -267,7 +266,7 @@ bool GenerateVertexShaderGLSL(const VShaderID &id, char *buffer, const GLSLShade
|
||||
if (doTexture && hasTexcoord) {
|
||||
if (!useHWTransform && doTextureTransform && !isModeThrough) {
|
||||
WRITE(p, "%s vec3 texcoord;\n", compat.attribute);
|
||||
texcoordVec3In = true;
|
||||
texcoordInVec3 = true;
|
||||
} else {
|
||||
WRITE(p, "%s vec2 texcoord;\n", compat.attribute);
|
||||
}
|
||||
@ -521,7 +520,7 @@ bool GenerateVertexShaderGLSL(const VShaderID &id, char *buffer, const GLSLShade
|
||||
if (!useHWTransform) {
|
||||
// Simple pass-through of vertex data to fragment shader
|
||||
if (doTexture) {
|
||||
if (texcoordVec3In) {
|
||||
if (texcoordInVec3) {
|
||||
WRITE(p, " v_texcoord = texcoord;\n");
|
||||
} else {
|
||||
WRITE(p, " v_texcoord = vec3(texcoord, 1.0);\n");
|
||||
@ -584,15 +583,17 @@ bool GenerateVertexShaderGLSL(const VShaderID &id, char *buffer, const GLSLShade
|
||||
|
||||
// Uncomment this to screw up bone shaders to check the vertex shader software fallback
|
||||
// WRITE(p, "THIS SHOULD ERROR! #error");
|
||||
if (numBoneWeights == 1)
|
||||
if (numBoneWeights == 1 && !compat.vulkan)
|
||||
WRITE(p, " %s skinMatrix = w1 * u_bone0", boneMatrix);
|
||||
else
|
||||
WRITE(p, " %s skinMatrix = w1.x * u_bone0", boneMatrix);
|
||||
for (int i = 1; i < numBoneWeights; i++) {
|
||||
const char *weightAttr = boneWeightAttr[i];
|
||||
// workaround for "cant do .x of scalar" issue
|
||||
if (numBoneWeights == 1 && i == 0) weightAttr = "w1";
|
||||
if (numBoneWeights == 5 && i == 4) weightAttr = "w2";
|
||||
if (!compat.vulkan) {
|
||||
if (numBoneWeights == 1 && i == 0) weightAttr = "w1";
|
||||
if (numBoneWeights == 5 && i == 4) weightAttr = "w2";
|
||||
}
|
||||
WRITE(p, " + %s * u_bone%i", weightAttr, i);
|
||||
}
|
||||
|
||||
|
@ -406,6 +406,7 @@ bool GenerateVertexShaderVulkanGLSL(const VShaderID &id, char *buffer, std::stri
|
||||
bool specularIsZero = true;
|
||||
bool distanceNeeded = false;
|
||||
|
||||
bool anySpots = false;
|
||||
if (enableLighting) {
|
||||
WRITE(p, " lowp vec4 lightSum0 = u_ambient * %s + vec4(u_matemissive, 0.0);\n", ambientStr);
|
||||
|
||||
@ -419,18 +420,24 @@ bool GenerateVertexShaderVulkanGLSL(const VShaderID &id, char *buffer, std::stri
|
||||
specularIsZero = false;
|
||||
if (type != GE_LIGHTTYPE_DIRECTIONAL)
|
||||
distanceNeeded = true;
|
||||
if (type == GE_LIGHTTYPE_SPOT || type == GE_LIGHTTYPE_UNKNOWN)
|
||||
anySpots = true;
|
||||
}
|
||||
|
||||
if (!specularIsZero) {
|
||||
WRITE(p, " vec3 lightSum1 = vec3(0.0);\n");
|
||||
WRITE(p, " lowp vec3 lightSum1 = vec3(0.0);\n");
|
||||
}
|
||||
if (!diffuseIsZero) {
|
||||
WRITE(p, " vec3 toLight;\n");
|
||||
WRITE(p, " vec3 diffuse;\n");
|
||||
WRITE(p, " lowp vec3 diffuse;\n");
|
||||
}
|
||||
if (distanceNeeded) {
|
||||
WRITE(p, " float distance;\n");
|
||||
WRITE(p, " float lightScale;\n");
|
||||
WRITE(p, " lowp float lightScale;\n");
|
||||
}
|
||||
WRITE(p, " mediump float ldot;\n");
|
||||
if (anySpots) {
|
||||
WRITE(p, " lowp float angle;\n");
|
||||
}
|
||||
}
|
||||
|
||||
@ -455,14 +462,14 @@ bool GenerateVertexShaderVulkanGLSL(const VShaderID &id, char *buffer, std::stri
|
||||
bool doSpecular = comp == GE_LIGHTCOMP_BOTH;
|
||||
bool poweredDiffuse = comp == GE_LIGHTCOMP_ONLYPOWDIFFUSE;
|
||||
|
||||
WRITE(p, " mediump float dot%i = dot(toLight, worldnormal);\n", i);
|
||||
WRITE(p, " ldot = dot(toLight, worldnormal);\n");
|
||||
if (poweredDiffuse) {
|
||||
// pow(0.0, 0.0) may be undefined, but the PSP seems to treat it as 1.0.
|
||||
// Seen in Tales of the World: Radiant Mythology (#2424.)
|
||||
WRITE(p, " if (u_matspecular.a <= 0.0) {\n");
|
||||
WRITE(p, " dot%i = 1.0;\n", i);
|
||||
WRITE(p, " ldot = 1.0;\n");
|
||||
WRITE(p, " } else {\n");
|
||||
WRITE(p, " dot%i = pow(max(dot%i, 0.0), u_matspecular.a);\n", i, i);
|
||||
WRITE(p, " ldot = pow(max(ldot, 0.0), u_matspecular.a);\n");
|
||||
WRITE(p, " }\n");
|
||||
}
|
||||
|
||||
@ -478,9 +485,9 @@ bool GenerateVertexShaderVulkanGLSL(const VShaderID &id, char *buffer, std::stri
|
||||
break;
|
||||
case GE_LIGHTTYPE_SPOT:
|
||||
case GE_LIGHTTYPE_UNKNOWN:
|
||||
WRITE(p, " float angle%i = length(u_lightdir%d) == 0.0 ? 0.0 : dot(normalize(u_lightdir%d), toLight);\n", i, i, i);
|
||||
WRITE(p, " if (angle%i >= u_lightangle_spotCoef%d.x) {\n", i, i);
|
||||
WRITE(p, " lightScale = clamp(1.0 / dot(u_lightatt%d, vec3(1.0, distance, distance*distance)), 0.0, 1.0) * (u_lightangle_spotCoef%d.y <= 0.0 ? 1.0 : pow(angle%i, u_lightangle_spotCoef%d.y));\n", i, i, i, i);
|
||||
WRITE(p, " angle = length(u_lightdir%d) == 0.0 ? 0.0 : dot(normalize(u_lightdir%d), toLight);\n", i, i);
|
||||
WRITE(p, " if (angle >= u_lightangle_spotCoef%d.x) {\n", i);
|
||||
WRITE(p, " lightScale = clamp(1.0 / dot(u_lightatt%d, vec3(1.0, distance, distance*distance)), 0.0, 1.0) * (u_lightangle_spotCoef%d.y <= 0.0 ? 1.0 : pow(angle, u_lightangle_spotCoef%d.y));\n", i, i, i);
|
||||
WRITE(p, " } else {\n");
|
||||
WRITE(p, " lightScale = 0.0;\n");
|
||||
WRITE(p, " }\n");
|
||||
@ -490,17 +497,17 @@ bool GenerateVertexShaderVulkanGLSL(const VShaderID &id, char *buffer, std::stri
|
||||
break;
|
||||
}
|
||||
|
||||
WRITE(p, " diffuse = (u_lightdiffuse%d * %s) * max(dot%i, 0.0);\n", i, diffuseStr, i);
|
||||
WRITE(p, " diffuse = (u_lightdiffuse%d * %s) * max(ldot, 0.0);\n", i, diffuseStr);
|
||||
if (doSpecular) {
|
||||
WRITE(p, " if (dot%i >= 0.0) {\n", i);
|
||||
WRITE(p, " dot%i = dot(normalize(toLight + vec3(0.0, 0.0, 1.0)), worldnormal);\n", i);
|
||||
WRITE(p, " if (ldot >= 0.0) {\n");
|
||||
WRITE(p, " ldot = dot(normalize(toLight + vec3(0.0, 0.0, 1.0)), worldnormal);\n");
|
||||
WRITE(p, " if (u_matspecular.a <= 0.0) {\n");
|
||||
WRITE(p, " dot%i = 1.0;\n", i);
|
||||
WRITE(p, " ldot = 1.0;\n");
|
||||
WRITE(p, " } else {\n");
|
||||
WRITE(p, " dot%i = pow(max(dot%i, 0.0), u_matspecular.a);\n", i, i);
|
||||
WRITE(p, " ldot = pow(max(ldot, 0.0), u_matspecular.a);\n");
|
||||
WRITE(p, " }\n");
|
||||
WRITE(p, " if (dot%i > 0.0)\n", i);
|
||||
WRITE(p, " lightSum1 += u_lightspecular%d * %s * dot%i %s;\n", i, specularStr, i, timesLightScale);
|
||||
WRITE(p, " if (ldot > 0.0)\n");
|
||||
WRITE(p, " lightSum1 += u_lightspecular%d * %s * ldot %s;\n", i, specularStr, timesLightScale);
|
||||
WRITE(p, " }\n");
|
||||
}
|
||||
WRITE(p, " lightSum0.rgb += (u_lightambient%d * %s.rgb + diffuse)%s;\n", i, ambientStr, timesLightScale);
|
||||
|
Loading…
Reference in New Issue
Block a user