浏览代码

Merge pull request #1445 from Unity-Technologies/Replace-EmissiveIntesnity-by-EmissveColor-HDR

Replace EmissiveIntesnity by EmissiveColor HDR
/main
GitHub 7 年前
当前提交
a3255733
共有 21 个文件被更改,包括 24 次插入80 次删除
  1. 1
      com.unity.render-pipelines.high-definition/CHANGELOG.md
  2. 4
      com.unity.render-pipelines.high-definition/HDRP/Editor/Material/LayeredLit/LayeredLitUI.cs
  3. 11
      com.unity.render-pipelines.high-definition/HDRP/Editor/Material/Lit/LitUI.cs
  4. 15
      com.unity.render-pipelines.high-definition/HDRP/Editor/Material/Lit/StandardsToHDLitMaterialUpgrader.cs
  5. 6
      com.unity.render-pipelines.high-definition/HDRP/Editor/Material/StackLit/StackLitUI.cs
  6. 9
      com.unity.render-pipelines.high-definition/HDRP/Editor/Material/Unlit/UnlitUI.cs
  7. 4
      com.unity.render-pipelines.high-definition/HDRP/Material/Builtin/BuiltinData.cs
  8. 14
      com.unity.render-pipelines.high-definition/HDRP/Material/Builtin/BuiltinData.cs.hlsl
  9. 4
      com.unity.render-pipelines.high-definition/HDRP/Material/Builtin/BuiltinData.hlsl
  10. 3
      com.unity.render-pipelines.high-definition/HDRP/Material/LayeredLit/LayeredLit.shader
  11. 3
      com.unity.render-pipelines.high-definition/HDRP/Material/LayeredLit/LayeredLitTessellation.shader
  12. 3
      com.unity.render-pipelines.high-definition/HDRP/Material/Lit/Lit.shader
  13. 5
      com.unity.render-pipelines.high-definition/HDRP/Material/Lit/LitBuiltinData.hlsl
  14. 1
      com.unity.render-pipelines.high-definition/HDRP/Material/Lit/LitProperties.hlsl
  15. 3
      com.unity.render-pipelines.high-definition/HDRP/Material/Lit/LitTessellation.shader
  16. 1
      com.unity.render-pipelines.high-definition/HDRP/Material/StackLit/StackLit.shader
  17. 4
      com.unity.render-pipelines.high-definition/HDRP/Material/StackLit/StackLitData.hlsl
  18. 1
      com.unity.render-pipelines.high-definition/HDRP/Material/StackLit/StackLitProperties.hlsl
  19. 3
      com.unity.render-pipelines.high-definition/HDRP/Material/Unlit/Unlit.shader
  20. 7
      com.unity.render-pipelines.high-definition/HDRP/Material/Unlit/UnlitData.hlsl
  21. 2
      com.unity.render-pipelines.high-definition/HDRP/Material/Unlit/UnlitProperties.hlsl

1
com.unity.render-pipelines.high-definition/CHANGELOG.md


### Changed, Removals and deprecations
- Removed GlobalLightLoopSettings.maxPlanarReflectionProbes and instead use value of GlobalLightLoopSettings.planarReflectionProbeCacheSize
- Changed SupportForwardOnly to SupportOnlyForward in render pipeline settings
- Remove EmissiveIntensity parameter and change EmissiveColor to be HDR (Matching Builtin Unity behavior) - Data need to be updated
### Bug fixes
- Fix issue with LOD transition and instancing

4
com.unity.render-pipelines.high-definition/HDRP/Editor/Material/LayeredLit/LayeredLitUI.cs


return layerChanged;
}
protected override bool ShouldEmissionBeEnabled(Material mat)
protected override bool ShouldEmissionBeEnabled(Material material)
return mat.GetFloat(kEmissiveIntensity) > 0.0f;
return (material.GetColor(kEmissiveColor) != Color.black) || material.GetTexture(kEmissiveColorMap);
}
protected override void SetupMaterialKeywordsAndPassInternal(Material material)

11
com.unity.render-pipelines.high-definition/HDRP/Editor/Material/Lit/LitUI.cs


// Emissive
public static string emissiveLabelText = "Emissive Inputs";
public static GUIContent emissiveText = new GUIContent("Emissive Color", "Emissive");
public static GUIContent emissiveIntensityText = new GUIContent("Emissive Intensity", "Emissive");
public static GUIContent emissiveText = new GUIContent("Emissive Color", "Emissive Color (linear RGB) in nits unit");
public static GUIContent albedoAffectEmissiveText = new GUIContent("Albedo Affect Emissive", "Specifies whether or not the emissive color is multiplied by the albedo.");
public static GUIContent normalMapSpaceWarning = new GUIContent("Object space normal can't be use with triplanar mapping.");

protected const string kEmissiveColor = "_EmissiveColor";
protected MaterialProperty emissiveColorMap = null;
protected const string kEmissiveColorMap = "_EmissiveColorMap";
protected MaterialProperty emissiveIntensity = null;
protected const string kEmissiveIntensity = "_EmissiveIntensity";
protected MaterialProperty albedoAffectEmissive = null;
protected const string kAlbedoAffectEmissive = "_AlbedoAffectEmissive";
protected MaterialProperty UVEmissive = null;

emissiveColorMode = FindProperty(kEmissiveColorMode, props);
emissiveColor = FindProperty(kEmissiveColor, props);
emissiveColorMap = FindProperty(kEmissiveColorMap, props);
emissiveIntensity = FindProperty(kEmissiveIntensity, props);
albedoAffectEmissive = FindProperty(kAlbedoAffectEmissive, props);
UVEmissive = FindProperty(kUVEmissive, props);

EditorGUI.indentLevel--;
}
m_MaterialEditor.ShaderProperty(emissiveIntensity, Styles.emissiveIntensityText);
m_MaterialEditor.ShaderProperty(albedoAffectEmissive, Styles.albedoAffectEmissiveText);
EditorGUI.indentLevel--;
}

m_MaterialEditor.ShaderProperty(enableSpecularOcclusion, Styles.enableSpecularOcclusionText);
}
protected override bool ShouldEmissionBeEnabled(Material mat)
protected override bool ShouldEmissionBeEnabled(Material material)
return mat.GetFloat(kEmissiveIntensity) > 0.0f;
return (material.GetColor(kEmissiveColor) != Color.black) || material.GetTexture(kEmissiveColorMap);
}
protected override void SetupMaterialKeywordsAndPassInternal(Material material)

15
com.unity.render-pipelines.high-definition/HDRP/Editor/Material/Lit/StandardsToHDLitMaterialUpgrader.cs


break;
}
// Emission: Convert the HDR emissive color to ldr color + intensity
float intensity = Mathf.Max(hdrEmission.r, Mathf.Max(hdrEmission.g, hdrEmission.b));
if (intensity > 1f)
{
hdrEmission.r /= intensity;
hdrEmission.g /= intensity;
hdrEmission.b /= intensity;
}
else
intensity = 1f;
intensity = Mathf.Pow(intensity, 2.2f); // Gamma to Linear conversion
dstMaterial.SetFloat("_EmissiveIntensity", intensity);
HDEditorUtils.ResetMaterialKeywords(dstMaterial);
}

6
com.unity.render-pipelines.high-definition/HDRP/Editor/Material/StackLit/StackLitUI.cs


protected const string k_EmissiveColor = "_EmissiveColor";
protected const string k_EmissiveColorMap = "_EmissiveColorMap";
protected const string k_EmissiveColorMapUV = "_EmissiveColorMapUV";
protected const string k_EmissiveIntensity = "_EmissiveIntensity";
protected const string k_AlbedoAffectEmissive = "_AlbedoAffectEmissive";
// Coat

protected const string kStencilWriteMaskMV = "_StencilWriteMaskMV";
protected const string k_GeometricNormalFilteringEnabled = "_GeometricNormalFilteringEnabled";
protected const string k_TextureNormalFilteringEnabled = "_TextureNormalFilteringEnabled";
protected const string k_TextureNormalFilteringEnabled = "_TextureNormalFilteringEnabled";
#endregion

new GroupProperty(this, "_Emissive", "Emissive", new BaseProperty[]
{
new TextureProperty(this, k_EmissiveColorMap, k_EmissiveColor, "Emissive Color", "Emissive", true, false),
new Property(this, k_EmissiveIntensity, "Emissive Intensity", "Emissive", false),
new Property(this, k_AlbedoAffectEmissive, "Albedo Affect Emissive", "Specifies whether or not the emissive color is multiplied by the albedo.", false),
}),

protected override bool ShouldEmissionBeEnabled(Material material)
{
return material.GetFloat(k_EmissiveIntensity) > 0.0f;
return (material.GetColor(k_EmissiveColor) != Color.black) || material.GetTexture(k_EmissiveColorMap);
}
protected override void FindBaseMaterialProperties(MaterialProperty[] props)

9
com.unity.render-pipelines.high-definition/HDRP/Editor/Material/Unlit/UnlitUI.cs


public static GUIContent colorText = new GUIContent("Color", "Color");
public static GUIContent emissiveText = new GUIContent("Emissive Color", "Emissive");
public static GUIContent emissiveIntensityText = new GUIContent("Emissive Intensity", "Emissive");
}
protected MaterialProperty color = null;

protected const string kEmissiveColor = "_EmissiveColor";
protected MaterialProperty emissiveColorMap = null;
protected const string kEmissiveColorMap = "_EmissiveColorMap";
protected MaterialProperty emissiveIntensity = null;
protected const string kEmissiveIntensity = "_EmissiveIntensity";
override protected void FindMaterialProperties(MaterialProperty[] props)
{

emissiveColor = FindProperty(kEmissiveColor, props);
emissiveColorMap = FindProperty(kEmissiveColorMap, props);
emissiveIntensity = FindProperty(kEmissiveIntensity, props);
}
protected override void MaterialPropertiesGUI(Material material)

m_MaterialEditor.TexturePropertySingleLine(Styles.emissiveText, emissiveColorMap, emissiveColor);
m_MaterialEditor.TextureScaleOffsetProperty(emissiveColorMap);
m_MaterialEditor.ShaderProperty(emissiveIntensity, Styles.emissiveIntensityText);
var surfaceTypeValue = (SurfaceType)surfaceType.floatValue;
if (surfaceTypeValue == SurfaceType.Transparent)

{
}
protected override bool ShouldEmissionBeEnabled(Material mat)
protected override bool ShouldEmissionBeEnabled(Material material)
return mat.GetFloat(kEmissiveIntensity) > 0.0f;
return (material.GetColor(kEmissiveColor) != Color.black) || material.GetTexture(kEmissiveColorMap);
}
protected override void SetupMaterialKeywordsAndPassInternal(Material material)

4
com.unity.render-pipelines.high-definition/HDRP/Material/Builtin/BuiltinData.cs


[SurfaceDataAttributes("Shadow Mask 3")]
public float shadowMask3;
[SurfaceDataAttributes("Emissive Color", false, true)]
[SurfaceDataAttributes("Emissive Color", false, false)]
[SurfaceDataAttributes("Emissive Intensity")]
public float emissiveIntensity;
// These is required for motion blur and temporalAA
[SurfaceDataAttributes("Velocity")]

14
com.unity.render-pipelines.high-definition/HDRP/Material/Builtin/BuiltinData.cs.hlsl


#define DEBUGVIEW_BUILTIN_BUILTINDATA_SHADOW_MASK_2 (104)
#define DEBUGVIEW_BUILTIN_BUILTINDATA_SHADOW_MASK_3 (105)
#define DEBUGVIEW_BUILTIN_BUILTINDATA_EMISSIVE_COLOR (106)
#define DEBUGVIEW_BUILTIN_BUILTINDATA_EMISSIVE_INTENSITY (107)
#define DEBUGVIEW_BUILTIN_BUILTINDATA_VELOCITY (108)
#define DEBUGVIEW_BUILTIN_BUILTINDATA_DISTORTION (109)
#define DEBUGVIEW_BUILTIN_BUILTINDATA_DISTORTION_BLUR (110)
#define DEBUGVIEW_BUILTIN_BUILTINDATA_DEPTH_OFFSET (111)
#define DEBUGVIEW_BUILTIN_BUILTINDATA_VELOCITY (107)
#define DEBUGVIEW_BUILTIN_BUILTINDATA_DISTORTION (108)
#define DEBUGVIEW_BUILTIN_BUILTINDATA_DISTORTION_BLUR (109)
#define DEBUGVIEW_BUILTIN_BUILTINDATA_DEPTH_OFFSET (110)
//
// UnityEngine.Experimental.Rendering.HDPipeline.Builtin+LightTransportData: static fields

float shadowMask2;
float shadowMask3;
float3 emissiveColor;
float emissiveIntensity;
float2 velocity;
float2 distortion;
float distortionBlur;

break;
case DEBUGVIEW_BUILTIN_BUILTINDATA_EMISSIVE_COLOR:
result = builtindata.emissiveColor;
needLinearToSRGB = true;
break;
case DEBUGVIEW_BUILTIN_BUILTINDATA_EMISSIVE_INTENSITY:
result = builtindata.emissiveIntensity.xxx;
break;
case DEBUGVIEW_BUILTIN_BUILTINDATA_VELOCITY:
result = float3(builtindata.velocity, 0.0);

4
com.unity.render-pipelines.high-definition/HDRP/Material/Builtin/BuiltinData.hlsl


// TODO: we should not gamma correct, but easier to debug for now without correct high range value
result = builtinData.bakeDiffuseLighting; needLinearToSRGB = true;
break;
case DEBUGVIEW_BUILTIN_BUILTINDATA_EMISSIVE_COLOR:
// emissiveColor is premultiply by emissive intensity
result = (builtinData.emissiveColor / builtinData.emissiveIntensity); needLinearToSRGB = true;
break;
case DEBUGVIEW_BUILTIN_BUILTINDATA_DEPTH_OFFSET:
result = builtinData.depthOffset.xxx * 10.0; // * 10 assuming 1 unity is 1m
break;

3
com.unity.render-pipelines.high-definition/HDRP/Material/LayeredLit/LayeredLit.shader


[ToggleUI] _EnableSpecularOcclusion("Enable specular occlusion", Float) = 0.0
_EmissiveColor("EmissiveColor", Color) = (1, 1, 1)
[HDR] _EmissiveColor("EmissiveColor", Color) = (1, 1, 1)
_EmissiveIntensity("EmissiveIntensity", Float) = 0
[ToggleUI] _AlbedoAffectEmissive("Albedo Affect Emissive", Float) = 0.0
[ToggleUI] _AlphaCutoffEnable("Alpha Cutoff Enable", Float) = 0.0

3
com.unity.render-pipelines.high-definition/HDRP/Material/LayeredLit/LayeredLitTessellation.shader


[ToggleUI] _EnableSpecularOcclusion("Enable specular occlusion", Float) = 0.0
_EmissiveColor("EmissiveColor", Color) = (1, 1, 1)
[HDR] _EmissiveColor("EmissiveColor", Color) = (1, 1, 1)
_EmissiveIntensity("EmissiveIntensity", Float) = 0
[ToggleUI] _AlbedoAffectEmissive("Albedo Affect Emissive", Float) = 0.0
[ToggleUI] _AlphaCutoffEnable("Alpha Cutoff Enable", Float) = 0.0

3
com.unity.render-pipelines.high-definition/HDRP/Material/Lit/Lit.shader


// These option below will cause different compilation flag.
[ToggleUI] _EnableSpecularOcclusion("Enable specular occlusion", Float) = 0.0
_EmissiveColor("EmissiveColor", Color) = (1, 1, 1)
[HDR] _EmissiveColor("EmissiveColor", Color) = (1, 1, 1)
_EmissiveIntensity("EmissiveIntensity", Float) = 0
[ToggleUI] _AlbedoAffectEmissive("Albedo Affect Emissive", Float) = 0.0
_DistortionVectorMap("DistortionVectorMap", 2D) = "black" {}

5
com.unity.render-pipelines.high-definition/HDRP/Material/Lit/LitBuiltinData.hlsl


builtinData.shadowMask3 = 0.0;
#endif
// Emissive Intensity is only use here, but is part of BuiltinData to enforce UI parameters as we want the users to fill one color and one intensity
builtinData.emissiveIntensity = _EmissiveIntensity; // We still store intensity here so we can reuse it with debug code
builtinData.emissiveColor = _EmissiveColor * builtinData.emissiveIntensity * lerp(float3(1.0, 1.0, 1.0), surfaceData.baseColor.rgb, _AlbedoAffectEmissive);
builtinData.emissiveColor = _EmissiveColor * lerp(float3(1.0, 1.0, 1.0), surfaceData.baseColor.rgb, _AlbedoAffectEmissive);
#ifdef _EMISSIVE_COLOR_MAP
// Use layer0 of LayerTexCoord to retrieve emissive color mapping information

1
com.unity.render-pipelines.high-definition/HDRP/Material/Lit/LitProperties.hlsl


float _PPDLodThreshold;
float3 _EmissiveColor;
float _EmissiveIntensity;
float _AlbedoAffectEmissive;
float _EnableSpecularOcclusion;

3
com.unity.render-pipelines.high-definition/HDRP/Material/Lit/LitTessellation.shader


// These option below will cause different compilation flag.
[ToggleUI] _EnableSpecularOcclusion("Enable specular occlusion", Float) = 0.0
_EmissiveColor("EmissiveColor", Color) = (1, 1, 1)
[HDR] _EmissiveColor("EmissiveColor", Color) = (1, 1, 1)
_EmissiveIntensity("EmissiveIntensity", Float) = 0
[ToggleUI] _AlbedoAffectEmissive("Albedo Affect Emissive", Float) = 0.0
_DistortionVectorMap("DistortionVectorMap", 2D) = "black" {}

