浏览代码
Merge pull request #987 from Unity-Technologies/Add-physical-Light-unit-2
Merge pull request #987 from Unity-Technologies/Add-physical-Light-unit-2
Add physical light unit/main
GitHub
7 年前
当前提交
29fc3c6e
共有 7 个文件被更改,包括 209 次插入 和 8 次删除
-
46ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/HDRenderPipelineMenuItems.cs
-
3ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/HDLightEditor.Styles.cs
-
78ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/HDLightEditor.cs
-
6ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Light/HDAdditionalLightData.cs
-
6ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/Lit.hlsl
-
67ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightUtils.cs
-
11ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightUtils.cs.meta
|
|||
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 lumen (Luminous power)
|
|||
// Punctual light (point, spot) are convert to candela (cd = lumens / steradian)
|
|||
// Area light are convert to luminance (cd/(m^2*steradian)) with the following formulation: Luminous Power / (Area * PI * steradian)
|
|||
|
|||
// Ref: Moving Frostbite to PBR
|
|||
// Also good ref: https://www.radiance-online.org/community/workshops/2004-fribourg/presentations/Wandachowicz_paper.pdf
|
|||
|
|||
// convert intensity (lumen) to candela
|
|||
public static float ConvertPointLightIntensity(float intensity) |
|||
{ |
|||
return intensity / (4.0f * Mathf.PI); |
|||
} |
|||
|
|||
// angle is the full angle, not the half angle in radiant
|
|||
// convert intensity (lumen) to candela
|
|||
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
|
|||
// convert intensity (lumen) to candela
|
|||
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))); |
|||
} |
|||
|
|||
// convert intensity (lumen) to nits
|
|||
public static float ConvertSphereLightIntensity(float intensity, float sphereRadius) |
|||
{ |
|||
return intensity / ((4.0f * Mathf.PI * sphereRadius * sphereRadius) * Mathf.PI); |
|||
} |
|||
|
|||
// convert intensity (lumen) to nits
|
|||
public static float ConvertDiscLightIntensity(float intensity, float discRadius) |
|||
{ |
|||
return intensity / ((discRadius * discRadius * Mathf.PI) * Mathf.PI); |
|||
} |
|||
|
|||
// convert intensity (lumen) to nits
|
|||
public static float ConvertRectLightIntensity(float intensity, float width, float height) |
|||
{ |
|||
return intensity / ((width * height) * Mathf.PI); |
|||
} |
|||
|
|||
// convert intensity (lumen) to nits
|
|||
public static float calculateLineLightArea(float intensity, float lineWidth) |
|||
{ |
|||
// The area of a cylinder is this:
|
|||
// float lineRadius = 0.01f; // 1cm
|
|||
//return intensity / (2.0f * Mathf.PI * lineRadius * lineWidth * Mathf.PI);
|
|||
// But with our current line light algorithm we get an insane gap in intensity
|
|||
// following formula (fully empirical) give a better match to a rect light of 1cm of width.
|
|||
// It is basically point light intensity / line width.
|
|||
return intensity / (4.0f * Mathf.PI * lineWidth); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 04acc467a6eef0b45b027f43ed25662b |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue