PR #235 also enable light culling plane by flag

This commit is contained in:
dexy
2024-07-18 14:05:49 +10:00
Unverified
parent 29530a05f6
commit d049e3ad1c
15 changed files with 1401 additions and 1053 deletions
@@ -27,26 +27,26 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
+10 -5
View File
@@ -38,6 +38,10 @@ cbuffer PSLightInstVars : register(b2)
uint InstType;
float3 InstCullingPlaneNormal;
float InstCullingPlaneOffset;
uint InstCullingPlaneEnable;
uint InstUnused1;
uint InstUnused2;
uint InstUnused3;
}
@@ -170,19 +174,20 @@ float4 DeferredLight(float3 camRel, float3 norm, float4 diffuse, float4 specular
{
float3 srpos = InstPosition - camRel; //light position relative to surface position
float ldist = length(srpos);
if (InstCullingPlaneEnable == 1)
{
float d = dot(srpos, InstCullingPlaneNormal) - InstCullingPlaneOffset;
if (d > 0) return 0;
}
if (InstType == 4)//capsule
{
float3 ext = InstDirection.xyz * (InstCapsuleExtent.y * 0.5);
float3 ext = InstDirection.xyz * (InstCapsuleExtent.x * 0.5);
float4 lsn = GetLineSegmentNearestPoint(srpos, ext, -ext);
ldist = lsn.w;
srpos.xyz = lsn.xyz;
}
if (ldist > InstFalloff) return 0;
if (ldist <= 0) return 0;
float d = dot(srpos, InstCullingPlaneNormal) - InstCullingPlaneOffset;
if (d > 0) return 0;
float4 rgbi = float4(InstColour, InstIntensity);
float3 lcol = rgbi.rgb;// * rgbi.a; // * 5.0f;
float3 ldir = srpos / ldist;
+1 -1
View File
@@ -56,7 +56,7 @@ VS_Output main(float4 ipos : POSITION, uint iid : SV_InstanceID)
else if (InstType == 4)//capsule
{
float3 cpos = ipos.xyz * extent;
cpos.y += abs(InstCapsuleExtent.y) * (ipos.w - 0.5);
cpos.y += abs(InstCapsuleExtent.x) * (ipos.w - 0.5);
opos = (cpos.x * InstTangentX.xyz) + (cpos.y * InstDirection.xyz) + (cpos.z * InstTangentY.xyz);
}