浏览代码

Added LightweightPipeline shader GUI. Updated PBR material with the new keywords.

/RenderPassXR_Sandbox
Felipe Lira 7 年前
当前提交
87ac03cd
共有 26 个文件被更改,包括 644 次插入31 次删除
  1. 10
      ScriptableRenderPipeline/LightweightPipeline/Shaders/LightweightPipelineInput.cginc
  2. 15
      ScriptableRenderPipeline/LightweightPipeline/Shaders/LightweightStandardShader.shader
  3. 9
      Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/012_PBS_EnvironmentBRDF_Spheres/PBRSphere 1.mat
  4. 9
      Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/012_PBS_EnvironmentBRDF_Spheres/PBRSphere 10.mat
  5. 9
      Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/012_PBS_EnvironmentBRDF_Spheres/PBRSphere 11.mat
  6. 9
      Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/012_PBS_EnvironmentBRDF_Spheres/PBRSphere 12.mat
  7. 9
      Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/012_PBS_EnvironmentBRDF_Spheres/PBRSphere 13.mat
  8. 9
      Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/012_PBS_EnvironmentBRDF_Spheres/PBRSphere 14.mat
  9. 9
      Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/012_PBS_EnvironmentBRDF_Spheres/PBRSphere 15.mat
  10. 9
      Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/012_PBS_EnvironmentBRDF_Spheres/PBRSphere 16.mat
  11. 9
      Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/012_PBS_EnvironmentBRDF_Spheres/PBRSphere 17.mat
  12. 9
      Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/012_PBS_EnvironmentBRDF_Spheres/PBRSphere 18.mat
  13. 9
      Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/012_PBS_EnvironmentBRDF_Spheres/PBRSphere 19.mat
  14. 9
      Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/012_PBS_EnvironmentBRDF_Spheres/PBRSphere 2.mat
  15. 9
      Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/012_PBS_EnvironmentBRDF_Spheres/PBRSphere 20.mat
  16. 9
      Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/012_PBS_EnvironmentBRDF_Spheres/PBRSphere 21.mat
  17. 9
      Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/012_PBS_EnvironmentBRDF_Spheres/PBRSphere 3.mat
  18. 9
      Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/012_PBS_EnvironmentBRDF_Spheres/PBRSphere 4.mat
  19. 9
      Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/012_PBS_EnvironmentBRDF_Spheres/PBRSphere 5.mat
  20. 9
      Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/012_PBS_EnvironmentBRDF_Spheres/PBRSphere 6.mat
  21. 9
      Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/012_PBS_EnvironmentBRDF_Spheres/PBRSphere 7.mat
  22. 9
      Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/012_PBS_EnvironmentBRDF_Spheres/PBRSphere 8.mat
  23. 9
      Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/012_PBS_EnvironmentBRDF_Spheres/PBRSphere 9.mat
  24. 9
      Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/012_PBS_EnvironmentBRDF_Spheres/PBRSphere.mat
  25. 439
      ScriptableRenderPipeline/LightweightPipeline/Editor/ShaderGUI/LightweightStandardShaderGUI.cs
  26. 13
      ScriptableRenderPipeline/LightweightPipeline/Editor/ShaderGUI/LightweightStandardShaderGUI.cs.meta

10
ScriptableRenderPipeline/LightweightPipeline/Shaders/LightweightPipelineInput.cginc


half4 _LightSpotDir;
#endif
sampler2D _MetallicSpecGlossMap;
half _Shininess;
samplerCUBE _Cube;
half4 _ReflectColor;

{
half2 mg;
#ifdef _METALLICGLOSSMAP
#ifdef _METALLICSPECGLOSSMAP
mg.r = tex2D(_MetallicGlossMap, uv).r;
mg.r = tex2D(_MetallicSpecGlossMap, uv).r;
mg = tex2D(_MetallicGlossMap, uv).ra;
mg = tex2D(_MetallicSpecGlossMap, uv).ra;
#else // _METALLICGLOSSMAP
#else // _METALLICSPECGLOSSMAP
mg.r = _Metallic;
#ifdef _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A

15
ScriptableRenderPipeline/LightweightPipeline/Shaders/LightweightStandardShader.shader


{
Properties
{
// Specular vs Metallic workflow
[HideInInspector] _WorkflowMode("WorkflowMode", Float) = 1.0
_Color("Color", Color) = (1,1,1,1)
_MainTex("Albedo", 2D) = "white" {}

_GlossMapScale("Smoothness Scale", Range(0.0, 1.0)) = 1.0
[Enum(Metallic Alpha,0,Albedo Alpha,1)] _SmoothnessTextureChannel("Smoothness texture channel", Float) = 0
_SmoothnessTextureChannel("Smoothness texture channel", Float) = 0
_MetallicGlossMap("Metallic", 2D) = "white" {}
_SpecColor("Specular", Color) = (0.2, 0.2, 0.2)
_MetallicSpecGlossMap("MetallicSpecGlossMap", 2D) = "white" {} // SpecGloss map when _SPECULAR_SETUP, MetallicGloss otherwise
[ToggleOff] _SpecularHighlights("Specular Highlights", Float) = 1.0
[ToggleOff] _GlossyReflections("Glossy Reflections", Float) = 1.0

#pragma target 3.0
// -------------------------------------
#pragma shader_feature _METALLIC_SETUP _SPECULAR_SETUP
#pragma shader_feature _METALLICGLOSSMAP
#pragma shader_feature _METALLICSPECGLOSSMAP
#pragma shader_feature ___ _DETAIL_MULX2
#pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
#pragma shader_feature _ _SPECULARHIGHLIGHTS_OFF

#if defined(_SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A)
half alpha = _Color.a;
half glossiness = albedorTex.a;
half glossiness = albedoTex.a;
#else
half alpha = albedoTex.a * _Color.a;
half glossiness = _Glossiness;

}
}
FallBack "VertexLit"
CustomEditor "StandardShaderGUI"
CustomEditor "LightweightStandardShaderGUI"
}

