CPhazonBeam::CPhazonBeam(CAssetId characterId, EWeaponType type, TUniqueId playerId, EMaterialTypes playerMaterial, const zeus::CVector3f& scale) : CGunWeapon(characterId, type, playerId, playerMaterial, scale) , x238_aaBoxScale(zeus::CVector3f(-0.14664599f, 0.f, -0.14909725f) * scale.y(), zeus::CVector3f(0.14664599f, 0.64619601f, 0.14909725f) * scale.y()) , x250_aaBoxTranslate(zeus::CVector3f(-0.0625f, 0.f, -0.09375f) * scale.y(), zeus::CVector3f(0.0625f, -0.25f, 0.09375f) * scale.y()) { x21c_phazonVeins = g_SimplePool->GetObj("PhazonVeins"); x228_phazon2nd1 = g_SimplePool->GetObj("Phazon2nd_1"); x274_24_loaded = false; x274_25_clipWipeActive = true; x274_26_veinsAlphaActive = false; x274_27_phazonVeinsIdx = false; m_aaboxShaderScale.setAABB(x238_aaBoxScale); m_aaboxShaderTranslate.setAABB(x250_aaBoxTranslate); }
void CSpaceWarpFilter::draw(const zeus::CVector3f& pt) { /* Indirect coords are full-texture sampling when warp is completely in viewport */ m_uniform.m_indXf[1][1] = 1.f; m_uniform.m_indXf[0][0] = 1.f; m_uniform.m_indXf[2][0] = 0.f; m_uniform.m_indXf[2][1] = 0.f; /* Warp effect is fixed at 192x192 rectangle in original (1/2.5 viewport height) */ float aspect = CGraphics::g_CroppedViewport.xc_width / float(CGraphics::g_CroppedViewport.x10_height); m_uniform.m_matrix[1][1] = 1.f / 2.5f; m_uniform.m_matrix[0][0] = m_uniform.m_matrix[1][1] / aspect; SClipScreenRect clipRect = {}; clipRect.x4_left = ((pt[0] - m_uniform.m_matrix[0][0]) / 2.f + 0.5f) * CGraphics::g_CroppedViewport.xc_width; if (clipRect.x4_left >= CGraphics::g_CroppedViewport.xc_width) return; clipRect.x8_top = ((pt[1] - m_uniform.m_matrix[1][1]) / 2.f + 0.5f) * CGraphics::g_CroppedViewport.x10_height; if (clipRect.x8_top >= CGraphics::g_CroppedViewport.x10_height) return; clipRect.xc_width = CGraphics::g_CroppedViewport.xc_width * m_uniform.m_matrix[0][0]; if (clipRect.x4_left + clipRect.xc_width <= 0) return; clipRect.x10_height = CGraphics::g_CroppedViewport.x10_height * m_uniform.m_matrix[1][1]; if (clipRect.x8_top + clipRect.x10_height <= 0) return; float oldW = clipRect.xc_width; if (clipRect.x4_left < 0) { clipRect.xc_width += clipRect.x4_left; m_uniform.m_indXf[0][0] = clipRect.xc_width / oldW; m_uniform.m_indXf[2][0] = -clipRect.x4_left / oldW; clipRect.x4_left = 0; } float oldH = clipRect.x10_height; if (clipRect.x8_top < 0) { clipRect.x10_height += clipRect.x8_top; m_uniform.m_indXf[1][1] = clipRect.x10_height / oldH; m_uniform.m_indXf[2][1] = -clipRect.x8_top / oldH; clipRect.x8_top = 0; } float tmp = clipRect.x4_left + clipRect.xc_width; if (tmp >= CGraphics::g_CroppedViewport.xc_width) { clipRect.xc_width = CGraphics::g_CroppedViewport.xc_width - clipRect.x4_left; m_uniform.m_indXf[0][0] = clipRect.xc_width / oldW; } tmp = clipRect.x8_top + clipRect.x10_height; if (tmp >= CGraphics::g_CroppedViewport.x10_height) { clipRect.x10_height = CGraphics::g_CroppedViewport.x10_height - clipRect.x8_top; m_uniform.m_indXf[1][1] = clipRect.x10_height / oldH; } /* Transform UV coordinates of rectangle within viewport and sampled scene texels (clamped to viewport bounds) */ zeus::CVector2f vp{float(CGraphics::g_CroppedViewport.xc_width), float(CGraphics::g_CroppedViewport.x10_height)}; m_uniform.m_matrix[0][0] = clipRect.xc_width / vp.x(); m_uniform.m_matrix[1][1] = clipRect.x10_height / vp.y(); m_uniform.m_matrix[3][0] = pt.x() + (1.f / vp.x()); m_uniform.m_matrix[3][1] = pt.y() + (1.f / vp.y()); if (CGraphics::g_BooPlatform == boo::IGraphicsDataFactory::Platform::OpenGL) { m_uniform.m_matrix[3][2] = pt.z() * 2.f - 1.f; } else { m_uniform.m_matrix[1][1] *= -1.f; m_uniform.m_matrix[3][1] *= -1.f; m_uniform.m_matrix[3][2] = pt.z(); } if (clipRect.x4_left) { clipRect.x4_left -= 1; clipRect.xc_width += 1; } if (clipRect.x8_top) { clipRect.x8_top -= 1; clipRect.x10_height += 1; } if (clipRect.x4_left + clipRect.xc_width < CGraphics::g_CroppedViewport.xc_width) clipRect.xc_width += 1; if (clipRect.x8_top + clipRect.x10_height < CGraphics::g_CroppedViewport.x10_height) clipRect.x10_height += 1; clipRect.x4_left += CGraphics::g_CroppedViewport.x4_left; clipRect.x8_top += CGraphics::g_CroppedViewport.x8_top; clipRect.x8_top = g_Viewport.xc_height - clipRect.x10_height - clipRect.x8_top; CGraphics::ResolveSpareTexture(clipRect); m_uniform.m_strength.x() = m_uniform.m_matrix[0][0] * m_strength * 0.5f * (clipRect.x10_height / float(clipRect.xc_width)); m_uniform.m_strength.y() = m_uniform.m_matrix[1][1] * m_strength * 0.5f; m_uniBuf->load(&m_uniform, sizeof(m_uniform)); CGraphics::SetShaderDataBinding(m_dataBind); CGraphics::DrawArray(0, 4); }