浏览代码

HDRenderPipeline: Rename BlendDiffuseSpecular to ApplyBlendMode + fix some comment

/Yibing-Project-2
sebastienlagarde 7 年前
当前提交
b4ced9f3
共有 3 个文件被更改,包括 21 次插入16 次删除
  1. 2
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Editor/LitUI.cs
  2. 2
      ScriptableRenderPipeline/HDRenderPipeline/Material/Unlit/Editor/BaseUnlitUI.cs
  3. 33
      ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/ShaderPassForward.hlsl

2
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Editor/LitUI.cs


m_MaterialEditor.ShaderProperty(ior, Styles.refractionIORText);
blendMode.floatValue = (float)BlendMode.Lerp;
blendMode.floatValue = (float)BlendMode.Alpha;
if (mode != Lit.RefractionMode.ThinPlane)
{

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


SurfaceType surfaceType = (SurfaceType)material.GetFloat(kSurfaceType);
BlendMode blendMode = (BlendMode)material.GetFloat(kBlendMode);
// These need to always been set either with opaque or transparent! So a users can swtich to opaque and remove the keyword correctly
// 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, "_BLENDMODE_ADD", false);
SetKeyword(material, "_BLENDMODE_MULTIPLY", false);

33
ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/ShaderPassForward.hlsl


#if SHADERPASS != SHADERPASS_FORWARD
#if SHADERPASS != SHADERPASS_FORWARD
#error SHADERPASS_is_not_correctly_define
#endif

#endif // TESSELLATION_ON
float4 BlendDiffuseSpecular(float3 diffuse, float3 specular, float opacity)
float4 ApplyBlendMode(float3 diffuseLighting, float3 specularLighting, float opacity)
return float4(diffuse + specular, opacity);
return float4(diffuseLighting + specularLighting, opacity);
float4 BlendDiffuseWithConsistentSpecular(float3 diffuse, float3 specular, float opacity)
// ref: http://advances.realtimerendering.com/other/2016/naughty_dog/index.html
// 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)
return float4(diffuse + (specular / max(opacity, 0.01)), opacity);
return float4(diffuseLighting + (specularLighting / max(opacity, 0.01)), opacity);
return float4(diffuse * opacity + specular, opacity);
return float4(diffuseLighting * opacity + specularLighting, opacity);
return BlendDiffuseSpecular(diffuse, specular, opacity);
return ApplyBlendMode(diffuseLighting, specularLighting, opacity);
#endif
}

if (_DebugLightingMode != DEBUGLIGHTINGMODE_NONE)
#endif
{
uint featureFlags = 0xFFFFFFFF;
float3 diffuseLighting;
float3 specularLighting;
float3 bakeDiffuseLighting = GetBakedDiffuseLigthing(surfaceData, builtinData, bsdfData, preLightData);
LightLoop(V, posInput, preLightData, bsdfData, bakeDiffuseLighting, featureFlags, diffuseLighting, specularLighting);
uint featureFlags = 0xFFFFFFFF;
float3 diffuseLighting;
float3 specularLighting;
float3 bakeDiffuseLighting = GetBakedDiffuseLigthing(surfaceData, builtinData, bsdfData, preLightData);
LightLoop(V, posInput, preLightData, bsdfData, bakeDiffuseLighting, featureFlags, diffuseLighting, specularLighting);
outColor = BlendDiffuseWithConsistentSpecular(diffuseLighting, specularLighting, builtinData.opacity);
}
outColor = ApplyBlendModeAccurateLighting(diffuseLighting, specularLighting, builtinData.opacity);
}
#ifdef _DEPTHOFFSET_ON
outputDepth = posInput.depthRaw;

正在加载...
取消
保存