diff --git a/Runtime/World/CPatterned.cpp b/Runtime/World/CPatterned.cpp index 26832deb4..df5e4c665 100644 --- a/Runtime/World/CPatterned.cpp +++ b/Runtime/World/CPatterned.cpp @@ -1651,11 +1651,11 @@ void CPatterned::PreRender(CStateManager& mgr, const zeus::CFrustum& frustum) { } if (x401_29_laggedBurnDeath) { - int stripedAlpha = 255; + u32 stripedAlpha = 255; if (alpha > 127) { - stripedAlpha = (alpha - 128) * 2; + stripedAlpha = u32(alpha) * 2; } - xb4_drawFlags = CModelFlags(3, 0, 3, zeus::CColor(0.f, float(stripedAlpha * stripedAlpha) / 65025.f)); + xb4_drawFlags = CModelFlags(3, 0, 3, zeus::CColor(0.f, float((stripedAlpha * stripedAlpha) >> 8) / 255.f)); } else if (x401_28_burning) { xb4_drawFlags = CModelFlags(5, 0, 3, zeus::CColor(0.f, 1.f)); } else { @@ -1667,10 +1667,8 @@ void CPatterned::PreRender(CStateManager& mgr, const zeus::CFrustum& frustum) { if (col.r() != 0.f || col.g() != 0.f || col.b() != 0.f) { /* Being damaged */ zeus::CColor col2 = col; - col2.a() = float(alpha) / 255.f; - xb4_drawFlags = CModelFlags(2, 0, 3, zeus::skWhite); - /* Make color additive */ - // TODO xb4_drawFlags.addColor = col2; + col2.a() = 1.f; + xb4_drawFlags = CModelFlags(2, 0, 3, col2); } else { xb4_drawFlags = CModelFlags(0, 0, 3, zeus::skWhite); } diff --git a/aurora/lib/gfx/gx.cpp b/aurora/lib/gfx/gx.cpp index d9407c2e6..26e358d13 100644 --- a/aurora/lib/gfx/gx.cpp +++ b/aurora/lib/gfx/gx.cpp @@ -149,7 +149,6 @@ void load_light(GX::LightID id, const Light& light) noexcept { gx::g_gxState.lig void load_light_ambient(GX::LightID id, const zeus::CColor& ambient) noexcept { gx::g_gxState.lights[std::log2(id)] = ambient; } -void set_light_state(GX::LightMask bits) noexcept { gx::g_gxState.lightState = bits; } namespace gx { using gpu::g_device; @@ -384,8 +383,9 @@ Range build_uniform(const ShaderInfo& info) noexcept { if (g_gxState.colorChannelConfig[i].lightingEnabled) { zeus::CColor ambient = zeus::skClear; int addedLights = 0; - for (int li = 0; li < g_gxState.lightState.size(); ++li) { - if (!g_gxState.lightState.test(li)) { + const auto& lightState = g_gxState.colorChannelState[i].lightState; + for (int li = 0; li < lightState.size(); ++li) { + if (!lightState.test(li)) { continue; } const auto& variant = g_gxState.lights[li]; diff --git a/aurora/lib/gfx/gx.hpp b/aurora/lib/gfx/gx.hpp index d9971f83d..b40e87cce 100644 --- a/aurora/lib/gfx/gx.hpp +++ b/aurora/lib/gfx/gx.hpp @@ -83,7 +83,6 @@ struct GXState { std::array lights; std::array tevStages; std::array textures; - GX::LightMask lightState; bool depthCompare = true; bool depthUpdate = true; bool alphaUpdate = true; diff --git a/aurora/lib/gfx/gx_shader.cpp b/aurora/lib/gfx/gx_shader.cpp index 7ec787e02..db8908e21 100644 --- a/aurora/lib/gfx/gx_shader.cpp +++ b/aurora/lib/gfx/gx_shader.cpp @@ -433,7 +433,7 @@ var v_packed_uvs: Vec2Block; vtxOutAttrs += "\n @builtin(position) pos: vec4;"; vtxXfrAttrsPre += "\n var obj_pos = vec4(v_verts.data[in_pos_nrm_idx[0]].xyz, 1.0);" - "\n var obj_norm = vec4(v_verts.data[in_pos_nrm_idx[1]].xyz, 0.0);" + "\n var obj_norm = vec4(v_norms.data[in_pos_nrm_idx[1]].xyz, 0.0);" "\n var mv_pos = ubuf.mv * obj_pos;" "\n var mv_norm = ubuf.mv_inv * obj_norm;" "\n out.pos = ubuf.proj * mv_pos;"; @@ -555,14 +555,13 @@ var v_packed_uvs: Vec2Block; var dist = length(delta); var delta_norm = delta / dist; var ang_dot = max(dot(delta_norm, light.dir), 0.0); - var lin_att = light.lin_att; - var att = 1.0 / (lin_att.z * dist * dist * lin_att.y * dist + lin_att.x); - var ang_att = light.ang_att; - var ang_att_d = ang_att.z * ang_dot * ang_dot * ang_att.y * ang_dot + ang_att.x; - var this_color = light.color.xyz * ang_att_d * att * max(dot(-delta_norm, mv_norm.xyz), 0.0); -// if (i == 0 && c_traits.shader.world_shadow == 1u) {{ -// // TODO ExtTex0 sample -// }} + var att = 1.0 / (light.lin_att.z * dist * dist + + light.lin_att.y * dist + + light.lin_att.x); + var ang_att = light.ang_att.z * ang_dot * ang_dot + + light.ang_att.y * ang_dot + + light.ang_att.x; + var this_color = light.color.xyz * ang_att * att * max(dot(-delta_norm, mv_norm.xyz), 0.0); lighting = lighting + vec4(this_color, 0.0); }} out.cc{0} = clamp(lighting, vec4(0.0), vec4(1.0));