Commit ad51876a authored by AL's avatar AL

scaling effects somewhat works

parent 08a3f452
......@@ -2,6 +2,14 @@
#include "Framework/BindableCommon.h"
#include "Framework/TransformCbuf2D.h"
struct EffectCBuff
{
float val;
float pad1;
float pad2;
float pad3;
};
Effect2DData Effect2DDataInterpolate(Effect2DData e1, Effect2DData e2, float progress)
{
return Effect2DData(e1*(1.0f-progress)+e2*progress);
......@@ -83,16 +91,24 @@ HudEffect<Effect2DSequence,HudElement>::HudEffect(DXGraphics& gfx, Effect2DSeque
HudEffect<Effect3DSequence, PlaneTexNorm>::HudEffect(DXGraphics& gfx, Effect3DSequence data, std::wstring spriteName) :
PlaneTexNorm(spriteName, gfx),effectSequence(data), gfx(gfx)
{
auto& s = Drawable::Drawable::GetTechniquesReference()[4].GetSteps()[0];
s.DeleteBindableByUID(L"class Bind::VertexShader#PhongVSNormalMap.cso");
s.AddBindable(Bind::VertexShader::Resolve(gfx, L"PhongVSScale.cso"));
scaleCbuf = std::make_shared<Bind::VertexConstantBuffer<EffectCBuff>>(gfx, 3);
cbuf = std::make_shared<Bind::PixelConstantBuffer<EffectCBuff>>(gfx, 4);
s.AddBindable(cbuf);
s.AddBindable(scaleCbuf);
BindPositionData(&refPosData);
BindAdditionalData(&refAddData);
refAddData.emplace_back();
refPosData.emplace_back();
}
template<typename T, typename Base>
HudEffect<T,Base>::HudEffect(HudEffect&& mvFrom):
HudElement(std::move(mvFrom)),
cbData (std::move(mvFrom.cbData)),
cbData0 (std::move(mvFrom.cbData0)),
refPosData (std::move(mvFrom.refPosData)),
cbuf (std::move(mvFrom.cbuf )),
effectSequence (std::move(mvFrom.effectSequence)),
......@@ -101,9 +117,9 @@ gfx (std::move(mvFrom.gfx)){}
HudEffect<Effect3DSequence, PlaneTexNorm>::HudEffect(HudEffect&& mvFrom) :
PlaneTexNorm(std::move(mvFrom)),
cbData(std::move(mvFrom.cbData)),
cbData0(std::move(mvFrom.cbData0)),
cbData1(std::move(mvFrom.cbData1)),
refPosData(std::move(mvFrom.refPosData)),
refAddData(std::move(mvFrom.refAddData)),
cbuf(std::move(mvFrom.cbuf)),
effectSequence(std::move(mvFrom.effectSequence)),
gfx(std::move(mvFrom.gfx)) {}
......@@ -119,8 +135,8 @@ bool HudEffect<Effect2DSequence, HudElement>::UpdateData(float dt)
refPosData[0].pos.y = nd->posY;
refPosData[0].pos.z = nd->scale;
refPosData[0].rot.x = nd->rotation;
cbData.fillness = nd->opacity;
cbuf->Update(gfx, cbData);
cbData0.val = nd->opacity;
cbuf->Update(gfx, cbData0);
return 0;
}
else return 1;
......@@ -137,12 +153,10 @@ bool HudEffect<Effect3DSequence, PlaneTexNorm>::UpdateData(float dt)
refPosData[0].rot.x = nd->roll;
refPosData[0].rot.y = nd->pitch;
refPosData[0].rot.z = nd->yaw;
refAddData[0].x = nd->scale;
refAddData[0].y = nd->scale;
refAddData[0].z = nd->scale;
refAddData[0].w = nd->scale;
//cbData.fillness = nd->opacity;
//cbuf->Update(gfx, cbData);
cbData0.val = nd->scale;
cbData1.val = nd->opacity;
scaleCbuf->Update(gfx, cbData0);
cbuf->Update(gfx, cbData1);
return 0;
}
else return 1;
......@@ -278,13 +292,13 @@ void EffectHandler::AddEffect3D(Effect e)
{
PositionData posData = { 3.7f, 1.0f, 1.0f, 0.0f, 3 * PI / 2.0f, PI / 2.0f };
Effect3DSequence e3ds1;
e3ds1.AddStage({ posData.pos.x,posData.pos.y,posData.pos.z , 0.8f ,1.0f,posData.rot.x,posData.rot.y,posData.rot.z }, 2.65f);
e3ds1.AddStage({ posData.pos.x,posData.pos.y,posData.pos.z, 0.0f ,0.5f,posData.rot.x,posData.rot.y,posData.rot.z }, 0.0f);
e3ds1.AddStage({ posData.pos.x,posData.pos.y,posData.pos.z , 0.8f ,1.0f,posData.rot.x,posData.rot.y,posData.rot.z }, 2.65f);
e3ds1.AddStage({ posData.pos.x,posData.pos.y,posData.pos.z, 0.3f ,0.5f,posData.rot.x,posData.rot.y,posData.rot.z }, 0.0f);
EffectHandler::AddEffect3D(e3ds1, L"Media\\Models\\Enemy_hit.obj");
Effect3DSequence e3ds2;
e3ds2.AddStage({ posData.pos.x,posData.pos.y,posData.pos.z, 0.0f ,0.5f,posData.rot.x,posData.rot.y,posData.rot.z }, 5.0f);
e3ds2.AddStage({ posData.pos.x,posData.pos.y,posData.pos.z, 1.0f ,1.0f,posData.rot.x,posData.rot.y,posData.rot.z }, 0.0f);
e3ds2.AddStage({ posData.pos.x,posData.pos.y,posData.pos.z, 0.5f ,0.5f,posData.rot.x,posData.rot.y,posData.rot.z }, 5.0f);
e3ds2.AddStage({ posData.pos.x,posData.pos.y,posData.pos.z, 1.0f ,1.0f,posData.rot.x,posData.rot.y,posData.rot.z }, 0.0f);
EffectHandler::AddEffect3D(e3ds2, L"Media\\Models\\Enemy_hit.obj");
break;
}
......
......@@ -114,17 +114,11 @@ public:
HudEffect& operator = (const HudEffect&) = delete;
bool UpdateData(float dt); //returns 1 if object is dead
private:
struct EffectCBuff
{
float fillness;
float pad1;
float pad2;
float pad3;
};
EffectCBuff cbData;
struct EffectCBuff cbData0;
struct EffectCBuff cbData1;
std::vector<PositionData> refPosData;
std::vector<DirectX::XMFLOAT4> refAddData;
std::shared_ptr <Bind::PixelConstantBuffer<EffectCBuff>> cbuf;
std::shared_ptr <Bind::PixelConstantBuffer<struct EffectCBuff>> cbuf = nullptr;
std::shared_ptr <Bind::VertexConstantBuffer<struct EffectCBuff>> scaleCbuf = nullptr;
T effectSequence;
DXGraphics& gfx;
};
......
......@@ -629,6 +629,18 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</FxCompile>
<FxCompile Include="Opacity.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">4.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">4.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">4.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|x64'">4.0</ShaderModel>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
</FxCompile>
<FxCompile Include="PhongPS.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Pixel</ShaderType>
<ObjectFileOutput Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(RiftedTimes\Engine)%(Filename).cso</ObjectFileOutput>
......@@ -752,6 +764,18 @@
<FileType>Document</FileType>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClInclude>
<FxCompile Include="Scale.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">4.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">4.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">4.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|x64'">4.0</ShaderModel>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
</FxCompile>
<FxCompile Include="ShaderOps.hlsl">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
......@@ -821,6 +845,16 @@
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|x64'">4.0</ShaderModel>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</FxCompile>
<FxCompile Include="PhongVSScale.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Vertex</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Vertex</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Vertex</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Vertex</ShaderType>
<ObjectFileOutput Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(RiftedTimes\Engine)%(Filename).cso</ObjectFileOutput>
<ObjectFileOutput Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(RiftedTimes\Engine)%(Filename).cso</ObjectFileOutput>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">5.0</ShaderModel>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|x64'">5.0</ShaderModel>
</FxCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Resource.rc" />
......
......@@ -893,9 +893,6 @@
<ClCompile Include="Skills0.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Framework\PlaneTex.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<FxCompile Include="PhongVSNormalMap.hlsl">
......@@ -991,6 +988,15 @@
<FxCompile Include="VertexShader.hlsl">
<Filter>Shaders\old%3f</Filter>
</FxCompile>
<FxCompile Include="Scale.hlsl">
<Filter>Shaders</Filter>
</FxCompile>
<FxCompile Include="Opacity.hlsl">
<Filter>Shaders</Filter>
</FxCompile>
<FxCompile Include="PhongVSScale.hlsl">
<Filter>Shaders</Filter>
</FxCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Resource.rc">
......
......@@ -14,7 +14,7 @@ namespace Bind
{}
virtual std::wstring GetUID() const noexcept
{
assert(false);
assert(false&&"this Bindable does not have UID");
return L"";
}
virtual ~Bindable() = default;
......
......@@ -66,6 +66,7 @@ namespace Bind
PixelConstantBufferEX( gfx,*layout.ShareRoot(),slot,nullptr ),
buf( Dcb::Buffer( layout ) )
{}
CachingPixelConstantBufferEX( DXGraphics& gfx,const Dcb::Buffer& buf,UINT slot )
:
PixelConstantBufferEX( gfx,buf.GetRootLayoutElement(),slot,&buf ),
......@@ -79,6 +80,10 @@ namespace Bind
{
return buf;
}
virtual std::wstring GetUID() const noexcept override
{
return L"CachingPixelConstantBufferEX";
}
void SetBuffer( const Dcb::Buffer& buf_in )
{
buf.CopyFrom( buf_in );
......
......@@ -193,22 +193,11 @@ DirectX::XMMATRIX PlaneTexNorm::GetTransformXM() const noexcept
return transMat;
}
DirectX::XMFLOAT4 PlaneTexNorm::GetAdditionalTransformData() const
{
assert(additionlData->size() && "no additional data bound for this object - can't draw CamFacingEX");
return additionlData->at(currentObjectBeingDrawn);
}
void PlaneTexNorm::BindPositionData(std::vector<PositionData>* posData)
{
this->posData = posData;
}
void PlaneTexNorm::BindAdditionalData(std::vector<DirectX::XMFLOAT4>* addData)
{
additionlData = addData;
}
void PlaneTexNorm::SmartSubmit(FrameCommander& fc, Techniques mainTec)
{
this->Submit(fc,mainTec);
......
......@@ -21,15 +21,12 @@ public:
PlaneTexNorm& operator=(PlaneTexNorm&&) = delete;
PlaneTexNorm& operator=(const PlaneTexNorm&) = default;
DirectX::XMMATRIX GetTransformXM() const noexcept override;
DirectX::XMFLOAT4 GetAdditionalTransformData() const override;
void BindPositionData(std::vector<PositionData>* posData);
void BindAdditionalData(std::vector<DirectX::XMFLOAT4>* addData);
void SmartSubmit(FrameCommander& fc, Techniques mainTec); //uses Submit with standart tecqunice for first draw call
virtual ~PlaneTexNorm() = default;
//and consecutive for all the rest in posData
private:
const std::vector<PositionData>* posData; // one position for one object
const std::vector<DirectX::XMFLOAT4>* additionlData = nullptr; //for CamFacingEX only
mutable size_t currentObjectBeingDrawn = 0;
};
......@@ -89,7 +89,6 @@ namespace Bind
namespace dx = DirectX;
auto modelTransform = pParent->GetTransformXM(); //world
const auto addData = pParent->GetAdditionalTransformData(); //roll+scale
const auto camera = gfx.GetCamera(); //view
const auto camPos = gfx.GetCamPos();
......
......@@ -25,6 +25,10 @@ namespace Bind
TransformCbuf(DXGraphics& gfx,DataType type = DataType::Standart, UINT slot = 0u);
void Bind(DXGraphics& gfx) noexcept override;
void InitializeParentReference(const Drawable& parent) noexcept override;
virtual std::wstring GetUID() const noexcept
{
return L"TransformCbuf" + std::to_wstring(static_cast<size_t>(datTyp));
}
protected:
void UpdateBindImpl(DXGraphics& gfx, const Transforms& tf) noexcept;
Transforms GetTransforms(DXGraphics& gfx) noexcept;
......
cbuffer Opacity : register(b4)
{
float opacity;
float3 padding;
};
\ No newline at end of file
#include "Transform.hlsl"
#include "LightVectorData.hlsl"
#include "Scale.hlsl"
struct VSOut
{
......@@ -15,6 +16,9 @@ struct VSOut
VSOut main(float3 pos : Position, float3 n : Normal, float3 tan : Tangent, float3 bitan : Bitangent, float2 tc : Texcoord)
{
VSOut vso;
#ifdef SCALE_BOI
pos*=scale;
#endif
vso.viewPos = (float3) mul(float4(pos, 1.0f), modelView);
vso.viewNormal = mul(n, (float3x3) modelView);
vso.tan = mul(tan, (float3x3) modelView);
......
#define SCALE_BOI
#include "PhongVSNormalMap.hlsl"
\ No newline at end of file
cbuffer Scale : register(b3)
{
float scale;
float3 padding;
};
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment