Thermal Hot filter HLSL

This commit is contained in:
Jack Andersen 2016-08-03 13:16:31 -10:00
parent 9222a928ef
commit dc1ad1c773
8 changed files with 99 additions and 8 deletions

View File

@ -28,7 +28,7 @@ zeus::CTransform CMappableObject::AdjustTransformForType()
|| x0_type == EMappableObjectType::PlasmaDoorCeiling) || x0_type == EMappableObjectType::PlasmaDoorCeiling)
{ {
zeus::CTransform orientation; zeus::CTransform orientation;
orientation.origin = {-1.65 * doorCenterX, 0.f, -1.5 * doorCenterZ}; orientation.origin = {-1.65f * doorCenterX, 0.f, -1.5f * doorCenterZ};
orientation.rotateLocalY(zeus::degToRad(90.f)); orientation.rotateLocalY(zeus::degToRad(90.f));
return x10_transform * orientation; return x10_transform * orientation;
} }
@ -36,7 +36,7 @@ zeus::CTransform CMappableObject::AdjustTransformForType()
|| x0_type == EMappableObjectType::PlasmaDoorFloor) || x0_type == EMappableObjectType::PlasmaDoorFloor)
{ {
zeus::CTransform orientation; zeus::CTransform orientation;
orientation.origin = {-1.65 * doorCenterX, 0.f, -1.0 * doorCenterZ}; orientation.origin = {-1.65f * doorCenterX, 0.f, -1.f * doorCenterZ};
orientation.rotateLocalY(zeus::degToRad(90.f)); orientation.rotateLocalY(zeus::degToRad(90.f));
return x10_transform * orientation; return x10_transform * orientation;
} }
@ -44,7 +44,7 @@ zeus::CTransform CMappableObject::AdjustTransformForType()
|| x0_type == EMappableObjectType::Fifteen) || x0_type == EMappableObjectType::Fifteen)
{ {
zeus::CTransform orientation; zeus::CTransform orientation;
orientation.origin = {-0.49 * doorCenterX, 0.f, -1.0 * doorCenterZ}; orientation.origin = {-0.49f * doorCenterX, 0.f, -1.f * doorCenterZ};
orientation.rotateLocalY(zeus::degToRad(90.f)); orientation.rotateLocalY(zeus::degToRad(90.f));
return x10_transform * orientation; return x10_transform * orientation;
} }

View File

@ -3,11 +3,13 @@ if(WIN32)
Shaders/CLineRendererShadersHLSL.cpp Shaders/CLineRendererShadersHLSL.cpp
Shaders/CModelShadersHLSL.cpp Shaders/CModelShadersHLSL.cpp
Shaders/CThermalColdFilterHLSL.cpp Shaders/CThermalColdFilterHLSL.cpp
Shaders/CThermalHotFilterHLSL.cpp
Shaders/CSpaceWarpFilterHLSL.cpp) Shaders/CSpaceWarpFilterHLSL.cpp)
elseif(APPLE) elseif(APPLE)
set(PLAT_SRCS Shaders/CLineRendererShadersMetal.cpp set(PLAT_SRCS Shaders/CLineRendererShadersMetal.cpp
Shaders/CModelShadersMetal.cpp Shaders/CModelShadersMetal.cpp
Shaders/CThermalColdFilterMetal.cpp Shaders/CThermalColdFilterMetal.cpp
Shaders/CThermalHotFilterMetal.cpp
Shaders/CSpaceWarpFilterMetal.cpp) Shaders/CSpaceWarpFilterMetal.cpp)
endif() endif()

View File

@ -52,7 +52,7 @@ static const char* ThermalPostGLSL =
"};\n" "};\n"
"vec4 ThermalPostFunc(vec4 colorIn)\n" "vec4 ThermalPostFunc(vec4 colorIn)\n"
"{\n" "{\n"
" return texture(tex7, vtf.extTcgs[0]).rrrr * mulColor + addColor;\n" " return vec4(texture(tex7, vtf.extTcgs[0]).rrr * mulColor.rgb + addColor.rgb, 1.0);\n"
"}\n" "}\n"
"\n"; "\n";

View File

@ -51,7 +51,7 @@ static const char* ThermalPostHLSL =
"};\n" "};\n"
"float4 ThermalPostFunc(in VertToFrag vtf, float4 colorIn)\n" "float4 ThermalPostFunc(in VertToFrag vtf, float4 colorIn)\n"
"{\n" "{\n"
" return extTex7.Sample(samp, vtf.extTcgs[0]).rrrr * mulColor + addColor;\n" " return float4(extTex7.Sample(samp, vtf.extTcgs[0]).rrr * mulColor.rgb + addColor.rgb, 1.0);\n"
"}\n" "}\n"
"\n"; "\n";

View File

