浏览代码

Fixed emission in LightweightSimpleLighting shader. Fixed shader inspectors.

/RenderPassXR_Sandbox
Felipe Lira 7 年前
当前提交
0c75b7cd
共有 5 个文件被更改,包括 24 次插入32 次删除
  1. 8
      ScriptableRenderPipeline/LightweightPipeline/Editor/LightweightPipelineUpgraders.cs
  2. 35
      ScriptableRenderPipeline/LightweightPipeline/Editor/ShaderGUI/LightweightStandardSimpleLightingGUI.cs
  3. 6
      ScriptableRenderPipeline/LightweightPipeline/Shaders/LightweightPassLit.cginc
  4. 2
      ScriptableRenderPipeline/LightweightPipeline/Shaders/LightweightStandard.shader
  5. 5
      ScriptableRenderPipeline/LightweightPipeline/Shaders/LightweightStandardSimpleLighting.shader

8
ScriptableRenderPipeline/LightweightPipeline/Editor/LightweightPipelineUpgraders.cs


LightweightShaderHelper.SetMaterialBlendMode(material);
UpdateMaterialSpecularSource(material);
LightweightShaderHelper.SetKeyword(material, "_NORMALMAP", material.GetTexture("_BumpMap"));
LightweightShaderHelper.SetKeyword(material, "_EMISSION", material.GetTexture("_EmissionMap"));
// A material's GI flag internally keeps track of whether emission is enabled at all, it's enabled but has no effect
// or is enabled and may be modified at runtime. This state depends on the values of the current flag and emissive color.
// The fixup routine makes sure that the material is in the correct state if/when changes are made to the mode or color.
MaterialEditor.FixupEmissiveFlag(material);
bool shouldEmissionBeEnabled = (material.globalIlluminationFlags & MaterialGlobalIlluminationFlags.EmissiveIsBlack) == 0;
LightweightShaderHelper.SetKeyword(material, "_EMISSION", shouldEmissionBeEnabled);
}
private static void UpdateMaterialSpecularSource(Material material)

35
ScriptableRenderPipeline/LightweightPipeline/Editor/ShaderGUI/LightweightStandardSimpleLightingGUI.cs


public static GUIContent normalMapText = new GUIContent("Normal Map", "Normal Map");
public static GUIContent emissionMapLabel = new GUIContent("Emission Map", "Emission Map");
public static GUIContent alphaCutoutWarning =
new GUIContent(
"This material has alpha cutout enabled. Alpha cutout has severe performance impact on mobile!");
public static GUIStyle warningStyle = new GUIStyle();
public static readonly string[] blendNames = Enum.GetNames(typeof(UpgradeBlendMode));
public static readonly string[] glossinessSourceNames = Enum.GetNames(typeof(GlossinessSource));

FindMaterialProperties(properties);
EditorGUI.BeginChangeCheck();
DoBlendMode();
{
DoBlendMode();
EditorGUILayout.Space();
DoSpecular();
EditorGUILayout.Space();
DoSpecular();
EditorGUILayout.Space();
m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, bumpMapProp);
EditorGUILayout.Space();
m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, bumpMapProp);
EditorGUILayout.Space();
DoEmissionArea(material);
EditorGUILayout.Space();
DoEmissionArea(material);
EditorGUI.BeginChangeCheck();
m_MaterialEditor.TextureScaleOffsetProperty(albedoMapProp);
if (EditorGUI.EndChangeCheck())
emissionMapProp.textureScaleAndOffset = albedoMapProp.textureScaleAndOffset; // Apply the main texture scale and offset to the emission texture as well, for Enlighten's sake
}
if (EditorGUI.EndChangeCheck())
LegacyBlinnPhongUpgrader.UpdateMaterialKeywords(material);

EditorGUILayout.Space();
EditorGUILayout.Space();
if ((UpgradeBlendMode)blendModeProp.floatValue == UpgradeBlendMode.Cutout)
{
Styles.warningStyle.normal.textColor = Color.yellow;
EditorGUILayout.LabelField(Styles.alphaCutoutWarning, Styles.warningStyle);
}
}
public override void AssignNewShaderToMaterial(Material material, Shader oldShader, Shader newShader)

int glossSource = (int)glossinessSourceProp.floatValue;
m_MaterialEditor.TexturePropertySingleLine(Styles.albedoGlosinessLabels[glossSource], albedoMapProp,
albedoColorProp);
m_MaterialEditor.TextureScaleOffsetProperty(albedoMapProp);
}
m_MaterialEditor.TextureScaleOffsetProperty(albedoMapProp);}
m_MaterialEditor.TextureScaleOffsetProperty(albedoMapProp);
if (mode == UpgradeBlendMode.Cutout)
m_MaterialEditor.RangeProperty(alphaCutoffProp, "Cutoff");
}

6
ScriptableRenderPipeline/LightweightPipeline/Shaders/LightweightPassLit.cginc


#endif // _MULTIPLE_LIGHTS
#ifdef _EMISSION
color += LIGHTWEIGHT_GAMMA_TO_LINEAR(tex2D(_EmissionMap, i.uv01.xy).rgb) * _EmissionColor;
#else
color += _EmissionColor;
#endif
color += EmissionLW(i.uv01.xy);
#if defined(LIGHTMAP_ON)
color += DecodeLightmap(UNITY_SAMPLE_TEX2D(unity_Lightmap, i.uv01.zw)) * diffuse;

2
ScriptableRenderPipeline/LightweightPipeline/Shaders/LightweightStandard.shader


}
}
FallBack "Standard"
CustomEditor "LightweightStandardShaderGUI"
CustomEditor "LightweightStandardGUI"
}

5
ScriptableRenderPipeline/LightweightPipeline/Shaders/LightweightStandardSimpleLighting.shader


_Glossiness("Glossiness", Range(0.0, 1.0)) = 0.5
[Enum(Specular Alpha,0,Albedo Alpha,1)] _SmoothnessTextureChannel("Smoothness texture channel", Float) = 0
_Cube ("Reflection Cubemap", CUBE) = "" {}
_ReflectionSource("Reflection Source", Float) = 0
[HideInInspector] _SpecSource("Specular Color Source", Float) = 0.0
_SpecColor("Specular", Color) = (1.0, 1.0, 1.0)
_SpecGlossMap("Specular", 2D) = "white" {}

}
}
Fallback "Standard (Specular setup)"
CustomEditor "LightweightPipelineMaterialEditor"
CustomEditor "LightweightStandardSimpleLightingGUI"
}
正在加载...
取消
保存