Metal API adjustments; MSAA support

This commit is contained in:
Jack Andersen 2018-01-06 19:19:49 -10:00
parent fd33d05fc0
commit 4e5c991424
45 changed files with 327 additions and 281 deletions

View File

@ -196,7 +196,7 @@ void ViewManager::pushRecentFile(hecl::SystemStringView path)
void ViewManager::init(boo::IApplication* app)
{
m_mainWindow = app->newWindow(_S("URDE"), 1);
m_mainWindow = app->newWindow(_S("URDE"));
m_mainWindow->showWindow();
m_mainWindow->setWaitCursor(true);

View File

@ -57,6 +57,8 @@ struct Application : boo::IApplicationCallback
hecl::Runtime::FileStoreManager m_fileMgr;
hecl::CVarManager m_cvarManager;
std::unique_ptr<ViewManager> m_viewManager;
hecl::CVar* m_drawSamples;
hecl::CVar* m_texAnisotropy;
bool m_running = true;
@ -64,6 +66,13 @@ struct Application : boo::IApplicationCallback
m_fileMgr(_S("urde")),
m_cvarManager(m_fileMgr)
{
m_drawSamples = m_cvarManager.findOrMakeCVar("drawSamples"sv,
"Number of MSAA samples to use for render targets"sv,
1, hecl::CVar::EFlags::System | hecl::CVar::EFlags::Archive);
m_texAnisotropy = m_cvarManager.findOrMakeCVar("texAnisotropy"sv,
"Number of anisotropic samples to use for sampling textures"sv,
1, hecl::CVar::EFlags::System | hecl::CVar::EFlags::Archive);
m_viewManager = std::make_unique<ViewManager>(m_fileMgr, m_cvarManager);
}
@ -119,6 +128,16 @@ struct Application : boo::IApplicationCallback
Log.report(logvisor::Info, "CPU Vendor: %s", cpuInf.cpuVendor);
Log.report(logvisor::Info, _S("CPU Features: %s"), CPUFeatureString(cpuInf).c_str());
}
uint32_t getSamples()
{
return uint32_t(std::max(1, m_drawSamples->toInteger()));
}
uint32_t getAnisotropy()
{
return uint32_t(std::max(1, m_texAnisotropy->toInteger()));
}
};
}
@ -185,7 +204,7 @@ int main(int argc, const boo::SystemChar** argv)
urde::Application appCb;
int ret = boo::ApplicationRun(boo::IApplication::EPlatformType::Auto,
appCb, _S("urde"), _S("URDE"), argc, argv, false);
appCb, _S("urde"), _S("URDE"), argc, argv, appCb.getSamples(), appCb.getAnisotropy(), false);
printf("IM DYING!!\n");
return ret;
}

View File

@ -582,13 +582,13 @@ zeus::CFrustum CStateManager::SetupViewForDraw(const SViewport& vp) const
zeus::CTransform camXf = x870_cameraManager->GetCurrentCameraTransform(*this);
g_Renderer->SetWorldViewpoint(camXf);
CBooModel::SetNewPlayerPositionAndTime(x84c_player->GetTranslation());
int vpWidth = xf2c_viewportScale.x * vp.x8_width;
int vpHeight = xf2c_viewportScale.y * vp.xc_height;
int vpLeft = (vp.x8_width - vpWidth) / 2 + vp.x0_left;
int vpTop = (vp.xc_height - vpHeight) / 2 + vp.x4_top;
g_Renderer->SetViewport(vpLeft, vpTop, vpWidth, vpHeight);
//int vpWidth = xf2c_viewportScale.x * vp.x8_width;
//int vpHeight = xf2c_viewportScale.y * vp.xc_height;
//int vpLeft = (vp.x8_width - vpWidth) / 2 + vp.x0_left;
//int vpTop = (vp.xc_height - vpHeight) / 2 + vp.x4_top;
//g_Renderer->SetViewport(vpLeft, vpTop, vpWidth, vpHeight);
CGraphics::SetDepthRange(DEPTH_WORLD, DEPTH_FAR);
float fov = std::atan(std::tan(zeus::degToRad(cam->GetFov()) * 0.5f) * xf2c_viewportScale.y * 2.f);
float fov = std::atan(std::tan(zeus::degToRad(cam->GetFov()) * 0.5f) * (1.f / xf2c_viewportScale.y) * 2.f);
float width = xf2c_viewportScale.x * vp.x8_width;
float height = xf2c_viewportScale.y * vp.xc_height;
g_Renderer->SetPerspective(zeus::radToDeg(fov), width, height,

View File

@ -72,31 +72,30 @@ zeus::CVector3f CGameCamera::ConvertToScreenSpace(const zeus::CVector3f& v) cons
return mtx.multiplyOneOverW(rVec);
}
zeus::CTransform CGameCamera::ValidateCameraTransform(const zeus::CTransform& a, const zeus::CTransform& b)
zeus::CTransform CGameCamera::ValidateCameraTransform(const zeus::CTransform& newXf, const zeus::CTransform& oldXf)
{
zeus::CTransform xfCpy(a);
constexpr double epsilon = FLT_EPSILON * 1000.f;
if ((a.rightVector().magnitude() - 1.f) >= epsilon || (a.frontVector().magnitude() - 1.f) >= epsilon ||
(a.upVector().magnitude() - 1.f) >= epsilon)
zeus::CTransform xfCpy(newXf);
if (!zeus::close_enough(newXf.rightVector().magnitude(), 1.f) ||
!zeus::close_enough(newXf.frontVector().magnitude(), 1.f) ||
!zeus::close_enough(newXf.upVector().magnitude(), 1.f))
xfCpy.orthonormalize();
float f2 = a.basis[1].dot(zeus::CVector3f::skUp);
if (std::fabs(f2) > 1.0f)
f2 = (f2 >= -0.f ? -1.0f : 1.0f);
float f2 = zeus::clamp(-1.f, newXf.frontVector().dot(zeus::CVector3f::skUp), 1.f);
if (std::fabs(f2) > 0.999f)
xfCpy = b;
xfCpy = oldXf;
if (xfCpy.upVector().z < -0.2f)
xfCpy = zeus::CQuaternion::fromAxisAngle(xfCpy.frontVector(), M_PIF).toTransform() * xfCpy;
if (std::fabs(xfCpy.rightVector().z) >= 0.000009f && std::fabs(xfCpy.upVector().z) > 0.000009f)
if (!zeus::close_enough(xfCpy.rightVector().z, 0.f) &&
!zeus::close_enough(xfCpy.upVector().z, 0.f))
{
if (xfCpy.frontVector().canBeNormalized())
xfCpy = zeus::lookAt(zeus::CUnitVector3f(xfCpy.frontVector(), true), zeus::CVector3f::skZero);
xfCpy = zeus::lookAt(zeus::CVector3f::skZero, xfCpy.frontVector());
else
xfCpy = b;
xfCpy = oldXf;
}
xfCpy.origin = a.origin;
xfCpy.origin = newXf.origin;
return xfCpy;
}

View File

@ -101,8 +101,10 @@ CSkinnedModel& CModelData::PickAnimatedModel(EWhichModel which) const
{
case EWhichModel::XRay:
ret = x10_animData->xf4_xrayModel.get();
break;
case EWhichModel::Thermal:
ret = x10_animData->xf8_infraModel.get();
break;
default: break;
}
if (ret)
@ -117,11 +119,13 @@ const std::unique_ptr<CBooModel>& CModelData::PickStaticModel(EWhichModel which)
{
case EWhichModel::XRay:
ret = &m_xrayModelInst;
break;
case EWhichModel::Thermal:
ret = &m_infraModelInst;
break;
default: break;
}
if (ret)
if (ret && *ret)
return *ret;
return m_normalModelInst;
}

View File

@ -28,7 +28,6 @@ zeus::CVector3f CGraphics::g_ViewPoint;
zeus::CTransform CGraphics::g_GXViewPointMatrix;
zeus::CTransform CGraphics::g_CameraMatrix;
SClipScreenRect CGraphics::g_CroppedViewport;
unsigned int CGraphics::g_ViewportSamples = 1;
bool CGraphics::g_IsGXModelMatrixIdentity = true;
SViewport g_Viewport = {0, 0, 640, 480, 640 / 2.f, 480 / 2.f};
u32 CGraphics::g_FrameCounter = 0;

View File

@ -268,7 +268,6 @@ public:
static zeus::CTransform g_GXViewPointMatrix;
static zeus::CTransform g_CameraMatrix;
static SClipScreenRect g_CroppedViewport;
static unsigned int g_ViewportSamples;
static bool g_IsGXModelMatrixIdentity;
static void DisableAllLights();

View File

@ -129,14 +129,14 @@ SPECTER_METAL_VIEW_VERT_BLOCK
static const char* FS_METAL_YUV =
"#include <metal_stdlib>\n"
"using namespace metal;\n"
"constexpr sampler samp(address::repeat, filter::linear);\n"
"struct VertToFrag\n"
"{\n"
" float4 position [[ position ]];\n"
" float4 color;\n"
" float2 uv;\n"
"};\n"
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]],"
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]],\n"
" sampler samp [[ sampler(0) ]],\n"
" texture2d<float> tex0 [[ texture(0) ]],\n"
" texture2d<float> tex1 [[ texture(1) ]],\n"
" texture2d<float> tex2 [[ texture(2) ]])\n"
@ -232,7 +232,7 @@ void CMoviePlayer::Initialize()
#if BOO_HAS_METAL
case boo::IGraphicsDataFactory::Platform::Metal:
YUVShaderPipeline = static_cast<boo::MetalDataFactory::Context&>(ctx).newShaderPipeline
(VS_METAL_YUV, FS_METAL_YUV, nullptr, nullptr, YUVVTXFmt, 1,
(VS_METAL_YUV, FS_METAL_YUV, nullptr, nullptr, YUVVTXFmt,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::None, false, true, false, boo::CullMode::None);
break;

View File

@ -74,11 +74,11 @@ TShader<CAABoxShader>::IDataBindingFactory* CAABoxShader::Initialize(boo::MetalD
};
s_VtxFmt = ctx.newVertexFormat(1, VtxVmt);
s_Pipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
s_VtxFmt, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
boo::ZTest::LEqual, true, true, false, boo::CullMode::None);
s_zOnlyPipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
s_VtxFmt, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
boo::ZTest::LEqual, true, false, false, boo::CullMode::None);
return new CAABoxShaderMetalDataBindingFactory;

View File

@ -39,19 +39,19 @@ static const char* VS =
"{\n"
" VertToFrag vtf;\n"
" vtf.uvReg = v.uvIn.xy;\n"
" vtf.uvReg.y = -vtf.uvReg.y;\n"
" vtf.uvReg.y = 1.0 - vtf.uvReg.y;\n"
" vtf.uv0 = uv0.xy + v.uvIn.xy;\n"
" vtf.uv0.y = -vtf.uv0.y;\n"
" vtf.uv0.y = 1.0 - vtf.uv0.y;\n"
" vtf.uv1 = uv1.xy + v.uvIn.xy;\n"
" vtf.uv1.y = -vtf.uv1.y;\n"
" vtf.uv1.y = 1.0 - vtf.uv1.y;\n"
" vtf.uv2 = uv2.xy + v.uvIn.xy;\n"
" vtf.uv2.y = -vtf.uv2.y;\n"
" vtf.uv2.y = 1.0 - vtf.uv2.y;\n"
" vtf.uv3 = uv3.xy + v.uvIn.xy;\n"
" vtf.uv3.y = -vtf.uv3.y;\n"
" vtf.uv3.y = 1.0 - vtf.uv3.y;\n"
" vtf.uv4 = uv4.xy + v.uvIn.xy;\n"
" vtf.uv4.y = -vtf.uv4.y;\n"
" vtf.uv4.y = 1.0 - vtf.uv4.y;\n"
" vtf.uv5 = uv5.xy + v.uvIn.xy;\n"
" vtf.uv5.y = -vtf.uv5.y;\n"
" vtf.uv5.y = 1.0 - vtf.uv5.y;\n"
" vtf.opacity = opacity;\n"
" vtf.position = float4(v.posIn.xyz, 1.0);\n"
" return vtf;\n"

View File

@ -41,19 +41,19 @@ static const char* VS =
"{\n"
" VertToFrag vtf;\n"
" vtf.uvReg = v.uvIn.xy;\n"
" vtf.uvReg.y = -vtf.uvReg.y;\n"
" vtf.uvReg.y = 1.0 - vtf.uvReg.y;\n"
" vtf.uv0 = cbu.uv0.xy + v.uvIn.xy;\n"
" vtf.uv0.y = -vtf.uv0.y;\n"
" vtf.uv0.y = 1.0 - vtf.uv0.y;\n"
" vtf.uv1 = cbu.uv1.xy + v.uvIn.xy;\n"
" vtf.uv1.y = -vtf.uv1.y;\n"
" vtf.uv1.y = 1.0 - vtf.uv1.y;\n"
" vtf.uv2 = cbu.uv2.xy + v.uvIn.xy;\n"
" vtf.uv2.y = -vtf.uv2.y;\n"
" vtf.uv2.y = 1.0 - vtf.uv2.y;\n"
" vtf.uv3 = cbu.uv3.xy + v.uvIn.xy;\n"
" vtf.uv3.y = -vtf.uv3.y;\n"
" vtf.uv3.y = 1.0 - vtf.uv3.y;\n"
" vtf.uv4 = cbu.uv4.xy + v.uvIn.xy;\n"
" vtf.uv4.y = -vtf.uv4.y;\n"
" vtf.uv4.y = 1.0 - vtf.uv4.y;\n"
" vtf.uv5 = cbu.uv5.xy + v.uvIn.xy;\n"
" vtf.uv5.y = -vtf.uv5.y;\n"
" vtf.uv5.y = 1.0 - vtf.uv5.y;\n"
" vtf.opacity = cbu.opacity;\n"
" vtf.position = float4(v.posIn.xyz, 1.0);\n"
" return vtf;\n"
@ -62,7 +62,6 @@ static const char* VS =
static const char* FS =
"#include <metal_stdlib>\n"
"using namespace metal;\n"
"constexpr sampler samp(address::repeat, filter::linear);\n"
"struct VertToFrag\n"
"{\n"
" float4 position [[ position ]];\n"
@ -76,7 +75,8 @@ static const char* FS =
" float opacity;\n"
"};\n"
"\n"
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]], texture2d<float> sceneTex [[ texture(0) ]])\n"
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]], sampler samp [[ sampler(0) ]],\n"
" texture2d<float> sceneTex [[ texture(0) ]])\n"
"{\n"
" float4 colorSample = sceneTex.sample(samp, vtf.uvReg) * 0.14285715;\n"
" colorSample += sceneTex.sample(samp, vtf.uv0) * 0.14285715;\n"
@ -117,7 +117,7 @@ TShader<CCameraBlurFilter>::IDataBindingFactory* CCameraBlurFilter::Initialize(b
};
s_VtxFmt = ctx.newVertexFormat(2, VtxVmt);
s_Pipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
s_VtxFmt, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::None);
return new CCameraBlurFilterMetalDataBindingFactory;

View File

@ -90,15 +90,15 @@ CColoredQuadFilter::Initialize(boo::MetalDataFactory::Context& ctx)
};
s_VtxFmt = ctx.newVertexFormat(1, VtxVmt);
s_AlphaPipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
s_VtxFmt, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::None);
s_AddPipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
s_VtxFmt, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::None);
s_MultPipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::Zero,
s_VtxFmt, boo::BlendFactor::Zero,
boo::BlendFactor::SrcColor, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::None);
return new CColoredQuadFilterMetalDataBindingFactory;

View File

@ -43,7 +43,6 @@ static const char* VS_METAL_TEX =
static const char* FS_METAL_TEX =
"#include <metal_stdlib>\n"
"using namespace metal;\n"
"constexpr sampler samp(address::repeat, filter::linear, mip_filter::linear);\n"
"struct VertToFrag\n"
"{\n"
" float4 position [[ position ]];\n"
@ -52,6 +51,7 @@ static const char* FS_METAL_TEX =
"};\n"
"\n"
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]],\n"
" sampler samp [[ sampler(0) ]],\n"
" texture2d<float> tex0 [[ texture(0) ]])\n"
"{\n"
" return vtf.color * tex0.sample(samp, vtf.uv);\n"
@ -60,7 +60,6 @@ static const char* FS_METAL_TEX =
static const char* FS_METAL_TEX_REDTOALPHA =
"#include <metal_stdlib>\n"
"using namespace metal;\n"
"constexpr sampler samp(address::repeat, filter::linear, mip_filter::linear);\n"
"struct VertToFrag\n"
"{\n"
" float4 position [[ position ]];\n"
@ -69,6 +68,7 @@ static const char* FS_METAL_TEX_REDTOALPHA =
"};\n"
"\n"
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]],\n"
" sampler samp [[ sampler(0) ]],\n"
" texture2d<float> tex0 [[ texture(0) ]])\n"
"{\n"
" return float4(vtf.color.rgb, tex0.sample(samp, vtf.uv).r);\n"
@ -117,7 +117,6 @@ static const char* VS_METAL_INDTEX =
static const char* FS_METAL_INDTEX =
"#include <metal_stdlib>\n"
"using namespace metal;\n"
"constexpr sampler samp(address::repeat, filter::linear, mip_filter::linear);\n"
"struct VertToFrag\n"
"{\n"
" float4 position [[ position ]];\n"
@ -128,6 +127,7 @@ static const char* FS_METAL_INDTEX =
"};\n"
"\n"
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]],\n"
" sampler samp [[ sampler(0) ]],"
" texture2d<float> tex0 [[ texture(0) ]],\n"
" texture2d<float> tex1 [[ texture(1) ]],\n"
" texture2d<float> tex2 [[ texture(2) ]])\n"
@ -142,7 +142,6 @@ static const char* FS_METAL_INDTEX =
static const char* FS_METAL_CINDTEX =
"#include <metal_stdlib>\n"
"using namespace metal;\n"
"constexpr sampler samp(address::repeat, filter::linear, mip_filter::linear);\n"
"struct VertToFrag\n"
"{\n"
" float4 position [[ position ]];\n"
@ -153,6 +152,7 @@ static const char* FS_METAL_CINDTEX =
"};\n"
"\n"
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]],\n"
" sampler samp [[ sampler(0) ]],\n"
" texture2d<float> tex0 [[ texture(0) ]],\n"
" texture2d<float> tex1 [[ texture(1) ]],\n"
" texture2d<float> tex2 [[ texture(2) ]])\n"
@ -315,112 +315,88 @@ TShader<CElementGenShaders>::IDataBindingFactory* CElementGenShaders::Initialize
};
m_vtxFormatNoTex = ctx.newVertexFormat(5, TexFmtNoTex);
m_texZTestZWrite = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr,
m_vtxFormatTex, CGraphics::g_ViewportSamples,
m_texZTestZWrite = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr, m_vtxFormatTex,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::LEqual, true, true, false, boo::CullMode::None);
m_texNoZTestZWrite = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr,
m_vtxFormatTex, CGraphics::g_ViewportSamples,
m_texNoZTestZWrite = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr, m_vtxFormatTex,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::None, true, true, false, boo::CullMode::None);
m_texZTestNoZWrite = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr,
m_vtxFormatTex, CGraphics::g_ViewportSamples,
m_texZTestNoZWrite = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr, m_vtxFormatTex,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, false, boo::CullMode::None);
m_texNoZTestNoZWrite = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr,
m_vtxFormatTex, CGraphics::g_ViewportSamples,
m_texNoZTestNoZWrite = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr, m_vtxFormatTex,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::None, false, true, false, boo::CullMode::None);
m_texAdditiveZTest = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr,
m_vtxFormatTex, CGraphics::g_ViewportSamples,
m_texAdditiveZTest = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr, m_vtxFormatTex,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, false, boo::CullMode::None);
m_texAdditiveNoZTest = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr,
m_vtxFormatTex, CGraphics::g_ViewportSamples,
m_texAdditiveNoZTest = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr, m_vtxFormatTex,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
boo::Primitive::TriStrips, boo::ZTest::None, false, true, false, boo::CullMode::None);
m_texRedToAlphaZTest = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX_REDTOALPHA, nullptr, nullptr,
m_vtxFormatTex, CGraphics::g_ViewportSamples,
m_texRedToAlphaZTest = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX_REDTOALPHA, nullptr, nullptr, m_vtxFormatTex,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, true, boo::CullMode::None);
m_texRedToAlphaNoZTest = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX_REDTOALPHA, nullptr, nullptr,
m_vtxFormatTex, CGraphics::g_ViewportSamples,
m_texRedToAlphaNoZTest = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX_REDTOALPHA, nullptr, nullptr, m_vtxFormatTex,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::None, false, true, true, boo::CullMode::None);
m_texZTestNoZWriteSub = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr,
m_vtxFormatTex, CGraphics::g_ViewportSamples,
m_texZTestNoZWriteSub = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr, m_vtxFormatTex,
boo::BlendFactor::Subtract, boo::BlendFactor::Subtract,
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
true, false, boo::CullMode::None);
m_texNoZTestNoZWriteSub = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr,
m_vtxFormatTex, CGraphics::g_ViewportSamples,
m_texNoZTestNoZWriteSub = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr, m_vtxFormatTex,
boo::BlendFactor::Subtract, boo::BlendFactor::Subtract,
boo::Primitive::TriStrips, boo::ZTest::None, false,
true, false, boo::CullMode::None);
m_texRedToAlphaZTestSub = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX_REDTOALPHA, nullptr, nullptr,
m_vtxFormatTex, CGraphics::g_ViewportSamples,
m_texRedToAlphaZTestSub = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX_REDTOALPHA, nullptr, nullptr, m_vtxFormatTex,
boo::BlendFactor::Subtract, boo::BlendFactor::Subtract,
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
true, true, boo::CullMode::None);
m_texRedToAlphaNoZTestSub = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX_REDTOALPHA, nullptr, nullptr,
m_vtxFormatTex, CGraphics::g_ViewportSamples,
m_texRedToAlphaNoZTestSub = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX_REDTOALPHA, nullptr, nullptr, m_vtxFormatTex,
boo::BlendFactor::Subtract, boo::BlendFactor::Subtract,
boo::Primitive::TriStrips, boo::ZTest::None, false,
true, true, boo::CullMode::None);
m_indTexZWrite = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_INDTEX, nullptr, nullptr,
m_vtxFormatIndTex, CGraphics::g_ViewportSamples,
m_indTexZWrite = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_INDTEX, nullptr, nullptr, m_vtxFormatIndTex,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::None, true, true, false, boo::CullMode::None);
m_indTexNoZWrite = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_INDTEX, nullptr, nullptr,
m_vtxFormatIndTex, CGraphics::g_ViewportSamples,
m_indTexNoZWrite = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_INDTEX, nullptr, nullptr, m_vtxFormatIndTex,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::None, false, true, false, boo::CullMode::None);
m_indTexAdditive = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_INDTEX, nullptr, nullptr,
m_vtxFormatIndTex, CGraphics::g_ViewportSamples,
m_indTexAdditive = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_INDTEX, nullptr, nullptr, m_vtxFormatIndTex,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
boo::Primitive::TriStrips, boo::ZTest::None, true, true, false, boo::CullMode::None);
m_cindTexZWrite = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_CINDTEX, nullptr, nullptr,
m_vtxFormatIndTex, CGraphics::g_ViewportSamples,
m_cindTexZWrite = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_CINDTEX, nullptr, nullptr, m_vtxFormatIndTex,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::None, true, true, false, boo::CullMode::None);
m_cindTexNoZWrite = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_CINDTEX, nullptr, nullptr,
m_vtxFormatIndTex, CGraphics::g_ViewportSamples,
m_cindTexNoZWrite = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_CINDTEX, nullptr, nullptr, m_vtxFormatIndTex,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::None, false, true, false, boo::CullMode::None);
m_cindTexAdditive = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_CINDTEX, nullptr, nullptr,
m_vtxFormatIndTex, CGraphics::g_ViewportSamples,
m_cindTexAdditive = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_CINDTEX, nullptr, nullptr, m_vtxFormatIndTex,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
boo::Primitive::TriStrips, boo::ZTest::None, true, true, false, boo::CullMode::None);
m_noTexZTestZWrite = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, nullptr, nullptr,
m_vtxFormatNoTex, CGraphics::g_ViewportSamples,
m_noTexZTestZWrite = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, nullptr, nullptr, m_vtxFormatNoTex,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::LEqual, true, true, false, boo::CullMode::None);
m_noTexNoZTestZWrite = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, nullptr, nullptr,
m_vtxFormatNoTex, CGraphics::g_ViewportSamples,
m_noTexNoZTestZWrite = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, nullptr, nullptr, m_vtxFormatNoTex,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::None, true, true, false, boo::CullMode::None);
m_noTexZTestNoZWrite = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, nullptr, nullptr,
m_vtxFormatNoTex, CGraphics::g_ViewportSamples,
m_noTexZTestNoZWrite = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, nullptr, nullptr, m_vtxFormatNoTex,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, false, boo::CullMode::None);
m_noTexNoZTestNoZWrite = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, nullptr, nullptr,
m_vtxFormatNoTex, CGraphics::g_ViewportSamples,
m_noTexNoZTestNoZWrite = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, nullptr, nullptr, m_vtxFormatNoTex,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::None, false, true, false, boo::CullMode::None);
m_noTexAdditiveZTest = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, nullptr, nullptr,
m_vtxFormatNoTex, CGraphics::g_ViewportSamples,
m_noTexAdditiveZTest = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, nullptr, nullptr, m_vtxFormatNoTex,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, false, boo::CullMode::None);
m_noTexAdditiveNoZTest = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, nullptr, nullptr,
m_vtxFormatNoTex, CGraphics::g_ViewportSamples,
m_noTexAdditiveNoZTest = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, nullptr, nullptr, m_vtxFormatNoTex,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
boo::Primitive::TriStrips, boo::ZTest::None, false, true, false, boo::CullMode::None);

View File

@ -39,7 +39,6 @@ static const char* VS =
static const char* FS =
"#include <metal_stdlib>\n"
"using namespace metal;\n"
"constexpr sampler samp(address::repeat, filter::linear, mip_filter::linear);\n"
"struct VertToFrag\n"
"{\n"
" float4 position [[ position ]];\n"
@ -47,7 +46,9 @@ static const char* FS =
" float2 uv;\n"
"};\n"
"\n"
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]], texture2d<float> tex [[ texture(0) ]])\n"
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]],\n"
" sampler samp [[ sampler(0) ]],\n"
" texture2d<float> tex [[ texture(0) ]])\n"
"{\n"
" return vtf.color * tex.sample(samp, vtf.uv);\n"
"}\n";
@ -86,8 +87,7 @@ CEnergyBarShader::Initialize(boo::MetalDataFactory::Context& ctx)
{nullptr, nullptr, boo::VertexSemantic::UV4}
};
s_VtxFmt = ctx.newVertexFormat(2, VtxVmt);
s_Pipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples,
s_Pipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr, s_VtxFmt,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
boo::Primitive::TriStrips, boo::ZTest::LEqual,
false, true, false, boo::CullMode::None);

View File

@ -62,7 +62,6 @@ static const char* VS =
static const char* FS =
"#include <metal_stdlib>\n"
"using namespace metal;\n"
"constexpr sampler samp(address::repeat, filter::linear, mip_filter::linear);\n"
"\n"
"struct Light\n"
"{\n"
@ -129,6 +128,7 @@ static const char* FS =
"};\n"
"\n"
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]],\n"
" sampler samp [[ sampler(0) ]],\n"
" constant LightingUniform& lu [[ buffer(4) ]]%s)\n" // Textures here
"{\n"
" float4 lighting = LightingFunc(vtf.mvPos, normalize(vtf.mvNorm));\n"
@ -140,7 +140,6 @@ static const char* FS =
static const char* FSDoor =
"#include <metal_stdlib>\n"
"using namespace metal;\n"
"constexpr sampler samp(address::repeat, filter::linear, mip_filter::linear);\n"
"\n"
"struct Light\n"
"{\n"
@ -186,6 +185,7 @@ static const char* FSDoor =
"};\n"
"\n"
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]],\n"
" sampler samp [[ sampler(0) ]],\n"
" constant LightingUniform& lu [[ buffer(4) ]]%s)\n" // Textures here
"{\n"
" float4 colorOut;\n"
@ -513,8 +513,7 @@ CFluidPlaneShader::BuildShader(boo::MetalDataFactory::Context& ctx, const SFluid
asprintf(&finalVS, VS, additionalTCGs.c_str());
asprintf(&finalFS, FS, textures.c_str(), combiner.c_str());
auto ret = ctx.newShaderPipeline(finalVS, finalFS, nullptr, nullptr,
s_vtxFmt, CGraphics::g_ViewportSamples,
auto ret = ctx.newShaderPipeline(finalVS, finalFS, nullptr, nullptr, s_vtxFmt,
info.m_additive ? boo::BlendFactor::One : boo::BlendFactor::SrcAlpha,
info.m_additive ? boo::BlendFactor::One : boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, false,
@ -576,8 +575,7 @@ CFluidPlaneShader::BuildShader(boo::MetalDataFactory::Context& ctx, const SFluid
asprintf(&finalVS, VS, additionalTCGs.c_str());
asprintf(&finalFS, FSDoor, textures.c_str(), combiner.c_str());
auto ret = ctx.newShaderPipeline(finalVS, finalFS, nullptr, nullptr,
s_vtxFmt, CGraphics::g_ViewportSamples,
auto ret = ctx.newShaderPipeline(finalVS, finalFS, nullptr, nullptr, s_vtxFmt,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, false,
boo::CullMode::None);

View File

@ -40,7 +40,6 @@ static const char* VS =
static const char* FS1Way =
"#include <metal_stdlib>\n"
"using namespace metal;\n"
"constexpr sampler samp(address::repeat, filter::linear, mip_filter::linear);\n"
"struct VertToFrag\n"
"{\n"
" float4 pos [[ position ]];\n"
@ -49,6 +48,7 @@ static const char* FS1Way =
"};\n"
"\n"
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]],\n"
" sampler samp [[ sampler(0) ]],\n"
" texture2d<float> zFrontfaceTex [[ texture(0) ]],\n"
" texture2d<float> zBackfaceTex [[ texture(1) ]],\n"
" texture2d<float> zLinearizer [[ texture(2) ]])\n"
@ -64,7 +64,6 @@ static const char* FS1Way =
static const char* FS2Way =
"#include <metal_stdlib>\n"
"using namespace metal;\n"
"constexpr sampler samp(address::repeat, filter::linear, mip_filter::linear);\n"
"struct VertToFrag\n"
"{\n"
" float4 pos [[ position ]];\n"
@ -73,6 +72,7 @@ static const char* FS2Way =
"};\n"
"\n"
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]],\n"
" sampler samp [[ sampler(0) ]],\n"
" texture2d<float> zFrontfaceTex [[ texture(0) ]],\n"
" texture2d<float> zBackfaceTex [[ texture(1) ]],\n"
" texture2d<float> zLinearizer [[ texture(2) ]])\n"
@ -126,11 +126,11 @@ CFogVolumeFilter::Initialize(boo::MetalDataFactory::Context& ctx)
};
s_VtxFmt = ctx.newVertexFormat(2, VtxVmt);
s_1WayPipeline = ctx.newShaderPipeline(VS, FS1Way, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::DstAlpha,
s_VtxFmt, boo::BlendFactor::DstAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::None);
s_2WayPipeline = ctx.newShaderPipeline(VS, FS2Way, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
s_VtxFmt, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::None);
return new CFogVolumeFilterMetalDataBindingFactory;

View File

@ -66,19 +66,19 @@ CFogVolumePlaneShader::Initialize(boo::MetalDataFactory::Context& ctx)
};
s_VtxFmt = ctx.newVertexFormat(1, VtxVmt);
s_Pipelines[0] = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::Zero,
s_VtxFmt, boo::BlendFactor::Zero,
boo::BlendFactor::Zero, boo::Primitive::TriStrips,
boo::ZTest::LEqual, true, false, false, boo::CullMode::Frontface);
s_Pipelines[1] = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::Zero,
s_VtxFmt, boo::BlendFactor::Zero,
boo::BlendFactor::Zero, boo::Primitive::TriStrips,
boo::ZTest::None, false, false, false, boo::CullMode::Frontface);
s_Pipelines[2] = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::Zero,
s_VtxFmt, boo::BlendFactor::Zero,
boo::BlendFactor::Zero, boo::Primitive::TriStrips,
boo::ZTest::LEqual, true, false, false, boo::CullMode::Backface);
s_Pipelines[3] = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::Zero,
s_VtxFmt, boo::BlendFactor::Zero,
boo::BlendFactor::Zero, boo::Primitive::TriStrips,
boo::ZTest::Greater, false, false, false, boo::CullMode::Backface);
return new CFogVolumePlaneShaderMetalDataBindingFactory;

View File

@ -42,7 +42,6 @@ static const char* VS_METAL_TEX =
static const char* FS_METAL_TEX =
"#include <metal_stdlib>\n"
"using namespace metal;\n"
"constexpr sampler samp(address::repeat, filter::linear, mip_filter::linear);\n"
"struct VertToFrag\n"
"{\n"
" float4 position [[ position ]];\n"
@ -51,6 +50,7 @@ static const char* FS_METAL_TEX =
"};\n"
"\n"
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]],\n"
" sampler samp [[ sampler(0) ]],\n"
" texture2d<float> tex0 [[ texture(0) ]])\n"
"{\n"
" return vtf.color * tex0.sample(samp, vtf.uv);\n"
@ -157,22 +157,18 @@ CLineRendererShaders::IDataBindingFactory* CLineRendererShaders::Initialize(boo:
m_noTexVtxFmt = ctx.newVertexFormat(2, VtxFmtNoTex);
m_texAlpha = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr, m_texVtxFmt,
CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::None,
false, true, false, boo::CullMode::None);
m_texAdditive = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr, m_texVtxFmt,
CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
boo::Primitive::TriStrips, boo::ZTest::None,
false, true, false, boo::CullMode::None);
m_noTexAlpha = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, nullptr, nullptr, m_noTexVtxFmt,
CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::None,
false, true, false, boo::CullMode::None);
m_noTexAdditive = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, nullptr, nullptr, m_noTexVtxFmt,
CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
boo::Primitive::TriStrips, boo::ZTest::None,
false, true, false, boo::CullMode::None);

View File

@ -73,8 +73,7 @@ CMapSurfaceShader::Initialize(boo::MetalDataFactory::Context& ctx)
{nullptr, nullptr, boo::VertexSemantic::Position4}
};
s_VtxFmt = ctx.newVertexFormat(1, VtxVmt);
s_Pipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples,
s_Pipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr, s_VtxFmt,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::Backface);
return new CMapSurfaceShaderMetalDataBindingFactory;

View File

@ -79,7 +79,7 @@ static const char* LightingShadowMetal =
"};\n"
"\n"
"static float4 EXTLightingShadowFunc(constant LightingUniform& lu, float4 mvPosIn, float4 mvNormIn,\n"
" thread VertToFrag& vtf, texture2d<float> extTex7)\n"
" thread VertToFrag& vtf, sampler samp, sampler clampSamp, texture2d<float> extTex7)\n"
"{\n"
" float4 ret = lu.ambient;\n"
" \n"
@ -126,7 +126,8 @@ static const char* ThermalPostMetal =
" float4 tmulColor;\n"
" float4 addColor;\n"
"};\n"
"static float4 EXTThermalPostFunc(thread VertToFrag& vtf, constant ThermalUniform& lu, texture2d<float> extTex7, float4 colorIn)\n"
"static float4 EXTThermalPostFunc(thread VertToFrag& vtf, constant ThermalUniform& lu,\n"
" sampler samp, sampler clampSamp, texture2d<float> extTex7, float4 colorIn)\n"
"{\n"
" return float4(extTex7.sample(samp, vtf.extTcgs0).rrr * lu.tmulColor.rgb + lu.addColor.rgb, 1.0);\n"
"}\n"
@ -149,7 +150,7 @@ static const char* MBShadowPostMetal =
" float4 shadowUp;\n"
" float shadowId;\n"
"};\n"
"static float4 EXTMBShadowPostFunc(thread VertToFrag& vtf, constant MBShadowUniform& su,\n"
"static float4 EXTMBShadowPostFunc(thread VertToFrag& vtf, constant MBShadowUniform& su, sampler samp, sampler clampSamp,\n"
" texture2d<float> extTex0, texture2d<float> extTex1, texture2d<float> extTex2, float4 colorIn)\n"
"{\n"
" float idTexel = extTex0.sample(samp, vtf.extTcgs0).a;\n"

View File

@ -39,7 +39,6 @@ static const char* VS =
static const char* FS_TEX =
"#include <metal_stdlib>\n"
"using namespace metal;\n"
"constexpr sampler samp(address::repeat, filter::linear, mip_filter::linear);\n"
"struct VertToFrag\n"
"{\n"
" float4 pos [[ position ]];\n"
@ -48,6 +47,7 @@ static const char* FS_TEX =
"};\n"
"\n"
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]],\n"
" sampler samp [[ sampler(0) ]],\n"
" texture2d<float> tex [[ texture(0) ]])\n"
"{\n"
" return vtf.color * tex.sample(samp, vtf.uv);\n"
@ -97,44 +97,36 @@ TShader<CParticleSwooshShaders>::IDataBindingFactory* CParticleSwooshShaders::In
};
m_vtxFormat = ctx.newVertexFormat(3, VtxFmt);
m_texZWrite = ctx.newShaderPipeline(VS, FS_TEX, nullptr, nullptr,
m_vtxFormat, CGraphics::g_ViewportSamples,
m_texZWrite = ctx.newShaderPipeline(VS, FS_TEX, nullptr, nullptr, m_vtxFormat,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::LEqual, true,
true, false, boo::CullMode::None);
m_texNoZWrite = ctx.newShaderPipeline(VS, FS_TEX, nullptr, nullptr,
m_vtxFormat, CGraphics::g_ViewportSamples,
m_texNoZWrite = ctx.newShaderPipeline(VS, FS_TEX, nullptr, nullptr, m_vtxFormat,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
true, false, boo::CullMode::None);
m_texAdditiveZWrite = ctx.newShaderPipeline(VS, FS_TEX, nullptr, nullptr,
m_vtxFormat, CGraphics::g_ViewportSamples,
m_texAdditiveZWrite = ctx.newShaderPipeline(VS, FS_TEX, nullptr, nullptr, m_vtxFormat,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
boo::Primitive::TriStrips, boo::ZTest::LEqual, true,
true, false, boo::CullMode::None);
m_texAdditiveNoZWrite = ctx.newShaderPipeline(VS, FS_TEX, nullptr, nullptr,
m_vtxFormat, CGraphics::g_ViewportSamples,
m_texAdditiveNoZWrite = ctx.newShaderPipeline(VS, FS_TEX, nullptr, nullptr, m_vtxFormat,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
true, false, boo::CullMode::None);
m_noTexZWrite = ctx.newShaderPipeline(VS, FS_NOTEX, nullptr, nullptr,
m_vtxFormat, CGraphics::g_ViewportSamples,
m_noTexZWrite = ctx.newShaderPipeline(VS, FS_NOTEX, nullptr, nullptr, m_vtxFormat,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::LEqual, true,
true, false, boo::CullMode::None);
m_noTexNoZWrite = ctx.newShaderPipeline(VS, FS_NOTEX, nullptr, nullptr,
m_vtxFormat, CGraphics::g_ViewportSamples,
m_noTexNoZWrite = ctx.newShaderPipeline(VS, FS_NOTEX, nullptr, nullptr, m_vtxFormat,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
true, false, boo::CullMode::None);
m_noTexAdditiveZWrite = ctx.newShaderPipeline(VS, FS_NOTEX, nullptr, nullptr,
m_vtxFormat, CGraphics::g_ViewportSamples,
m_noTexAdditiveZWrite = ctx.newShaderPipeline(VS, FS_NOTEX, nullptr, nullptr, m_vtxFormat,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
boo::Primitive::TriStrips, boo::ZTest::LEqual, true,
true, false, boo::CullMode::None);
m_noTexAdditiveNoZWrite = ctx.newShaderPipeline(VS, FS_NOTEX, nullptr, nullptr,
m_vtxFormat, CGraphics::g_ViewportSamples,
m_noTexAdditiveNoZWrite = ctx.newShaderPipeline(VS, FS_NOTEX, nullptr, nullptr, m_vtxFormat,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
true, false, boo::CullMode::None);

View File

@ -49,7 +49,6 @@ static const char* VS =
static const char* IndFS =
"#include <metal_stdlib>\n"
"using namespace metal;\n"
"constexpr sampler samp(address::repeat, filter::linear, mip_filter::linear);\n"
"struct VertToFrag\n"
"{\n"
" float4 position [[ position ]];\n"
@ -61,6 +60,7 @@ static const char* IndFS =
"};\n"
"\n"
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]],\n"
" sampler samp [[ sampler(0) ]],\n"
" texture2d<float> screenTex [[ texture(0) ]],\n"
" texture2d<float> indTex [[ texture(1) ]],\n"
" texture2d<float> maskTex [[ texture(2) ]],\n"
@ -75,7 +75,6 @@ static const char* IndFS =
static const char* FS =
"#include <metal_stdlib>\n"
"using namespace metal;\n"
"constexpr sampler samp(address::clamp_to_edge, filter::linear, mip_filter::linear);\n"
"struct VertToFrag\n"
"{\n"
" float4 color;\n"
@ -86,12 +85,13 @@ static const char* FS =
"};\n"
"\n"
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]],\n"
" sampler clampSamp [[ sampler(2) ]],\n"
" texture2d<float> screenTex [[ texture(0) ]],\n"
" texture2d<float> maskTex [[ texture(1) ]],\n"
" texture2d<float> maskTexBlur [[ texture(2) ]])\n"
"{\n"
" float maskBlurAlpha = saturate((maskTexBlur.sample(samp, vtf.maskUv).a - maskTex.sample(samp, vtf.maskUv).a) * 2.0);\n"
" return float4((vtf.color * screenTex.sample(samp, vtf.screenUv) * maskBlurAlpha).rgb, vtf.color.a);\n"
" float maskBlurAlpha = saturate((maskTexBlur.sample(clampSamp, vtf.maskUv).a - maskTex.sample(clampSamp, vtf.maskUv).a) * 2.0);\n"
" return float4((vtf.color * screenTex.sample(clampSamp, vtf.screenUv) * maskBlurAlpha).rgb, vtf.color.a);\n"
"}\n";
static const char* BlurVS =
@ -128,7 +128,6 @@ static const char* BlurVS =
static const char* BlurFS =
"#include <metal_stdlib>\n"
"using namespace metal;\n"
"constexpr sampler samp(address::clamp_to_edge, filter::linear, mip_filter::linear);\n"
"struct VertToFrag\n"
"{\n"
" float4 position [[ position ]];\n"
@ -137,35 +136,36 @@ static const char* BlurFS =
"};\n"
"\n"
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]],\n"
" sampler clampSamp [[ sampler(2) ]],\n"
" texture2d<float> maskTex [[ texture(0) ]])\n"
"{\n"
" //this will be our alpha sum\n"
" float sum = 0.0;\n"
"\n"
" //apply blurring, using a 23-tap filter with predefined gaussian weights\n"
" sum += maskTex.sample(samp, vtf.uv + -11.0 * vtf.blurDir).a * 0.007249;\n"
" sum += maskTex.sample(samp, vtf.uv + -10.0 * vtf.blurDir).a * 0.011032;\n"
" sum += maskTex.sample(samp, vtf.uv + -9.0 * vtf.blurDir).a * 0.016133;\n"
" sum += maskTex.sample(samp, vtf.uv + -8.0 * vtf.blurDir).a * 0.022665;\n"
" sum += maskTex.sample(samp, vtf.uv + -7.0 * vtf.blurDir).a * 0.030595;\n"
" sum += maskTex.sample(samp, vtf.uv + -6.0 * vtf.blurDir).a * 0.039680;\n"
" sum += maskTex.sample(samp, vtf.uv + -5.0 * vtf.blurDir).a * 0.049444;\n"
" sum += maskTex.sample(samp, vtf.uv + -4.0 * vtf.blurDir).a * 0.059195;\n"
" sum += maskTex.sample(samp, vtf.uv + -3.0 * vtf.blurDir).a * 0.068091;\n"
" sum += maskTex.sample(samp, vtf.uv + -2.0 * vtf.blurDir).a * 0.075252;\n"
" sum += maskTex.sample(samp, vtf.uv + -1.0 * vtf.blurDir).a * 0.079905;\n"
" sum += maskTex.sample(samp, vtf.uv).a * 0.081519;\n"
" sum += maskTex.sample(samp, vtf.uv + 1.0 * vtf.blurDir).a * 0.079905;\n"
" sum += maskTex.sample(samp, vtf.uv + 2.0 * vtf.blurDir).a * 0.075252;\n"
" sum += maskTex.sample(samp, vtf.uv + 3.0 * vtf.blurDir).a * 0.068091;\n"
" sum += maskTex.sample(samp, vtf.uv + 4.0 * vtf.blurDir).a * 0.059195;\n"
" sum += maskTex.sample(samp, vtf.uv + 5.0 * vtf.blurDir).a * 0.049444;\n"
" sum += maskTex.sample(samp, vtf.uv + 6.0 * vtf.blurDir).a * 0.039680;\n"
" sum += maskTex.sample(samp, vtf.uv + 7.0 * vtf.blurDir).a * 0.030595;\n"
" sum += maskTex.sample(samp, vtf.uv + 8.0 * vtf.blurDir).a * 0.022665;\n"
" sum += maskTex.sample(samp, vtf.uv + 9.0 * vtf.blurDir).a * 0.016133;\n"
" sum += maskTex.sample(samp, vtf.uv + 10.0 * vtf.blurDir).a * 0.011032;\n"
" sum += maskTex.sample(samp, vtf.uv + 11.0 * vtf.blurDir).a * 0.007249;\n"
" sum += maskTex.sample(clampSamp, vtf.uv + -11.0 * vtf.blurDir).a * 0.007249;\n"
" sum += maskTex.sample(clampSamp, vtf.uv + -10.0 * vtf.blurDir).a * 0.011032;\n"
" sum += maskTex.sample(clampSamp, vtf.uv + -9.0 * vtf.blurDir).a * 0.016133;\n"
" sum += maskTex.sample(clampSamp, vtf.uv + -8.0 * vtf.blurDir).a * 0.022665;\n"
" sum += maskTex.sample(clampSamp, vtf.uv + -7.0 * vtf.blurDir).a * 0.030595;\n"
" sum += maskTex.sample(clampSamp, vtf.uv + -6.0 * vtf.blurDir).a * 0.039680;\n"
" sum += maskTex.sample(clampSamp, vtf.uv + -5.0 * vtf.blurDir).a * 0.049444;\n"
" sum += maskTex.sample(clampSamp, vtf.uv + -4.0 * vtf.blurDir).a * 0.059195;\n"
" sum += maskTex.sample(clampSamp, vtf.uv + -3.0 * vtf.blurDir).a * 0.068091;\n"
" sum += maskTex.sample(clampSamp, vtf.uv + -2.0 * vtf.blurDir).a * 0.075252;\n"
" sum += maskTex.sample(clampSamp, vtf.uv + -1.0 * vtf.blurDir).a * 0.079905;\n"
" sum += maskTex.sample(clampSamp, vtf.uv).a * 0.081519;\n"
" sum += maskTex.sample(clampSamp, vtf.uv + 1.0 * vtf.blurDir).a * 0.079905;\n"
" sum += maskTex.sample(clampSamp, vtf.uv + 2.0 * vtf.blurDir).a * 0.075252;\n"
" sum += maskTex.sample(clampSamp, vtf.uv + 3.0 * vtf.blurDir).a * 0.068091;\n"
" sum += maskTex.sample(clampSamp, vtf.uv + 4.0 * vtf.blurDir).a * 0.059195;\n"
" sum += maskTex.sample(clampSamp, vtf.uv + 5.0 * vtf.blurDir).a * 0.049444;\n"
" sum += maskTex.sample(clampSamp, vtf.uv + 6.0 * vtf.blurDir).a * 0.039680;\n"
" sum += maskTex.sample(clampSamp, vtf.uv + 7.0 * vtf.blurDir).a * 0.030595;\n"
" sum += maskTex.sample(clampSamp, vtf.uv + 8.0 * vtf.blurDir).a * 0.022665;\n"
" sum += maskTex.sample(clampSamp, vtf.uv + 9.0 * vtf.blurDir).a * 0.016133;\n"
" sum += maskTex.sample(clampSamp, vtf.uv + 10.0 * vtf.blurDir).a * 0.011032;\n"
" sum += maskTex.sample(clampSamp, vtf.uv + 11.0 * vtf.blurDir).a * 0.007249;\n"
"\n"
" return float4(1.0, 1.0, 1.0, sum);\n"
"}\n";
@ -252,15 +252,15 @@ CPhazonSuitFilter::Initialize(boo::MetalDataFactory::Context& ctx)
};
s_BlurVtxFmt = ctx.newVertexFormat(2, BlurVtxVmt);
s_IndPipeline = ctx.newShaderPipeline(VS, IndFS, nullptr, nullptr, s_VtxFmt,
CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::None);
s_Pipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr, s_VtxFmt,
CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::None);
s_BlurPipeline = ctx.newShaderPipeline(BlurVS, BlurFS, nullptr, nullptr, s_BlurVtxFmt,
CGraphics::g_ViewportSamples, boo::BlendFactor::One,
boo::BlendFactor::One,
boo::BlendFactor::Zero, boo::Primitive::TriStrips,
boo::ZTest::None, false, false, true, boo::CullMode::None);
return new CPhazonSuitFilterMetalDataBindingFactory;

View File

@ -42,7 +42,6 @@ static const char* VS =
static const char* FS =
"#include <metal_stdlib>\n"
"using namespace metal;\n"
"constexpr sampler samp(address::repeat, filter::linear, mip_filter::linear);\n"
"struct VertToFrag\n"
"{\n"
" float4 position [[ position ]];\n"
@ -51,6 +50,7 @@ static const char* FS =
"};\n"
"\n"
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]],\n"
" sampler samp [[ sampler(0) ]],\n"
" texture2d<float> tex [[ texture(0) ]])\n"
"{\n"
" return vtf.color * tex.sample(samp, vtf.uv);\n"
@ -92,8 +92,7 @@ CRadarPaintShader::Initialize(boo::MetalDataFactory::Context& ctx)
{nullptr, nullptr, boo::VertexSemantic::Color}
};
s_VtxFmt = ctx.newVertexFormat(9, VtxVmt);
s_Pipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples,
s_Pipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr, s_VtxFmt,
boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::None);

View File

@ -157,23 +157,19 @@ CRandomStaticFilter::Initialize(boo::MetalDataFactory::Context& ctx)
{nullptr, nullptr, boo::VertexSemantic::UV4}
};
s_VtxFmt = ctx.newVertexFormat(2, VtxVmt);
s_AlphaPipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples,
s_AlphaPipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr, s_VtxFmt,
boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::None);
s_AddPipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples,
s_AddPipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr, s_VtxFmt,
boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::None);
s_MultPipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples,
s_MultPipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr, s_VtxFmt,
boo::BlendFactor::Zero,
boo::BlendFactor::SrcColor, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::None);
s_CookieCutterPipeline = ctx.newShaderPipeline(VS, FSCookieCutter, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples,
s_CookieCutterPipeline = ctx.newShaderPipeline(VS, FSCookieCutter, nullptr, nullptr, s_VtxFmt,
boo::BlendFactor::SrcColor,
boo::BlendFactor::DstColor, boo::Primitive::TriStrips,
boo::ZTest::LEqual, true, false, false, boo::CullMode::None);

View File

@ -94,15 +94,15 @@ CScanLinesFilter::Initialize(boo::MetalDataFactory::Context& ctx)
};
s_VtxFmt = ctx.newVertexFormat(1, VtxVmt);
s_AlphaPipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
s_VtxFmt, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::None);
s_AddPipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
s_VtxFmt, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::None);
s_MultPipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::Zero,
s_VtxFmt, boo::BlendFactor::Zero,
boo::BlendFactor::SrcColor, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::None);
return new CScanLinesFilterMetalDataBindingFactory;

View File

@ -29,9 +29,9 @@ static const char* VS =
" VertToFrag vtf;\n"
" vtf.position = mul(mainMtx, float4(v.posIn.xy, 0.0, 1.0));\n"
" vtf.sceneUv = vtf.position.xy * float2(0.5, 0.5) + float2(0.5, 0.5);\n"
" vtf.sceneUv.y = -vtf.sceneUv.y;\n"
" vtf.sceneUv.y = 1.0 - vtf.sceneUv.y;\n"
" vtf.indUv = mul(float3x3(indMtx[0].xyz, indMtx[1].xyz, indMtx[2].xyz), float3(v.uvIn.xy, 1.0)).xy;\n"
" vtf.indUv.y = -vtf.indUv.y;\n"
" vtf.indUv.y = 1.0 - vtf.indUv.y;\n"
" vtf.strength = strength.xy;\n"
" return vtf;\n"
"}\n";

View File

@ -31,9 +31,9 @@ static const char* VS =
" VertToFrag vtf;\n"
" vtf.position = swu.mainMtx * float4(v.posIn.xy, 0.0, 1.0);\n"
" vtf.sceneUv = vtf.position.xy * float2(0.5) + float2(0.5);\n"
" vtf.sceneUv.y = -vtf.sceneUv.y;\n"
" vtf.sceneUv.y = 1.0 - vtf.sceneUv.y;\n"
" vtf.indUv = (float3x3(swu.indMtx[0].xyz, swu.indMtx[1].xyz, swu.indMtx[2].xyz) * float3(v.uvIn.xy, 1.0)).xy;\n"
" vtf.indUv.y = -vtf.indUv.y;\n"
" vtf.indUv.y = 1.0 - vtf.indUv.y;\n"
" vtf.strength = swu.strength.xy;\n"
" return vtf;\n"
"}\n";
@ -41,7 +41,6 @@ static const char* VS =
static const char* FS =
"#include <metal_stdlib>\n"
"using namespace metal;\n"
"constexpr sampler samp(address::repeat, filter::linear, mip_filter::linear);\n"
"struct VertToFrag\n"
"{\n"
" float4 position [[ position ]];\n"
@ -50,7 +49,10 @@ static const char* FS =
" float2 strength;\n"
"};\n"
"\n"
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]], texture2d<float> sceneTex [[ texture(0) ]], texture2d<float> indTex [[ texture(1) ]])\n"
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]],\n"
" sampler samp [[ sampler(0) ]],\n"
" texture2d<float> sceneTex [[ texture(0) ]],\n"
" texture2d<float> indTex [[ texture(1) ]])\n"
"{\n"
" return sceneTex.sample(samp, vtf.sceneUv + (indTex.sample(samp, vtf.indUv).xy * float2(2.0) - float2(1.0 - 1.0 / 256.0)) * vtf.strength.xy);\n"
"}\n";
@ -84,7 +86,7 @@ TShader<CSpaceWarpFilter>::IDataBindingFactory* CSpaceWarpFilter::Initialize(boo
};
s_VtxFmt = ctx.newVertexFormat(2, VtxVmt);
s_Pipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::One,
s_VtxFmt, boo::BlendFactor::One,
boo::BlendFactor::Zero, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::None);
return new CSpaceWarpFilterMetalDataBindingFactory;

View File

@ -50,7 +50,6 @@ static const char* TextVS =
static const char* TextFS =
"#include <metal_stdlib>\n"
"using namespace metal;\n"
"constexpr sampler samp(address::clamp_to_edge, filter::linear, mip_filter::linear);\n"
"struct VertToFrag\n"
"{\n"
" float4 pos [[ position ]];\n"
@ -61,9 +60,10 @@ static const char* TextFS =
"};\n"
"\n"
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]],\n"
" sampler clampSamp [[ sampler(2) ]],\n"
" texture2d_array<float> tex [[ texture(0) ]])\n"
"{\n"
" float4 texel = tex.sample(samp, vtf.uv.xy, vtf.uv.z);\n"
" float4 texel = tex.sample(clampSamp, vtf.uv.xy, vtf.uv.z);\n"
" return (vtf.fontColor * texel.r + vtf.outlineColor * texel.g) * vtf.mulColor;\n"
"}\n";
@ -105,7 +105,6 @@ static const char* ImgVS =
static const char* ImgFS =
"#include <metal_stdlib>\n"
"using namespace metal;\n"
"constexpr sampler samp(address::clamp_to_edge, filter::linear, mip_filter::linear);\n"
"struct VertToFrag\n"
"{\n"
" float4 pos [[ position ]];\n"
@ -114,9 +113,10 @@ static const char* ImgFS =
"};\n"
"\n"
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]],\n"
" sampler clampSamp [[ sampler(2) ]],\n"
" texture2d<float> tex [[ texture(0) ]])\n"
"{\n"
" float4 texel = tex.sample(samp, vtf.uv);\n"
" float4 texel = tex.sample(clampSamp, vtf.uv);\n"
" return vtf.color * texel;\n"
"}\n";
@ -138,16 +138,13 @@ CTextSupportShader::Initialize(boo::MetalDataFactory::Context& ctx)
{nullptr, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced, 2},
};
s_TextVtxFmt = ctx.newVertexFormat(11, TextVtxVmt);
s_TextAlphaPipeline = ctx.newShaderPipeline(TextVS, TextFS, nullptr, nullptr,
s_TextVtxFmt, CGraphics::g_ViewportSamples,
s_TextAlphaPipeline = ctx.newShaderPipeline(TextVS, TextFS, nullptr, nullptr, s_TextVtxFmt,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
boo::ZTest::LEqual, false, true, false, boo::CullMode::None);
s_TextAddPipeline = ctx.newShaderPipeline(TextVS, TextFS, nullptr, nullptr,
s_TextVtxFmt, CGraphics::g_ViewportSamples,
s_TextAddPipeline = ctx.newShaderPipeline(TextVS, TextFS, nullptr, nullptr, s_TextVtxFmt,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One, boo::Primitive::TriStrips,
boo::ZTest::LEqual, false, true, false, boo::CullMode::None);
s_TextAddOverdrawPipeline = ctx.newShaderPipeline(TextVS, TextFS, nullptr, nullptr,
s_TextVtxFmt, CGraphics::g_ViewportSamples,
s_TextAddOverdrawPipeline = ctx.newShaderPipeline(TextVS, TextFS, nullptr, nullptr, s_TextVtxFmt,
boo::BlendFactor::One, boo::BlendFactor::One, boo::Primitive::TriStrips,
boo::ZTest::LEqual, false, true, false, boo::CullMode::None);
@ -164,16 +161,13 @@ CTextSupportShader::Initialize(boo::MetalDataFactory::Context& ctx)
{nullptr, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced, 0},
};
s_ImageVtxFmt = ctx.newVertexFormat(9, ImageVtxVmt);
s_ImageAlphaPipeline = ctx.newShaderPipeline(ImgVS, ImgFS, nullptr, nullptr,
s_ImageVtxFmt, CGraphics::g_ViewportSamples,
s_ImageAlphaPipeline = ctx.newShaderPipeline(ImgVS, ImgFS, nullptr, nullptr, s_ImageVtxFmt,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
boo::ZTest::LEqual, false, true, false, boo::CullMode::None);
s_ImageAddPipeline = ctx.newShaderPipeline(ImgVS, ImgFS, nullptr, nullptr,
s_ImageVtxFmt, CGraphics::g_ViewportSamples,
s_ImageAddPipeline = ctx.newShaderPipeline(ImgVS, ImgFS, nullptr, nullptr, s_ImageVtxFmt,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One, boo::Primitive::TriStrips,
boo::ZTest::LEqual, false, true, false, boo::CullMode::None);
s_ImageAddOverdrawPipeline = ctx.newShaderPipeline(ImgVS, ImgFS, nullptr, nullptr,
s_ImageVtxFmt, CGraphics::g_ViewportSamples,
s_ImageAddOverdrawPipeline = ctx.newShaderPipeline(ImgVS, ImgFS, nullptr, nullptr, s_ImageVtxFmt,
boo::BlendFactor::One, boo::BlendFactor::One, boo::Primitive::TriStrips,
boo::ZTest::LEqual, false, true, false, boo::CullMode::None);

View File

@ -77,7 +77,6 @@ static const char* VSNoFlip =
static const char* FS =
"#include <metal_stdlib>\n"
"using namespace metal;\n"
"constexpr sampler samp(address::clamp_to_edge, filter::linear, mip_filter::linear);\n"
"struct VertToFrag\n"
"{\n"
" float4 position [[ position ]];\n"
@ -86,15 +85,16 @@ static const char* FS =
" float lod;\n"
"};\n"
"\n"
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]], texture2d<float> tex [[ texture(0) ]])\n"
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]],\n"
" sampler clampSamp [[ sampler(2) ]],\n"
" texture2d<float> tex [[ texture(0) ]])\n"
"{\n"
" return vtf.color * float4(tex.sample(samp, vtf.uv, bias(vtf.lod)).rgb, 1.0);\n"
" return vtf.color * float4(tex.sample(clampSamp, vtf.uv, bias(vtf.lod)).rgb, 1.0);\n"
"}\n";
static const char* FSAlpha =
"#include <metal_stdlib>\n"
"using namespace metal;\n"
"constexpr sampler samp(address::clamp_to_edge, filter::linear, mip_filter::linear);\n"
"struct VertToFrag\n"
"{\n"
" float4 position [[ position ]];\n"
@ -103,9 +103,11 @@ static const char* FSAlpha =
" float lod;\n"
"};\n"
"\n"
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]], texture2d<float> tex [[ texture(0) ]])\n"
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]],\n"
" sampler clampSamp [[ sampler(2) ]],\n"
" texture2d<float> tex [[ texture(0) ]])\n"
"{\n"
" return vtf.color * tex.sample(samp, vtf.uv, bias(vtf.lod));\n"
" return vtf.color * tex.sample(clampSamp, vtf.uv, bias(vtf.lod));\n"
"}\n";
URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilter)
@ -158,19 +160,19 @@ CTexturedQuadFilter::Initialize(boo::MetalDataFactory::Context& ctx)
};
s_VtxFmt = ctx.newVertexFormat(2, VtxVmt);
s_AlphaPipeline = ctx.newShaderPipeline(VSNoFlip, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
s_VtxFmt, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, boo::ZTest::None, false,
true, false, boo::CullMode::None);
s_AlphaGEqualPipeline = ctx.newShaderPipeline(VSNoFlip, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
s_VtxFmt, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, boo::ZTest::GEqual, true,
true, false, boo::CullMode::None);
s_AddPipeline = ctx.newShaderPipeline(VSNoFlip, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
s_VtxFmt, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips, boo::ZTest::None, false,
true, false, boo::CullMode::None);
s_MultPipeline = ctx.newShaderPipeline(VSNoFlip, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::Zero,
s_VtxFmt, boo::BlendFactor::Zero,
boo::BlendFactor::SrcColor, boo::Primitive::TriStrips, boo::ZTest::None, false,
true, false, boo::CullMode::None);
return new CTexturedQuadFilterMetalDataBindingFactory;
@ -231,15 +233,15 @@ CTexturedQuadFilterAlpha::Initialize(boo::MetalDataFactory::Context& ctx)
};
s_AVtxFmt = ctx.newVertexFormat(2, VtxVmt);
s_AAlphaPipeline = ctx.newShaderPipeline(VSFlip, FSAlpha, nullptr, nullptr,
s_AVtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
s_AVtxFmt, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::None);
s_AAddPipeline = ctx.newShaderPipeline(VSFlip, FSAlpha, nullptr, nullptr,
s_AVtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
s_AVtxFmt, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::None);
s_AMultPipeline = ctx.newShaderPipeline(VSFlip, FSAlpha, nullptr, nullptr,
s_AVtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::Zero,
s_AVtxFmt, boo::BlendFactor::Zero,
boo::BlendFactor::SrcColor, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::None);
return new CTexturedQuadFilterAlphaMetalDataBindingFactory;

View File

@ -16,10 +16,10 @@ CThermalColdFilter::CThermalColdFilter()
zeus::CVector2f m_uv;
} verts[4] =
{
{{-1.0, -1.0}, {0.0, 0.0}},
{{-1.0, 1.0}, {0.0, 1.0}},
{{ 1.0, -1.0}, {1.0, 0.0}},
{{ 1.0, 1.0}, {1.0, 1.0}},
{{-1.f, -1.f}, {0.f, 0.f}},
{{-1.f, 1.f}, {0.f, 1.f}},
{{ 1.f, -1.f}, {1.f, 0.f}},
{{ 1.f, 1.f}, {1.f, 1.f}},
};
m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts, 32, 4);
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
@ -45,8 +45,8 @@ void CThermalColdFilter::setShift(unsigned shift)
if (ny > 3)
ny = 3;
unsigned nx = spx % 8;
m_shiftTexture[y][x][0] = nx * 255 / 7;
m_shiftTexture[y][x][1] = ny * 255 / 3;
m_shiftTexture[y][x][0] = u8(nx * 255 / 7);
m_shiftTexture[y][x][1] = u8(ny * 255 / 3);
}
}
m_shiftTex->load(m_shiftTexture[0][0], sizeof(m_shiftTexture));

View File

@ -40,7 +40,7 @@ static const char* VS =
" vtf.colorReg1 = colorReg1;\n"
" vtf.colorReg2 = colorReg2;\n"
" vtf.sceneUv = v.uvIn.xy;\n"
" vtf.sceneUv.y = -vtf.sceneUv.y;\n"
" vtf.sceneUv.y = 1.0 - vtf.sceneUv.y;\n"
" vtf.shiftUv = (mul(float3x3(shiftMtx[0].xyz, shiftMtx[1].xyz, shiftMtx[2].xyz), v.uvIn.xyz)).xy;\n"
" vtf.shiftScale = shiftScale.xy;\n"
" vtf.position = float4(v.posIn.xyz, 1.0);\n"
@ -50,7 +50,7 @@ static const char* VS =
static const char* FS =
"Texture2D sceneTex : register(t0);\n"
"Texture2D shiftTex : register(t1);\n"
"SamplerState samp : register(s0);\n"
"SamplerState samp : register(s2);\n"
"struct VertToFrag\n"
"{\n"
" float4 position : SV_Position;\n"

View File

@ -46,7 +46,7 @@ static const char* VS =
" vtf.colorReg1 = tcu.colorReg1;\n"
" vtf.colorReg2 = tcu.colorReg2;\n"
" vtf.sceneUv = v.uvIn.xy;\n"
" vtf.sceneUv.y = -vtf.sceneUv.y;\n"
" vtf.sceneUv.y = 1.0 - vtf.sceneUv.y;\n"
" vtf.shiftUv = (float3x3(tcu.shiftMtx[0].xyz, tcu.shiftMtx[1].xyz, tcu.shiftMtx[2].xyz) * v.uvIn.xyz).xy;\n"
" vtf.shiftScale = tcu.shiftScale.xy;\n"
" vtf.position = float4(v.posIn.xyz, 1.0);\n"
@ -56,7 +56,6 @@ static const char* VS =
static const char* FS =
"#include <metal_stdlib>\n"
"using namespace metal;\n"
"constexpr sampler samp(address::repeat, filter::linear, mip_filter::linear);\n"
"struct VertToFrag\n"
"{\n"
" float4 position [[ position ]];\n"
@ -72,7 +71,10 @@ static const char* FS =
"};\n"
"\n"
"constant float4 kRGBToYPrime = {0.299, 0.587, 0.114, 0.0};\n"
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]], texture2d<float> sceneTex [[ texture(0) ]], texture2d<float> shiftTex [[ texture(1) ]])\n"
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]],\n"
" sampler samp [[ sampler(2) ]],\n"
" texture2d<float> sceneTex [[ texture(0) ]],\n"
" texture2d<float> shiftTex [[ texture(1) ]])\n"
"{\n"
" float2 shiftCoordTexel = shiftTex.sample(samp, vtf.shiftUv).xy;\n"
" float2 shiftCoord = vtf.sceneUv + shiftCoordTexel * vtf.shiftScale;\n"
@ -112,7 +114,7 @@ TShader<CThermalColdFilter>::IDataBindingFactory* CThermalColdFilter::Initialize
};
s_VtxFmt = ctx.newVertexFormat(2, VtxVmt);
s_Pipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::One,
s_VtxFmt, boo::BlendFactor::One,
boo::BlendFactor::Zero, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::None);
return new CThermalColdFilterMetalDataBindingFactory;

View File

@ -29,7 +29,7 @@ static const char* VS =
"{\n"
" VertToFrag vtf;\n"
" vtf.sceneUv = v.uvIn.xy;\n"
" vtf.sceneUv.y = -vtf.sceneUv.y;\n"
" vtf.sceneUv.y = 1.0 - vtf.sceneUv.y;\n"
" vtf.position = float4(v.posIn.xyz, 1.0);\n"
" return vtf;\n"
"}\n";

View File

@ -31,7 +31,7 @@ static const char* VS =
"{\n"
" VertToFrag vtf;\n"
" vtf.sceneUv = v.uvIn.xy;\n"
" vtf.sceneUv.y = -vtf.sceneUv.y;\n"
" vtf.sceneUv.y = 1.0 - vtf.sceneUv.y;\n"
" vtf.position = float4(v.posIn.xyz, 1.0);\n"
" return vtf;\n"
"}\n";
@ -39,7 +39,6 @@ static const char* VS =
static const char* FS =
"#include <metal_stdlib>\n"
"using namespace metal;\n"
"constexpr sampler samp(address::repeat, filter::linear, mip_filter::linear);\n"
"struct VertToFrag\n"
"{\n"
" float4 position [[ position ]];\n"
@ -48,6 +47,7 @@ static const char* FS =
"\n"
"constant float4 kRGBToYPrime = float4(0.299, 0.587, 0.114, 0.0);\n"
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]],\n"
" sampler samp [[ sampler(0) ]],\n"
" texture2d<float> sceneTex [[ texture(0) ]],\n"
" texture2d<float> paletteTex [[ texture(1) ]])\n"
"{\n"
@ -84,8 +84,7 @@ TShader<CThermalHotFilter>::IDataBindingFactory* CThermalHotFilter::Initialize(b
{nullptr, nullptr, boo::VertexSemantic::UV4}
};
s_VtxFmt = ctx.newVertexFormat(2, VtxVmt);
s_Pipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples,
s_Pipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr, s_VtxFmt,
boo::BlendFactor::DstAlpha, boo::BlendFactor::InvDstAlpha,
boo::Primitive::TriStrips, boo::ZTest::None, false,
true, false, boo::CullMode::None);

View File

@ -78,11 +78,11 @@ CWorldShadowShader::Initialize(boo::MetalDataFactory::Context& ctx)
};
s_VtxFmt = ctx.newVertexFormat(1, VtxVmt);
s_Pipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
s_VtxFmt, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::None);
s_ZPipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
s_VtxFmt, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
boo::ZTest::LEqual, true, true, false, boo::CullMode::None);
return new CWorldShadowShaderMetalDataBindingFactory;

View File

