Felipe Lira
8 年前
当前提交
53105986
共有 14 个文件被更改,包括 1055 次插入 和 292 次删除
-
18Assets/GraphicsTests/RenderPipeline/LightweightPipeline/Assets/LDPipe_Shader/LDPipe_UnlitMat.mat
-
3Assets/GraphicsTests/RenderPipeline/LightweightPipeline/Assets/LDPipe_Shader/LDPipe_UnlitMatTexture.mat
-
83Assets/ScriptableRenderPipeline/LightweightPipeline/Editor/LightweightPipelineUpgraders.cs
-
999ImageTemplates/LightweightPipeline/Scenes/Shaders/LDPipe_LitShaderMaps.unity.png
-
53Assets/ScriptableRenderPipeline/LightweightPipeline/Editor/LightweightShaderHelper.cs
-
12Assets/ScriptableRenderPipeline/LightweightPipeline/Editor/LightweightShaderHelper.cs.meta
-
9Assets/ScriptableRenderPipeline/LightweightPipeline/Editor/ShaderGUI.meta
-
81Assets/ScriptableRenderPipeline/LightweightPipeline/Shaders/LightweightUnlit.shader
-
9Assets/ScriptableRenderPipeline/LightweightPipeline/Shaders/LightweightUnlit.shader.meta
-
68Assets/ScriptableRenderPipeline/LightweightPipeline/Editor/ShaderGUI/LightweightUnlitGUI.cs
-
12Assets/ScriptableRenderPipeline/LightweightPipeline/Editor/ShaderGUI/LightweightUnlitGUI.cs.meta
-
0/Assets/ScriptableRenderPipeline/LightweightPipeline/Editor/ShaderGUI/LightweightPipelineMaterialEditor.cs.meta
-
0/Assets/ScriptableRenderPipeline/LightweightPipeline/Editor/ShaderGUI/LightweightPipelineMaterialEditor.cs
999
ImageTemplates/LightweightPipeline/Scenes/Shaders/LDPipe_LitShaderMaps.unity.png
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
using UnityEngine; |
|||
using UnityEngine.Rendering; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering.LightweightPipeline |
|||
{ |
|||
public static class LightweightShaderHelper |
|||
{ |
|||
public static void SetMaterialBlendMode(Material material) |
|||
{ |
|||
UpgradeBlendMode mode = (UpgradeBlendMode) material.GetFloat("_Mode"); |
|||
switch (mode) |
|||
{ |
|||
case UpgradeBlendMode.Opaque: |
|||
material.SetOverrideTag("RenderType", ""); |
|||
material.SetInt("_SrcBlend", (int) UnityEngine.Rendering.BlendMode.One); |
|||
material.SetInt("_DstBlend", (int) UnityEngine.Rendering.BlendMode.Zero); |
|||
material.SetInt("_ZWrite", 1); |
|||
SetKeyword(material, "_ALPHATEST_ON", false); |
|||
SetKeyword(material, "_ALPHABLEND_ON", false); |
|||
material.renderQueue = -1; |
|||
break; |
|||
|
|||
case UpgradeBlendMode.Cutout: |
|||
material.SetOverrideTag("RenderType", "Transparent"); |
|||
material.SetInt("_SrcBlend", (int) UnityEngine.Rendering.BlendMode.One); |
|||
material.SetInt("_DstBlend", (int) UnityEngine.Rendering.BlendMode.Zero); |
|||
material.SetInt("_ZWrite", 1); |
|||
SetKeyword(material, "_ALPHATEST_ON", true); |
|||
SetKeyword(material, "_ALPHABLEND_ON", false); |
|||
material.renderQueue = (int) RenderQueue.AlphaTest; |
|||
break; |
|||
|
|||
case UpgradeBlendMode.Alpha: |
|||
material.SetOverrideTag("RenderType", "Transparent"); |
|||
material.SetInt("_SrcBlend", (int) UnityEngine.Rendering.BlendMode.SrcAlpha); |
|||
material.SetInt("_DstBlend", (int) UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha); |
|||
material.SetInt("_ZWrite", 0); |
|||
SetKeyword(material, "_ALPHATEST_ON", false); |
|||
SetKeyword(material, "_ALPHABLEND_ON", true); |
|||
material.renderQueue = (int) RenderQueue.Transparent; |
|||
break; |
|||
} |
|||
} |
|||
|
|||
public static void SetKeyword(Material material, string keyword, bool enable) |
|||
{ |
|||
if (enable) |
|||
material.EnableKeyword(keyword); |
|||
else |
|||
material.DisableKeyword(keyword); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 673aad8cdc228cf499f7974fb673fa10 |
|||
timeCreated: 1496821330 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: c8b417f54d2314549995022591d5454f |
|||
folderAsset: yes |
|||
timeCreated: 1496821940 |
|||
licenseType: Pro |
|||
DefaultImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
Shader "ScriptableRenderPipeline/LightweightPipeline/Unlit" |
|||
{ |
|||
Properties |
|||
{ |
|||
_MainTex("Texture", 2D) = "white" {} |
|||
_MainColor("MainColor", Color) = (1, 1, 1, 1) |
|||
_Cutoff("AlphaCutout", Range(0.0, 1.0)) = 0.5 |
|||
|
|||
// BlendMode |
|||
[HideInInspector] _Mode("Mode", Float) = 0.0 |
|||
[HideInInspector] _SrcBlend("Src", Float) = 1.0 |
|||
[HideInInspector] _DstBlend("Dst", Float) = 0.0 |
|||
[HideInInspector] _ZWrite("ZWrite", Float) = 1.0 |
|||
} |
|||
SubShader |
|||
{ |
|||
Tags { "RenderType" = "Opaque" "IgnoreProjectors" = "True" "RenderPipeline" = "LightweightPipe" "Lightmode" = "LightweightForward" } |
|||
LOD 100 |
|||
|
|||
Blend [_SrcBlend][_DstBlend] |
|||
ZWrite [_ZWrite] |
|||
|
|||
Pass |
|||
{ |
|||
CGPROGRAM |
|||
#pragma vertex vert |
|||
#pragma fragment frag |
|||
#pragma multi_compile_fog |
|||
#pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON |
|||
|
|||
#include "UnityCG.cginc" |
|||
|
|||
struct appdata |
|||
{ |
|||
float4 vertex : POSITION; |
|||
float2 uv : TEXCOORD0; |
|||
}; |
|||
|
|||
struct v2f |
|||
{ |
|||
float2 uv : TEXCOORD0; |
|||
UNITY_FOG_COORDS(1) |
|||
float4 vertex : SV_POSITION; |
|||
}; |
|||
|
|||
sampler2D _MainTex; |
|||
float4 _MainTex_ST; |
|||
half4 _MainColor; |
|||
half _Cutoff; |
|||
|
|||
v2f vert(appdata v) |
|||
{ |
|||
v2f o; |
|||
o.vertex = UnityObjectToClipPos(v.vertex); |
|||
o.uv = TRANSFORM_TEX(v.uv, _MainTex); |
|||
UNITY_TRANSFER_FOG(o,o.vertex); |
|||
return o; |
|||
} |
|||
|
|||
fixed4 frag(v2f i) : SV_Target |
|||
{ |
|||
fixed4 texColor = tex2D(_MainTex, i.uv); |
|||
fixed alpha = texColor.a * _MainColor.a; |
|||
fixed3 color = texColor.rgb * _MainColor.rgb; |
|||
|
|||
#ifdef _ALPHATEST_ON |
|||
clip(alpha - _Cutoff); |
|||
#endif |
|||
UNITY_APPLY_FOG(i.fogCoord, color); |
|||
|
|||
#ifdef _ALPHABLEND_ON |
|||
return fixed4(color, alpha); |
|||
#else |
|||
return fixed4(color, 1.0); |
|||
#endif |
|||
} |
|||
ENDCG |
|||
} |
|||
} |
|||
CustomEditor "LightweightUnlitGUI" |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 650dd9526735d5b46b79224bc6e94025 |
|||
timeCreated: 1496762173 |
|||
licenseType: Pro |
|||
ShaderImporter: |
|||
defaultTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using UnityEditor; |
|||
using UnityEngine; |
|||
using UnityEngine.Rendering; |
|||
using UnityEditor.Experimental.Rendering.LightweightPipeline; |
|||
|
|||
public class LightweightUnlitGUI : ShaderGUI |
|||
{ |
|||
private MaterialProperty blendModeProp = null; |
|||
private MaterialProperty mainTexProp = null; |
|||
private MaterialProperty mainColorProp = null; |
|||
private MaterialProperty alphaCutoffProp = null; |
|||
|
|||
private MaterialEditor m_MaterialEditor = null; |
|||
|
|||
private static class Styles |
|||
{ |
|||
public static GUIContent[] mainTexLabels = |
|||
{ |
|||
new GUIContent("MainTex (RGB)", "Base Color"), |
|||
new GUIContent("MainTex (RGB) Alpha (A)", "Base Color and Alpha") |
|||
}; |
|||
|
|||
public static readonly string[] blendNames = Enum.GetNames(typeof(UpgradeBlendMode)); |
|||
|
|||
public static string renderingModeLabel = "Rendering Mode"; |
|||
public static string alphaCutoffLabel = "Alpha Cutoff"; |
|||
} |
|||
|
|||
private void FindMaterialProperties(MaterialProperty[] properties) |
|||
{ |
|||
blendModeProp = FindProperty("_Mode", properties); |
|||
mainTexProp = FindProperty("_MainTex", properties); |
|||
mainColorProp = FindProperty("_MainColor", properties); |
|||
alphaCutoffProp = FindProperty("_Cutoff", properties); |
|||
} |
|||
|
|||
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties) |
|||
{ |
|||
Material material = materialEditor.target as Material; |
|||
m_MaterialEditor = materialEditor; |
|||
|
|||
FindMaterialProperties(properties); |
|||
|
|||
int modeValue = (int)blendModeProp.floatValue; |
|||
EditorGUI.BeginChangeCheck(); |
|||
modeValue = EditorGUILayout.Popup(Styles.renderingModeLabel, modeValue, Styles.blendNames); |
|||
if (EditorGUI.EndChangeCheck()) |
|||
blendModeProp.floatValue = modeValue; |
|||
|
|||
GUIContent mainTexLabel = Styles.mainTexLabels[Math.Min(modeValue, 1)]; |
|||
m_MaterialEditor.TexturePropertySingleLine(mainTexLabel, mainTexProp, mainColorProp); |
|||
m_MaterialEditor.TextureScaleOffsetProperty(mainTexProp); |
|||
|
|||
if ((UpgradeBlendMode) modeValue == UpgradeBlendMode.Cutout) |
|||
m_MaterialEditor.RangeProperty(alphaCutoffProp, Styles.alphaCutoffLabel); |
|||
|
|||
EditorGUILayout.Space(); |
|||
EditorGUILayout.Space(); |
|||
|
|||
materialEditor.RenderQueueField(); |
|||
|
|||
LightweightShaderHelper.SetMaterialBlendMode(material); |
|||
|
|||
EditorGUILayout.Space(); |
|||
EditorGUILayout.Space(); |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 3be3f3707c329b043b5816855ee127fd |
|||
timeCreated: 1487767801 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue