浏览代码

more renaming

- Rename _EnableTransparentFog to _EnableFogOnTransparent
- Rename _BLENDMODE_ACCURATE_LIGHTING to
_BLENDMODE_PRESERVE_SPECULAR_LIGHTING
/Yibing-Project-2
sebastienlagarde 7 年前
当前提交
d33ee23f
共有 9 个文件被更改,包括 64 次插入61 次删除
  1. 8
      ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/LayeredLit.shader
  2. 8
      ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/LayeredLitTessellation.shader
  3. 8
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.shader
  4. 8
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitTessellation.shader
  5. 16
      ScriptableRenderPipeline/HDRenderPipeline/Material/Material.hlsl
  6. 32
      ScriptableRenderPipeline/HDRenderPipeline/Material/Unlit/Editor/BaseUnlitUI.cs
  7. 2
      ScriptableRenderPipeline/HDRenderPipeline/Material/Unlit/ShaderPass/UnlitSharePass.hlsl
  8. 4
      ScriptableRenderPipeline/HDRenderPipeline/Material/Unlit/Unlit.shader
  9. 39
      ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/ShaderPassForward.hlsl

8
ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/LayeredLit.shader


[HideInInspector] _CullMode("__cullmode", Float) = 2.0
[HideInInspector] _ZTestMode("_ZTestMode", Int) = 8
[ToggleOff] _EnableTransparentFog ("Enable Fog", Float) = 1.0
[ToggleOff] _EnableBlendModeAccurateLighting("Enable Blend Mode Accurate Lighting", Float) = 1.0
[ToggleOff] _EnableFogOnTransparent("Enable Fog", Float) = 1.0
[ToggleOff] _EnableBlendModePreserveSpecularLighting("Enable Blend Mode Preserve Specular Lighting", Float) = 1.0
[ToggleOff] _DoubleSidedEnable("Double sided enable", Float) = 0.0
[Enum(None, 0, Mirror, 1, Flip, 2)] _DoubleSidedNormalMode("Double sided normal mode", Float) = 1

// Keyword for transparent
#pragma shader_feature _SURFACE_TYPE_TRANSPARENT
#pragma shader_feature _ _BLENDMODE_ALPHA _BLENDMODE_ADD _BLENDMODE_MULTIPLY _BLENDMODE_PRE_MULTIPLY
#pragma shader_feature _BLENDMODE_ACCURATE_LIGHTING
#pragma shader_feature _ENABLE_TRANSPARENT_FOG
#pragma shader_feature _BLENDMODE_PRESERVE_SPECULAR_LIGHTING
#pragma shader_feature _ENABLE_FOG_ON_TRANSPARENT
#pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON
#pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED

8
ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/LayeredLitTessellation.shader


[HideInInspector] _CullMode("__cullmode", Float) = 2.0
[HideInInspector] _ZTestMode("_ZTestMode", Int) = 8
[ToggleOff] _EnableTransparentFog("Enable Fog", Float) = 1.0
[ToggleOff] _EnableBlendModeAccurateLighting("Enable Blend Mode Accurate Lighting", Float) = 1.0
[ToggleOff] _EnableFogOnTransparent("Enable Fog", Float) = 1.0
[ToggleOff] _EnableBlendModePreserveSpecularLighting("Enable Blend Mode Preserve Specular Lighting", Float) = 1.0
[ToggleOff] _DoubleSidedEnable("Double sided enable", Float) = 0.0
[Enum(None, 0, Mirror, 1, Flip, 2)] _DoubleSidedNormalMode("Double sided normal mode", Float) = 1

// Keyword for transparent
#pragma shader_feature _SURFACE_TYPE_TRANSPARENT
#pragma shader_feature _ _BLENDMODE_ALPHA _BLENDMODE_ADD _BLENDMODE_MULTIPLY _BLENDMODE_PRE_MULTIPLY
#pragma shader_feature _BLENDMODE_ACCURATE_LIGHTING
#pragma shader_feature _ENABLE_TRANSPARENT_FOG
#pragma shader_feature _BLENDMODE_PRESERVE_SPECULAR_LIGHTING
#pragma shader_feature _ENABLE_FOG_ON_TRANSPARENT
#pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON
#pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED

8
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.shader


[HideInInspector] _CullMode("__cullmode", Float) = 2.0
[HideInInspector] _ZTestMode("_ZTestMode", Int) = 8
[ToggleOff] _EnableTransparentFog("Enable Fog", Float) = 1.0
[ToggleOff] _EnableBlendModeAccurateLighting("Enable Blend Mode Accurate Lighting", Float) = 1.0
[ToggleOff] _EnableFogOnTransparent("Enable Fog", Float) = 1.0
[ToggleOff] _EnableBlendModePreserveSpecularLighting("Enable Blend Mode Preserve Specular Lighting", Float) = 1.0
[ToggleOff] _DoubleSidedEnable("Double sided enable", Float) = 0.0
[Enum(None, 0, Mirror, 1, Flip, 2)] _DoubleSidedNormalMode("Double sided normal mode", Float) = 1

// Keyword for transparent
#pragma shader_feature _SURFACE_TYPE_TRANSPARENT
#pragma shader_feature _ _BLENDMODE_ALPHA _BLENDMODE_ADD _BLENDMODE_MULTIPLY _BLENDMODE_PRE_MULTIPLY
#pragma shader_feature _BLENDMODE_ACCURATE_LIGHTING
#pragma shader_feature _ENABLE_TRANSPARENT_FOG
#pragma shader_feature _BLENDMODE_PRESERVE_SPECULAR_LIGHTING
#pragma shader_feature _ENABLE_FOG_ON_TRANSPARENT
// MaterialId are used as shader feature to allow compiler to optimize properly
// Note _MATID_STANDARD is not define as there is always the default case "_". We assign default as _MATID_STANDARD, so we never test _MATID_STANDARD

8
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitTessellation.shader


[HideInInspector] _CullMode("__cullmode", Float) = 2.0
[HideInInspector] _ZTestMode("_ZTestMode", Int) = 8
[ToggleOff] _EnableTransparentFog("Enable Fog", Float) = 1.0
[ToggleOff] _EnableBlendModeAccurateLighting("Enable Blend Mode Accurate Lighting", Float) = 1.0
[ToggleOff] _EnableFogOnTransparent("Enable Fog", Float) = 1.0
[ToggleOff] _EnableBlendModePreserveSpecularLighting("Enable Blend Mode Preserve Specular Lighting", Float) = 1.0
[ToggleOff] _DoubleSidedEnable("Double sided enable", Float) = 0.0
[Enum(None, 0, Mirror, 1, Flip, 2)] _DoubleSidedNormalMode("Double sided normal mode", Float) = 1

// Keyword for transparent
#pragma shader_feature _SURFACE_TYPE_TRANSPARENT
#pragma shader_feature _ _BLENDMODE_ALPHA _BLENDMODE_ADD _BLENDMODE_MULTIPLY _BLENDMODE_PRE_MULTIPLY
#pragma shader_feature _BLENDMODE_ACCURATE_LIGHTING
#pragma shader_feature _ENABLE_TRANSPARENT_FOG
#pragma shader_feature _BLENDMODE_PRESERVE_SPECULAR_LIGHTING
#pragma shader_feature _ENABLE_FOG_ON_TRANSPARENT
// MaterialId are used as shader feature to allow compiler to optimize properly
// Note _MATID_STANDARD is not define as there is always the default case "_". We assign default as _MATID_STANDARD, so we never test _MATID_STANDARD

16
ScriptableRenderPipeline/HDRenderPipeline/Material/Material.hlsl


// .Shader need to define:
// - _SURFACE_TYPE_TRANSPARENT if they use a transparent material
// - _BLENDMODE_ALPHA, _BLENDMODE_ADD, _BLENDMODE_MULTIPLY, _BLENDMODE_PRE_MULTIPLY for blend mode
// - _BLENDMODE_ACCURATE_LIGHTING for correct lighting when blend mode are use with a Lit material
// - _ENABLE_TRANSPARENT_FOG if fog is enable on transparent surface
// - _BLENDMODE_PRESERVE_SPECULAR_LIGHTING for correct lighting when blend mode are use with a Lit material
// - _ENABLE_FOG_ON_TRANSPARENT if fog is enable on transparent surface
//-----------------------------------------------------------------------------
// Fog sampling function for materials

{
float4 result = inputColor;
#ifdef _ENABLE_TRANSPARENT_FOG
#ifdef _ENABLE_FOG_ON_TRANSPARENT
#if defined(_BLENDMODE_ALPHA)
#if defined(_BLENDMODE_ALPHA)
#elif defined(_BLENDMODE_ADD)
#elif defined(_BLENDMODE_ADD)
#elif defined(_BLENDMODE_MULTIPLY)
#elif defined(_BLENDMODE_MULTIPLY)
#elif defined(_BLENDMODE_PRE_MULTIPLY)
#elif defined(_BLENDMODE_PRE_MULTIPLY)
#endif
#endif
#else
// Evaluation of fog for opaque objects is currently done in a full screen pass independent from any material parameters.

32
ScriptableRenderPipeline/HDRenderPipeline/Material/Unlit/Editor/BaseUnlitUI.cs


public static GUIContent alphaCutoffShadowText = new GUIContent("Alpha Cutoff Shadow", "Threshold for alpha cutoff in case of shadow pass");
public static GUIContent alphaCutoffPrepassText = new GUIContent("Alpha Cutoff Prepass", "Threshold for alpha cutoff in case of depth prepass");
public static GUIContent transparentDepthPrepassEnableText = new GUIContent("Enable transparent depth prepass", "It allow to ");
public static GUIContent enableTransparentFogText = new GUIContent("Enable Fog");
public static GUIContent enableBlendModeAccurateLightingText = new GUIContent("Blend only diffuse lighting", "Blend mode will only affect diffuse lighting, allowing correct specular lighting (reflection) on transparent object");
public static GUIContent enableTransparentFogText = new GUIContent("Enable fog", "Enable fog on transparent material");
public static GUIContent enableBlendModePreserveSpecularLightingText = new GUIContent("Blend preserve specular lighting", "Blend mode will only affect diffuse lighting, allowing correct specular lighting (reflection) on transparent object");
public static GUIContent doubleSidedEnableText = new GUIContent("Double Sided", "This will render the two face of the objects (disable backface culling) and flip/mirror normal");
public static GUIContent distortionEnableText = new GUIContent("Distortion", "Enable distortion on this shader");

protected const string kDistortionBlurRemapMax = "_DistortionBlurRemapMax";
protected MaterialProperty preRefractionPass = null;
protected const string kPreRefractionPass = "_PreRefractionPass";
protected MaterialProperty enableTransparentFog = null;
protected const string kEnableTransparentFog = "_EnableTransparentFog";
protected MaterialProperty enableBlendModeAccurateLighting = null;
protected const string kEnableBlendModeAccurateLighting = "_EnableBlendModeAccurateLighting";
protected MaterialProperty enableFogOnTransparent = null;
protected const string kEnableFogOnTransparent = "_EnableFogOnTransparent";
protected MaterialProperty enableBlendModePreserveSpecularLighting = null;
protected const string kEnableBlendModePreserveSpecularLighting = "_EnableBlendModePreserveSpecularLighting";
// See comment in LitProperties.hlsl

distortionBlurRemapMax = FindProperty(kDistortionBlurRemapMax, props, false);
preRefractionPass = FindProperty(kPreRefractionPass, props, false);
enableTransparentFog = FindProperty(kEnableTransparentFog, props, false);
enableBlendModeAccurateLighting = FindProperty(kEnableBlendModeAccurateLighting, props, false);
enableFogOnTransparent = FindProperty(kEnableFogOnTransparent, props, false);
enableBlendModePreserveSpecularLighting = FindProperty(kEnableBlendModePreserveSpecularLighting, props, false);
}
void SurfaceTypePopup()

BlendModePopup();
EditorGUI.indentLevel++;
if (enableBlendModeAccurateLighting != null && blendMode != null && showBlendModePopup)
m_MaterialEditor.ShaderProperty(enableBlendModeAccurateLighting, StylesBaseUnlit.enableBlendModeAccurateLightingText);
if (enableTransparentFog != null)
m_MaterialEditor.ShaderProperty(enableTransparentFog, StylesBaseUnlit.enableTransparentFogText);
if (enableBlendModePreserveSpecularLighting != null && blendMode != null && showBlendModePopup)
m_MaterialEditor.ShaderProperty(enableBlendModePreserveSpecularLighting, StylesBaseUnlit.enableBlendModePreserveSpecularLightingText);
if (enableFogOnTransparent != null)
m_MaterialEditor.ShaderProperty(enableFogOnTransparent, StylesBaseUnlit.enableTransparentFogText);
if (preRefractionPass != null)
m_MaterialEditor.ShaderProperty(preRefractionPass, StylesBaseUnlit.transparentPrePassText);
EditorGUI.indentLevel--;

SurfaceType surfaceType = (SurfaceType)material.GetFloat(kSurfaceType);
SetKeyword(material, "_SURFACE_TYPE_TRANSPARENT", surfaceType == SurfaceType.Transparent);
bool enableBlendModeAccurateLighting = material.HasProperty(kEnableBlendModeAccurateLighting) && material.GetFloat(kEnableBlendModeAccurateLighting) > 0.0f;
SetKeyword(material, "_BLENDMODE_ACCURATE_LIGHTING", enableBlendModeAccurateLighting);
bool enableBlendModePreserveSpecularLighting = material.HasProperty(kEnableBlendModePreserveSpecularLighting) && material.GetFloat(kEnableBlendModePreserveSpecularLighting) > 0.0f;
SetKeyword(material, "_BLENDMODE_PRESERVE_SPECULAR_LIGHTING", enableBlendModePreserveSpecularLighting);
// These need to always been set either with opaque or transparent! So a users can switch to opaque and remove the keyword correctly
SetKeyword(material, "_BLENDMODE_ALPHA", false);

SetKeyword(material, "_DOUBLESIDED_ON", doubleSidedEnable);
bool fogEnabled = material.HasProperty(kEnableTransparentFog) && material.GetFloat(kEnableTransparentFog) > 0.0f;
SetKeyword(material, "_ENABLE_TRANSPARENT_FOG", fogEnabled);
bool fogEnabled = material.HasProperty(kEnableFogOnTransparent) && material.GetFloat(kEnableFogOnTransparent) > 0.0f && surfaceType == SurfaceType.Transparent;
SetKeyword(material, "_ENABLE_FOG_ON_TRANSPARENT", fogEnabled);
if (material.HasProperty(kDistortionEnable))
{

2
ScriptableRenderPipeline/HDRenderPipeline/Material/Unlit/ShaderPass/UnlitSharePass.hlsl


#define ATTRIBUTES_NEED_TEXCOORD0
#if defined(_ENABLE_TRANSPARENT_FOG)
#if defined(_ENABLE_FOG_ON_TRANSPARENT)
#define VARYINGS_NEED_POSITION_WS
#endif

4
ScriptableRenderPipeline/HDRenderPipeline/Material/Unlit/Unlit.shader


[HideInInspector] _CullMode("__cullmode", Float) = 2.0
[HideInInspector] _ZTestMode("_ZTestMode", Int) = 8
[ToggleOff] _EnableTransparentFog("Enable Fog", Float) = 0.0
[ToggleOff] _EnableFogOnTransparent("Enable Fog", Float) = 0.0
[ToggleOff] _DoubleSidedEnable("Double sided enable", Float) = 0.0
// Caution: C# code in BaseLitUI.cs call LightmapEmissionFlagsProperty() which assume that there is an existing "_EmissionColor"

// Keyword for transparent
#pragma shader_feature _SURFACE_TYPE_TRANSPARENT
#pragma shader_feature _ _BLENDMODE_ALPHA _BLENDMODE_ADD _BLENDMODE_MULTIPLY _BLENDMODE_PRE_MULTIPLY
#pragma shader_feature _ENABLE_TRANSPARENT_FOG
#pragma shader_feature _ENABLE_FOG_ON_TRANSPARENT
//-------------------------------------------------------------------------------------
// Define

39
ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/ShaderPassForward.hlsl


float4 ApplyBlendMode(float3 diffuseLighting, float3 specularLighting, float opacity)
{
return float4(diffuseLighting + specularLighting, opacity);
}
// ref: http://advances.realtimerendering.com/other/2016/naughty_dog/NaughtyDog_TechArt_Final.pdf
// Lit transparent object should have reflection and tramission.
// Transmission when not using "rough refraction mode" (with fetch in preblured background) is handled with blend mode.
// However reflection should not be affected by blend mode. For example a glass should still display reflection and not lose the highlight when blend
// This is the purpose of following function, "Cancel" the blend mode effect on the specular lighting but not on the diffuse lighting
#ifdef _BLENDMODE_PRESERVE_SPECULAR_LIGHTING
// ref: http://advances.realtimerendering.com/other/2016/naughty_dog/NaughtyDog_TechArt_Final.pdf
// Lit transparent object should have reflection and tramission.
// Transmission when not using "rough refraction mode" (with fetch in preblured background) is handled with blend mode.
// However reflection should not be affected by blend mode. For example a glass should still display reflection and not lose the highlight when blend
// This is the purpose of following function, "Cancel" the blend mode effect on the specular lighting but not on the diffuse lighting
float4 ApplyBlendModeAccurateLighting(float3 diffuseLighting, float3 specularLighting, float opacity)
{
#ifdef _BLENDMODE_ALPHA
#ifdef _BLENDMODE_ALPHA
#elif defined(_BLENDMODE_ADD) || defined(_BLENDMODE_PRE_MULTIPLY)
#elif defined(_BLENDMODE_ADD) || defined(_BLENDMODE_PRE_MULTIPLY)
#else
return float4(diffuseLighting + specularLighting, opacity);
#endif
return ApplyBlendMode(diffuseLighting, specularLighting, opacity);
return float4(diffuseLighting + specularLighting, opacity);
}
float4 ApplyBlendModePerserveSpecularLighting(float3 diffuseLighting, float3 specularLighting, float opacity)
{
}
void Frag(PackedVaryingsToPS packedInput,

float3 bakeDiffuseLighting = GetBakedDiffuseLigthing(surfaceData, builtinData, bsdfData, preLightData);
LightLoop(V, posInput, preLightData, bsdfData, bakeDiffuseLighting, featureFlags, diffuseLighting, specularLighting);
// Note: When we are lit (which is the case here, else we use unlit pass), we should always use _BLENDMODE_ACCURATE_LIGHTING
// however artists may not be use to this new mode and would like to use old fashion blending with lighting, so keep a fallback
#ifdef _BLENDMODE_ACCURATE_LIGHTING
outColor = ApplyBlendModeAccurateLighting(diffuseLighting, specularLighting, builtinData.opacity);
#else
#endif
outColor = EvaluateAtmosphericScattering(posInput, outColor);
}

正在加载...
取消
保存