9
Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/012_PBS_EnvironmentBRDF_Spheres/PBRSphere 1.mat


m_PrefabInternal: {fileID: 0}
m_Name: PBRSphere 1
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _SPECULARHIGHLIGHTS_OFF
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _METALLIC_SETUP _SPECULARHIGHLIGHTS_OFF
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0

m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicSpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}

- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _WorkFlowMode: 0
- _WorkflowMode: 1
- _MetallicSpecColor: {r: 0, g: 0.19999996, b: 0.19999996, a: 0.2}
- _SpecColor: {r: 1, g: 1, b: 1, a: 1}

9
Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/012_PBS_EnvironmentBRDF_Spheres/PBRSphere 10.mat


m_PrefabInternal: {fileID: 0}
m_Name: PBRSphere 10
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _SPECULARHIGHLIGHTS_OFF
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _METALLIC_SETUP _SPECULARHIGHLIGHTS_OFF
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0

m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicSpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}

- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _WorkFlowMode: 0
- _WorkflowMode: 1
- _MetallicSpecColor: {r: 0, g: 0.19999996, b: 0.19999996, a: 0.2}
- _SpecColor: {r: 1, g: 1, b: 1, a: 1}

9
Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/012_PBS_EnvironmentBRDF_Spheres/PBRSphere 11.mat


m_PrefabInternal: {fileID: 0}
m_Name: PBRSphere 11
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _SPECULARHIGHLIGHTS_OFF
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _METALLIC_SETUP _SPECULARHIGHLIGHTS_OFF
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0

m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicSpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}

- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _WorkFlowMode: 0
- _WorkflowMode: 1
- _MetallicSpecColor: {r: 0, g: 0.19999996, b: 0.19999996, a: 0.2}
- _SpecColor: {r: 1, g: 1, b: 1, a: 1}

9
Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/012_PBS_EnvironmentBRDF_Spheres/PBRSphere 12.mat


m_PrefabInternal: {fileID: 0}
m_Name: PBRSphere 12
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _SPECULARHIGHLIGHTS_OFF
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _METALLIC_SETUP _SPECULARHIGHLIGHTS_OFF
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0

m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicSpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}

- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _WorkFlowMode: 0
- _WorkflowMode: 1
- _MetallicSpecColor: {r: 0, g: 0.19999996, b: 0.19999996, a: 0.2}
- _SpecColor: {r: 1, g: 1, b: 1, a: 1}

9
Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/012_PBS_EnvironmentBRDF_Spheres/PBRSphere 13.mat


m_PrefabInternal: {fileID: 0}
m_Name: PBRSphere 13
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _SPECULARHIGHLIGHTS_OFF
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _METALLIC_SETUP _SPECULARHIGHLIGHTS_OFF
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0

m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicSpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}

- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _WorkFlowMode: 0
- _WorkflowMode: 1
- _MetallicSpecColor: {r: 0, g: 0.19999996, b: 0.19999996, a: 0.2}
- _SpecColor: {r: 1, g: 1, b: 1, a: 1}

9
Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/012_PBS_EnvironmentBRDF_Spheres/PBRSphere 14.mat


m_PrefabInternal: {fileID: 0}
m_Name: PBRSphere 14
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _SPECULARHIGHLIGHTS_OFF
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _METALLIC_SETUP _SPECULARHIGHLIGHTS_OFF
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0

m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicSpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}

- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _WorkFlowMode: 0
- _WorkflowMode: 1
- _MetallicSpecColor: {r: 0, g: 0.19999996, b: 0.19999996, a: 0.2}
- _SpecColor: {r: 1, g: 1, b: 1, a: 1}

