Rebased Lights to Use World Coordinates
This commit is contained in:
parent
3139585e7b
commit
341e33ee78
|
@ -37,6 +37,7 @@ namespace Oyster
|
||||||
Math::Float2 Pixels;
|
Math::Float2 Pixels;
|
||||||
int Lights;
|
int Lights;
|
||||||
float Pad;
|
float Pad;
|
||||||
|
Oyster::Math::Float4x4 View;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Pointlight
|
struct Pointlight
|
||||||
|
|
|
@ -33,6 +33,7 @@ namespace Oyster
|
||||||
lc.InvProj = Projection.GetInverse();
|
lc.InvProj = Projection.GetInverse();
|
||||||
lc.Pixels = Core::resolution;
|
lc.Pixels = Core::resolution;
|
||||||
lc.Lights = numLights;
|
lc.Lights = numLights;
|
||||||
|
lc.View = View;
|
||||||
|
|
||||||
data = Resources::Deffered::LightConstantsData.Map();
|
data = Resources::Deffered::LightConstantsData.Map();
|
||||||
memcpy(data, &lc, sizeof(Definitions::LightConstants));
|
memcpy(data, &lc, sizeof(Definitions::LightConstants));
|
||||||
|
|
|
@ -21,6 +21,7 @@ cbuffer LightConstants : register(b0)
|
||||||
float2 Pixels;
|
float2 Pixels;
|
||||||
int Lights;
|
int Lights;
|
||||||
float Pad;
|
float Pad;
|
||||||
|
float4x4 View;
|
||||||
}
|
}
|
||||||
|
|
||||||
Texture2D DiffuseGlow : register(t0);
|
Texture2D DiffuseGlow : register(t0);
|
||||||
|
|
|
@ -4,7 +4,8 @@ DiffSpec LightCalc(PointLight pl, float3 pos, int2 texCoord)
|
||||||
{
|
{
|
||||||
DiffSpec output;
|
DiffSpec output;
|
||||||
float4 normalSpec = NormalSpec[texCoord];
|
float4 normalSpec = NormalSpec[texCoord];
|
||||||
float3 lightVec = pl.Pos - pos.xyz;
|
float4 LPos = mul(View, float4(pl.Pos, 1));
|
||||||
|
float3 lightVec = LPos.xyz - pos.xyz;
|
||||||
float d = length(lightVec);
|
float d = length(lightVec);
|
||||||
lightVec = lightVec/d;
|
lightVec = lightVec/d;
|
||||||
|
|
||||||
|
|
|
@ -210,7 +210,7 @@ HRESULT InitDirect3D()
|
||||||
Oyster::Graphics::Definitions::Pointlight pl;
|
Oyster::Graphics::Definitions::Pointlight pl;
|
||||||
pl.Color = Oyster::Math::Float3(1,1,1);
|
pl.Color = Oyster::Math::Float3(1,1,1);
|
||||||
pl.Bright = 1;
|
pl.Bright = 1;
|
||||||
pl.Pos = (V * Oyster::Math::Float4(Oyster::Math::Float3(0,0,5.4f), 1)).xyz;
|
pl.Pos = Oyster::Math::Float3(0,0,5.4f);
|
||||||
pl.Radius = 15;
|
pl.Radius = 15;
|
||||||
|
|
||||||
Oyster::Graphics::API::AddLight(pl);
|
Oyster::Graphics::API::AddLight(pl);
|
||||||
|
|
Loading…
Reference in New Issue