mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2024-11-22 15:02:54 +08:00
Interior lights improvements
This commit is contained in:
parent
c6aa4c7baf
commit
d59663d87e
@ -103,8 +103,8 @@ float4 DeferredLODLight(float3 camRel, float3 norm, float4 diffuse, float4 specu
|
|||||||
else if (LightType == 2)//spot (cone)
|
else if (LightType == 2)//spot (cone)
|
||||||
{
|
{
|
||||||
float ang = acos(-dot(ldir, lodlight.Direction));
|
float ang = acos(-dot(ldir, lodlight.Direction));
|
||||||
float iang = lodlight.InnerAngle * 0.01745329 * 0.5;
|
float iang = lodlight.InnerAngle;
|
||||||
float oang = lodlight.OuterAngleOrCapExt * 0.01745329 * 0.5;
|
float oang = lodlight.OuterAngleOrCapExt;
|
||||||
if (ang > oang) return 0;
|
if (ang > oang) return 0;
|
||||||
lamt *= saturate(1 - ((ang - iang) / (oang - iang)));
|
lamt *= saturate(1 - ((ang - iang) / (oang - iang)));
|
||||||
lamt *= pow(saturate(1 - (ldist / lodlight.Falloff)), lodlight.FalloffExponent);
|
lamt *= pow(saturate(1 - (ldist / lodlight.Falloff)), lodlight.FalloffExponent);
|
||||||
@ -148,8 +148,8 @@ float4 DeferredLight(float3 camRel, float3 norm, float4 diffuse, float4 specular
|
|||||||
else if (InstType == 2)//spot (cone)
|
else if (InstType == 2)//spot (cone)
|
||||||
{
|
{
|
||||||
float ang = acos(-dot(ldir, InstDirection));
|
float ang = acos(-dot(ldir, InstDirection));
|
||||||
float iang = InstConeInnerAngle * 0.01745329 * 0.5;
|
float iang = InstConeInnerAngle;
|
||||||
float oang = InstConeOuterAngle * 0.01745329 * 0.5;
|
float oang = InstConeOuterAngle;
|
||||||
if (ang > oang) return 0;
|
if (ang > oang) return 0;
|
||||||
lamt *= saturate(1 - ((ang - iang) / (oang - iang)));
|
lamt *= saturate(1 - ((ang - iang) / (oang - iang)));
|
||||||
lamt *= pow(saturate(1 - (ldist / InstFalloff)), InstFalloffExponent);
|
lamt *= pow(saturate(1 - (ldist / InstFalloff)), InstFalloffExponent);
|
||||||
|
@ -48,7 +48,7 @@ VS_Output main(float4 ipos : POSITION, uint iid : SV_InstanceID)
|
|||||||
}
|
}
|
||||||
else if (InstType == 2)//spot (cone)
|
else if (InstType == 2)//spot (cone)
|
||||||
{
|
{
|
||||||
float arads = InstConeOuterAngle * 0.01745329 * 0.5; // deg -> rad
|
float arads = InstConeOuterAngle;
|
||||||
float3 cpos = ipos.xyz * (tan(arads) * extent);
|
float3 cpos = ipos.xyz * (tan(arads) * extent);
|
||||||
cpos.y += ipos.w * extent;
|
cpos.y += ipos.w * extent;
|
||||||
opos = (cpos.x * InstTangentX) + (cpos.y * InstDirection) + (cpos.z * InstTangentY);
|
opos = (cpos.x * InstTangentX) + (cpos.y * InstDirection) + (cpos.z * InstTangentY);
|
||||||
|
@ -46,7 +46,7 @@ VS_Output main(float4 ipos : POSITION, uint iid : SV_InstanceID)
|
|||||||
}
|
}
|
||||||
else if (LightType == 2)//spot (cone)
|
else if (LightType == 2)//spot (cone)
|
||||||
{
|
{
|
||||||
float arads = lodlight.OuterAngleOrCapExt * 0.01745329 * 0.5; // deg -> rad
|
float arads = lodlight.OuterAngleOrCapExt;
|
||||||
float3 cpos = ipos.xyz * (tan(arads) * extent);
|
float3 cpos = ipos.xyz * (tan(arads) * extent);
|
||||||
cpos.y += ipos.w * extent;
|
cpos.y += ipos.w * extent;
|
||||||
opos = (cpos.x * lodlight.TangentX.xyz) + (cpos.y * lodlight.Direction.xyz) + (cpos.z * lodlight.TangentY.xyz);
|
opos = (cpos.x * lodlight.TangentX.xyz) + (cpos.y * lodlight.Direction.xyz) + (cpos.z * lodlight.TangentY.xyz);
|
||||||
@ -54,7 +54,7 @@ VS_Output main(float4 ipos : POSITION, uint iid : SV_InstanceID)
|
|||||||
else if (LightType == 4)//capsule
|
else if (LightType == 4)//capsule
|
||||||
{
|
{
|
||||||
float3 cpos = ipos.xyz * extent;
|
float3 cpos = ipos.xyz * extent;
|
||||||
cpos.y += (ipos.w * 2 - 1) * lodlight.OuterAngleOrCapExt * 0.1;
|
cpos.y += (ipos.w * 2 - 1) * lodlight.OuterAngleOrCapExt;
|
||||||
opos = (cpos.x * lodlight.TangentX.xyz) + (cpos.y * lodlight.Direction.xyz) + (cpos.z * lodlight.TangentY.xyz);
|
opos = (cpos.x * lodlight.TangentX.xyz) + (cpos.y * lodlight.Direction.xyz) + (cpos.z * lodlight.TangentY.xyz);
|
||||||
}
|
}
|
||||||
opos += (lodlight.Position - CameraPos.xyz);
|
opos += (lodlight.Position - CameraPos.xyz);
|
||||||
|
@ -1359,9 +1359,9 @@ namespace CodeWalker.Rendering
|
|||||||
Type = l.Type;
|
Type = l.Type;
|
||||||
Intensity = l.Intensity;
|
Intensity = l.Intensity;
|
||||||
Falloff = l.Falloff;
|
Falloff = l.Falloff;
|
||||||
FalloffExponent = l.FalloffExponent;
|
FalloffExponent = Math.Max(l.FalloffExponent * 0.25f, 0.5f);//is this right?
|
||||||
ConeInnerAngle = l.ConeInnerAngle;
|
ConeInnerAngle = l.ConeInnerAngle * 0.01745329f; //is this right??
|
||||||
ConeOuterAngle = l.ConeOuterAngle;
|
ConeOuterAngle = l.ConeOuterAngle * 0.01745329f; //pi/180
|
||||||
CapsuleExtent = l.Extent;
|
CapsuleExtent = l.Extent;
|
||||||
CullingPlaneNormal = l.CullingPlaneNormal;
|
CullingPlaneNormal = l.CullingPlaneNormal;
|
||||||
CullingPlaneOffset = l.CullingPlaneOffset;
|
CullingPlaneOffset = l.CullingPlaneOffset;
|
||||||
@ -1491,8 +1491,8 @@ namespace CodeWalker.Rendering
|
|||||||
light.TangentY = new Vector4(Vector3.Cross(light.Direction, light.TangentX.XYZ()), 0.0f);
|
light.TangentY = new Vector4(Vector3.Cross(light.Direction, light.TangentX.XYZ()), 0.0f);
|
||||||
light.Falloff = ll.falloff[i];
|
light.Falloff = ll.falloff[i];
|
||||||
light.FalloffExponent = Math.Max(ll.falloffExponent[i]*0.01f, 0.5f);//is this right?
|
light.FalloffExponent = Math.Max(ll.falloffExponent[i]*0.01f, 0.5f);//is this right?
|
||||||
light.InnerAngle = ll.coneInnerAngle[i];
|
light.InnerAngle = ll.coneInnerAngle[i] * 0.0087266462f; //pi/360
|
||||||
light.OuterAngleOrCapExt = ll.coneOuterAngleOrCapExt[i];
|
light.OuterAngleOrCapExt = ll.coneOuterAngleOrCapExt[i] * 0.0087266462f; //pi/360
|
||||||
var type = (LightType)((light.TimeAndStateFlags >> 26) & 7);
|
var type = (LightType)((light.TimeAndStateFlags >> 26) & 7);
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
@ -1503,6 +1503,7 @@ namespace CodeWalker.Rendering
|
|||||||
spots.Add(light);
|
spots.Add(light);
|
||||||
break;
|
break;
|
||||||
case LightType.Capsule:
|
case LightType.Capsule:
|
||||||
|
light.OuterAngleOrCapExt = ll.coneOuterAngleOrCapExt[i] * 0.1f;//is this right?
|
||||||
caps.Add(light);
|
caps.Add(light);
|
||||||
break;
|
break;
|
||||||
default: break;//just checking...
|
default: break;//just checking...
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user