@ -17,10 +17,10 @@ CXRayBlurFilter::CXRayBlurFilter(TLockedToken<CTexture>& tex)
zeus::CVector2f m_uv;
} verts[4] =
{
{{-1.0, -1.0}, {0.0, 0.0}},
{{-1.0, 1.0}, {0.0, 1.0}},
{{ 1.0, -1.0}, {1.0, 0.0}},
{{ 1.0, 1.0}, {1.0, 1.0}},
{{-1.f, -1.f}, {0.f, 0.f}},
{{-1.f, 1.f}, {0.f, 1.f}},
{{ 1.f, -1.f}, {1.f, 0.f}},
{{ 1.f, 1.f}, {1.f, 1.f}},
};
m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts, 32, 4);
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
@ -36,9 +36,9 @@ void CXRayBlurFilter::draw(float amount)
float blurL = amount * g_tweakGui->GetXrayBlurScaleLinear() * 0.25f;
float blurQ = amount * g_tweakGui->GetXrayBlurScaleQuadratic() * 0.25f;
for (int i=0 ; i<4 ; ++i)
for (int i=0 ; i<8 ; ++i)
{
float iflt = i;
float iflt = i / 2.f;
float uvScale = (1.f - (blurL * iflt + blurQ * iflt * iflt));
float uvOffset = uvScale * -0.5f + 0.5f;
m_uniform.m_uv[i][0][0] = uvScale;

View File

@ -19,7 +19,7 @@ class CXRayBlurFilter
struct Uniform
{
zeus::CMatrix4f m_uv[4];
zeus::CMatrix4f m_uv[8];
};
TLockedToken<CTexture> m_paletteTex;
boo::ObjToken<boo::ITexture> m_booTex;

View File

@ -17,6 +17,10 @@ BOO_GLSL_BINDING_HEAD
" mat4 uv1;\n"
" mat4 uv2;\n"
" mat4 uv3;\n"
" mat4 uv4;\n"
" mat4 uv5;\n"
" mat4 uv6;\n"
" mat4 uv7;\n"
"};\n"
"\n"
"struct VertToFrag\n"
@ -25,6 +29,10 @@ BOO_GLSL_BINDING_HEAD
" vec2 uv1;\n"
" vec2 uv2;\n"
" vec2 uv3;\n"
" vec2 uv4;\n"
" vec2 uv5;\n"
" vec2 uv6;\n"
" vec2 uv7;\n"
"};\n"
"\n"
"SBINDING(0) out VertToFrag vtf;\n"
@ -34,6 +42,10 @@ BOO_GLSL_BINDING_HEAD
" vtf.uv1 = (uv1 * vec4(uvIn.xy, 0.0, 1.0)).xy;\n"
" vtf.uv2 = (uv2 * vec4(uvIn.xy, 0.0, 1.0)).xy;\n"
" vtf.uv3 = (uv3 * vec4(uvIn.xy, 0.0, 1.0)).xy;\n"
" vtf.uv4 = (uv4 * vec4(uvIn.xy, 0.0, 1.0)).xy;\n"
" vtf.uv5 = (uv5 * vec4(uvIn.xy, 0.0, 1.0)).xy;\n"
" vtf.uv6 = (uv6 * vec4(uvIn.xy, 0.0, 1.0)).xy;\n"
" vtf.uv7 = (uv7 * vec4(uvIn.xy, 0.0, 1.0)).xy;\n"
" gl_Position = vec4(posIn.xyz, 1.0);\n"
"}\n";
@ -46,6 +58,10 @@ BOO_GLSL_BINDING_HEAD
" vec2 uv1;\n"
" vec2 uv2;\n"
" vec2 uv3;\n"
" vec2 uv4;\n"
" vec2 uv5;\n"
" vec2 uv6;\n"
" vec2 uv7;\n"
"};\n"
"\n"
"SBINDING(0) in VertToFrag vtf;\n"
@ -55,10 +71,14 @@ BOO_GLSL_BINDING_HEAD
"const vec4 kRGBToYPrime = vec4(0.299, 0.587, 0.114, 0.0);\n"
"void main()\n"
"{\n"
" vec4 colorSample = texture(paletteTex, vec2(dot(texture(sceneTex, vtf.uv0), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.25;\n"
" colorSample += texture(paletteTex, vec2(dot(texture(sceneTex, vtf.uv1), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.25;\n"
" colorSample += texture(paletteTex, vec2(dot(texture(sceneTex, vtf.uv2), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.25;\n"
" colorSample += texture(paletteTex, vec2(dot(texture(sceneTex, vtf.uv3), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.25;\n"
" vec4 colorSample = texture(paletteTex, vec2(dot(texture(sceneTex, vtf.uv0), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.125;\n"
" colorSample += texture(paletteTex, vec2(dot(texture(sceneTex, vtf.uv1), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.125;\n"
" colorSample += texture(paletteTex, vec2(dot(texture(sceneTex, vtf.uv2), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.125;\n"
" colorSample += texture(paletteTex, vec2(dot(texture(sceneTex, vtf.uv3), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.125;\n"
" colorSample += texture(paletteTex, vec2(dot(texture(sceneTex, vtf.uv4), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.125;\n"
" colorSample += texture(paletteTex, vec2(dot(texture(sceneTex, vtf.uv5), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.125;\n"
" colorSample += texture(paletteTex, vec2(dot(texture(sceneTex, vtf.uv6), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.125;\n"
" colorSample += texture(paletteTex, vec2(dot(texture(sceneTex, vtf.uv7), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.125;\n"
" colorOut = colorSample;\n"
"}\n";

View File

@ -18,6 +18,10 @@ static const char* VS =
" float4x4 uv1;\n"
" float4x4 uv2;\n"
" float4x4 uv3;\n"
" float4x4 uv4;\n"
" float4x4 uv5;\n"
" float4x4 uv6;\n"
" float4x4 uv7;\n"
"};\n"
"\n"
"struct VertToFrag\n"
@ -27,19 +31,31 @@ static const char* VS =
" float2 uv1 : UV1;\n"
" float2 uv2 : UV2;\n"
" float2 uv3 : UV3;\n"
" float2 uv4 : UV4;\n"
" float2 uv5 : UV5;\n"
" float2 uv6 : UV6;\n"
" float2 uv7 : UV7;\n"
"};\n"
"\n"
"VertToFrag main(in VertData v)\n"
"{\n"
" VertToFrag vtf;\n"
" vtf.uv0 = mul(uv0, float4(v.uvIn.xy, 0.0, 1.0)).xy;\n"
" vtf.uv0.y = -vtf.uv0.y;\n"
" vtf.uv0.y = 1.0 - vtf.uv0.y;\n"
" vtf.uv1 = mul(uv1, float4(v.uvIn.xy, 0.0, 1.0)).xy;\n"
" vtf.uv1.y = -vtf.uv1.y;\n"
" vtf.uv1.y = 1.0 - vtf.uv1.y;\n"
" vtf.uv2 = mul(uv2, float4(v.uvIn.xy, 0.0, 1.0)).xy;\n"
" vtf.uv2.y = -vtf.uv2.y;\n"
" vtf.uv2.y = 1.0 - vtf.uv2.y;\n"
" vtf.uv3 = mul(uv3, float4(v.uvIn.xy, 0.0, 1.0)).xy;\n"
" vtf.uv3.y = -vtf.uv3.y;\n"
" vtf.uv3.y = 1.0 - vtf.uv3.y;\n"
" vtf.uv4 = mul(uv4, float4(v.uvIn.xy, 0.0, 1.0)).xy;\n"
" vtf.uv4.y = 1.0 - vtf.uv4.y;\n"
" vtf.uv5 = mul(uv5, float4(v.uvIn.xy, 0.0, 1.0)).xy;\n"
" vtf.uv5.y = 1.0 - vtf.uv5.y;\n"
" vtf.uv6 = mul(uv6, float4(v.uvIn.xy, 0.0, 1.0)).xy;\n"
" vtf.uv6.y = 1.0 - vtf.uv6.y;\n"
" vtf.uv7 = mul(uv7, float4(v.uvIn.xy, 0.0, 1.0)).xy;\n"
" vtf.uv7.y = 1.0 - vtf.uv7.y;\n"
" vtf.position = float4(v.posIn.xyz, 1.0);\n"
" return vtf;\n"
"}\n";
@ -47,7 +63,7 @@ static const char* VS =
static const char* FS =
"Texture2D sceneTex : register(t0);\n"
"Texture2D paletteTex : register(t1);\n"
"SamplerState samp : register(s0);\n"
"SamplerState samp : register(s2);\n"
"struct VertToFrag\n"
"{\n"
" float4 position : SV_Position;\n"
@ -55,15 +71,23 @@ static const char* FS =
" float2 uv1 : UV1;\n"
" float2 uv2 : UV2;\n"
" float2 uv3 : UV3;\n"
" float2 uv4 : UV4;\n"
" float2 uv5 : UV5;\n"
" float2 uv6 : UV6;\n"
" float2 uv7 : UV7;\n"
"};\n"
"\n"
"static const float4 kRGBToYPrime = float4(0.299, 0.587, 0.114, 0.0);\n"
"float4 main(in VertToFrag vtf) : SV_Target0\n"
"{\n"
" float4 colorSample = paletteTex.Sample(samp, float2(dot(sceneTex.Sample(samp, vtf.uv0), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.25;\n"
" colorSample += paletteTex.Sample(samp, float2(dot(sceneTex.Sample(samp, vtf.uv1), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.25;\n"
" colorSample += paletteTex.Sample(samp, float2(dot(sceneTex.Sample(samp, vtf.uv2), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.25;\n"
" colorSample += paletteTex.Sample(samp, float2(dot(sceneTex.Sample(samp, vtf.uv3), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.25;\n"
" float4 colorSample = paletteTex.Sample(samp, float2(dot(sceneTex.Sample(samp, vtf.uv0), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.125;\n"
" colorSample += paletteTex.Sample(samp, float2(dot(sceneTex.Sample(samp, vtf.uv1), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.125;\n"
" colorSample += paletteTex.Sample(samp, float2(dot(sceneTex.Sample(samp, vtf.uv2), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.125;\n"
" colorSample += paletteTex.Sample(samp, float2(dot(sceneTex.Sample(samp, vtf.uv3), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.125;\n"
" colorSample += paletteTex.Sample(samp, float2(dot(sceneTex.Sample(samp, vtf.uv4), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.125;\n"
" colorSample += paletteTex.Sample(samp, float2(dot(sceneTex.Sample(samp, vtf.uv5), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.125;\n"
" colorSample += paletteTex.Sample(samp, float2(dot(sceneTex.Sample(samp, vtf.uv6), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.125;\n"
" colorSample += paletteTex.Sample(samp, float2(dot(sceneTex.Sample(samp, vtf.uv7), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.125;\n"
" return colorSample;\n"
"}\n";

View File

@ -20,6 +20,10 @@ static const char* VS =
" float4x4 uv1;\n"
" float4x4 uv2;\n"
" float4x4 uv3;\n"
" float4x4 uv4;\n"
" float4x4 uv5;\n"
" float4x4 uv6;\n"
" float4x4 uv7;\n"
"};\n"
"\n"
"struct VertToFrag\n"
@ -29,19 +33,31 @@ static const char* VS =
" float2 uv1;\n"
" float2 uv2;\n"
" float2 uv3;\n"
" float2 uv4;\n"
" float2 uv5;\n"
" float2 uv6;\n"
" float2 uv7;\n"
"};\n"
"\n"
"vertex VertToFrag vmain(VertData v [[ stage_in ]], constant XRayBlurUniform& xbu [[ buffer(2) ]])\n"
"{\n"
" VertToFrag vtf;\n"
" vtf.uv0 = (xbu.uv0 * float4(v.uvIn.xy, 0.0, 1.0)).xy;\n"
" vtf.uv0.y = -vtf.uv0.y;\n"
" vtf.uv0.y = 1.0 - vtf.uv0.y;\n"
" vtf.uv1 = (xbu.uv1 * float4(v.uvIn.xy, 0.0, 1.0)).xy;\n"
" vtf.uv1.y = -vtf.uv1.y;\n"
" vtf.uv1.y = 1.0 - vtf.uv1.y;\n"
" vtf.uv2 = (xbu.uv2 * float4(v.uvIn.xy, 0.0, 1.0)).xy;\n"
" vtf.uv2.y = -vtf.uv2.y;\n"
" vtf.uv2.y = 1.0 - vtf.uv2.y;\n"
" vtf.uv3 = (xbu.uv3 * float4(v.uvIn.xy, 0.0, 1.0)).xy;\n"
" vtf.uv3.y = -vtf.uv3.y;\n"
" vtf.uv3.y = 1.0 - vtf.uv3.y;\n"
" vtf.uv4 = (xbu.uv4 * float4(v.uvIn.xy, 0.0, 1.0)).xy;\n"
" vtf.uv4.y = 1.0 - vtf.uv4.y;\n"
" vtf.uv5 = (xbu.uv5 * float4(v.uvIn.xy, 0.0, 1.0)).xy;\n"
" vtf.uv5.y = 1.0 - vtf.uv5.y;\n"
" vtf.uv6 = (xbu.uv6 * float4(v.uvIn.xy, 0.0, 1.0)).xy;\n"
" vtf.uv6.y = 1.0 - vtf.uv6.y;\n"
" vtf.uv7 = (xbu.uv7 * float4(v.uvIn.xy, 0.0, 1.0)).xy;\n"
" vtf.uv7.y = 1.0 - vtf.uv7.y;\n"
" vtf.position = float4(v.posIn.xyz, 1.0);\n"
" return vtf;\n"
"}\n";
@ -49,7 +65,6 @@ static const char* VS =
static const char* FS =
"#include <metal_stdlib>\n"
"using namespace metal;\n"
"constexpr sampler samp(address::repeat, filter::linear, mip_filter::linear);\n"
"struct VertToFrag\n"
"{\n"
" float4 position [[ position ]];\n"
@ -57,17 +72,26 @@ static const char* FS =
" float2 uv1;\n"
" float2 uv2;\n"
" float2 uv3;\n"
" float2 uv4;\n"
" float2 uv5;\n"
" float2 uv6;\n"
" float2 uv7;\n"
"};\n"
"\n"
"constant float4 kRGBToYPrime = float4(0.299, 0.587, 0.114, 0.0);\n"
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]],\n"
" sampler samp [[ sampler(2) ]],\n"
" texture2d<float> sceneTex [[ texture(0) ]],\n"
" texture2d<float> paletteTex [[ texture(1) ]])\n"
"{\n"
" float4 colorSample = paletteTex.sample(samp, float2(dot(sceneTex.sample(samp, vtf.uv0), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.25;\n"
" colorSample += paletteTex.sample(samp, float2(dot(sceneTex.sample(samp, vtf.uv1), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.25;\n"
" colorSample += paletteTex.sample(samp, float2(dot(sceneTex.sample(samp, vtf.uv2), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.25;\n"
" colorSample += paletteTex.sample(samp, float2(dot(sceneTex.sample(samp, vtf.uv3), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.25;\n"
" float4 colorSample = paletteTex.sample(samp, float2(dot(sceneTex.sample(samp, vtf.uv0), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.125;\n"
" colorSample += paletteTex.sample(samp, float2(dot(sceneTex.sample(samp, vtf.uv1), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.125;\n"
" colorSample += paletteTex.sample(samp, float2(dot(sceneTex.sample(samp, vtf.uv2), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.125;\n"
" colorSample += paletteTex.sample(samp, float2(dot(sceneTex.sample(samp, vtf.uv3), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.125;\n"
" colorSample += paletteTex.sample(samp, float2(dot(sceneTex.sample(samp, vtf.uv4), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.125;\n"
" colorSample += paletteTex.sample(samp, float2(dot(sceneTex.sample(samp, vtf.uv5), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.125;\n"
" colorSample += paletteTex.sample(samp, float2(dot(sceneTex.sample(samp, vtf.uv6), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.125;\n"
" colorSample += paletteTex.sample(samp, float2(dot(sceneTex.sample(samp, vtf.uv7), kRGBToYPrime) * 0.98 + 0.01, 0.5)) * 0.125;\n"
" return colorSample;\n"
"}\n";
@ -100,7 +124,7 @@ TShader<CXRayBlurFilter>::IDataBindingFactory* CXRayBlurFilter::Initialize(boo::
};
s_VtxFmt = ctx.newVertexFormat(2, VtxVmt);
s_Pipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::One,
s_VtxFmt, boo::BlendFactor::One,
boo::BlendFactor::Zero, boo::Primitive::TriStrips, boo::ZTest::None, false,
true, false, boo::CullMode::None);
return new CXRayBlurFilterMetalDataBindingFactory;

View File

@ -554,8 +554,8 @@ void CPlayerVisor::BeginTransitionIn(const CStateManager&)
{
case CPlayerState::EPlayerVisor::XRay:
x90_xrayBlur.SetBlur(EBlurType::Xray, 0.f, 0.f);
xc4_vpScaleX = 0.9f;
xc8_vpScaleY = 0.9f;
xc4_vpScaleX = 0.95f;
xc8_vpScaleY = 0.95f;
CSfxManager::SfxStart(1383, x24_visorSfxVol, 0.f, false, 0x7f, false, kInvalidAreaId);
break;
case CPlayerState::EPlayerVisor::Scan:

View File

@ -13,6 +13,8 @@ CScriptSpawnPoint::CScriptSpawnPoint(TUniqueId uid, std::string_view name, const
bool defaultSpawn, bool active, bool morphed)
: CEntity(uid, info, active, name), x34_xf(xf), x64_itemCounts(itemCounts)
{
x64_itemCounts[int(CPlayerState::EItemType::ThermalVisor)] = 1;
x64_itemCounts[int(CPlayerState::EItemType::XRayVisor)] = 1;
x10c_24_firstSpawn = defaultSpawn;
x10c_25_morphed = morphed;
}

2
amuse

@ -1 +1 @@
Subproject commit 3f9a91b0ab960f6f4581343645fa4c2e871a0694
Subproject commit 380381c7d1865cc069317c258ae740a789baf8c9

2
hecl

@ -1 +1 @@
Subproject commit c29999e1d9e000980c4dfcb3265dd5fee53af044
Subproject commit 9823ddeec4875d15b41de1dc5c61a814be8a5192

@ -1 +1 @@
Subproject commit 2a3ed450af9cc58e284b9bac830c099700d3098c
Subproject commit 712b8bc9048b175a1528fa13362090d17c2d4002