比较提交

...
此合并请求有变更与目标分支冲突。
/ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/HDLightEditor.Styles.cs
/ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/HDLightEditor.cs
/ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/HDAdditionalLightData.cs
/ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightUtils.cs
/ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightUtils.cs.meta

3 次代码提交

共有 5 个文件被更改,包括 103 次插入6 次删除
  1. 1
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/HDLightEditor.Styles.cs
  2. 29
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/HDLightEditor.cs
  3. 13
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/HDAdditionalLightData.cs
  4. 55
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightUtils.cs
  5. 11
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightUtils.cs.meta

1
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/HDLightEditor.Styles.cs


public readonly GUIContent shapeWidthLine = new GUIContent("Length", "Length of the line light");
public readonly GUIContent shapeWidthRect = new GUIContent("Size X", "SizeX of the rectangle light");
public readonly GUIContent shapeHeightRect = new GUIContent("Size Y", "SizeY of the rectangle light");
public readonly GUIContent intensityPhysicalUnit = new GUIContent("intensity (in Lumens)", "Luminous power of the light in lumens, typical value is 600 for a light bulb - 1200 for a strong light bulb");
public readonly GUIContent aspectRatioPyramid = new GUIContent("Aspect ratio", "");
public readonly GUIContent shapeWidthBox = new GUIContent("Size X", "");
public readonly GUIContent shapeHeightBox = new GUIContent("Size Y", "");

29
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/HDLightEditor.cs


{
sealed class SerializedLightData
{
public SerializedProperty directionalIntensity;
public SerializedProperty punctualIntensity;
public SerializedProperty spotInnerPercent;
public SerializedProperty lightDimmer;
public SerializedProperty fadeDistance;

using (var o = new PropertyFetcher<HDAdditionalLightData>(m_SerializedAdditionalLightData))
m_AdditionalLightData = new SerializedLightData
{
directionalIntensity = o.Find(x => x.directionalIntensity),
punctualIntensity = o.Find(x => x.punctualIntensity),
spotInnerPercent = o.Find(x => x.m_InnerSpotPercent),
lightDimmer = o.Find(x => x.lightDimmer),
fadeDistance = o.Find(x => x.fadeDistance),

void DrawLightSettings()
{
settings.DrawColor();
// Customize the
/*
EditorGUI.BeginChangeCheck();
switch (m_LightShape)
{
case LightShape.Directional:
settings.lightType.enumValueIndex = (int)LightType.Directional;
m_AdditionalLightData.lightTypeExtent.enumValueIndex = (int)LightTypeExtent.Punctual;
break;
case LightShape.Point:
case LightShape.Spot:
settings.lightType.enumValueIndex = (int)LightType.Point;
m_AdditionalLightData.lightTypeExtent.enumValueIndex = (int)LightTypeExtent.Punctual;
EditorGUILayout.PropertyField(m_AdditionalLightData.maxSmoothness, s_Styles.maxSmoothness);
break;
}
EditorGUILayout.PropertyField(settings.punctualIntensity, s_Styles.intensityPhysicalUnit);
if (EditorGUI.EndChangeCheck())
{
//settings.intensity.floatValue =
}
*/
settings.DrawIntensity();
settings.DrawBounceIntensity();
settings.DrawLightmapping();

13
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/HDAdditionalLightData.cs


// We can't rely on Unity for our additional data, we need to version it ourself.
[SerializeField]
float m_Version = 1.0f;
#pragma warning restore 414
#pragma warning restore 414
// To be able to have correct default values for our lights and to also control the conversion of intensity from the light editor (so it is compatible with GI)
// we add intensity (for each type of light we want to manage).
public float directionalIntensity = 10000.0f; // Sun Light default to 10000 lux
public float punctualIntensity = 600.0f; // Light default to 600 lumens
[FormerlySerializedAs("m_innerSpotPercent")]
public float m_InnerSpotPercent = 0.0f; // To display this field in the UI this need to be public
public float GetInnerSpotPercent01()

public bool affectDiffuse = true;
public bool affectSpecular = true;
[FormerlySerializedAs("archetype")]
public LightTypeExtent lightTypeExtent = LightTypeExtent.Punctual;
// Only for Spotlight, should be hide for other light

[FormerlySerializedAs("lightWidth")]
[FormerlySerializedAs("lightHeight")]
public float shapeHeight = 0.5f;
// Only for pyramid projector

55
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightUtils.cs


using System;
using System.Collections.Generic;
using System.Linq;
namespace UnityEngine.Experimental.Rendering.HDPipeline
{
public class LightUtils
{
// Physical light unit helper
// All light unit are in lumens (Luminous power) and convert to cd/(m^2*steradian) (luminance)
// For an area light it is (Luminous Power / (Area * PI * steradian))
// In the case of a punctual light, there is no area, so theoretically it is Candela but math are the same
// Note: area light calculation is done in Luminance, but punctual light calculation should be done in luminous intensity (Candela)
// Math are identical, so no need to make a distinction here, the conversion handle it.
// No change to shader code is required
public static float ConvertPointLightIntensity(float intensity)
{
return intensity / (4.0f * Mathf.PI);
}
// angle is the full angle, not the half angle in radiant
public static float ConvertSpotLightIntensity(float intensity, float angle, bool exact)
{
return exact ? intensity / (2.0f * (1.0f - Mathf.Cos(angle / 2.0f)) * Mathf.PI) : intensity / Mathf.PI;
}
// angleA and angleB are the full opening angle, not half angle
public static float ConvertFrustrumLightIntensity(float intensity, float angleA, float angleB)
{
return intensity / (4.0f * Mathf.Asin(Mathf.Sin(angleA / 2.0f) * Mathf.Sin(angleB / 2.0f)));
}
public static float ConvertSphereLightIntensity(float intensity, float sphereRadius)
{
return intensity / (4.0f * Mathf.PI * sphereRadius * sphereRadius * Mathf.PI * Mathf.PI);
}
public static float ConvertDiscLightIntensity(float intensity, float discRadius)
{
return intensity / (discRadius * discRadius * Mathf.PI * Mathf.PI);
}
public static float ConvertRectLightIntensity(float intensity, float width, float height)
{
return intensity / (width * height * Mathf.PI);
}
public static float calculateLineLightArea(float intensity, float lineRadius, float lineWidth)
{
return intensity / (2.0f * Mathf.PI * lineRadius * lineWidth * Mathf.PI);
}
}
}

11
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightUtils.cs.meta


fileFormatVersion: 2
guid: 130051a9e68edfe40ba94d4098cba040
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存