softgpu: Retain floats in diffuse/specular.

This seems to be a bit more accurate.  Color blending seems correct now,
but the factors and especially pow results are off.

Also, normalize normal to 0, 0, 1, which seems to match results better.
This commit is contained in:
Unknown W. Brackets committed 2022-01-06 21:52:31 -08:00
1 parent bd354164bc
commit ce8a49b1c1
2 files changed
+6 -4

No files matched your search

+5 -3
View File
@@ -131,7 +131,9 @@ void Process(VertexData& vertex, bool hasColor) {
}
if (diffuse_factor > 0.0f) {
int diffuse_attspot = (int)ceilf(attspot * diffuse_factor + 1);
int diffuse_attspot = (int)ceilf(256 * 2 * att * spot * diffuse_factor + 1);
if (diffuse_attspot > 512)
diffuse_attspot = 512;
Vec4<int> ldc = Vec4<int>::FromRGBA(gstate.getDiffuseColor(light));
Vec4<int> mdc = (materialupdate & 2) ? vertex.color0 : Vec4<int>::FromRGBA(gstate.getMaterialDiffuse());
Vec4<int> ldiffuse = ((ldc * 2 + ones) * (mdc * 2 + ones) * diffuse_attspot) / (1024 * 512);
@@ -145,8 +147,8 @@ void Process(VertexData& vertex, bool hasColor) {
float k = gstate.getMaterialSpecularCoef();
specular_factor = pspLightPow(specular_factor, k);
if (specular_factor > 0.f) {
int specular_attspot = (int)ceilf(attspot * specular_factor + 1);
if (specular_factor > 0.0f) {
int specular_attspot = (int)ceilf(256 * 2 * att * spot * specular_factor + 1);
if (specular_attspot > 512)
specular_attspot = 512;
Vec4<int> lsc = Vec4<int>::FromRGBA(gstate.getSpecularColor(light));
+1 -1
View File
@@ -227,7 +227,7 @@ VertexData TransformUnit::ReadVertex(VertexReader &vreader, bool &outside_range_
vertex.screenpos = ClipToScreenInternal(vertex.clippos, &outside_range_flag);
if (vreader.hasNormal()) {
vertex.worldnormal = TransformUnit::ModelToWorldNormal(vertex.normal).Normalized(cpu_info.bSSE4_1);
vertex.worldnormal = TransformUnit::ModelToWorldNormal(vertex.normal).NormalizedOr001(cpu_info.bSSE4_1);
} else {
vertex.worldnormal = Vec3<float>(0.0f, 0.0f, 1.0f);
}