@ -51,7 +51,7 @@ static const char* ThermalPostMetal =
"};\n" "};\n"
"static float4 ThermalPostFunc(thread VertToFrag& vtf, constant ThermalUniform& lu, texture2d<float> tex7, float4 colorIn)\n" "static float4 ThermalPostFunc(thread VertToFrag& vtf, constant ThermalUniform& lu, texture2d<float> tex7, float4 colorIn)\n"
"{\n" "{\n"
" return tex7.sample(samp, vtf.extTcgs0).rrrr * lu.mulColor + lu.addColor;\n" " return float4(tex7.sample(samp, vtf.extTcgs0).rrr * lu.mulColor.rgb + lu.addColor.rgb, 1.0);\n"
"}\n" "}\n"
"\n"; "\n";

View File

@ -40,6 +40,7 @@ static const char* VS =
" vtf.colorReg1 = colorReg1;\n" " vtf.colorReg1 = colorReg1;\n"
" vtf.colorReg2 = colorReg2;\n" " vtf.colorReg2 = colorReg2;\n"
" vtf.sceneUv = v.uvIn.xy;\n" " vtf.sceneUv = v.uvIn.xy;\n"
" vtf.sceneUv.y = -vtf.sceneUv.y;\n"
" vtf.shiftUv = (mul(float3x3(shiftMtx[0].xyz, shiftMtx[1].xyz, shiftMtx[2].xyz), v.uvIn.xyz)).xy;\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.shiftScale = shiftScale.xy;\n"
" vtf.position = float4(v.posIn.xyz, 1.0);\n" " vtf.position = float4(v.posIn.xyz, 1.0);\n"

View File

@ -0,0 +1,88 @@
#include "CThermalHotFilter.hpp"
#include "Graphics/CBooRenderer.hpp"
#include "GameGlobalObjects.hpp"
namespace urde
{
static const char* VS =
"struct VertData\n"
"{\n"
" float4 posIn : POSITION;\n"
" float4 uvIn : UV;\n"
"};\n"
"\n"
"cbuffer ThermalHotUniform : register(b0)\n"
"{\n"
" float4 colorReg0;\n"
" float4 colorReg1;\n"
" float4 colorReg2;\n"
"};\n"
"\n"
"struct VertToFrag\n"
"{\n"
" float4 position : SV_Position;\n"
" float2 sceneUv : UV;\n"
"};\n"
"\n"
"VertToFrag main(in VertData v)\n"
"{\n"
" VertToFrag vtf;\n"
" vtf.sceneUv = v.uvIn.xy;\n"
" vtf.sceneUv.y = -vtf.sceneUv.y;\n"
" vtf.position = float4(v.posIn.xyz, 1.0);\n"
" return vtf;\n"
"}\n";
static const char* FS =
"Texture2D sceneTex : register(t0);\n"
"Texture2D paletteTex : register(t1);\n"
"SamplerState samp : register(s0);\n"
"struct VertToFrag\n"
"{\n"
" float4 position : SV_Position;\n"
" float2 sceneUv : UV;\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"
" float sceneSample = dot(sceneTex.Sample(samp, vtf.sceneUv), kRGBToYPrime);\n"
" float4 colorSample = paletteTex.Sample(samp, float2(sceneSample / 17.0, 0.5));\n"
" return colorSample * sceneSample;\n"
"}\n";
URDE_DECL_SPECIALIZE_SHADER(CThermalHotFilter)
struct CThermalHotFilterD3DDataBindingFactory : TShader<CThermalHotFilter>::IDataBindingFactory
{
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CThermalHotFilter& filter)
{
boo::ID3DDataFactory::Context& cctx = static_cast<boo::ID3DDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
boo::ITexture* texs[] = {CGraphics::g_SpareTexture, g_Renderer->GetThermoPalette()};
return cctx.newShaderDataBinding(TShader<CThermalHotFilter>::m_pipeline,
TShader<CThermalHotFilter>::m_vtxFmt,
filter.m_vbo, nullptr, nullptr, 1, bufs,
nullptr, nullptr, nullptr, 2, texs);
}
};
TShader<CThermalHotFilter>::IDataBindingFactory* CThermalHotFilter::Initialize(boo::ID3DDataFactory::Context& ctx,
boo::IShaderPipeline*& pipeOut,
boo::IVertexFormat*& vtxFmtOut)
{
const boo::VertexElementDescriptor VtxVmt[] =
{
{nullptr, nullptr, boo::VertexSemantic::Position4},
{nullptr, nullptr, boo::VertexSemantic::UV4}
};
vtxFmtOut = ctx.newVertexFormat(2, VtxVmt);
pipeOut = ctx.newShaderPipeline(VS, FS, ComPtr<ID3DBlob>(), ComPtr<ID3DBlob>(), ComPtr<ID3DBlob>(),
vtxFmtOut, boo::BlendFactor::DstAlpha, boo::BlendFactor::InvDstAlpha,
boo::Primitive::TriStrips, false, false, false);
return new CThermalHotFilterD3DDataBindingFactory;
}
}

2
hecl

@ -1 +1 @@
Subproject commit 089e1bd167135f24b2c2bb972f4616bd761d2f2e Subproject commit ecddcbf1a46cf5a1d7b610de97a10718cebcd75e