浏览代码

Fix issue with last merge + make bent normal work

/main
sebastienlagarde 7 年前
当前提交
05c7d851
共有 5 个文件被更改,包括 33 次插入11 次删除
  1. 2
      ScriptableRenderPipeline/Core/ShaderLibrary/CommonLighting.hlsl
  2. 18
      ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/Editor/LayeredLitUI.cs
  3. 15
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Editor/LitUI.cs
  4. 3
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl
  5. 6
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitProperties.hlsl

2
ScriptableRenderPipeline/Core/ShaderLibrary/CommonLighting.hlsl


// Ref: Moving Frostbite to PBR - Gotanda siggraph 2011
// Return specular occlusion based on ambient occlusion (usually get from SSAO) and view/roughness info
float SpecularOcclusionFromAmbientOcclusion(float NdotV, float ambientOcclusion, float roughness)
float GetSpecularOcclusionFromAmbientOcclusion(float NdotV, float ambientOcclusion, float roughness)
{
return saturate(PositivePow(NdotV + ambientOcclusion, exp2(-16.0 * roughness - 1.0)) - 1.0 + ambientOcclusion);
}

18
ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/Editor/LayeredLitUI.cs


}
SetKeyword(material, "_DENSITY_MODE", useDensityModeEnable);
}
private void DoEmissiveGUI(Material material)
{
EditorGUILayout.Space();
EditorGUILayout.LabelField(Styles.lightingText, EditorStyles.boldLabel);
m_MaterialEditor.ShaderProperty(enableSpecularOcclusion, Styles.enableSpecularOcclusionText);
// TODO: display warning if we don't have bent normal (either OS or TS) and ambient occlusion
//if (enableSpecularOcclusion.floatValue > 0.0f)
{
// EditorGUILayout.HelpBox(Styles.specularOcclusionWarning.text, MessageType.Error);
}
EditorGUI.indentLevel++;
m_MaterialEditor.TexturePropertySingleLine(Styles.emissiveText, emissiveColorMap, emissiveColor);
m_MaterialEditor.ShaderProperty(emissiveIntensity, Styles.emissiveIntensityText);
m_MaterialEditor.ShaderProperty(albedoAffectEmissive, Styles.albedoAffectEmissiveText);
EditorGUI.indentLevel--;
}
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
{

}
bool layerChanged = DoLayersGUI(materialImporter);
DoEmissiveGUI();
DoEmissiveGUI(material);
DoEmissionArea(material);
EditorGUI.indentLevel--;
m_MaterialEditor.EnableInstancingField();

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


public static GUIContent specularColorText = new GUIContent("Specular Color", "Specular color (RGB)");
// Specular occlusion
public static GUIContent enableSpecularOcclusionText = new GUIContent("Enable Specular Occlusion", "Require cosine weighted bent normal and cosine weighted ambient occlusion. Specular occlusion for reflection probe");
public static GUIContent enableSpecularOcclusionText = new GUIContent("Enable Specular Occlusion from Bent normal", "Require cosine weighted bent normal and cosine weighted ambient occlusion. Specular occlusion for reflection probe");
public static GUIContent specularOcclusionWarning = new GUIContent("Require a cosine weighted bent normal and ambient occlusion maps");
// Emissive
public static string lightingText = "Lighting Inputs";

EditorGUI.indentLevel--;
}
protected void DoEmissiveGUI()
private void DoEmissiveGUI(Material material)
EditorGUI.indentLevel++;
// TODO: display warning if we don't have bent normal (either OS or TS) and ambient occlusion
//if (enableSpecularOcclusion.floatValue > 0.0f)
{
//EditorGUILayout.HelpBox(Styles.specularOcclusionWarning.text, MessageType.Error);
}
EditorGUI.indentLevel++;
m_MaterialEditor.TexturePropertySingleLine(Styles.emissiveText, emissiveColorMap, emissiveColor);
m_MaterialEditor.ShaderProperty(emissiveIntensity, Styles.emissiveIntensityText);
m_MaterialEditor.ShaderProperty(albedoAffectEmissive, Styles.albedoAffectEmissiveText);

protected override void MaterialPropertiesGUI(Material material)
{
DoLayerGUI(material, 0);
DoEmissiveGUI();
DoEmissiveGUI(material);
// The parent Base.ShaderPropertiesGUI will call DoEmissionArea
}

3
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl


float specularOcclusion = GetSpecularOcclusionFromAmbientOcclusion(preLightData.NdotV, lightLoopContext.indirectAmbientOcclusion, bsdfData.roughness);
// Try to mimic multibounce with specular color. Not the point of the original formula but ok result.
accLighting.envSpecularLighting *= bsdfData.specularOcclusion * GTAOMultiBounce(specularOcclusion, bsdfData.fresnel0);
// Take the min of screenspace specular occlusion and visibility cone specular occlusion
accLighting.envSpecularLighting *= GTAOMultiBounce(min(bsdfData.specularOcclusion, specularOcclusion), bsdfData.fresnel0);
// TODO: we could call a function like PostBSDF that will apply albedo and divide by PI once for the loop

6
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitProperties.hlsl


TEXTURE2D(_MaskMap);
SAMPLER2D(sampler_MaskMap);
TEXTURE2D(_SpecularOcclusionMap);
SAMPLER2D(sampler_SpecularOcclusionMap);
TEXTURE2D(_BentNormalMap); // Reuse sampler from normal map
SAMPLER2D(sampler_BentNormalMap);
TEXTURE2D(_NormalMap);
SAMPLER2D(sampler_NormalMap);

PROP_DECL_TEX2D(_BaseColorMap);
PROP_DECL_TEX2D(_MaskMap);
PROP_DECL_TEX2D(_SpecularOcclusionMap);
PROP_DECL_TEX2D(_BentNormalMap);
PROP_DECL_TEX2D(_NormalMap);
PROP_DECL_TEX2D(_NormalMapOS);
PROP_DECL_TEX2D(_HeightMap);

正在加载...
取消
保存