Irányfény fancy shaderrel
This commit is contained in:
parent
b1cba59ea8
commit
cc27d73ade
@ -284,7 +284,7 @@ namespace eg3d {
|
|||||||
mCommandList->RSSetViewports(1, &mViewPort);
|
mCommandList->RSSetViewports(1, &mViewPort);
|
||||||
mCommandList->RSSetScissorRects(1, &mScissorRect);
|
mCommandList->RSSetScissorRects(1, &mScissorRect);
|
||||||
|
|
||||||
mCommandList->ClearRenderTargetView(getCurrentBackBufferRTVHandle(), DirectX::Colors::LightSteelBlue, 0, nullptr);
|
mCommandList->ClearRenderTargetView(getCurrentBackBufferRTVHandle(), DirectX::Colors::Black, 0, nullptr);
|
||||||
mCommandList->ClearDepthStencilView(getDSVHandle(), D3D12_CLEAR_FLAG_DEPTH | D3D12_CLEAR_FLAG_STENCIL, 1.0f, 0, 0, nullptr);
|
mCommandList->ClearDepthStencilView(getDSVHandle(), D3D12_CLEAR_FLAG_DEPTH | D3D12_CLEAR_FLAG_STENCIL, 1.0f, 0, 0, nullptr);
|
||||||
|
|
||||||
mCommandList->OMSetRenderTargets(1, &getCurrentBackBufferRTVHandle(), true, &getDSVHandle());
|
mCommandList->OMSetRenderTargets(1, &getCurrentBackBufferRTVHandle(), true, &getDSVHandle());
|
||||||
@ -376,11 +376,14 @@ namespace eg3d {
|
|||||||
|
|
||||||
void DXWindow::updateConstantBuffers()
|
void DXWindow::updateConstantBuffers()
|
||||||
{
|
{
|
||||||
DirectX::XMStoreFloat4x4(&constantBuffer.transformMatrix, XMMatrixTranspose(XMMatrixRotationX(-XM_PIDIV2)));
|
//DirectX::XMStoreFloat4x4(&constantBuffer.transformMatrix, XMMatrixTranspose(XMMatrixRotationX(-XM_PIDIV2)));
|
||||||
|
|
||||||
if (pCam != nullptr) {
|
if (pCam != nullptr) {
|
||||||
constantBuffer.viewMatrix = pCam->getViewMatrix();
|
constantBuffer.viewMatrix = pCam->getViewMatrix();
|
||||||
constantBuffer.projMatrix = pCam->getProjMatrix();
|
constantBuffer.projMatrix = pCam->getProjMatrix();
|
||||||
|
|
||||||
|
XMFLOAT3 camPos = pCam->getViewParams().position;
|
||||||
|
constantBuffer.camPosition = { camPos.x, camPos.y, camPos.z, 0.0 };
|
||||||
}
|
}
|
||||||
|
|
||||||
bufferMapCopy(cbResource, static_cast<void *>(&constantBuffer), sizeof(constantBuffer));
|
bufferMapCopy(cbResource, static_cast<void *>(&constantBuffer), sizeof(constantBuffer));
|
||||||
|
@ -8,6 +8,7 @@ struct VSOutput // vertex shader kimeneti strukt
|
|||||||
{
|
{
|
||||||
float4 position_H : SV_Position;
|
float4 position_H : SV_Position;
|
||||||
float3 color : COLOR;
|
float3 color : COLOR;
|
||||||
|
float3 worldPosition : WORLDPOS;
|
||||||
};
|
};
|
||||||
|
|
||||||
cbuffer CFrame : register(b0)
|
cbuffer CFrame : register(b0)
|
||||||
@ -15,6 +16,7 @@ cbuffer CFrame : register(b0)
|
|||||||
float4x4 transformMatrix;
|
float4x4 transformMatrix;
|
||||||
float4x4 viewMatrix;
|
float4x4 viewMatrix;
|
||||||
float4x4 projMatrix;
|
float4x4 projMatrix;
|
||||||
|
float4 camPosition;
|
||||||
};
|
};
|
||||||
cbuffer CEntity : register(b1)
|
cbuffer CEntity : register(b1)
|
||||||
{
|
{
|
||||||
@ -26,10 +28,18 @@ VSOutput vs_main(VSInput input)
|
|||||||
{
|
{
|
||||||
VSOutput output; // vertex shader kimenete
|
VSOutput output; // vertex shader kimenete
|
||||||
|
|
||||||
output.position_H = mul(float4(input.position_D, 1.0), mul(worldMatrix, mul(viewMatrix, projMatrix)));
|
float4 worldCoords = mul(float4(input.position_D, 1.0), worldMatrix);
|
||||||
output.color = color;
|
output.position_H = mul(worldCoords, mul(viewMatrix, projMatrix));
|
||||||
|
|
||||||
// TODO fények
|
// TODO fények
|
||||||
|
float3 L = normalize(float3(1.0, 1.0, 0.5));
|
||||||
|
float3 I = float3(1.0, 1.0, 0.8);
|
||||||
|
float3 md = float3(1.0, 0.1, 0.1);
|
||||||
|
|
||||||
|
//float3 p = float3(1440, 370, -1365);
|
||||||
|
output.color = (I * color.xyz) * max(dot(input.normal, L), 0);
|
||||||
|
|
||||||
|
output.worldPosition = worldCoords;
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
@ -44,7 +54,8 @@ PSOutput ps_main(VSOutput input)
|
|||||||
PSOutput output;
|
PSOutput output;
|
||||||
|
|
||||||
//output.color = float4(0.0f, 1.0f, 0.0f, 1.0f);
|
//output.color = float4(0.0f, 1.0f, 0.0f, 1.0f);
|
||||||
output.color = float4(input.color, 1.0f);
|
output.color = float4(input.color, 1.0f) / length(input.worldPosition -
|
||||||
|
camPosition.xyz) * 200;
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
@ -4,4 +4,5 @@ SET PATH=%PATH%;C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\V
|
|||||||
fxc "basic_shader.hlsl" /Od /Zi /T vs_5_0 /E "vs_main" /Fo "vs.cso"
|
fxc "basic_shader.hlsl" /Od /Zi /T vs_5_0 /E "vs_main" /Fo "vs.cso"
|
||||||
fxc "basic_shader.hlsl" /Od /Zi /T ps_5_0 /E "ps_main" /Fo "ps.cso"
|
fxc "basic_shader.hlsl" /Od /Zi /T ps_5_0 /E "ps_main" /Fo "ps.cso"
|
||||||
|
|
||||||
|
|
||||||
::PAUSE
|
::PAUSE
|
@ -14,6 +14,7 @@ struct CB_Frame
|
|||||||
DirectX::XMFLOAT4X4 transformMatrix;
|
DirectX::XMFLOAT4X4 transformMatrix;
|
||||||
DirectX::XMFLOAT4X4 viewMatrix; // nézet-mátrix
|
DirectX::XMFLOAT4X4 viewMatrix; // nézet-mátrix
|
||||||
DirectX::XMFLOAT4X4 projMatrix; // vetítési mátrix
|
DirectX::XMFLOAT4X4 projMatrix; // vetítési mátrix
|
||||||
|
DirectX::XMFLOAT4 camPosition; // kamerapozíció
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CB_Entity {
|
struct CB_Entity {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user