Skip to content

Commit 1e9188b

Browse files
committed
Add the 'Line' light archetype and fix the scene
1 parent 3730965 commit 1e9188b

File tree

3 files changed

+86
-21
lines changed

3 files changed

+86
-21
lines changed

Assets/ScriptableRenderLoop/AdditionalLightData.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
namespace UnityEngine.Experimental.ScriptableRenderLoop
22
{
3-
//@TODO: We should continously move these values
3+
public enum LightArchetype {Punctual, Rectangle, Line};
4+
5+
//@TODO: We should continuously move these values
46
// into the engine when we can see them being generally useful
57
[RequireComponent(typeof(Light))]
68
public class AdditionalLightData : MonoBehaviour
79
{
10+
811
public const int DefaultShadowResolution = 512;
912

1013
public int shadowResolution = DefaultShadowResolution;
@@ -31,9 +34,8 @@ public float GetInnerSpotPercent01()
3134
public bool affectDiffuse = true;
3235
public bool affectSpecular = true;
3336

34-
// Area Light Hack
35-
public bool treatAsAreaLight = false;
36-
public bool isDoubleSided = false;
37+
public LightArchetype archetype = LightArchetype.Punctual;
38+
public bool isDoubleSided = false;
3739

3840
[RangeAttribute(0.0f, 20.0f)]
3941
public float areaLightLength = 0.0f;

Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.cs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -776,15 +776,22 @@ void ConvertLightForGPU(CullResults cullResults, ref ShadowOutput shadowOutput,
776776
// Note: LightType.Area is offline only, use for baking, no need to test it
777777
var lightData = new LightData();
778778

779-
// Early out if we reach the maximum
780779
// Test whether we should treat this punctual light as an area light.
781780
// It's a temporary hack until the proper UI support is added.
782-
if (additionalData.treatAsAreaLight)
781+
if (additionalData.archetype != LightArchetype.Punctual)
783782
{
783+
// Early out if we reach the maximum
784784
if (lightList.areaLights.Count >= k_MaxAreaLightsOnSCreen)
785785
continue;
786786

787-
lightData.lightType = GPULightType.Rectangle;
787+
if (additionalData.archetype == LightArchetype.Rectangle)
788+
{
789+
lightData.lightType = GPULightType.Rectangle;
790+
}
791+
else
792+
{
793+
lightData.lightType = GPULightType.Line;
794+
}
788795
}
789796
else
790797
{
@@ -874,13 +881,14 @@ void ConvertLightForGPU(CullResults cullResults, ref ShadowOutput shadowOutput,
874881
lightData.size = new Vector2(additionalData.areaLightLength, additionalData.areaLightWidth);
875882
lightData.twoSided = additionalData.isDoubleSided;
876883

877-
if (additionalData.treatAsAreaLight)
884+
if (additionalData.archetype == LightArchetype.Punctual)
878885
{
879-
lightList.areaLights.Add(lightData);
886+
lightList.punctualLights.Add(lightData);
880887
}
881888
else
882889
{
883-
lightList.punctualLights.Add(lightData);
890+
// Area and line lights are both currently stored as area lights on the GPU.
891+
lightList.areaLights.Add(lightData);
884892
}
885893
}
886894

Assets/TestScenes/HDTest/HDRenderLoopTest.unity

Lines changed: 66 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ RenderSettings:
2525
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
2626
m_AmbientIntensity: 1
2727
m_AmbientMode: 0
28-
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
28+
m_SkyboxMaterial: {fileID: 0}
2929
m_HaloStrength: 0.5
3030
m_FlareStrength: 1
3131
m_FlareFadeSpeed: 3
@@ -1786,7 +1786,7 @@ MonoBehaviour:
17861786
shadowDimmer: 1
17871787
affectDiffuse: 1
17881788
affectSpecular: 1
1789-
treatAsAreaLight: 0
1789+
archetype: 0
17901790
isDoubleSided: 0
17911791
areaLightLength: 0
17921792
areaLightWidth: 0
@@ -1933,7 +1933,7 @@ MonoBehaviour:
19331933
shadowDimmer: 1
19341934
affectDiffuse: 1
19351935
affectSpecular: 1
1936-
treatAsAreaLight: 0
1936+
archetype: 0
19371937
isDoubleSided: 0
19381938
areaLightLength: 0
19391939
areaLightWidth: 0
@@ -2531,7 +2531,7 @@ MonoBehaviour:
25312531
shadowDimmer: 1
25322532
affectDiffuse: 1
25332533
affectSpecular: 1
2534-
treatAsAreaLight: 0
2534+
archetype: 0
25352535
isDoubleSided: 0
25362536
areaLightLength: 0
25372537
areaLightWidth: 0
@@ -2885,7 +2885,7 @@ MonoBehaviour:
28852885
shadowDimmer: 1
28862886
affectDiffuse: 1
28872887
affectSpecular: 1
2888-
treatAsAreaLight: 0
2888+
archetype: 0
28892889
isDoubleSided: 0
28902890
areaLightLength: 0
28912891
areaLightWidth: 0
@@ -3009,7 +3009,7 @@ MonoBehaviour:
30093009
shadowDimmer: 1
30103010
affectDiffuse: 1
30113011
affectSpecular: 1
3012-
treatAsAreaLight: 1
3012+
archetype: 0
30133013
isDoubleSided: 1
30143014
areaLightLength: 16
30153015
areaLightWidth: 2
@@ -3226,6 +3226,8 @@ GameObject:
32263226
- component: {fileID: 925222277}
32273227
- component: {fileID: 925222276}
32283228
- component: {fileID: 925222275}
3229+
- component: {fileID: 925222279}
3230+
- component: {fileID: 925222278}
32293231
m_Layer: 0
32303232
m_Name: LightQuad
32313233
m_TagString: Untagged
@@ -3299,6 +3301,59 @@ MeshFilter:
32993301
m_PrefabInternal: {fileID: 0}
33003302
m_GameObject: {fileID: 925222273}
33013303
m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0}
3304+
--- !u!114 &925222278
3305+
MonoBehaviour:
3306+
m_ObjectHideFlags: 0
3307+
m_PrefabParentObject: {fileID: 0}
3308+
m_PrefabInternal: {fileID: 0}
3309+
m_GameObject: {fileID: 925222273}
3310+
m_Enabled: 1
3311+
m_EditorHideFlags: 0
3312+
m_Script: {fileID: 11500000, guid: 7a68c43fe1f2a47cfa234b5eeaa98012, type: 3}
3313+
m_Name:
3314+
m_EditorClassIdentifier:
3315+
shadowResolution: 512
3316+
shadowDimmer: 1
3317+
affectDiffuse: 1
3318+
affectSpecular: 1
3319+
archetype: 1
3320+
isDoubleSided: 1
3321+
areaLightLength: 16
3322+
areaLightWidth: 2
3323+
--- !u!108 &925222279
3324+
Light:
3325+
m_ObjectHideFlags: 0
3326+
m_PrefabParentObject: {fileID: 0}
3327+
m_PrefabInternal: {fileID: 0}
3328+
m_GameObject: {fileID: 925222273}
3329+
m_Enabled: 1
3330+
serializedVersion: 7
3331+
m_Type: 2
3332+
m_Color: {r: 1, g: 1, b: 1, a: 1}
3333+
m_Intensity: 1
3334+
m_Range: 10
3335+
m_SpotAngle: 30
3336+
m_CookieSize: 10
3337+
m_Shadows:
3338+
m_Type: 0
3339+
m_Resolution: -1
3340+
m_CustomResolution: -1
3341+
m_Strength: 1
3342+
m_Bias: 0.05
3343+
m_NormalBias: 0.4
3344+
m_NearPlane: 0.2
3345+
m_Cookie: {fileID: 0}
3346+
m_DrawHalo: 0
3347+
m_Flare: {fileID: 0}
3348+
m_RenderMode: 0
3349+
m_CullingMask:
3350+
serializedVersion: 2
3351+
m_Bits: 4294967295
3352+
m_Lightmapping: 4
3353+
m_AreaSize: {x: 1, y: 1}
3354+
m_BounceIntensity: 1
3355+
m_ShadowRadius: 0
3356+
m_ShadowAngle: 0
33023357
--- !u!1 &928571527
33033358
GameObject:
33043359
m_ObjectHideFlags: 0
@@ -3436,7 +3491,7 @@ MonoBehaviour:
34363491
shadowDimmer: 1
34373492
affectDiffuse: 1
34383493
affectSpecular: 1
3439-
treatAsAreaLight: 0
3494+
archetype: 0
34403495
isDoubleSided: 0
34413496
areaLightLength: 0
34423497
areaLightWidth: 0
@@ -4628,7 +4683,7 @@ MonoBehaviour:
46284683
shadowDimmer: 1
46294684
affectDiffuse: 1
46304685
affectSpecular: 1
4631-
treatAsAreaLight: 0
4686+
archetype: 0
46324687
isDoubleSided: 0
46334688
areaLightLength: 0
46344689
areaLightWidth: 0
@@ -6218,7 +6273,7 @@ MonoBehaviour:
62186273
shadowDimmer: 1
62196274
affectDiffuse: 1
62206275
affectSpecular: 1
6221-
treatAsAreaLight: 1
6276+
archetype: 1
62226277
isDoubleSided: 1
62236278
areaLightLength: 4
62246279
areaLightWidth: 2
@@ -6730,7 +6785,7 @@ MeshRenderer:
67306785
m_LightProbeUsage: 1
67316786
m_ReflectionProbeUsage: 1
67326787
m_Materials:
6733-
- {fileID: 2100000, guid: 7af9798eeefeae34c83aca56762a2938, type: 2}
6788+
- {fileID: 2100000, guid: f03665895dc89b84487310c5216b8458, type: 2}
67346789
m_StaticBatchInfo:
67356790
firstSubMesh: 0
67366791
subMeshCount: 0
@@ -7646,7 +7701,7 @@ MonoBehaviour:
76467701
shadowDimmer: 1
76477702
affectDiffuse: 1
76487703
affectSpecular: 1
7649-
treatAsAreaLight: 0
7704+
archetype: 0
76507705
isDoubleSided: 0
76517706
areaLightLength: 0
76527707
areaLightWidth: 0

0 commit comments

Comments
 (0)