Commit d6e000ca authored by chili's avatar chili
Browse files

cylinder all fixed up

parent 59fa1103
...@@ -55,10 +55,10 @@ Box::Box( Graphics& gfx, ...@@ -55,10 +55,10 @@ Box::Box( Graphics& gfx,
struct PSMaterialConstant struct PSMaterialConstant
{ {
alignas(16) dx::XMFLOAT3 color; dx::XMFLOAT3 color;
float specularIntensity = 0.6f; float specularIntensity = 0.6f;
float specularPower = 30.0f; float specularPower = 30.0f;
float padding[2]; float padding[3];
} colorConst; } colorConst;
colorConst.color = material; colorConst.color = material;
AddBind( std::make_unique<PixelConstantBuffer<PSMaterialConstant>>( gfx,colorConst,1u ) ); AddBind( std::make_unique<PixelConstantBuffer<PSMaterialConstant>>( gfx,colorConst,1u ) );
......
...@@ -44,7 +44,7 @@ Cylinder::Cylinder( Graphics& gfx,std::mt19937& rng, ...@@ -44,7 +44,7 @@ Cylinder::Cylinder( Graphics& gfx,std::mt19937& rng,
struct PSMaterialConstant struct PSMaterialConstant
{ {
alignas(16) dx::XMFLOAT3A colors[6] = { dx::XMFLOAT3A colors[6] = {
{1.0f,0.0f,0.0f}, {1.0f,0.0f,0.0f},
{0.0f,1.0f,0.0f}, {0.0f,1.0f,0.0f},
{0.0f,0.0f,1.0f}, {0.0f,0.0f,1.0f},
......
...@@ -12,6 +12,7 @@ cbuffer LightCBuf ...@@ -12,6 +12,7 @@ cbuffer LightCBuf
cbuffer ObjectCBuf cbuffer ObjectCBuf
{ {
float3 materialColors[6]; float3 materialColors[6];
float padding;
float specularIntensity; float specularIntensity;
float specularPower; float specularPower;
}; };
...@@ -33,5 +34,5 @@ float4 main( float3 worldPos : Position,float3 n : Normal,uint tid : SV_Primitiv ...@@ -33,5 +34,5 @@ float4 main( float3 worldPos : Position,float3 n : Normal,uint tid : SV_Primitiv
// calculate specular intensity based on angle between viewing vector and reflection vector, narrow with power function // calculate specular intensity based on angle between viewing vector and reflection vector, narrow with power function
const float3 specular = att * (diffuseColor * diffuseIntensity) * specularIntensity * pow( max( 0.0f,dot( normalize( -r ),normalize( worldPos ) ) ),specularPower ); const float3 specular = att * (diffuseColor * diffuseIntensity) * specularIntensity * pow( max( 0.0f,dot( normalize( -r ),normalize( worldPos ) ) ),specularPower );
// final color // final color
return float4(saturate( (diffuse + ambient + specular) * materialColors[tid % 6] ),1.0f); return float4(saturate((diffuse + ambient + specular) * materialColors[(tid / 2) % 6]), 1.0f);
} }
\ No newline at end of file
...@@ -289,6 +289,12 @@ ...@@ -289,6 +289,12 @@
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">4.0</ShaderModel> <ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">4.0</ShaderModel>
<ObjectFileOutput Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir)%(Filename).cso</ObjectFileOutput> <ObjectFileOutput Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir)%(Filename).cso</ObjectFileOutput>
<ObjectFileOutput Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectDir)%(Filename).cso</ObjectFileOutput> <ObjectFileOutput Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectDir)%(Filename).cso</ObjectFileOutput>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Pixel</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">4.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Pixel</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|x64'">4.0</ShaderModel>
<ObjectFileOutput Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir)%(Filename).cso</ObjectFileOutput>
<ObjectFileOutput Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectDir)%(Filename).cso</ObjectFileOutput>
</FxCompile> </FxCompile>
<FxCompile Include="SolidPS.hlsl"> <FxCompile Include="SolidPS.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Pixel</ShaderType> <ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Pixel</ShaderType>
......
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