1
com.unity.render-pipelines.high-definition/HDRP/Material/StackLit/StackLit.shader


_EmissiveColorMap("Emissive Color Map", 2D) = "white" {}
_EmissiveColorMapUV("Emissive Color Map UV", Range(0.0, 1.0)) = 0
_EmissiveColorMapUVLocal("Emissive Color Map UV Local", Float) = 0.0
_EmissiveIntensity("Emissive Intensity", Float) = 0
[ToggleUI] _AlbedoAffectEmissive("Albedo Affect Emissive", Float) = 0.0
[ToggleUI] _EnableSubsurfaceScattering("Enable Subsurface Scattering", Float) = 0.0

4
com.unity.render-pipelines.high-definition/HDRP/Material/StackLit/StackLitData.hlsl


builtinData.bakeDiffuseLighting += SampleBakedGI(input.positionWS, -input.worldToTangent[2], input.texCoord1, input.texCoord2) * bsdfData.transmittance;
}
// Emissive Intensity is only use here, but is part of BuiltinData to enforce UI parameters as we want the users to fill one color and one intensity
builtinData.emissiveIntensity = _EmissiveIntensity; // We still store intensity here so we can reuse it with debug code
builtinData.emissiveColor = _EmissiveColor * builtinData.emissiveIntensity * lerp(float3(1.0, 1.0, 1.0), surfaceData.baseColor.rgb, _AlbedoAffectEmissive);
builtinData.emissiveColor = _EmissiveColor * lerp(float3(1.0, 1.0, 1.0), surfaceData.baseColor.rgb, _AlbedoAffectEmissive);
builtinData.emissiveColor *= SAMPLE_TEXTURE2D_SCALE_BIAS(_EmissiveColorMap).rgb;
// TODO:

1
com.unity.render-pipelines.high-definition/HDRP/Material/StackLit/StackLitProperties.hlsl


float4 _EmissiveColorMap_MipInfo;
float _EmissiveColorMapUV;
float _EmissiveColorMapUVLocal;
float _EmissiveIntensity;
float _AlbedoAffectEmissive;
float _GeometricNormalFilteringEnabled;

3
com.unity.render-pipelines.high-definition/HDRP/Material/Unlit/Unlit.shader


_UnlitColor("Color", Color) = (1,1,1,1)
_UnlitColorMap("ColorMap", 2D) = "white" {}
_EmissiveColor("EmissiveColor", Color) = (1, 1, 1)
[HDR] _EmissiveColor("EmissiveColor", Color) = (1, 1, 1)
_EmissiveIntensity("EmissiveIntensity", Float) = 0
_DistortionVectorMap("DistortionVectorMap", 2D) = "black" {}
[ToggleUI] _DistortionEnable("Enable Distortion", Float) = 0.0

7
com.unity.render-pipelines.high-definition/HDRP/Material/Unlit/UnlitData.hlsl


builtinData.bakeDiffuseLighting = float3(0.0, 0.0, 0.0);
// Emissive Intensity is only use here, but is part of BuiltinData to enforce UI parameters as we want the users to fill one color and one intensity
builtinData.emissiveIntensity = _EmissiveIntensity;
builtinData.emissiveColor = SAMPLE_TEXTURE2D(_EmissiveColorMap, sampler_EmissiveColorMap, TRANSFORM_TEX(input.texCoord0, _EmissiveColorMap)).rgb * _EmissiveColor * builtinData.emissiveIntensity;
builtinData.emissiveColor = SAMPLE_TEXTURE2D(_EmissiveColorMap, sampler_EmissiveColorMap, TRANSFORM_TEX(input.texCoord0, _EmissiveColorMap)).rgb * _EmissiveColor;
builtinData.emissiveColor = _EmissiveColor * builtinData.emissiveIntensity;
builtinData.emissiveColor = _EmissiveColor;
#endif
builtinData.velocity = float2(0.0, 0.0);

2
com.unity.render-pipelines.high-definition/HDRP/Material/Unlit/UnlitProperties.hlsl


float3 _EmissiveColor;
float4 _EmissiveColorMap_ST;
float _EmissiveIntensity;
float _AlphaCutoff;
float _DistortionScale;
float _DistortionVectorScale;

正在加载...
取消
保存