9
Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/012_PBS_EnvironmentBRDF_Spheres/PBRSphere 15.mat


m_PrefabInternal: {fileID: 0}
m_Name: PBRSphere 15
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _SPECULARHIGHLIGHTS_OFF
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _METALLIC_SETUP _SPECULARHIGHLIGHTS_OFF
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0

m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicSpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}

- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _WorkFlowMode: 0
- _WorkflowMode: 1
- _MetallicSpecColor: {r: 0, g: 0.19999996, b: 0.19999996, a: 0.2}
- _SpecColor: {r: 1, g: 1, b: 1, a: 1}

9
Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/012_PBS_EnvironmentBRDF_Spheres/PBRSphere 16.mat


m_PrefabInternal: {fileID: 0}
m_Name: PBRSphere 16
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _SPECULARHIGHLIGHTS_OFF
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _METALLIC_SETUP _SPECULARHIGHLIGHTS_OFF
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0

m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicSpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}

- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _WorkFlowMode: 0
- _WorkflowMode: 1
- _MetallicSpecColor: {r: 0, g: 0.19999996, b: 0.19999996, a: 0.2}
- _SpecColor: {r: 1, g: 1, b: 1, a: 1}

9
Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/012_PBS_EnvironmentBRDF_Spheres/PBRSphere 17.mat


m_PrefabInternal: {fileID: 0}
m_Name: PBRSphere 17
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _SPECULARHIGHLIGHTS_OFF
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _METALLIC_SETUP _SPECULARHIGHLIGHTS_OFF
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0

m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicSpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}

- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _WorkFlowMode: 0
- _WorkflowMode: 1
- _MetallicSpecColor: {r: 0, g: 0.19999996, b: 0.19999996, a: 0.2}
- _SpecColor: {r: 1, g: 1, b: 1, a: 1}

9
Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/012_PBS_EnvironmentBRDF_Spheres/PBRSphere 18.mat


m_PrefabInternal: {fileID: 0}
m_Name: PBRSphere 18
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _SPECULARHIGHLIGHTS_OFF
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _METALLIC_SETUP _SPECULARHIGHLIGHTS_OFF
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0

m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicSpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}

- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _WorkFlowMode: 0
- _WorkflowMode: 1
- _MetallicSpecColor: {r: 0, g: 0.19999996, b: 0.19999996, a: 0.2}
- _SpecColor: {r: 1, g: 1, b: 1, a: 1}

9
Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/012_PBS_EnvironmentBRDF_Spheres/PBRSphere 19.mat


m_PrefabInternal: {fileID: 0}
m_Name: PBRSphere 19
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _SPECULARHIGHLIGHTS_OFF
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _METALLIC_SETUP _SPECULARHIGHLIGHTS_OFF
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0

m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicSpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}

- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _WorkFlowMode: 0
- _WorkflowMode: 1
- _MetallicSpecColor: {r: 0, g: 0.19999996, b: 0.19999996, a: 0.2}
- _SpecColor: {r: 1, g: 1, b: 1, a: 1}

9
Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/012_PBS_EnvironmentBRDF_Spheres/PBRSphere 2.mat


m_PrefabInternal: {fileID: 0}
m_Name: PBRSphere 2
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _SPECULARHIGHLIGHTS_OFF
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _METALLIC_SETUP _SPECULARHIGHLIGHTS_OFF
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0

m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicSpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}

- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _WorkFlowMode: 0
- _WorkflowMode: 1
- _MetallicSpecColor: {r: 0, g: 0.19999996, b: 0.19999996, a: 0.2}
- _SpecColor: {r: 1, g: 1, b: 1, a: 1}

9
Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/012_PBS_EnvironmentBRDF_Spheres/PBRSphere 20.mat


m_PrefabInternal: {fileID: 0}
m_Name: PBRSphere 20
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _SPECULARHIGHLIGHTS_OFF
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _METALLIC_SETUP _SPECULARHIGHLIGHTS_OFF
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0

m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicSpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}

- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _WorkFlowMode: 0
- _WorkflowMode: 1
- _MetallicSpecColor: {r: 0, g: 0.19999996, b: 0.19999996, a: 0.2}
- _SpecColor: {r: 1, g: 1, b: 1, a: 1}

9
Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/012_PBS_EnvironmentBRDF_Spheres/PBRSphere 21.mat


m_PrefabInternal: {fileID: 0}
m_Name: PBRSphere 21
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _SPECULARHIGHLIGHTS_OFF
m_ShaderKeywords: _METALLIC_SETUP
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0

m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicSpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}

- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _WorkFlowMode: 0
- _WorkflowMode: 1
- _MetallicSpecColor: {r: 0, g: 0.19999996, b: 0.19999996, a: 0.2}
- _SpecColor: {r: 1, g: 1, b: 1, a: 1}

9
Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/012_PBS_EnvironmentBRDF_Spheres/PBRSphere 3.mat


m_PrefabInternal: {fileID: 0}
m_Name: PBRSphere 3
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _SPECULARHIGHLIGHTS_OFF
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _METALLIC_SETUP _SPECULARHIGHLIGHTS_OFF
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0

m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicSpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}

- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _WorkFlowMode: 0
- _WorkflowMode: 1
- _MetallicSpecColor: {r: 0, g: 0.19999996, b: 0.19999996, a: 0.2}
- _SpecColor: {r: 1, g: 1, b: 1, a: 1}

9
Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/012_PBS_EnvironmentBRDF_Spheres/PBRSphere 4.mat


m_PrefabInternal: {fileID: 0}
m_Name: PBRSphere 4
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _SPECULARHIGHLIGHTS_OFF
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _METALLIC_SETUP _SPECULARHIGHLIGHTS_OFF
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0

m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicSpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}

- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _WorkFlowMode: 0
- _WorkflowMode: 1
- _MetallicSpecColor: {r: 0, g: 0.19999996, b: 0.19999996, a: 0.2}
- _SpecColor: {r: 1, g: 1, b: 1, a: 1}

9
Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/012_PBS_EnvironmentBRDF_Spheres/PBRSphere 5.mat


m_PrefabInternal: {fileID: 0}
m_Name: PBRSphere 5
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _SPECULARHIGHLIGHTS_OFF
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _METALLIC_SETUP _SPECULARHIGHLIGHTS_OFF
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0

m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicSpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}

- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _WorkFlowMode: 0
- _WorkflowMode: 1
- _MetallicSpecColor: {r: 0, g: 0.19999996, b: 0.19999996, a: 0.2}
- _SpecColor: {r: 1, g: 1, b: 1, a: 1}

9
Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/012_PBS_EnvironmentBRDF_Spheres/PBRSphere 6.mat


m_PrefabInternal: {fileID: 0}
m_Name: PBRSphere 6
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _SPECULARHIGHLIGHTS_OFF
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _METALLIC_SETUP _SPECULARHIGHLIGHTS_OFF
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0

m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicSpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}

- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _WorkFlowMode: 0
- _WorkflowMode: 1
- _MetallicSpecColor: {r: 0, g: 0.19999996, b: 0.19999996, a: 0.2}
- _SpecColor: {r: 1, g: 1, b: 1, a: 1}

9
Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/012_PBS_EnvironmentBRDF_Spheres/PBRSphere 7.mat


m_PrefabInternal: {fileID: 0}
m_Name: PBRSphere 7
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _SPECULARHIGHLIGHTS_OFF
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _METALLIC_SETUP _SPECULARHIGHLIGHTS_OFF
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0

m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicSpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}

- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _WorkFlowMode: 0
- _WorkflowMode: 1
- _MetallicSpecColor: {r: 0, g: 0.19999996, b: 0.19999996, a: 0.2}
- _SpecColor: {r: 1, g: 1, b: 1, a: 1}

9
Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/012_PBS_EnvironmentBRDF_Spheres/PBRSphere 8.mat


m_PrefabInternal: {fileID: 0}
m_Name: PBRSphere 8
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _SPECULARHIGHLIGHTS_OFF
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _METALLIC_SETUP _SPECULARHIGHLIGHTS_OFF
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0

m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicSpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}

- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _WorkFlowMode: 0
- _WorkflowMode: 1
- _MetallicSpecColor: {r: 0, g: 0.19999996, b: 0.19999996, a: 0.2}
- _SpecColor: {r: 1, g: 1, b: 1, a: 1}

9
Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/012_PBS_EnvironmentBRDF_Spheres/PBRSphere 9.mat


m_PrefabInternal: {fileID: 0}
m_Name: PBRSphere 9
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _SPECULARHIGHLIGHTS_OFF
m_ShaderKeywords: _METALLIC_SETUP
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0

m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicSpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}

- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _WorkFlowMode: 0
- _WorkflowMode: 1
- _MetallicSpecColor: {r: 0, g: 0.19999996, b: 0.19999996, a: 0.2}
- _SpecColor: {r: 1, g: 1, b: 1, a: 1}

9
Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/012_PBS_EnvironmentBRDF_Spheres/PBRSphere.mat


m_PrefabInternal: {fileID: 0}
m_Name: PBRSphere
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _SPECULARHIGHLIGHTS_OFF
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _METALLIC_SETUP _SPECULARHIGHLIGHTS_OFF
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0

m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicSpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}

- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _WorkFlowMode: 0
- _WorkflowMode: 1
- _MetallicSpecColor: {r: 0, g: 0.19999996, b: 0.19999996, a: 0.2}
- _SpecColor: {r: 1, g: 1, b: 1, a: 1}

439
ScriptableRenderPipeline/LightweightPipeline/Editor/ShaderGUI/LightweightStandardShaderGUI.cs


using System;
using UnityEngine;
namespace UnityEditor
{
internal class LightweightStandardShaderGUI : ShaderGUI
{
public enum WorkflowMode : int
{
Specular = 0,
Metallic
}
public enum BlendMode : int
{
Opaque,
Cutout,
Fade, // Old school alpha-blending mode, fresnel does not affect amount of transparency
Transparent // Physically plausible transparency mode, implemented as alpha pre-multiply
}
public enum SmoothnessMapChannel : int
{
SpecularMetallicAlpha,
AlbedoAlpha,
}
private static class Styles
{
public static GUIContent uvSetLabel = new GUIContent("UV Set");
public static GUIContent albedoText = new GUIContent("Albedo", "Albedo (RGB) and Transparency (A)");
public static GUIContent alphaCutoffText = new GUIContent("Alpha Cutoff", "Threshold for alpha cutoff");
public static GUIContent specularMapText = new GUIContent("Specular", "Specular (RGB) and Smoothness (A)");
public static GUIContent metallicMapText = new GUIContent("Metallic", "Metallic (R) and Smoothness (A)");
public static GUIContent smoothnessText = new GUIContent("Smoothness", "Smoothness value");
public static GUIContent smoothnessScaleText = new GUIContent("Smoothness", "Smoothness scale factor");
public static GUIContent smoothnessMapChannelText = new GUIContent("Source", "Smoothness texture and channel");
public static GUIContent highlightsText = new GUIContent("Specular Highlights", "Specular Highlights");
public static GUIContent reflectionsText = new GUIContent("Reflections", "Glossy Reflections");
public static GUIContent normalMapText = new GUIContent("Normal Map", "Normal Map");
public static GUIContent heightMapText = new GUIContent("Height Map", "Height Map (G)");
public static GUIContent occlusionText = new GUIContent("Occlusion", "Occlusion (G)");
public static GUIContent emissionText = new GUIContent("Color", "Emission (RGB)");
public static GUIContent detailMaskText = new GUIContent("Detail Mask", "Mask for Secondary Maps (A)");
public static GUIContent detailAlbedoText = new GUIContent("Detail Albedo x2", "Albedo (RGB) multiplied by 2");
public static GUIContent detailNormalMapText = new GUIContent("Normal Map", "Normal Map");
public static string primaryMapsText = "Main Maps";
public static string secondaryMapsText = "Secondary Maps";
public static string forwardText = "Forward Rendering Options";
public static string workflowModeText = "Workflow Mode";
public static string renderingMode = "Rendering Mode";
public static string advancedText = "Advanced Options";
public static readonly string[] workflowNames = Enum.GetNames(typeof(WorkflowMode));
public static readonly string[] blendNames = Enum.GetNames(typeof(BlendMode));
public static readonly string[] metallicSmoothnessChannelNames = {"Metallic Alpha", "Albedo Alpha"};
public static readonly string[] specularSmoothnessChannelNames = {"Specular Alpha", "Albedo Alpha"};
}
private MaterialProperty workflowMode = null;
private MaterialProperty blendMode = null;
private MaterialProperty albedoColor = null;
private MaterialProperty albedoMap = null;
private MaterialProperty alphaCutoff = null;
private MaterialProperty smoothness = null;
private MaterialProperty smoothnessScale = null;
private MaterialProperty smoothnessMapChannel = null;
private MaterialProperty metallic = null;
private MaterialProperty specColor = null;
private MaterialProperty metallicSpecMap = null;
private MaterialProperty highlights = null;
private MaterialProperty reflections = null;
private MaterialProperty bumpScale = null;
private MaterialProperty bumpMap = null;
private MaterialProperty occlusionStrength = null;
private MaterialProperty occlusionMap = null;
private MaterialProperty heigtMapScale = null;
private MaterialProperty heightMap = null;
private MaterialProperty emissionColorForRendering = null;
private MaterialProperty emissionMap = null;
private MaterialProperty detailMask = null;
private MaterialProperty detailAlbedoMap = null;
private MaterialProperty detailNormalMapScale = null;
private MaterialProperty detailNormalMap = null;
private MaterialProperty uvSetSecondary = null;
private MaterialEditor m_MaterialEditor;
private WorkflowMode m_WorkflowMode = WorkflowMode.Metallic;
private const float kMaxfp16 = 65536f; // Clamp to a value that fits into fp16.
private ColorPickerHDRConfig m_ColorPickerHDRConfig = new ColorPickerHDRConfig(0f, kMaxfp16, 1 / kMaxfp16, 3f);
private bool m_FirstTimeApply = true;
public void FindProperties(MaterialProperty[] props)
{
workflowMode = FindProperty("_WorkflowMode", props);
blendMode = FindProperty("_Mode", props);
albedoColor = FindProperty("_Color", props);
albedoMap = FindProperty("_MainTex", props);
alphaCutoff = FindProperty("_Cutoff", props);
smoothness = FindProperty("_Glossiness", props);
smoothnessScale = FindProperty("_GlossMapScale", props, false);
smoothnessMapChannel = FindProperty("_SmoothnessTextureChannel", props, false);
metallic = FindProperty("_Metallic", props);
specColor = FindProperty("_SpecColor", props);
metallicSpecMap = FindProperty("_MetallicSpecGlossMap", props);
highlights = FindProperty("_SpecularHighlights", props, false);
reflections = FindProperty("_GlossyReflections", props, false);
bumpScale = FindProperty("_BumpScale", props);
bumpMap = FindProperty("_BumpMap", props);
heigtMapScale = FindProperty("_Parallax", props);
heightMap = FindProperty("_ParallaxMap", props);
occlusionStrength = FindProperty("_OcclusionStrength", props);
occlusionMap = FindProperty("_OcclusionMap", props);
emissionColorForRendering = FindProperty("_EmissionColor", props);
emissionMap = FindProperty("_EmissionMap", props);
detailMask = FindProperty("_DetailMask", props);
detailAlbedoMap = FindProperty("_DetailAlbedoMap", props);
detailNormalMapScale = FindProperty("_DetailNormalMapScale", props);
detailNormalMap = FindProperty("_DetailNormalMap", props);
uvSetSecondary = FindProperty("_UVSec", props);
}
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
{
FindProperties(props); // MaterialProperties can be animated so we do not cache them but fetch them every event to ensure animated values are updated correctly
m_MaterialEditor = materialEditor;
Material material = materialEditor.target as Material;
// Make sure that needed setup (ie keywords/renderqueue) are set up if we're switching some existing
// material to a lightweight shader.
if (m_FirstTimeApply)
{
MaterialChanged(material, m_WorkflowMode);
m_FirstTimeApply = false;
}
ShaderPropertiesGUI(material);
}
public void ShaderPropertiesGUI(Material material)
{
// Use default labelWidth
EditorGUIUtility.labelWidth = 0f;
// Detect any changes to the material
EditorGUI.BeginChangeCheck();
{
DoPopup(Styles.workflowModeText, workflowMode, Styles.workflowNames);
DoPopup(Styles.renderingMode, blendMode, Styles.blendNames);
// Primary properties
GUILayout.Label(Styles.primaryMapsText, EditorStyles.boldLabel);
DoAlbedoArea(material);
DoMetallicSpecularArea();
DoNormalArea();
// ATM not supported
//m_MaterialEditor.TexturePropertySingleLine(Styles.heightMapText, heightMap, heightMap.textureValue != null ? heigtMapScale : null);
m_MaterialEditor.TexturePropertySingleLine(Styles.occlusionText, occlusionMap, occlusionMap.textureValue != null ? occlusionStrength : null);
// ATM not supported
//m_MaterialEditor.TexturePropertySingleLine(Styles.detailMaskText, detailMask);
DoEmissionArea(material);
EditorGUI.BeginChangeCheck();
m_MaterialEditor.TextureScaleOffsetProperty(albedoMap);
if (EditorGUI.EndChangeCheck())
emissionMap.textureScaleAndOffset = albedoMap.textureScaleAndOffset; // Apply the main texture scale and offset to the emission texture as well, for Enlighten's sake
EditorGUILayout.Space();
// ATM not supported
//// Secondary properties
//GUILayout.Label(Styles.secondaryMapsText, EditorStyles.boldLabel);
//m_MaterialEditor.TexturePropertySingleLine(Styles.detailAlbedoText, detailAlbedoMap);
//m_MaterialEditor.TexturePropertySingleLine(Styles.detailNormalMapText, detailNormalMap, detailNormalMapScale);
//m_MaterialEditor.TextureScaleOffsetProperty(detailAlbedoMap);
//m_MaterialEditor.ShaderProperty(uvSetSecondary, Styles.uvSetLabel.text);
// Third properties
GUILayout.Label(Styles.forwardText, EditorStyles.boldLabel);
if (highlights != null)
m_MaterialEditor.ShaderProperty(highlights, Styles.highlightsText);
if (reflections != null)
m_MaterialEditor.ShaderProperty(reflections, Styles.reflectionsText);
}
if (EditorGUI.EndChangeCheck())
{
foreach (var obj in blendMode.targets)
MaterialChanged((Material)obj, m_WorkflowMode);
}
EditorGUILayout.Space();
// NB renderqueue editor is not shown on purpose: we want to override it based on blend mode
GUILayout.Label(Styles.advancedText, EditorStyles.boldLabel);
m_MaterialEditor.EnableInstancingField();
m_MaterialEditor.DoubleSidedGIField();
}
public override void AssignNewShaderToMaterial(Material material, Shader oldShader, Shader newShader)
{
// _Emission property is lost after assigning Standard shader to the material
// thus transfer it before assigning the new shader
if (material.HasProperty("_Emission"))
{
material.SetColor("_EmissionColor", material.GetColor("_Emission"));
}
base.AssignNewShaderToMaterial(material, oldShader, newShader);
if (oldShader == null || !oldShader.name.Contains("Legacy Shaders/"))
{
SetupMaterialWithBlendMode(material, (BlendMode)material.GetFloat("_Mode"));
return;
}
BlendMode blendMode = BlendMode.Opaque;
if (oldShader.name.Contains("/Transparent/Cutout/"))
{
blendMode = BlendMode.Cutout;
}
else if (oldShader.name.Contains("/Transparent/"))
{
// NOTE: legacy shaders did not provide physically based transparency
// therefore Fade mode
blendMode = BlendMode.Fade;
}
material.SetFloat("_Mode", (float)blendMode);
// TODO: material.HasKeyword()?
if (oldShader.name.Equals("Standard (Specular setup)"))
m_WorkflowMode = WorkflowMode.Specular;
else
m_WorkflowMode = WorkflowMode.Metallic;
MaterialChanged(material, m_WorkflowMode);
}
private void DoPopup(string label, MaterialProperty property, string[] options)
{
EditorGUI.showMixedValue = property.hasMixedValue;
var mode = property.floatValue;
EditorGUI.BeginChangeCheck();
mode = EditorGUILayout.Popup(label, (int) mode, options);
if (EditorGUI.EndChangeCheck())
{
m_MaterialEditor.RegisterPropertyChangeUndo(label);
property.floatValue = (float)mode;
}
EditorGUI.showMixedValue = false;
}
void DoNormalArea()
{
m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, bumpMap, bumpMap.textureValue != null ? bumpScale : null);
if (bumpScale.floatValue != 1 && UnityEditorInternal.InternalEditorUtility.IsMobilePlatform(EditorUserBuildSettings.activeBuildTarget))
if (m_MaterialEditor.HelpBoxWithButton(
new GUIContent("Bump scale is not supported on mobile platforms"),
new GUIContent("Fix Now")))
{
bumpScale.floatValue = 1;
}
}
void DoAlbedoArea(Material material)
{
m_MaterialEditor.TexturePropertySingleLine(Styles.albedoText, albedoMap, albedoColor);
if (((BlendMode)material.GetFloat("_Mode") == BlendMode.Cutout))
{
m_MaterialEditor.ShaderProperty(alphaCutoff, Styles.alphaCutoffText.text, MaterialEditor.kMiniTextureFieldLabelIndentLevel + 1);
}
}
void DoEmissionArea(Material material)
{
// Emission for GI?
if (m_MaterialEditor.EmissionEnabledProperty())
{
bool hadEmissionTexture = emissionMap.textureValue != null;
// Texture and HDR color controls
m_MaterialEditor.TexturePropertyWithHDRColor(Styles.emissionText, emissionMap, emissionColorForRendering, m_ColorPickerHDRConfig, false);
// If texture was assigned and color was black set color to white
float brightness = emissionColorForRendering.colorValue.maxColorComponent;
if (emissionMap.textureValue != null && !hadEmissionTexture && brightness <= 0f)
emissionColorForRendering.colorValue = Color.white;
// change the GI flag and fix it up with emissive as black if necessary
m_MaterialEditor.LightmapEmissionFlagsProperty(MaterialEditor.kMiniTextureFieldLabelIndentLevel, true);
}
}
void DoMetallicSpecularArea()
{
GUIContent metallicSpecMapName;
string[] metallicSpecSmoothnessChannelName;
MaterialProperty metallicSpecColorProp;
if ((WorkflowMode) workflowMode.floatValue == WorkflowMode.Metallic)
{
metallicSpecMapName = Styles.metallicMapText;
metallicSpecSmoothnessChannelName = Styles.metallicSmoothnessChannelNames;
metallicSpecColorProp = metallic;
}
else
{
metallicSpecMapName = Styles.specularMapText;
metallicSpecSmoothnessChannelName = Styles.specularSmoothnessChannelNames;
metallicSpecColorProp = specColor;
}
bool hasGlossMap = metallicSpecMap.textureValue != null;
m_MaterialEditor.TexturePropertySingleLine(metallicSpecMapName, metallicSpecMap, hasGlossMap ? null : metallicSpecColorProp);
bool showSmoothnessScale = hasGlossMap;
if (smoothnessMapChannel != null)
{
int smoothnessChannel = (int)smoothnessMapChannel.floatValue;
if (smoothnessChannel == (int)SmoothnessMapChannel.AlbedoAlpha)
showSmoothnessScale = true;
}
int indentation = 2; // align with labels of texture properties
m_MaterialEditor.ShaderProperty(showSmoothnessScale ? smoothnessScale : smoothness, showSmoothnessScale ? Styles.smoothnessScaleText : Styles.smoothnessText, indentation);
int prevIndentLevel = EditorGUI.indentLevel;
EditorGUI.indentLevel = 3;
if (smoothnessMapChannel != null)
DoPopup(Styles.smoothnessMapChannelText.text, smoothnessMapChannel, metallicSpecSmoothnessChannelName);
EditorGUI.indentLevel = prevIndentLevel;
}
public static void SetupMaterialWithBlendMode(Material material, BlendMode blendMode)
{
switch (blendMode)
{
case BlendMode.Opaque:
material.SetOverrideTag("RenderType", "");
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
material.SetInt("_ZWrite", 1);
material.DisableKeyword("_ALPHATEST_ON");
material.DisableKeyword("_ALPHABLEND_ON");
material.DisableKeyword("_ALPHAPREMULTIPLY_ON");
material.renderQueue = -1;
break;
case BlendMode.Cutout:
material.SetOverrideTag("RenderType", "TransparentCutout");
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
material.SetInt("_ZWrite", 1);
material.EnableKeyword("_ALPHATEST_ON");
material.DisableKeyword("_ALPHABLEND_ON");
material.DisableKeyword("_ALPHAPREMULTIPLY_ON");
material.renderQueue = (int)UnityEngine.Rendering.RenderQueue.AlphaTest;
break;
case BlendMode.Fade:
material.SetOverrideTag("RenderType", "Transparent");
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha);
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
material.SetInt("_ZWrite", 0);
material.DisableKeyword("_ALPHATEST_ON");
material.EnableKeyword("_ALPHABLEND_ON");
material.DisableKeyword("_ALPHAPREMULTIPLY_ON");
material.renderQueue = (int)UnityEngine.Rendering.RenderQueue.Transparent;
break;
case BlendMode.Transparent:
material.SetOverrideTag("RenderType", "Transparent");
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
material.SetInt("_ZWrite", 0);
material.DisableKeyword("_ALPHATEST_ON");
material.DisableKeyword("_ALPHABLEND_ON");
material.EnableKeyword("_ALPHAPREMULTIPLY_ON");
material.renderQueue = (int)UnityEngine.Rendering.RenderQueue.Transparent;
break;
}
}
static SmoothnessMapChannel GetSmoothnessMapChannel(Material material)
{
int ch = (int)material.GetFloat("_SmoothnessTextureChannel");
if (ch == (int)SmoothnessMapChannel.AlbedoAlpha)
return SmoothnessMapChannel.AlbedoAlpha;
else
return SmoothnessMapChannel.SpecularMetallicAlpha;
}
static void SetMaterialKeywords(Material material, WorkflowMode workflowMode)
{
// Note: keywords must be based on Material value not on MaterialProperty due to multi-edit & material animation
// (MaterialProperty value might come from renderer material property block)
SetKeyword(material, "_NORMALMAP", material.GetTexture("_BumpMap") || material.GetTexture("_DetailNormalMap"));
SetKeyword(material, "_SPECULAR_SETUP", workflowMode == WorkflowMode.Specular);
SetKeyword(material, "_METALLIC_SETUP", workflowMode == WorkflowMode.Metallic);
SetKeyword(material, "_PARALLAXMAP", material.GetTexture("_ParallaxMap"));
SetKeyword(material, "_DETAIL_MULX2", material.GetTexture("_DetailAlbedoMap") || material.GetTexture("_DetailNormalMap"));
// 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;
SetKeyword(material, "_EMISSION", shouldEmissionBeEnabled);
if (material.HasProperty("_SmoothnessTextureChannel"))
{
SetKeyword(material, "_SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A", GetSmoothnessMapChannel(material) == SmoothnessMapChannel.AlbedoAlpha);
}
}
static void MaterialChanged(Material material, WorkflowMode workflowMode)
{
SetupMaterialWithBlendMode(material, (BlendMode)material.GetFloat("_Mode"));
SetMaterialKeywords(material, workflowMode);
}
static void SetKeyword(Material m, string keyword, bool state)
{
if (state)
m.EnableKeyword(keyword);
else
m.DisableKeyword(keyword);
}
}
} // namespace UnityEditor

13
ScriptableRenderPipeline/LightweightPipeline/Editor/ShaderGUI/LightweightStandardShaderGUI.cs.meta


fileFormatVersion: 2
guid: a72ab9c46e7987c40bcd48bcf9e7c0dd
timeCreated: 1504689095
licenseType: Pro
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存