From 3a4308e17378083bc16c46eb6492b4742decb5dd Mon Sep 17 00:00:00 2001 From: Luke Street Date: Wed, 9 Mar 2022 00:44:52 -0500 Subject: [PATCH] aurora: Move lighting func to SRC_REG only --- aurora/lib/gfx/gx_shader.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/aurora/lib/gfx/gx_shader.cpp b/aurora/lib/gfx/gx_shader.cpp index 182dd137a..f2f6e354a 100644 --- a/aurora/lib/gfx/gx_shader.cpp +++ b/aurora/lib/gfx/gx_shader.cpp @@ -541,8 +541,21 @@ var v_packed_uvs: Vec2Block; info.uniformSize += 32; vtxOutAttrs += fmt::format(FMT_STRING("\n @location({}) cc{}: vec4;"), locIdx++, i); - // TODO only perform lighting on CC0 when enabled - vtxXfrAttrs += fmt::format(FMT_STRING(R"""( + + if (config.channelMatSrcs[i] == GX::SRC_VTX) { + if (config.denormalizedVertexAttributes) { + if (!info.usesVtxColor) { + vtxInAttrs += fmt::format(FMT_STRING("\n , @location({}) in_clr: vec4"), locIdx); + vtxXfrAttrs += fmt::format(FMT_STRING("\n out.cc{} = in_clr;"), i); + } + fragmentFnPre += fmt::format(FMT_STRING("\n var rast{0} = in.cc{0};"), i); + } else { + Log.report(logvisor::Fatal, FMT_STRING("SRC_VTX unsupported with normalized vertex attributes")); + } + info.usesVtxColor = true; + } else { + // TODO only perform lighting on CC0 when enabled + vtxXfrAttrs += fmt::format(FMT_STRING(R"""( {{ var lighting = ubuf.lighting_ambient + ubuf.cc{0}_amb; for (var i = 0; i < {1}; i = i + 1) {{ @@ -563,19 +576,6 @@ var v_packed_uvs: Vec2Block; }} out.cc{0} = clamp(lighting, vec4(0.0), vec4(1.0)); }})"""), i, MaxLights); - - if (config.channelMatSrcs[i] == GX::SRC_VTX) { - if (config.denormalizedVertexAttributes) { - if (!info.usesVtxColor) { - vtxInAttrs += fmt::format(FMT_STRING("\n , @location({}) in_clr: vec4"), locIdx); - vtxXfrAttrs += fmt::format(FMT_STRING("\n out.cc{} = in_clr;"), i); - } - fragmentFnPre += fmt::format(FMT_STRING("\n var rast{0} = in.cc{0};"), i); - } else { - Log.report(logvisor::Fatal, FMT_STRING("SRC_VTX unsupported with normalized vertex attributes")); - } - info.usesVtxColor = true; - } else { fragmentFnPre += fmt::format(FMT_STRING("\n var rast{0} = in.cc{0};"), i); } }