Passthrough shader for DirectX GUI
This commit is contained in:
Vendored
BIN
Binary file not shown.
@@ -67,7 +67,8 @@ private:
|
||||
float paddingBitch;
|
||||
} constantBufferStruct;
|
||||
|
||||
ShaderProgram* shaderProgram = nullptr;
|
||||
ShaderProgram* m_ForwardShaderProgram = nullptr;
|
||||
ShaderProgram* m_GUIShaderProgram = nullptr;
|
||||
ID3D11Buffer* constantBuffer = nullptr;
|
||||
|
||||
Model* m_UnitQuad = nullptr;
|
||||
|
||||
@@ -101,9 +101,6 @@ void dd::Renderer::Initialize()
|
||||
m_DeviceContext->OMSetBlendState(blendState, nullptr, 0xffffffff);
|
||||
|
||||
|
||||
shaderProgram = new ShaderProgram();
|
||||
shaderProgram->CompileVertexShader(L"Shaders/DirectX/vertex.hlsl");
|
||||
shaderProgram->CompilePixelShader(L"Shaders/DirectX/pixel.hlsl");
|
||||
D3D11_INPUT_ELEMENT_DESC VertexIED[] = {
|
||||
{"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
||||
{"NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
||||
@@ -117,8 +114,14 @@ void dd::Renderer::Initialize()
|
||||
{"BLENDWEIGHT", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
||||
{"BLENDWEIGHT", 1, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
||||
};
|
||||
shaderProgram->CreateInputLayout(VertexIED, sizeof(VertexIED) / sizeof(VertexIED[0]));
|
||||
shaderProgram->Bind();
|
||||
m_ForwardShaderProgram = new ShaderProgram();
|
||||
m_ForwardShaderProgram->CompileVertexShader(L"Shaders/DirectX/vertex.hlsl");
|
||||
m_ForwardShaderProgram->CompilePixelShader(L"Shaders/DirectX/pixel.hlsl");
|
||||
m_ForwardShaderProgram->CreateInputLayout(VertexIED, sizeof(VertexIED) / sizeof(VertexIED[0]));
|
||||
m_GUIShaderProgram = new ShaderProgram();
|
||||
m_GUIShaderProgram->CompileVertexShader(L"Shaders/DirectX/vertex.hlsl");
|
||||
m_GUIShaderProgram->CompilePixelShader(L"Shaders/DirectX/Flat.pixel.hlsl");
|
||||
m_GUIShaderProgram->CreateInputLayout(VertexIED, sizeof(VertexIED) / sizeof(VertexIED[0]));
|
||||
|
||||
// Create constant buffer
|
||||
// TODO: Put this in shader
|
||||
@@ -170,6 +173,8 @@ void dd::Renderer::Draw(RenderQueueCollection& rq)
|
||||
viewport.MaxDepth = 1;
|
||||
m_DeviceContext->RSSetViewports(1, &viewport);
|
||||
|
||||
m_ForwardShaderProgram->Bind();
|
||||
|
||||
Matrix proj = DirectX::SimpleMath::Matrix::CreatePerspectiveFieldOfView(m_Camera->m_FOV, m_Camera->m_AspectRatio, m_Camera->m_NearClip, m_Camera->m_FarClip); // Right-handed
|
||||
Matrix view = Matrix::CreateTranslation(Vector3(m_Camera->Position().x, m_Camera->Position().y, -m_Camera->Position().z));
|
||||
|
||||
@@ -263,6 +268,8 @@ void dd::Renderer::Draw(RenderQueueCollection& rq)
|
||||
}
|
||||
|
||||
m_DeviceContext->OMSetRenderTargets(1, &m_BackBuffer, nullptr);
|
||||
m_GUIShaderProgram->Bind();
|
||||
|
||||
for (auto &job : rq.GUI) {
|
||||
auto frameJob = std::dynamic_pointer_cast<FrameJob>(job);
|
||||
if (frameJob) {
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
cbuffer ConstantBuffer
|
||||
{
|
||||
float4x4 MVP;
|
||||
float4x4 ModelMatrix;
|
||||
float4x4 ViewMatrix;
|
||||
float4x4 ProjectionMatrix;
|
||||
float4x4 InverseTransposeViewModel;
|
||||
float4 Color;
|
||||
float4 LightPositions[10];
|
||||
float4 LightColors[10];
|
||||
float LightRadii[10];
|
||||
uint NumLights;
|
||||
}
|
||||
|
||||
Texture2D Texture;
|
||||
SamplerState samplerState;
|
||||
|
||||
struct VOut
|
||||
{
|
||||
float4 PixelPosition : SV_POSITION;
|
||||
float4 Position : POSITION;
|
||||
float4 Normal : NORMAL;
|
||||
float4 Tangent : TANGENT0;
|
||||
float4 BiTangent : TANGENT1;
|
||||
float2 TextureCoord : TEXCOORD;
|
||||
float4 DiffuseColor : COLOR0;
|
||||
float4 SpecularColor : COLOR1;
|
||||
float4 BoneIndices1 : BLENDINDICES0;
|
||||
float4 BoneIndices2 : BLENDINDICES1;
|
||||
float4 BoneWeights1 : BLENDWEIGHT0;
|
||||
float4 BoneWeights2 : BLENDWEIGHT1;
|
||||
};
|
||||
|
||||
float4 main(VOut input) : SV_TARGET
|
||||
{
|
||||
float4 diffuseTexture = Texture.Sample(samplerState, input.TextureCoord) * Color;
|
||||
return diffuseTexture;
|
||||
}
|
||||
Reference in New Issue
Block a user