Commit 0b69ae86 authored by chili's avatar chili
Browse files

better, but position doesn't matter

parent 8332eb95
...@@ -4,12 +4,12 @@ cbuffer LightCBuf ...@@ -4,12 +4,12 @@ cbuffer LightCBuf
}; };
static const float3 materialColor = { 0.7f,0.7f,0.9f }; static const float3 materialColor = { 0.7f,0.7f,0.9f };
static const float3 ambient = { 0.15f,0.15f,0.15f }; static const float3 ambient = { 0.05f,0.05f,0.05f };
static const float3 diffuseColor = { 1.0f,1.0f,1.0f }; static const float3 diffuseColor = { 1.0f,1.0f,1.0f };
static const float diffuseIntensity = 1.0f; static const float diffuseIntensity = 1.0f;
static const float attConst = 1.0f; static const float attConst = 1.0f;
static const float attLin = 1.0f; static const float attLin = 0.045f;
static const float attQuad = 1.0f; static const float attQuad = 0.0075f;
float4 main( float3 worldPos : Position,float3 n : Normal ) : SV_Target float4 main( float3 worldPos : Position,float3 n : Normal ) : SV_Target
{ {
...@@ -18,7 +18,7 @@ float4 main( float3 worldPos : Position,float3 n : Normal ) : SV_Target ...@@ -18,7 +18,7 @@ float4 main( float3 worldPos : Position,float3 n : Normal ) : SV_Target
const float distToL = length( vToL ); const float distToL = length( vToL );
const float3 dirToL = vToL / distToL; const float3 dirToL = vToL / distToL;
// diffuse attenuation // diffuse attenuation
const float att = attConst + attLin * distToL + attQuad * (distToL * distToL); const float att = 1.0f / (attConst + attLin * distToL + attQuad * (distToL * distToL));
// diffuse intensity // diffuse intensity
const float3 diffuse = diffuseColor * diffuseIntensity * att * max( 0.0f,dot( dirToL,n ) ); const float3 diffuse = diffuseColor * diffuseIntensity * att * max( 0.0f,dot( dirToL,n ) );
// final color // final color
......
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