Remove that silly factor 2 for floating point texcoords and weights.

No longer needed since we treat the various vertex formats separately.
This commit is contained in:
Henrik Rydgard 2013-07-27 22:14:34 +02:00
parent afcb5add51
commit 8602c276ca
5 changed files with 27 additions and 23 deletions

View file

@ -517,27 +517,31 @@ void GLES_GPU::ExecuteOp(u32 op, u32 diff) {
break;
case GE_CMD_TEXSCALEU:
gstate_c.uScale = getFloat24(data);
if (diff)
if (diff) {
gstate_c.uScale = getFloat24(data);
shaderManager_->DirtyUniform(DIRTY_UVSCALEOFFSET);
}
break;
case GE_CMD_TEXSCALEV:
gstate_c.vScale = getFloat24(data);
if (diff)
if (diff) {
gstate_c.vScale = getFloat24(data);
shaderManager_->DirtyUniform(DIRTY_UVSCALEOFFSET);
}
break;
case GE_CMD_TEXOFFSETU:
gstate_c.uOff = getFloat24(data);
if (diff)
if (diff) {
gstate_c.uOff = getFloat24(data);
shaderManager_->DirtyUniform(DIRTY_UVSCALEOFFSET);
}
break;
case GE_CMD_TEXOFFSETV:
gstate_c.vOff = getFloat24(data);
if (diff)
if (diff) {
gstate_c.vOff = getFloat24(data);
shaderManager_->DirtyUniform(DIRTY_UVSCALEOFFSET);
}
break;
case GE_CMD_SCISSOR1:

View file

@ -337,7 +337,7 @@ void LinkedShader::updateUniforms() {
float widthFactor = (float)w / (float)gstate_c.curTextureWidth;
float heightFactor = (float)h / (float)gstate_c.curTextureHeight;
if ((gstate.texmapmode & 3) == 0) {
static const float rescale[4] = {2.0f, 2*127.5f/128.f, 2*32767.5f/32768.f, 2.0f};
static const float rescale[4] = {1.0f, 2*127.5f/128.f, 2*32767.5f/32768.f, 1.0f};
float factor = rescale[(gstate.vertType & GE_VTYPE_TC_MASK) >> GE_VTYPE_TC_SHIFT];
uvscaleoff[0] = gstate_c.uScale * factor * widthFactor;
uvscaleoff[1] = gstate_c.vScale * factor * heightFactor;

View file

@ -146,7 +146,7 @@ void VertexDecoder::Step_WeightsFloat() const
const float *wdata = (const float*)(ptr_);
int j;
for (j = 0; j < nweights; j++) {
wt[j] = wdata[j] * 0.5f;
wt[j] = wdata[j];
}
while (j & 3) // Zero additional weights rounding up to 4.
wt[j++] = 0.0f;
@ -195,16 +195,16 @@ void VertexDecoder::Step_TcFloat() const
{
float *uv = (float *)(decoded_ + decFmt.uvoff);
const float *uvdata = (const float*)(ptr_ + tcoff);
uv[0] = uvdata[0] * 0.5f;
uv[1] = uvdata[1] * 0.5f;
uv[0] = uvdata[0];
uv[1] = uvdata[1];
}
void VertexDecoder::Step_TcFloatThrough() const
{
float *uv = (float *)(decoded_ + decFmt.uvoff);
const float *uvdata = (const float*)(ptr_ + tcoff);
uv[0] = uvdata[0] * 0.5f;
uv[1] = uvdata[1] * 0.5f;
uv[0] = uvdata[0];
uv[1] = uvdata[1];
}
void VertexDecoder::Step_Color565() const

View file

@ -266,7 +266,7 @@ public:
{
const float *f = (const float *)(data_ + decFmt_.nrmoff);
for (int i = 0; i < 3; i++)
nrm[i] = f[i] ;
nrm[i] = f[i];
}
break;
case DEC_S16_3:
@ -311,8 +311,8 @@ public:
case DEC_FLOAT_2:
{
const float *f = (const float *)(data_ + decFmt_.uvoff);
uv[0] = f[0] * 2.f;
uv[1] = f[1] * 2.f;
uv[0] = f[0];
uv[1] = f[1];
}
break;
@ -378,7 +378,7 @@ public:
case DEC_FLOAT_3:
case DEC_FLOAT_4:
for (int i = 0; i <= decFmt_.w0fmt - DEC_FLOAT_1; i++)
weights[i] = f[i] * 2.f;
weights[i] = f[i];
break;
case DEC_U8_1: weights[0] = b[0] * (1.f / 128.f); break;
case DEC_U8_2: for (int i = 0; i < 2; i++) weights[i] = b[i] * (1.f / 128.f); break;
@ -406,7 +406,7 @@ public:
case DEC_FLOAT_3:
case DEC_FLOAT_4:
for (int i = 0; i <= decFmt_.w1fmt - DEC_FLOAT_1; i++)
weights[i+4] = f[i] * 2.f;
weights[i+4] = f[i];
break;
case DEC_U8_1: weights[4] = b[0] * (1.f / 128.f); break;
case DEC_U8_2: for (int i = 0; i < 2; i++) weights[i+4] = b[i] * (1.f / 128.f); break;

View file

@ -308,8 +308,8 @@ void GenerateVertexShader(int prim, char *buffer, bool useHWTransform) {
} else {
int numWeights = TranslateNumBones(gstate.getNumBoneWeights());
static const float rescale[4] = {0, 2*127.5f/128.f, 2*32767.5f/32768.f, 2.0f};
float factor = rescale[(vertType & GE_VTYPE_WEIGHT_MASK) >> GE_VTYPE_WEIGHT_SHIFT];
static const char *rescale[4] = {"", " * 1.9921875", " * 1.999969482421875", ""}; // 2*127.5f/128.f, 2*32767.5f/32768.f, 1.0f};
const char *factor = rescale[(vertType & GE_VTYPE_WEIGHT_MASK) >> GE_VTYPE_WEIGHT_SHIFT];
static const char * const boneWeightAttr[8] = {
"a_w1.x", "a_w1.y", "a_w1.z", "a_w1.w",
@ -373,11 +373,11 @@ void GenerateVertexShader(int prim, char *buffer, bool useHWTransform) {
WRITE(p, ";\n");
// Trying to simplify this results in bugs in LBP...
WRITE(p, " vec3 skinnedpos = (skinMatrix * vec4(a_position, 1.0)).xyz * %f;\n", factor);
WRITE(p, " vec3 skinnedpos = (skinMatrix * vec4(a_position, 1.0)).xyz %s;\n", factor);
WRITE(p, " vec3 worldpos = (u_world * vec4(skinnedpos, 1.0)).xyz;\n");
if (hasNormal) {
WRITE(p, " vec3 skinnednormal = (skinMatrix * vec4(a_normal, 0.0)).xyz * %f;\n", factor);
WRITE(p, " vec3 skinnednormal = (skinMatrix * vec4(a_normal, 0.0)).xyz %s;\n", factor);
WRITE(p, " vec3 worldnormal = normalize((u_world * vec4(skinnednormal, 0.0)).xyz);\n");
} else {
WRITE(p, " vec3 worldnormal = (u_world * (skinMatrix * vec4(0.0, 0.0, 1.0, 0.0))).xyz;\n");