Add more precision specifiers to vertex shader

This commit is contained in:
Henrik Rydgard 2013-05-18 19:50:07 +02:00
parent 2b683569f9
commit dca2406374

View file

@ -106,14 +106,14 @@ void ComputeVertexShaderID(VertexShaderID *id, int prim) {
}
static const char * const boneWeightAttrDecl[8] = {
"attribute float a_weight0123;\n",
"attribute vec2 a_weight0123;\n",
"attribute vec3 a_weight0123;\n",
"attribute vec4 a_weight0123;\n",
"attribute vec4 a_weight0123;\nattribute float a_weight4567;\n",
"attribute vec4 a_weight0123;\nattribute vec2 a_weight4567;\n",
"attribute vec4 a_weight0123;\nattribute vec3 a_weight4567;\n",
"attribute vec4 a_weight0123;\nattribute vec4 a_weight4567;\n",
"attribute mediump float a_weight0123;\n",
"attribute mediump vec2 a_weight0123;\n",
"attribute mediump vec3 a_weight0123;\n",
"attribute mediump vec4 a_weight0123;\n",
"attribute mediump vec4 a_weight0123;\nattribute mediump float a_weight4567;\n",
"attribute mediump vec4 a_weight0123;\nattribute mediump vec2 a_weight4567;\n",
"attribute mediump vec4 a_weight0123;\nattribute mediump vec3 a_weight4567;\n",
"attribute mediump vec4 a_weight0123;\nattribute mediump vec4 a_weight4567;\n",
};
static const char * const boneWeightAttr[8] = {
@ -217,11 +217,11 @@ void GenerateVertexShader(int prim, char *buffer) {
if (gstate.getUVGenMode() == 0)
WRITE(p, "uniform vec4 u_uvscaleoffset;\n");
else if (gstate.getUVGenMode() == 1)
WRITE(p, "uniform mat4 u_texmtx;\n");
WRITE(p, "uniform mediump mat4 u_texmtx;\n");
if ((vertType & GE_VTYPE_WEIGHT_MASK) != GE_VTYPE_WEIGHT_NONE) {
int numBones = 1 + ((vertType & GE_VTYPE_WEIGHTCOUNT_MASK) >> GE_VTYPE_WEIGHTCOUNT_SHIFT);
for (int i = 0; i < numBones; i++) {
WRITE(p, "uniform mat4 u_bone%i;\n", i);
WRITE(p, "uniform mediump mat4 u_bone%i;\n", i);
}
}
if (gstate.isLightingEnabled()) {
@ -239,10 +239,10 @@ void GenerateVertexShader(int prim, char *buffer) {
}
if (doLight[i] == LIGHT_FULL) {
// These are needed for the full thing
WRITE(p, "uniform vec3 u_lightdir%i;\n", i);
WRITE(p, "uniform vec3 u_lightatt%i;\n", i);
WRITE(p, "uniform float u_lightangle%i;\n", i);
WRITE(p, "uniform float u_lightspotCoef%i;\n", i);
WRITE(p, "uniform mediump vec3 u_lightdir%i;\n", i);
WRITE(p, "uniform mediump vec3 u_lightatt%i;\n", i);
WRITE(p, "uniform mediump float u_lightangle%i;\n", i);
WRITE(p, "uniform mediump float u_lightspotCoef%i;\n", i);
WRITE(p, "uniform lowp vec3 u_lightambient%i;\n", i);
WRITE(p, "uniform lowp vec3 u_lightdiffuse%i;\n", i);
@ -357,10 +357,10 @@ void GenerateVertexShader(int prim, char *buffer) {
bool doSpecular = (comp != GE_LIGHTCOMP_ONLYDIFFUSE);
bool poweredDiffuse = comp == GE_LIGHTCOMP_BOTHWITHPOWDIFFUSE;
WRITE(p, " float dot%i = dot(normalize(toLight%i), worldnormal);\n", i, i);
WRITE(p, " mediump float dot%i = dot(normalize(toLight%i), worldnormal);\n", i, i);
WRITE(p, " float distance%i = length(toLight%i);\n", i, i);
WRITE(p, " float lightScale%i = 0.0;\n", i);
WRITE(p, " float angle%i = 0.0;\n", i);
WRITE(p, " lowp float lightScale%i = 0.0;\n", i);
WRITE(p, " lowp float angle%i = 0.0;\n", i);
if (poweredDiffuse) {
WRITE(p, " dot%i = pow(dot%i, u_matspecular.a);\n", i, i);
@ -385,9 +385,9 @@ void GenerateVertexShader(int prim, char *buffer) {
break;
}
WRITE(p, " vec3 diffuse%i = (u_lightdiffuse%i * %s) * max(dot%i, 0.0);\n", i, i, diffuse, i);
WRITE(p, " lowp vec3 diffuse%i = (u_lightdiffuse%i * %s) * max(dot%i, 0.0);\n", i, i, diffuse, i);
if (doSpecular) {
WRITE(p, " vec3 halfVec%i = normalize(normalize(toLight%i) + vec3(0.0, 0.0, 1.0));\n", i, i);
WRITE(p, " mediump vec3 halfVec%i = normalize(normalize(toLight%i) + vec3(0.0, 0.0, 1.0));\n", i, i);
WRITE(p, " dot%i = dot(halfVec%i, worldnormal);\n", i, i);
WRITE(p, " if (dot%i > 0.0)\n", i);
WRITE(p, " lightSum1 += u_lightspecular%i * %s * (pow(dot%i, u_matspecular.a) * lightScale%i);\n", i, specular, i, i);