summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorTony Wasserka <NeoBrainX@gmail.com>2013-10-27 14:43:29 +0100
committerTony Wasserka <NeoBrainX@gmail.com>2014-03-14 22:31:19 +0100
commit3e6efdb53ec30fe65173c20ddbf97798f41ef7a7 (patch)
tree3af0840e291ab7e3bb74d7e5b13f47a6c1a2a3ba /Source/Core
parent387b9bf3c234a7b87a98c2b2066581c4aac13d96 (diff)
LightingShaderGen: Perform more lighting calculations with integers.
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/VideoCommon/LightingShaderGen.h18
-rw-r--r--Source/Core/VideoCommon/PixelShaderGen.cpp3
-rw-r--r--Source/Core/VideoCommon/VertexShaderGen.cpp3
3 files changed, 11 insertions, 13 deletions
diff --git a/Source/Core/VideoCommon/LightingShaderGen.h b/Source/Core/VideoCommon/LightingShaderGen.h
index 578a56d42a..87b4e3c14e 100644
--- a/Source/Core/VideoCommon/LightingShaderGen.h
+++ b/Source/Core/VideoCommon/LightingShaderGen.h
@@ -128,15 +128,15 @@ static void GenerateLightingShader(T& object, LightingUidData& uid_data, int com
if (color.matsource) // from vertex
{
if (components & (VB_HAS_COL0 << j))
- object.Write("mat = %s%d;\n", inColorName, j);
+ object.Write("int4 mat = int4(round(%s%d * 255.0));\n", inColorName, j);
else if (components & VB_HAS_COL0)
- object.Write("mat = %s0;\n", inColorName);
+ object.Write("int4 mat = int4(round(%s0 * 255.0));\n", inColorName);
else
- object.Write("mat = float4(1.0, 1.0, 1.0, 1.0);\n");
+ object.Write("int4 mat = int4(255, 255, 255, 255);\n");
}
else // from color
{
- object.Write("mat = float4(%s[%d])/255.0;\n", materialsName, j+2);
+ object.Write("int4 mat = %s[%d];\n", materialsName, j+2);
}
uid_data.enablelighting |= xfregs.color[j].enablelighting << j;
@@ -172,14 +172,14 @@ static void GenerateLightingShader(T& object, LightingUidData& uid_data, int com
if (alpha.matsource) // from vertex
{
if (components & (VB_HAS_COL0<<j))
- object.Write("mat.w = %s%d.w;\n", inColorName, j);
+ object.Write("mat.w = int(round(%s%d.w * 255.0));\n", inColorName, j);
else if (components & VB_HAS_COL0)
- object.Write("mat.w = %s0.w;\n", inColorName);
- else object.Write("mat.w = 1.0;\n");
+ object.Write("mat.w = int(round(%s0.w * 255.0));\n", inColorName);
+ else object.Write("mat.w = 255;\n");
}
else // from color
{
- object.Write("mat.w = float(%s[%d].w) / 255.0;\n", materialsName, j+2);
+ object.Write("mat.w = %s[%d].w;\n", materialsName, j+2);
}
}
@@ -255,7 +255,7 @@ static void GenerateLightingShader(T& object, LightingUidData& uid_data, int com
GenerateLightShader<T>(object, uid_data, i, lit_index, lightsColName, lightsName, coloralpha);
}
}
- object.Write("%s%d = mat * float4(clamp(lacc, 0, 255)) / 255.0;\n", dest, j);
+ object.Write("%s%d = float4(mat * clamp(lacc, 0, 255) / 255) / 255.0;\n", dest, j);
object.Write("}\n");
}
}
diff --git a/Source/Core/VideoCommon/PixelShaderGen.cpp b/Source/Core/VideoCommon/PixelShaderGen.cpp
index c08386dd59..6baf6d0907 100644
--- a/Source/Core/VideoCommon/PixelShaderGen.cpp
+++ b/Source/Core/VideoCommon/PixelShaderGen.cpp
@@ -413,8 +413,7 @@ static inline void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_T
out.Write("\tfloat3 _norm0 = normalize(Normal.xyz);\n\n");
out.Write("\tfloat3 pos = float3(clipPos.x,clipPos.y,Normal.w);\n");
- out.Write("\tfloat4 mat;\n"
- "\tint4 lacc;\n"
+ out.Write("\tint4 lacc;\n"
"\tfloat3 ldir, h;\n"
"\tfloat dist, dist2, attn;\n");
diff --git a/Source/Core/VideoCommon/VertexShaderGen.cpp b/Source/Core/VideoCommon/VertexShaderGen.cpp
index 860f5f36a6..448b0deb04 100644
--- a/Source/Core/VideoCommon/VertexShaderGen.cpp
+++ b/Source/Core/VideoCommon/VertexShaderGen.cpp
@@ -218,8 +218,7 @@ static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_typ
out.Write("o.pos = float4(dot(" I_PROJECTION"[0], pos), dot(" I_PROJECTION"[1], pos), dot(" I_PROJECTION"[2], pos), dot(" I_PROJECTION"[3], pos));\n");
- out.Write("float4 mat;\n"
- "int4 lacc;\n"
+ out.Write("int4 lacc;\n"
"float3 ldir, h;\n"
"float dist, dist2, attn;\n");