浏览代码

Add candela and luminance units for punctual and area lights

/main
Antoine Lelievre 6 年前
当前提交
33c68f5d
共有 2 个文件被更改,包括 66 次插入38 次删除
  1. 52
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/HDLightEditor.cs
  2. 52
      com.unity.render-pipelines.high-definition/HDRP/Lighting/Light/HDAdditionalLightData.cs

52
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/HDLightEditor.cs


//Disc,
}
enum LightUnits
{
Lumen,
Candela,
Lux,
Luminance,
}
enum DirectionalLightUnits
enum DirectionalLightUnit
Lux = LightUnits.Lux,
Lux = LightUnit.Lux,
enum AreaLightUnits
enum AreaLightUnit
Lumen = LightUnits.Lumen,
Luminance = LightUnits.Luminance,
Lumen = LightUnit.Lumen,
Luminance = LightUnit.Luminance,
enum PunctualLightUnits
enum PunctualLightUnit
Lumen = LightUnits.Lumen,
Candela = LightUnits.Candela,
Lumen = LightUnit.Lumen,
Candela = LightUnit.Candela,
}
const float k_MinAreaWidth = 0.01f; // Provide a small size of 1cm for line light

}*/
}
LightUnits LightIntensityUnitPopup(LightShape shape)
LightUnit LightIntensityUnitPopup(LightShape shape)
LightUnit selectedLightUnit;
LightUnit oldLigthUnit = (LightUnit)m_AdditionalLightData.lightUnit.enumValueIndex;
EditorGUI.BeginChangeCheck();
return (LightUnits)EditorGUILayout.EnumPopup((DirectionalLightUnits)m_AdditionalLightData.lightUnit.intValue);
selectedLightUnit = (LightUnit)EditorGUILayout.EnumPopup((DirectionalLightUnit)m_AdditionalLightData.lightUnit.enumValueIndex);
break;
return (LightUnits)EditorGUILayout.EnumPopup((PunctualLightUnits)m_AdditionalLightData.lightUnit.intValue);
selectedLightUnit = (LightUnit)EditorGUILayout.EnumPopup((PunctualLightUnit)m_AdditionalLightData.lightUnit.enumValueIndex);
break;
return (LightUnits)EditorGUILayout.EnumPopup((AreaLightUnits)m_AdditionalLightData.lightUnit.intValue);
selectedLightUnit = (LightUnit)EditorGUILayout.EnumPopup((AreaLightUnit)m_AdditionalLightData.lightUnit.enumValueIndex);
break;
if (EditorGUI.EndChangeCheck())
ConvertLightIntensity(oldLigthUnit, selectedLightUnit);
return selectedLightUnit;
}
void ConvertLightIntensity(LightUnit oldLightUnit, LightUnit newLightUnit)
{
}
void DrawLightSettings()

EditorGUI.BeginChangeCheck();
HDAdditionalLightData d = (target as Light).GetComponent<HDAdditionalLightData>();
m_AdditionalLightData.lightUnit.intValue = (int)LightIntensityUnitPopup(m_LightShape);
m_AdditionalLightData.lightUnit.enumValueIndex = (int)LightIntensityUnitPopup(m_LightShape);
EditorGUILayout.EndHorizontal();
// Only display reflector option if it make sense

52
com.unity.render-pipelines.high-definition/HDRP/Lighting/Light/HDAdditionalLightData.cs


};
public enum SpotLightShape { Cone, Pyramid, Box };
public enum LightUnit
{
Lumen,
Candela,
Lux,
Luminance,
}
//@TODO: We should continuously move these values
// into the engine when we can see them being generally useful

public float intensity
{
get { return m_Light.intensity; }
set { GetLightIntensity(value); }
get { return editorLightIntensity; }
set { SetLightIntensity(value); }
}
// Only for Spotlight, should be hide for other light

public float volumetricDimmer = 1.0f;
// Used internally to convert any light unit input into light intensity
public int lightUnit;
public LightUnit lightUnit;
// Not used for directional lights.
public float fadeDistance = 10000.0f;

}
}
void GetLightIntensity(float value)
void SetLightIntensity(float intensity)
GetLightIntensityPunctual(value);
SetLightIntensityPunctual(intensity);
m_Light.intensity = LightUtils.CalculateLineLightIntensity(value, shapeWidth);
if (lightUnit == LightUnit.Lumen)
m_Light.intensity = LightUtils.CalculateLineLightIntensity(intensity, shapeWidth);
else
m_Light.intensity = intensity;
m_Light.intensity = LightUtils.ConvertRectLightIntensity(value, shapeWidth, shapeHeight);
break ;
if (lightUnit == LightUnit.Lumen)
m_Light.intensity = LightUtils.ConvertRectLightIntensity(intensity, shapeWidth, shapeHeight);
else
m_Light.intensity = intensity;
break;
void GetLightIntensityPunctual(float value)
void SetLightIntensityPunctual(float intensity)
m_Light.intensity = directionalIntensity;
m_Light.intensity = intensity; // Alwas in lux
m_Light.intensity = LightUtils.ConvertPointLightIntensity(value);
if (lightUnit == LightUnit.Candela)
m_Light.intensity = intensity;
else
m_Light.intensity = LightUtils.ConvertPointLightIntensity(intensity);
if (enableSpotReflector)
if (lightUnit == LightUnit.Candela)
m_Light.intensity = intensity;
else if (enableSpotReflector)
m_Light.intensity = LightUtils.ConvertSpotLightIntensity(value, m_Light.spotAngle * Mathf.Deg2Rad, true);
m_Light.intensity = LightUtils.ConvertSpotLightIntensity(intensity, m_Light.spotAngle * Mathf.Deg2Rad, true);
}
else if (spotLightShape == SpotLightShape.Pyramid)
{

m_Light.intensity = LightUtils.ConvertFrustrumLightIntensity(value, angleA, angleB);
m_Light.intensity = LightUtils.ConvertFrustrumLightIntensity(intensity, angleA, angleB);
m_Light.intensity = LightUtils.ConvertPointLightIntensity(value);
m_Light.intensity = LightUtils.ConvertPointLightIntensity(intensity);
m_Light.intensity = LightUtils.ConvertPointLightIntensity(value);
m_Light.intensity = LightUtils.ConvertPointLightIntensity(intensity);
}
break;
}

正在加载...
取消
保存