Refactoring graphics
This commit is contained in:
@@ -4,7 +4,7 @@ import Common;
|
||||
|
||||
interface ILightEnv
|
||||
{
|
||||
float3 illuminate<B:IBRDF>(MaterialFragmentParameter input, B brdf);
|
||||
float3 illuminate<B:IBRDF>(MaterialParameter input, B brdf);
|
||||
};
|
||||
|
||||
struct DirectionalLight : ILightEnv
|
||||
@@ -12,9 +12,9 @@ struct DirectionalLight : ILightEnv
|
||||
float4 color;
|
||||
float4 direction;
|
||||
|
||||
float3 illuminate<B:IBRDF>(MaterialFragmentParameter input, B brdf)
|
||||
float3 illuminate<B:IBRDF>(MaterialParameter input, B brdf)
|
||||
{
|
||||
float3 lightDir_TS = input.transformWorldToTangent(normalize(direction.xyz));
|
||||
float3 lightDir_TS = normalize(direction.xyz);
|
||||
return brdf.evaluate(input.viewDir_TS, -lightDir_TS, color.xyz);
|
||||
}
|
||||
};
|
||||
@@ -24,9 +24,9 @@ struct PointLight : ILightEnv
|
||||
float4 position_WS;
|
||||
float4 colorRange;
|
||||
|
||||
float3 illuminate<B:IBRDF>(MaterialFragmentParameter input, B brdf)
|
||||
float3 illuminate<B:IBRDF>(MaterialParameter input, B brdf)
|
||||
{
|
||||
float3 position_TS = input.transformWorldToTangent(position_WS.xyz);
|
||||
float3 position_TS = position_WS.xyz;
|
||||
float3 lightDir_TS = position_TS - input.position_TS;
|
||||
float d = length(lightDir_TS);
|
||||
float illuminance = max(1 - d / colorRange.w, 0);
|
||||
@@ -48,7 +48,7 @@ struct PointLight : ILightEnv
|
||||
}
|
||||
for(int i = 0; i < 4 && result; ++i)
|
||||
{
|
||||
if(insidePlane(frustum.planes[i]))
|
||||
if(insidePlane(frustum.sides[i]))
|
||||
{
|
||||
//result = false;
|
||||
}
|
||||
@@ -57,7 +57,7 @@ struct PointLight : ILightEnv
|
||||
}
|
||||
float3 getViewPos()
|
||||
{
|
||||
return mul(gViewParams.viewMatrix, position_WS).xyz;
|
||||
return mul(viewParams.viewMatrix, position_WS).xyz;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -65,7 +65,7 @@ struct LightEnv
|
||||
{
|
||||
StructuredBuffer<DirectionalLight> directionalLights;
|
||||
uint numDirectionalLights;
|
||||
StructureBuffer<PointLight> pointLights;
|
||||
StructuredBuffer<PointLight> pointLights;
|
||||
uint numPointLights;
|
||||
};
|
||||
|
||||
|
||||
@@ -2,11 +2,13 @@ import VertexData;
|
||||
|
||||
struct MaterialParameter
|
||||
{
|
||||
float3 position_TS;
|
||||
float3 worldPosition;
|
||||
float2 texCoords;
|
||||
float3 normal;
|
||||
float3 tangent;
|
||||
float3 biTangent;
|
||||
float3 viewDir_TS;
|
||||
|
||||
static MaterialParameter create(VertexAttributes attrib)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user