Normalize in shader for broken drivers

This commit is contained in:
Benau
2017-12-27 11:33:30 +08:00
parent 891b053358
commit dbc3cd5ff5
11 changed files with 49 additions and 80 deletions

View File

@@ -11,24 +11,12 @@ vec4 getWorldPosition(vec3 origin, vec4 rotation, vec3 scale, vec3 local_pos)
return vec4(local_pos, 1.0);
}
vec4 convert10BitVector(int pked)
vec4 convert10BitVector(vec4 orig)
{
vec4 ret;
int part = pked & 1023;
float part_mix = float(clamp(int(part & 512), 0, 1));
ret.x = mix(float(part), float(-1024 + part), part_mix) * 0.00195694715;
part = (pked >> 10) & 1023;
part_mix = float(clamp(int(part & 512), 0, 1));
ret.y = mix(float(part), float(-1024 + part), part_mix) * 0.00195694715;
part = (pked >> 20) & 1023;
part_mix = float(clamp(int(part & 512), 0, 1));
ret.z = mix(float(part), float(-1024 + part), part_mix) * 0.00195694715;
part = pked >> 30;
part_mix = float(clamp(int(part & 2), 0, 1));
ret.w = mix(float(part), -1.0f, part_mix);
ret.x = orig.x * 0.00195694715;
ret.y = orig.y * 0.00195694715;
ret.z = orig.z * 0.00195694715;
ret.w = max(orig.w, -1.0);
return ret;
}