Commit 9b867608 authored by chili's avatar chili
Browse files

constant strife

parent 6ed79cdb
cbuffer LightCBuf
{
float3 lightPos;
float3 materialColor;
float3 ambient;
float3 diffuseColor;
float diffuseIntensity;
float attConst;
float attLin;
float attQuad;
};
static const float3 materialColor = { 0.7f,0.7f,0.9f };
static const float3 ambient = { 0.05f,0.05f,0.05f };
static const float3 diffuseColor = { 1.0f,1.0f,1.0f };
static const float diffuseIntensity = 1.0f;
static const float attConst = 1.0f;
static const float attLin = 0.045f;
static const float attQuad = 0.0075f;
float4 main( float3 worldPos : Position,float3 n : Normal ) : SV_Target
{
......
......@@ -5,16 +5,18 @@ PointLight::PointLight( Graphics& gfx,float radius )
:
mesh( gfx,radius ),
cbuf( gfx )
{}
{
Reset();
}
void PointLight::SpawnControlWindow() noexcept
{
if( ImGui::Begin( "Light" ) )
{
ImGui::Text( "Position" );
ImGui::SliderFloat( "X",&pos.x,-60.0f,60.0f,"%.1f" );
ImGui::SliderFloat( "Y",&pos.y,-60.0f,60.0f,"%.1f" );
ImGui::SliderFloat( "Z",&pos.z,-60.0f,60.0f,"%.1f" );
ImGui::SliderFloat( "X",&cbData.pos.x,-60.0f,60.0f,"%.1f" );
ImGui::SliderFloat( "Y",&cbData.pos.y,-60.0f,60.0f,"%.1f" );
ImGui::SliderFloat( "Z",&cbData.pos.z,-60.0f,60.0f,"%.1f" );
if( ImGui::Button( "Reset" ) )
{
Reset();
......@@ -25,17 +27,26 @@ void PointLight::SpawnControlWindow() noexcept
void PointLight::Reset() noexcept
{
pos = { 0.0f,0.0f,0.0f };
cbData = {
{ 0.0f,0.0f,0.0f },
{ 0.7f,0.7f,0.9f },
{ 0.05f,0.05f,0.05f },
{ 1.0f,1.0f,1.0f },
1.0f,
1.0f,
0.045f,
0.0075f,
};
}
void PointLight::Draw( Graphics& gfx ) const noexcept(!IS_DEBUG)
{
mesh.SetPos( pos );
mesh.SetPos( cbData.pos );
mesh.Draw( gfx );
}
void PointLight::Bind( Graphics& gfx ) const noexcept
{
cbuf.Update( gfx,PointLightCBuf{ pos } );
cbuf.Update( gfx,cbData );
cbuf.Bind( gfx );
}
......@@ -15,10 +15,16 @@ private:
struct PointLightCBuf
{
DirectX::XMFLOAT3 pos;
float padding;
DirectX::XMFLOAT3 materialColor;
DirectX::XMFLOAT3 ambient;
DirectX::XMFLOAT3 diffuseColor;
float diffuseIntensity;
float attConst;
float attLin;
float attQuad;
};
private:
DirectX::XMFLOAT3 pos = { 0.0f,0.0f,0.0f };;
PointLightCBuf cbData;
mutable SolidSphere mesh;
mutable PixelConstantBuffer<PointLightCBuf> cbuf;
};
\ 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