summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/Src/LightingShaderGen.cpp
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2013-04-24 09:21:54 -0400
committerLioncash <mathew1800@gmail.com>2013-04-24 09:21:54 -0400
commit8da425b008b46ef90d649e55c6c0d4a0bc2b556b (patch)
tree5b5fd33dc0274f35625a179adf0a7f93ebadeece /Source/Core/VideoCommon/Src/LightingShaderGen.cpp
parentc118c71eace1aef76687beb2e1fa6517498d84ed (diff)
Formatting cleanup for VideoCommon.
Block braces on new lines. Also killed off trailing whitespace and dangling elses. Spaced some things out to make them more readable (only in places where it looked like a bit of a clusterfuck).
Diffstat (limited to 'Source/Core/VideoCommon/Src/LightingShaderGen.cpp')
-rw-r--r--Source/Core/VideoCommon/Src/LightingShaderGen.cpp51
1 files changed, 35 insertions, 16 deletions
diff --git a/Source/Core/VideoCommon/Src/LightingShaderGen.cpp b/Source/Core/VideoCommon/Src/LightingShaderGen.cpp
index 95de5ebcfa..a9c602ad3d 100644
--- a/Source/Core/VideoCommon/Src/LightingShaderGen.cpp
+++ b/Source/Core/VideoCommon/Src/LightingShaderGen.cpp
@@ -27,12 +27,17 @@ int GetLightingShaderId(u32* out)
char *GenerateLightShader(char *p, int index, const LitChannel& chan, const char* lightsName, int coloralpha)
{
const char* swizzle = "xyzw";
- if (coloralpha == 1 ) swizzle = "xyz";
- else if (coloralpha == 2 ) swizzle = "w";
- if (!(chan.attnfunc & 1)) {
- // atten disabled
- switch (chan.diffusefunc) {
+ if (coloralpha == 1 )
+ swizzle = "xyz";
+ else if (coloralpha == 2 )
+ swizzle = "w";
+
+ if (!(chan.attnfunc & 1))
+ {
+ // attenuation disabled
+ switch (chan.diffusefunc)
+ {
case LIGHTDIF_NONE:
WRITE(p, "lacc.%s += %s[%d].%s;\n", swizzle, lightsName, index * 5, swizzle);
break;
@@ -45,8 +50,8 @@ char *GenerateLightShader(char *p, int index, const LitChannel& chan, const char
default: _assert_(0);
}
}
- else { // spec and spot
-
+ else // spec and spot
+ {
if (chan.attnfunc == 3)
{ // spot
WRITE(p, "ldir = %s[%d + 3].xyz - pos.xyz;\n", lightsName, index * 5);
@@ -74,13 +79,13 @@ char *GenerateLightShader(char *p, int index, const LitChannel& chan, const char
swizzle,
chan.diffusefunc != LIGHTDIF_SIGN ? "max(0.0f," :"(",
lightsName,
- index * 5,
+ index * 5,
swizzle);
break;
default: _assert_(0);
}
}
- WRITE(p, "\n");
+ WRITE(p, "\n");
return p;
}
@@ -98,7 +103,8 @@ char *GenerateLightingShader(char *p, int components, const char* materialsName,
WRITE(p, "{\n");
- if (color.matsource) {// from vertex
+ if (color.matsource) // from vertex
+ {
if (components & (VB_HAS_COL0 << j))
WRITE(p, "mat = %s%d;\n", inColorName, j);
else if (components & VB_HAS_COL0)
@@ -107,10 +113,14 @@ char *GenerateLightingShader(char *p, int components, const char* materialsName,
WRITE(p, "mat = float4(1.0f, 1.0f, 1.0f, 1.0f);\n");
}
else // from color
+ {
WRITE(p, "mat = %s[%d];\n", materialsName, j+2);
+ }
- if (color.enablelighting) {
- if (color.ambsource) { // from vertex
+ if (color.enablelighting)
+ {
+ if (color.ambsource) // from vertex
+ {
if (components & (VB_HAS_COL0<<j) )
WRITE(p, "lacc = %s%d;\n", inColorName, j);
else if (components & VB_HAS_COL0 )
@@ -119,7 +129,9 @@ char *GenerateLightingShader(char *p, int components, const char* materialsName,
WRITE(p, "lacc = float4(0.0f, 0.0f, 0.0f, 0.0f);\n");
}
else // from color
+ {
WRITE(p, "lacc = %s[%d];\n", materialsName, j);
+ }
}
else
{
@@ -127,8 +139,10 @@ char *GenerateLightingShader(char *p, int components, const char* materialsName,
}
// check if alpha is different
- if (alpha.matsource != color.matsource) {
- if (alpha.matsource) {// from vertex
+ if (alpha.matsource != color.matsource)
+ {
+ if (alpha.matsource) // from vertex
+ {
if (components & (VB_HAS_COL0<<j))
WRITE(p, "mat.w = %s%d.w;\n", inColorName, j);
else if (components & VB_HAS_COL0)
@@ -136,12 +150,15 @@ char *GenerateLightingShader(char *p, int components, const char* materialsName,
else WRITE(p, "mat.w = 1.0f;\n");
}
else // from color
+ {
WRITE(p, "mat.w = %s[%d].w;\n", materialsName, j+2);
+ }
}
if (alpha.enablelighting)
{
- if (alpha.ambsource) {// from vertex
+ if (alpha.ambsource) // from vertex
+ {
if (components & (VB_HAS_COL0<<j) )
WRITE(p, "lacc.w = %s%d.w;\n", inColorName, j);
else if (components & VB_HAS_COL0 )
@@ -150,12 +167,14 @@ char *GenerateLightingShader(char *p, int components, const char* materialsName,
WRITE(p, "lacc.w = 0.0f;\n");
}
else // from color
+ {
WRITE(p, "lacc.w = %s[%d].w;\n", materialsName, j);
+ }
}
else
{
WRITE(p, "lacc.w = 1.0f;\n");
- }
+ }
if(color.enablelighting && alpha.enablelighting)
{