summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/PixelShaderGen.cpp
diff options
context:
space:
mode:
authorJMC47 <JMC4789@gmail.com>2025-03-15 17:26:32 -0400
committerGitHub <noreply@github.com>2025-03-15 17:26:32 -0400
commite3deb14156cee95a9f4119aa11857731f3687ad2 (patch)
tree52b49aa074862d6c8185b7cd7b17a8afe1a969f0 /Source/Core/VideoCommon/PixelShaderGen.cpp
parent225039f742d14eacd704490bb1a66dc119a91320 (diff)
parent15372dc835a2c387f8f566fa86d6cc60b2534a7d (diff)
Merge pull request #13347 from iwubcode/custom_shader_overhaul_lighting
VideoCommon: move lighting shader logic to callable functions
Diffstat (limited to 'Source/Core/VideoCommon/PixelShaderGen.cpp')
-rw-r--r--Source/Core/VideoCommon/PixelShaderGen.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/Source/Core/VideoCommon/PixelShaderGen.cpp b/Source/Core/VideoCommon/PixelShaderGen.cpp
index 9fafd630b9..1b9e491a40 100644
--- a/Source/Core/VideoCommon/PixelShaderGen.cpp
+++ b/Source/Core/VideoCommon/PixelShaderGen.cpp
@@ -1057,6 +1057,11 @@ ShaderCode GeneratePixelShaderCode(APIType api_type, const ShaderHostConfig& hos
}
}
+ if (per_pixel_lighting)
+ {
+ GenerateLightingShaderHeader(out, uid_data->lighting);
+ }
+
out.Write("void main()\n{{\n");
out.Write("\tfloat4 rawpos = gl_FragCoord;\n");
@@ -1124,16 +1129,15 @@ ShaderCode GeneratePixelShaderCode(APIType api_type, const ShaderHostConfig& hos
out.Write("\tfloat3 _normal = normalize(Normal.xyz);\n\n"
"\tfloat3 pos = WorldPos;\n");
- out.Write("\tint4 lacc;\n"
- "\tfloat3 ldir, h, cosAttn, distAttn;\n"
- "\tfloat dist, dist2, attn;\n");
-
// TODO: Our current constant usage code isn't able to handle more than one buffer.
// So we can't mark the VS constant as used here. But keep them here as reference.
// out.SetConstantsUsed(C_PLIGHT_COLORS, C_PLIGHT_COLORS+7); // TODO: Can be optimized further
// out.SetConstantsUsed(C_PLIGHTS, C_PLIGHTS+31); // TODO: Can be optimized further
// out.SetConstantsUsed(C_PMATERIALS, C_PMATERIALS+3);
- GenerateLightingShaderCode(out, uid_data->lighting, "colors_", "col");
+ for (u32 chan = 0; chan < uid_data->numColorChans; chan++)
+ {
+ out.Write("\tcol{0} = dolphin_calculate_lighting_chn{0}(colors_{0}, pos, _normal);\n", chan);
+ }
// The number of colors available to TEV is determined by numColorChans.
// Normally this is performed in the vertex shader after lighting, but with per-pixel lighting,
// we need to perform it here. (It needs to be done after lighting, as what was originally