From e263345b0a8e9c82b3e3c4efef6440883f597494 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Mon, 12 Feb 2018 12:27:40 -1000 Subject: [PATCH] Fix ShotSmoke effect --- Runtime/Graphics/CGraphics.cpp | 6 +++--- Runtime/Graphics/Shaders/CElementGenShadersGLSL.cpp | 5 ++--- Runtime/Graphics/Shaders/CElementGenShadersHLSL.cpp | 8 +++++--- Runtime/Graphics/Shaders/CElementGenShadersMetal.cpp | 8 +++++--- Runtime/Weapon/CGunWeapon.cpp | 2 +- Runtime/Weapon/CPowerBeam.cpp | 3 ++- 6 files changed, 18 insertions(+), 14 deletions(-) diff --git a/Runtime/Graphics/CGraphics.cpp b/Runtime/Graphics/CGraphics.cpp index d30850ea5..92279b5ff 100644 --- a/Runtime/Graphics/CGraphics.cpp +++ b/Runtime/Graphics/CGraphics.cpp @@ -386,7 +386,7 @@ zeus::CVector2i CGraphics::ProjectPoint(const zeus::CVector3f& point) { zeus::CVector3f projPt = GetPerspectiveProjectionMatrix(false).multiplyOneOverW(point); return {int(projPt.x * g_Viewport.x10_halfWidth) + int(g_Viewport.x10_halfWidth), - int(g_Viewport.x14_halfHeight) - (int(projPt.y * g_Viewport.x14_halfHeight) + + int(g_Viewport.xc_height) - (int(projPt.y * g_Viewport.x14_halfHeight) + int(g_Viewport.x14_halfHeight))}; } @@ -406,9 +406,9 @@ SClipScreenRect CGraphics::ClipScreenRectFromVS(const zeus::CVector3f& p1, if (p2.x == 0.f && p2.y == 0.f && p2.z == 0.f) return {}; - if (p1.y < GetProjectionState().x14_near || p2.y < GetProjectionState().x14_near) + if (-p1.z < GetProjectionState().x14_near || -p2.z < GetProjectionState().x14_near) return {}; - if (p1.y > GetProjectionState().x18_far || p2.y > GetProjectionState().x18_far) + if (-p1.z > GetProjectionState().x18_far || -p2.z > GetProjectionState().x18_far) return {}; zeus::CVector2i sp1 = ProjectPoint(p1); diff --git a/Runtime/Graphics/Shaders/CElementGenShadersGLSL.cpp b/Runtime/Graphics/Shaders/CElementGenShadersGLSL.cpp index 80528bb76..460e678b8 100644 --- a/Runtime/Graphics/Shaders/CElementGenShadersGLSL.cpp +++ b/Runtime/Graphics/Shaders/CElementGenShadersGLSL.cpp @@ -124,8 +124,7 @@ BOO_GLSL_BINDING_HEAD " vec2 tindTexel = texture(tindMap, vtf.uvTind).zw;\n" " vec4 sceneTexel = texture(sceneMap, mix(vtf.uvScene.xy, vtf.uvScene.zw, tindTexel));\n" " vec4 texrTexel = texture(texrMap, vtf.uvTexr);\n" -" colorOut = vtf.color * sceneTexel + texrTexel;\n" -" colorOut.a = vtf.color.a * texrTexel.a;\n" +" colorOut = vtf.color * vec4(sceneTexel.rgb, 1.0) + texrTexel;\n" "}\n"; static const char* FS_GLSL_CINDTEX = @@ -148,7 +147,7 @@ BOO_GLSL_BINDING_HEAD "{\n" " vec2 tindTexel = texture(tindMap, vtf.uvTind).zw;\n" " vec4 sceneTexel = texture(sceneMap, mix(vtf.uvScene.xy, vtf.uvScene.zw, tindTexel));\n" -" colorOut = vtf.color * sceneTexel * texture(texrMap, vtf.uvTexr);\n" +" colorOut = vtf.color * vec4(sceneTexel.rgb, 1.0) * texture(texrMap, vtf.uvTexr);\n" "}\n"; static const char* VS_GLSL_NOTEX = diff --git a/Runtime/Graphics/Shaders/CElementGenShadersHLSL.cpp b/Runtime/Graphics/Shaders/CElementGenShadersHLSL.cpp index 864a3fe62..792dd686c 100644 --- a/Runtime/Graphics/Shaders/CElementGenShadersHLSL.cpp +++ b/Runtime/Graphics/Shaders/CElementGenShadersHLSL.cpp @@ -96,7 +96,9 @@ static const char* VS_HLSL_INDTEX = "{\n" " VertToFrag vtf;\n" " vtf.color = v.colorIn * moduColor;\n" -" vtf.uvScene = v.uvsInScene * float4(1.0, -1.0, 1.0, -1.0);\n" +" vtf.uvScene = v.uvsInScene;\n" +" vtf.uvScene.y = 1.0 - vtf.uvScene.y;\n" +" vtf.uvScene.w = 1.0 - vtf.uvScene.w;\n" " vtf.uvTexr = v.uvsInTexrTind[vertId].xy;\n" " vtf.uvTind = v.uvsInTexrTind[vertId].zw;\n" " vtf.position = mul(mvp, v.posIn[vertId]);\n" @@ -122,7 +124,7 @@ static const char* FS_HLSL_INDTEX = " float2 tindTexel = tex2.Sample(samp, vtf.uvTind).zw;\n" " float4 sceneTexel = tex1.Sample(samp, lerp(vtf.uvScene.xy, vtf.uvScene.zw, tindTexel));\n" " float4 texrTexel = tex0.Sample(samp, vtf.uvTexr);\n" -" float4 colorOut = vtf.color * sceneTexel + texrTexel;\n" +" float4 colorOut = vtf.color * float4(sceneTexel.rgb, 1.0) + texrTexel;\n" " colorOut.a = vtf.color.a * texrTexel.a;\n" " return colorOut;\n" "}\n"; @@ -145,7 +147,7 @@ static const char* FS_HLSL_CINDTEX = "{\n" " float2 tindTexel = tex2.Sample(samp, vtf.uvTind).ba;\n" " float4 sceneTexel = tex1.Sample(samp, lerp(vtf.uvScene.xy, vtf.uvScene.zw, tindTexel));\n" -" return vtf.color * sceneTexel * tex0.Sample(samp, vtf.uvTexr);\n" +" return vtf.color * float4(sceneTexel.rgb, 1.0) * tex0.Sample(samp, vtf.uvTexr);\n" "}\n"; static const char* VS_HLSL_NOTEX = diff --git a/Runtime/Graphics/Shaders/CElementGenShadersMetal.cpp b/Runtime/Graphics/Shaders/CElementGenShadersMetal.cpp index 95ebcb117..35d9ae6ed 100644 --- a/Runtime/Graphics/Shaders/CElementGenShadersMetal.cpp +++ b/Runtime/Graphics/Shaders/CElementGenShadersMetal.cpp @@ -107,7 +107,9 @@ static const char* VS_METAL_INDTEX = " VertToFrag vtf;\n" " constant VertData& v = va[instId];\n" " vtf.color = v.colorIn * particle.moduColor;\n" -" vtf.uvScene = v.uvsInScene * float4(1.0, -1.0, 1.0, -1.0);\n" +" vtf.uvScene = v.uvsInScene;\n" +" vtf.uvScene.y = 1.0 - vtf.uvScene.y;\n" +" vtf.uvScene.w = 1.0 - vtf.uvScene.w;\n" " vtf.uvTexr = v.uvsInTexrTind[vertId].xy;\n" " vtf.uvTind = v.uvsInTexrTind[vertId].zw;\n" " vtf.position = particle.mvp * v.posIn[vertId];\n" @@ -135,7 +137,7 @@ static const char* FS_METAL_INDTEX = " float2 tindTexel = tex2.sample(samp, vtf.uvTind).ba;\n" " float4 sceneTexel = tex1.sample(samp, mix(vtf.uvScene.xy, vtf.uvScene.zw, tindTexel));\n" " float4 texrTexel = tex0.sample(samp, vtf.uvTexr);\n" -" float4 colr = vtf.color * sceneTexel + texrTexel;\n" +" float4 colr = vtf.color * float4(sceneTexel.rgb, 1.0) + texrTexel;\n" " return float4(colr.rgb, vtf.color.a * texrTexel.a);" "}\n"; @@ -159,7 +161,7 @@ static const char* FS_METAL_CINDTEX = "{\n" " float2 tindTexel = tex2.sample(samp, vtf.uvTind).ba;\n" " float4 sceneTexel = tex1.sample(samp, mix(vtf.uvScene.xy, vtf.uvScene.zw, tindTexel));\n" -" return vtf.color * sceneTexel * tex0.sample(samp, vtf.uvTexr);\n" +" return vtf.color * float4(sceneTexel.rgb, 1.0) * tex0.sample(samp, vtf.uvTexr);\n" "}\n"; static const char* VS_METAL_NOTEX = diff --git a/Runtime/Weapon/CGunWeapon.cpp b/Runtime/Weapon/CGunWeapon.cpp index 3fcc330c3..d0cf8de52 100644 --- a/Runtime/Weapon/CGunWeapon.cpp +++ b/Runtime/Weapon/CGunWeapon.cpp @@ -117,7 +117,7 @@ void CGunWeapon::AllocResPools(CPlayerState::EBeamId beam) for (int i=0 ; i<2 ; ++i) { x16c_muzzleEffects.push_back(g_SimplePool->GetObj(muzzleNames[i])); - x144_weapons.push_back(g_SimplePool->GetObj(SObjectTag{FOURCC('WPSC'), wPair[1]})); + x144_weapons.push_back(g_SimplePool->GetObj(SObjectTag{FOURCC('WPSC'), wPair[i]})); x188_frozenEffects.push_back(g_SimplePool->GetObj(frozenNames[i])); } } diff --git a/Runtime/Weapon/CPowerBeam.cpp b/Runtime/Weapon/CPowerBeam.cpp index 902a96e67..e77995104 100644 --- a/Runtime/Weapon/CPowerBeam.cpp +++ b/Runtime/Weapon/CPowerBeam.cpp @@ -59,7 +59,8 @@ void CPowerBeam::UpdateGunFx(bool shotSmoke, float dt, const CStateManager& mgr, case ESmokeState::Done: if (x234_shotSmokeGen) { - x234_shotSmokeGen->SetGlobalTranslation(x10_solidModelData->GetScaledLocatorTransform("LBEAM").origin); + zeus::CTransform locator = x10_solidModelData->GetScaledLocatorTransform("LBEAM"); + x234_shotSmokeGen->SetGlobalTranslation(locator.origin); x234_shotSmokeGen->Update(dt); if (x240_smokeState == ESmokeState::Done && x234_shotSmokeGen->GetSystemCount() == 0) x240_smokeState = ESmokeState::Inactive;