- Added trees outside the stable.
- Added a video player with horse songs preloaded. - Adjusted post-processing to be less harsh outdoors, and more visible indoors.
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
Shader "Merlin/World/Render Texture Processor"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[HDR]_Color("Color", Color) = (1, 1, 1, 1)
|
||||
_SourceTexture("Source Texture", 2D) = "black"
|
||||
_IsAVPro("Is AV Pro", Int) = 0
|
||||
_TargetAspectRatio("Target Aspect Ratio", Float) = 1.77777777
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType" = "Opaque" }
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "ResizeInput"
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex CustomRenderTextureVertexShader
|
||||
#pragma fragment frag
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "UnityCustomRenderTexture.cginc"
|
||||
|
||||
float4 _Color;
|
||||
sampler2D_float _SourceTexture; float4 _SourceTexture_TexelSize; float4 _SourceTexture_ST;
|
||||
int _IsAVPro;
|
||||
float _TargetAspectRatio;
|
||||
|
||||
half3 VideoEmission(float2 uv)
|
||||
{
|
||||
uv = TRANSFORM_TEX(uv, _SourceTexture);
|
||||
|
||||
float2 emissionRes = _SourceTexture_TexelSize.zw;
|
||||
|
||||
float currentAspectRatio = emissionRes.x / emissionRes.y;
|
||||
|
||||
float visibility = 1.0;
|
||||
|
||||
// If the aspect ratio does not match the target ratio, then we fit the UVs to maintain the aspect ratio while fitting the range 0-1
|
||||
if (abs(currentAspectRatio - _TargetAspectRatio) > 0.001)
|
||||
{
|
||||
float2 normalizedVideoRes = float2(emissionRes.x / _TargetAspectRatio, emissionRes.y);
|
||||
float2 correctiveScale;
|
||||
|
||||
// Find which axis is greater, we will clamp to that
|
||||
if (normalizedVideoRes.x > normalizedVideoRes.y)
|
||||
correctiveScale = float2(1, normalizedVideoRes.y / normalizedVideoRes.x);
|
||||
else
|
||||
correctiveScale = float2(normalizedVideoRes.x / normalizedVideoRes.y, 1);
|
||||
|
||||
uv = ((uv - 0.5) / correctiveScale) + 0.5;
|
||||
|
||||
// Antialiasing on UV clipping
|
||||
//float2 uvPadding = 0;
|
||||
//float2 uvfwidth = fwidth(uv.xy);
|
||||
//float2 maxFactor = smoothstep(uvfwidth + uvPadding + 1, uvPadding + 1, uv.xy);
|
||||
//float2 minFactor = smoothstep(-uvfwidth - uvPadding, -uvPadding, uv.xy);
|
||||
|
||||
//visibility = maxFactor.x * maxFactor.y * minFactor.x * minFactor.y;
|
||||
}
|
||||
|
||||
if (any(uv <= 0) || any(uv >= 1))
|
||||
return float3(0, 0, 0);
|
||||
|
||||
#if UNITY_UV_STARTS_AT_TOP
|
||||
if (_IsAVPro)
|
||||
{
|
||||
uv = float2(uv.x, 1 - uv.y);
|
||||
}
|
||||
#endif
|
||||
|
||||
float3 texColor = tex2D(_SourceTexture, uv).rgb;
|
||||
|
||||
if (_IsAVPro)
|
||||
texColor = pow(texColor, 2.2f);
|
||||
|
||||
return texColor * _Color.rgb * visibility;
|
||||
}
|
||||
|
||||
float4 frag (v2f_customrendertexture i) : SV_Target
|
||||
{
|
||||
return float4(VideoEmission(i.globalTexcoord), 1);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a7fb769ed687dda428aebc72498f1d10
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8ae6454eba1075b43bdb65ec282aedd7
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,437 @@
|
||||
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor
|
||||
{
|
||||
internal class StandardVideoEmissiveShaderGUI : ShaderGUI
|
||||
{
|
||||
private enum WorkflowMode
|
||||
{
|
||||
Specular,
|
||||
Metallic,
|
||||
Dielectric
|
||||
}
|
||||
|
||||
public enum BlendMode
|
||||
{
|
||||
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
|
||||
{
|
||||
SpecularMetallicAlpha,
|
||||
AlbedoAlpha,
|
||||
}
|
||||
|
||||
private static class Styles
|
||||
{
|
||||
public static GUIContent uvSetLabel = EditorGUIUtility.TrTextContent("UV Set");
|
||||
|
||||
public static GUIContent albedoText = EditorGUIUtility.TrTextContent("Albedo", "Albedo (RGB) and Transparency (A)");
|
||||
public static GUIContent alphaCutoffText = EditorGUIUtility.TrTextContent("Alpha Cutoff", "Threshold for alpha cutoff");
|
||||
public static GUIContent specularMapText = EditorGUIUtility.TrTextContent("Specular", "Specular (RGB) and Smoothness (A)");
|
||||
public static GUIContent metallicMapText = EditorGUIUtility.TrTextContent("Metallic", "Metallic (R) and Smoothness (A)");
|
||||
public static GUIContent smoothnessText = EditorGUIUtility.TrTextContent("Smoothness", "Smoothness value");
|
||||
public static GUIContent smoothnessScaleText = EditorGUIUtility.TrTextContent("Smoothness", "Smoothness scale factor");
|
||||
public static GUIContent smoothnessMapChannelText = EditorGUIUtility.TrTextContent("Source", "Smoothness texture and channel");
|
||||
public static GUIContent highlightsText = EditorGUIUtility.TrTextContent("Specular Highlights", "Specular Highlights");
|
||||
public static GUIContent reflectionsText = EditorGUIUtility.TrTextContent("Reflections", "Glossy Reflections");
|
||||
public static GUIContent normalMapText = EditorGUIUtility.TrTextContent("Normal Map", "Normal Map");
|
||||
public static GUIContent heightMapText = EditorGUIUtility.TrTextContent("Height Map", "Height Map (G)");
|
||||
public static GUIContent occlusionText = EditorGUIUtility.TrTextContent("Occlusion", "Occlusion (G)");
|
||||
public static GUIContent emissionText = EditorGUIUtility.TrTextContent("Color", "Emission (RGB)");
|
||||
public static GUIContent detailMaskText = EditorGUIUtility.TrTextContent("Detail Mask", "Mask for Secondary Maps (A)");
|
||||
public static GUIContent detailAlbedoText = EditorGUIUtility.TrTextContent("Detail Albedo x2", "Albedo (RGB) multiplied by 2");
|
||||
public static GUIContent detailNormalMapText = EditorGUIUtility.TrTextContent("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 renderingMode = "Rendering Mode";
|
||||
public static string advancedText = "Advanced Options";
|
||||
public static readonly string[] blendNames = Enum.GetNames(typeof(BlendMode));
|
||||
}
|
||||
|
||||
MaterialProperty blendMode = null;
|
||||
MaterialProperty albedoMap = null;
|
||||
MaterialProperty albedoColor = null;
|
||||
MaterialProperty alphaCutoff = null;
|
||||
MaterialProperty specularMap = null;
|
||||
MaterialProperty specularColor = null;
|
||||
MaterialProperty metallicMap = null;
|
||||
MaterialProperty metallic = null;
|
||||
MaterialProperty smoothness = null;
|
||||
MaterialProperty smoothnessScale = null;
|
||||
MaterialProperty smoothnessMapChannel = null;
|
||||
MaterialProperty highlights = null;
|
||||
MaterialProperty reflections = null;
|
||||
MaterialProperty bumpScale = null;
|
||||
MaterialProperty bumpMap = null;
|
||||
MaterialProperty occlusionStrength = null;
|
||||
MaterialProperty occlusionMap = null;
|
||||
MaterialProperty heigtMapScale = null;
|
||||
MaterialProperty heightMap = null;
|
||||
MaterialProperty emissionColorForRendering = null;
|
||||
MaterialProperty emissionMap = null;
|
||||
MaterialProperty detailMask = null;
|
||||
MaterialProperty detailAlbedoMap = null;
|
||||
MaterialProperty detailNormalMapScale = null;
|
||||
MaterialProperty detailNormalMap = null;
|
||||
MaterialProperty uvSetSecondary = null;
|
||||
MaterialProperty emissiveBoost = null;
|
||||
MaterialProperty isAVProInput = null;
|
||||
MaterialProperty aspectRatio = null;
|
||||
|
||||
MaterialEditor m_MaterialEditor;
|
||||
WorkflowMode m_WorkflowMode = WorkflowMode.Specular;
|
||||
|
||||
bool m_FirstTimeApply = true;
|
||||
|
||||
public void FindProperties(MaterialProperty[] props)
|
||||
{
|
||||
blendMode = FindProperty("_Mode", props);
|
||||
albedoMap = FindProperty("_MainTex", props);
|
||||
albedoColor = FindProperty("_Color", props);
|
||||
alphaCutoff = FindProperty("_Cutoff", props);
|
||||
specularMap = FindProperty("_SpecGlossMap", props, false);
|
||||
specularColor = FindProperty("_SpecColor", props, false);
|
||||
metallicMap = FindProperty("_MetallicGlossMap", props, false);
|
||||
metallic = FindProperty("_Metallic", props, false);
|
||||
if (specularMap != null && specularColor != null)
|
||||
m_WorkflowMode = WorkflowMode.Specular;
|
||||
else if (metallicMap != null && metallic != null)
|
||||
m_WorkflowMode = WorkflowMode.Metallic;
|
||||
else
|
||||
m_WorkflowMode = WorkflowMode.Dielectric;
|
||||
smoothness = FindProperty("_Glossiness", props);
|
||||
smoothnessScale = FindProperty("_GlossMapScale", props, false);
|
||||
smoothnessMapChannel = FindProperty("_SmoothnessTextureChannel", props, false);
|
||||
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);
|
||||
emissiveBoost = FindProperty("_MetaPassEmissiveBoost", props);
|
||||
isAVProInput = FindProperty("_IsAVProInput", props);
|
||||
aspectRatio = FindProperty("_TargetAspectRatio", 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 standard shader.
|
||||
// Do this before any GUI code has been issued to prevent layout issues in subsequent GUILayout statements (case 780071)
|
||||
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();
|
||||
{
|
||||
BlendModePopup();
|
||||
|
||||
// Primary properties
|
||||
GUILayout.Label(Styles.primaryMapsText, EditorStyles.boldLabel);
|
||||
DoAlbedoArea(material);
|
||||
DoSpecularMetallicArea();
|
||||
DoNormalArea();
|
||||
m_MaterialEditor.TexturePropertySingleLine(Styles.heightMapText, heightMap, heightMap.textureValue != null ? heigtMapScale : null);
|
||||
m_MaterialEditor.TexturePropertySingleLine(Styles.occlusionText, occlusionMap, occlusionMap.textureValue != null ? occlusionStrength : null);
|
||||
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();
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
internal void DetermineWorkflow(MaterialProperty[] props)
|
||||
{
|
||||
if (FindProperty("_SpecGlossMap", props, false) != null && FindProperty("_SpecColor", props, false) != null)
|
||||
m_WorkflowMode = WorkflowMode.Specular;
|
||||
else if (FindProperty("_MetallicGlossMap", props, false) != null && FindProperty("_Metallic", props, false) != null)
|
||||
m_WorkflowMode = WorkflowMode.Metallic;
|
||||
else
|
||||
m_WorkflowMode = WorkflowMode.Dielectric;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
DetermineWorkflow(MaterialEditor.GetMaterialProperties(new Material[] { material }));
|
||||
MaterialChanged(material, m_WorkflowMode);
|
||||
}
|
||||
|
||||
void BlendModePopup()
|
||||
{
|
||||
EditorGUI.showMixedValue = blendMode.hasMixedValue;
|
||||
var mode = (BlendMode)blendMode.floatValue;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
mode = (BlendMode)EditorGUILayout.Popup(Styles.renderingMode, (int)mode, Styles.blendNames);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
m_MaterialEditor.RegisterPropertyChangeUndo("Rendering Mode");
|
||||
blendMode.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(
|
||||
EditorGUIUtility.TrTextContent("Bump scale is not supported on mobile platforms"),
|
||||
EditorGUIUtility.TrTextContent("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, 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);
|
||||
m_MaterialEditor.FloatProperty(emissiveBoost, "GI Emissive boost");
|
||||
}
|
||||
|
||||
m_MaterialEditor.ShaderProperty(isAVProInput, "Is AVPro input");
|
||||
m_MaterialEditor.ShaderProperty(aspectRatio, new GUIContent("Aspect ratio", "The aspect ratio of the video surface width/height. Default of 1.777 is a 16:9 widescreen aspect ratio"));
|
||||
}
|
||||
|
||||
void DoSpecularMetallicArea()
|
||||
{
|
||||
bool hasGlossMap = false;
|
||||
if (m_WorkflowMode == WorkflowMode.Specular)
|
||||
{
|
||||
hasGlossMap = specularMap.textureValue != null;
|
||||
m_MaterialEditor.TexturePropertySingleLine(Styles.specularMapText, specularMap, hasGlossMap ? null : specularColor);
|
||||
}
|
||||
else if (m_WorkflowMode == WorkflowMode.Metallic)
|
||||
{
|
||||
hasGlossMap = metallicMap.textureValue != null;
|
||||
m_MaterialEditor.TexturePropertySingleLine(Styles.metallicMapText, metallicMap, hasGlossMap ? null : metallic);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
++indentation;
|
||||
if (smoothnessMapChannel != null)
|
||||
m_MaterialEditor.ShaderProperty(smoothnessMapChannel, Styles.smoothnessMapChannelText, indentation);
|
||||
}
|
||||
|
||||
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"));
|
||||
if (workflowMode == WorkflowMode.Specular)
|
||||
SetKeyword(material, "_SPECGLOSSMAP", material.GetTexture("_SpecGlossMap"));
|
||||
else if (workflowMode == WorkflowMode.Metallic)
|
||||
SetKeyword(material, "_METALLICGLOSSMAP", material.GetTexture("_MetallicGlossMap"));
|
||||
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
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b49ac947cab3c524988eeee265c73b4f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,804 @@
|
||||
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
|
||||
|
||||
#ifndef VIDEO_STANDARD_CORE_INCLUDED
|
||||
#define VIDEO_STANDARD_CORE_INCLUDED
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "UnityShaderVariables.cginc"
|
||||
#include "UnityStandardConfig.cginc"
|
||||
#include "UnityStandardInput.cginc"
|
||||
#include "UnityPBSLighting.cginc"
|
||||
#include "UnityStandardUtils.cginc"
|
||||
#include "UnityGBuffer.cginc"
|
||||
#include "UnityStandardBRDF.cginc"
|
||||
|
||||
#include "AutoLight.cginc"
|
||||
|
||||
int _IsAVProInput;
|
||||
float _TargetAspectRatio;
|
||||
float4 _EmissionMap_TexelSize;
|
||||
|
||||
half3 VideoEmission(float2 uv)
|
||||
{
|
||||
#ifndef _EMISSION
|
||||
return 0;
|
||||
#else
|
||||
float2 emissionRes = _EmissionMap_TexelSize.zw;
|
||||
|
||||
float currentAspectRatio = emissionRes.x / emissionRes.y;
|
||||
|
||||
float visibility = 1.0;
|
||||
|
||||
// If the aspect ratio does not match the target ratio, then we fit the UVs to maintain the aspect ratio while fitting the range 0-1
|
||||
if (abs(currentAspectRatio - _TargetAspectRatio) > 0.001)
|
||||
{
|
||||
float2 normalizedVideoRes = float2(emissionRes.x / _TargetAspectRatio, emissionRes.y);
|
||||
float2 correctiveScale;
|
||||
|
||||
// Find which axis is greater, we will clamp to that
|
||||
if (normalizedVideoRes.x > normalizedVideoRes.y)
|
||||
correctiveScale = float2(1, normalizedVideoRes.y / normalizedVideoRes.x);
|
||||
else
|
||||
correctiveScale = float2(normalizedVideoRes.x / normalizedVideoRes.y, 1);
|
||||
|
||||
uv = ((uv - 0.5) / correctiveScale) + 0.5;
|
||||
|
||||
// Antialiasing on UV clipping
|
||||
float2 uvPadding = (1 / emissionRes) * 0.1;
|
||||
float2 uvfwidth = fwidth(uv.xy);
|
||||
float2 maxFactor = smoothstep(uvfwidth + uvPadding + 1, uvPadding + 1, uv.xy);
|
||||
float2 minFactor = smoothstep(-uvfwidth - uvPadding, -uvPadding, uv.xy);
|
||||
|
||||
visibility = maxFactor.x * maxFactor.y * minFactor.x * minFactor.y;
|
||||
|
||||
//if (any(uv <= 0) || any(uv >= 1))
|
||||
// return float3(0, 0, 0);
|
||||
}
|
||||
|
||||
#if UNITY_UV_STARTS_AT_TOP
|
||||
if (_IsAVProInput)
|
||||
{
|
||||
uv = float2(uv.x, 1 - uv.y);
|
||||
}
|
||||
#endif
|
||||
|
||||
float3 texColor = tex2D(_EmissionMap, uv).rgb;
|
||||
|
||||
#ifndef UNITY_COLORSPACE_GAMMA
|
||||
if (_IsAVProInput)
|
||||
{
|
||||
texColor = pow(texColor, 2.2f);
|
||||
}
|
||||
#endif
|
||||
|
||||
return texColor * _EmissionColor.rgb * visibility;
|
||||
#endif
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
// counterpart for NormalizePerPixelNormal
|
||||
// skips normalization per-vertex and expects normalization to happen per-pixel
|
||||
half3 NormalizePerVertexNormal (float3 n) // takes float to avoid overflow
|
||||
{
|
||||
#if (SHADER_TARGET < 30) || UNITY_STANDARD_SIMPLE
|
||||
return normalize(n);
|
||||
#else
|
||||
return n; // will normalize per-pixel instead
|
||||
#endif
|
||||
}
|
||||
|
||||
float3 NormalizePerPixelNormal (float3 n)
|
||||
{
|
||||
#if (SHADER_TARGET < 30) || UNITY_STANDARD_SIMPLE
|
||||
return n;
|
||||
#else
|
||||
return normalize((float3)n); // takes float to avoid overflow
|
||||
#endif
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
UnityLight MainLight ()
|
||||
{
|
||||
UnityLight l;
|
||||
|
||||
l.color = _LightColor0.rgb;
|
||||
l.dir = _WorldSpaceLightPos0.xyz;
|
||||
return l;
|
||||
}
|
||||
|
||||
UnityLight AdditiveLight (half3 lightDir, half atten)
|
||||
{
|
||||
UnityLight l;
|
||||
|
||||
l.color = _LightColor0.rgb;
|
||||
l.dir = lightDir;
|
||||
#ifndef USING_DIRECTIONAL_LIGHT
|
||||
l.dir = NormalizePerPixelNormal(l.dir);
|
||||
#endif
|
||||
|
||||
// shadow the light
|
||||
l.color *= atten;
|
||||
return l;
|
||||
}
|
||||
|
||||
UnityLight DummyLight ()
|
||||
{
|
||||
UnityLight l;
|
||||
l.color = 0;
|
||||
l.dir = half3 (0,1,0);
|
||||
return l;
|
||||
}
|
||||
|
||||
UnityIndirect ZeroIndirect ()
|
||||
{
|
||||
UnityIndirect ind;
|
||||
ind.diffuse = 0;
|
||||
ind.specular = 0;
|
||||
return ind;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
// Common fragment setup
|
||||
|
||||
// deprecated
|
||||
half3 WorldNormal(half4 tan2world[3])
|
||||
{
|
||||
return normalize(tan2world[2].xyz);
|
||||
}
|
||||
|
||||
// deprecated
|
||||
#ifdef _TANGENT_TO_WORLD
|
||||
half3x3 ExtractTangentToWorldPerPixel(half4 tan2world[3])
|
||||
{
|
||||
half3 t = tan2world[0].xyz;
|
||||
half3 b = tan2world[1].xyz;
|
||||
half3 n = tan2world[2].xyz;
|
||||
|
||||
#if UNITY_TANGENT_ORTHONORMALIZE
|
||||
n = NormalizePerPixelNormal(n);
|
||||
|
||||
// ortho-normalize Tangent
|
||||
t = normalize (t - n * dot(t, n));
|
||||
|
||||
// recalculate Binormal
|
||||
half3 newB = cross(n, t);
|
||||
b = newB * sign (dot (newB, b));
|
||||
#endif
|
||||
|
||||
return half3x3(t, b, n);
|
||||
}
|
||||
#else
|
||||
half3x3 ExtractTangentToWorldPerPixel(half4 tan2world[3])
|
||||
{
|
||||
return half3x3(0,0,0,0,0,0,0,0,0);
|
||||
}
|
||||
#endif
|
||||
|
||||
float3 PerPixelWorldNormal(float4 i_tex, float4 tangentToWorld[3])
|
||||
{
|
||||
#ifdef _NORMALMAP
|
||||
half3 tangent = tangentToWorld[0].xyz;
|
||||
half3 binormal = tangentToWorld[1].xyz;
|
||||
half3 normal = tangentToWorld[2].xyz;
|
||||
|
||||
#if UNITY_TANGENT_ORTHONORMALIZE
|
||||
normal = NormalizePerPixelNormal(normal);
|
||||
|
||||
// ortho-normalize Tangent
|
||||
tangent = normalize (tangent - normal * dot(tangent, normal));
|
||||
|
||||
// recalculate Binormal
|
||||
half3 newB = cross(normal, tangent);
|
||||
binormal = newB * sign (dot (newB, binormal));
|
||||
#endif
|
||||
|
||||
half3 normalTangent = NormalInTangentSpace(i_tex);
|
||||
float3 normalWorld = NormalizePerPixelNormal(tangent * normalTangent.x + binormal * normalTangent.y + normal * normalTangent.z); // @TODO: see if we can squeeze this normalize on SM2.0 as well
|
||||
#else
|
||||
float3 normalWorld = normalize(tangentToWorld[2].xyz);
|
||||
#endif
|
||||
return normalWorld;
|
||||
}
|
||||
|
||||
#ifdef _PARALLAXMAP
|
||||
#define IN_VIEWDIR4PARALLAX(i) NormalizePerPixelNormal(half3(i.tangentToWorldAndPackedData[0].w,i.tangentToWorldAndPackedData[1].w,i.tangentToWorldAndPackedData[2].w))
|
||||
#define IN_VIEWDIR4PARALLAX_FWDADD(i) NormalizePerPixelNormal(i.viewDirForParallax.xyz)
|
||||
#else
|
||||
#define IN_VIEWDIR4PARALLAX(i) half3(0,0,0)
|
||||
#define IN_VIEWDIR4PARALLAX_FWDADD(i) half3(0,0,0)
|
||||
#endif
|
||||
|
||||
#if UNITY_REQUIRE_FRAG_WORLDPOS
|
||||
#if UNITY_PACK_WORLDPOS_WITH_TANGENT
|
||||
#define IN_WORLDPOS(i) half3(i.tangentToWorldAndPackedData[0].w,i.tangentToWorldAndPackedData[1].w,i.tangentToWorldAndPackedData[2].w)
|
||||
#else
|
||||
#define IN_WORLDPOS(i) i.posWorld
|
||||
#endif
|
||||
#define IN_WORLDPOS_FWDADD(i) i.posWorld
|
||||
#else
|
||||
#define IN_WORLDPOS(i) half3(0,0,0)
|
||||
#define IN_WORLDPOS_FWDADD(i) half3(0,0,0)
|
||||
#endif
|
||||
|
||||
#define IN_LIGHTDIR_FWDADD(i) half3(i.tangentToWorldAndLightDir[0].w, i.tangentToWorldAndLightDir[1].w, i.tangentToWorldAndLightDir[2].w)
|
||||
|
||||
#define FRAGMENT_SETUP(x) FragmentCommonData x = \
|
||||
FragmentSetup(i.tex, i.eyeVec.xyz, IN_VIEWDIR4PARALLAX(i), i.tangentToWorldAndPackedData, IN_WORLDPOS(i));
|
||||
|
||||
#define FRAGMENT_SETUP_FWDADD(x) FragmentCommonData x = \
|
||||
FragmentSetup(i.tex, i.eyeVec.xyz, IN_VIEWDIR4PARALLAX_FWDADD(i), i.tangentToWorldAndLightDir, IN_WORLDPOS_FWDADD(i));
|
||||
|
||||
struct FragmentCommonData
|
||||
{
|
||||
half3 diffColor, specColor;
|
||||
// Note: smoothness & oneMinusReflectivity for optimization purposes, mostly for DX9 SM2.0 level.
|
||||
// Most of the math is being done on these (1-x) values, and that saves a few precious ALU slots.
|
||||
half oneMinusReflectivity, smoothness;
|
||||
float3 normalWorld;
|
||||
float3 eyeVec;
|
||||
half alpha;
|
||||
float3 posWorld;
|
||||
|
||||
#if UNITY_STANDARD_SIMPLE
|
||||
half3 reflUVW;
|
||||
#endif
|
||||
|
||||
#if UNITY_STANDARD_SIMPLE
|
||||
half3 tangentSpaceNormal;
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifndef UNITY_SETUP_BRDF_INPUT
|
||||
#define UNITY_SETUP_BRDF_INPUT SpecularSetup
|
||||
#endif
|
||||
|
||||
inline FragmentCommonData SpecularSetup (float4 i_tex)
|
||||
{
|
||||
half4 specGloss = SpecularGloss(i_tex.xy);
|
||||
half3 specColor = specGloss.rgb;
|
||||
half smoothness = specGloss.a;
|
||||
|
||||
half oneMinusReflectivity;
|
||||
half3 diffColor = EnergyConservationBetweenDiffuseAndSpecular (Albedo(i_tex), specColor, /*out*/ oneMinusReflectivity);
|
||||
|
||||
FragmentCommonData o = (FragmentCommonData)0;
|
||||
o.diffColor = diffColor;
|
||||
o.specColor = specColor;
|
||||
o.oneMinusReflectivity = oneMinusReflectivity;
|
||||
o.smoothness = smoothness;
|
||||
return o;
|
||||
}
|
||||
|
||||
inline FragmentCommonData RoughnessSetup(float4 i_tex)
|
||||
{
|
||||
half2 metallicGloss = MetallicRough(i_tex.xy);
|
||||
half metallic = metallicGloss.x;
|
||||
half smoothness = metallicGloss.y; // this is 1 minus the square root of real roughness m.
|
||||
|
||||
half oneMinusReflectivity;
|
||||
half3 specColor;
|
||||
half3 diffColor = DiffuseAndSpecularFromMetallic(Albedo(i_tex), metallic, /*out*/ specColor, /*out*/ oneMinusReflectivity);
|
||||
|
||||
FragmentCommonData o = (FragmentCommonData)0;
|
||||
o.diffColor = diffColor;
|
||||
o.specColor = specColor;
|
||||
o.oneMinusReflectivity = oneMinusReflectivity;
|
||||
o.smoothness = smoothness;
|
||||
return o;
|
||||
}
|
||||
|
||||
inline FragmentCommonData MetallicSetup (float4 i_tex)
|
||||
{
|
||||
half2 metallicGloss = MetallicGloss(i_tex.xy);
|
||||
half metallic = metallicGloss.x;
|
||||
half smoothness = metallicGloss.y; // this is 1 minus the square root of real roughness m.
|
||||
|
||||
half oneMinusReflectivity;
|
||||
half3 specColor;
|
||||
half3 diffColor = DiffuseAndSpecularFromMetallic (Albedo(i_tex), metallic, /*out*/ specColor, /*out*/ oneMinusReflectivity);
|
||||
|
||||
FragmentCommonData o = (FragmentCommonData)0;
|
||||
o.diffColor = diffColor;
|
||||
o.specColor = specColor;
|
||||
o.oneMinusReflectivity = oneMinusReflectivity;
|
||||
o.smoothness = smoothness;
|
||||
return o;
|
||||
}
|
||||
|
||||
// parallax transformed texcoord is used to sample occlusion
|
||||
inline FragmentCommonData FragmentSetup (inout float4 i_tex, float3 i_eyeVec, half3 i_viewDirForParallax, float4 tangentToWorld[3], float3 i_posWorld)
|
||||
{
|
||||
i_tex = Parallax(i_tex, i_viewDirForParallax);
|
||||
|
||||
half alpha = Alpha(i_tex.xy);
|
||||
#if defined(_ALPHATEST_ON)
|
||||
clip (alpha - _Cutoff);
|
||||
#endif
|
||||
|
||||
FragmentCommonData o = UNITY_SETUP_BRDF_INPUT (i_tex);
|
||||
o.normalWorld = PerPixelWorldNormal(i_tex, tangentToWorld);
|
||||
o.eyeVec = NormalizePerPixelNormal(i_eyeVec);
|
||||
o.posWorld = i_posWorld;
|
||||
|
||||
// NOTE: shader relies on pre-multiply alpha-blend (_SrcBlend = One, _DstBlend = OneMinusSrcAlpha)
|
||||
o.diffColor = PreMultiplyAlpha (o.diffColor, alpha, o.oneMinusReflectivity, /*out*/ o.alpha);
|
||||
return o;
|
||||
}
|
||||
|
||||
inline UnityGI FragmentGI (FragmentCommonData s, half occlusion, half4 i_ambientOrLightmapUV, half atten, UnityLight light, bool reflections)
|
||||
{
|
||||
UnityGIInput d;
|
||||
d.light = light;
|
||||
d.worldPos = s.posWorld;
|
||||
d.worldViewDir = -s.eyeVec;
|
||||
d.atten = atten;
|
||||
#if defined(LIGHTMAP_ON) || defined(DYNAMICLIGHTMAP_ON)
|
||||
d.ambient = 0;
|
||||
d.lightmapUV = i_ambientOrLightmapUV;
|
||||
#else
|
||||
d.ambient = i_ambientOrLightmapUV.rgb;
|
||||
d.lightmapUV = 0;
|
||||
#endif
|
||||
|
||||
d.probeHDR[0] = unity_SpecCube0_HDR;
|
||||
d.probeHDR[1] = unity_SpecCube1_HDR;
|
||||
#if defined(UNITY_SPECCUBE_BLENDING) || defined(UNITY_SPECCUBE_BOX_PROJECTION)
|
||||
d.boxMin[0] = unity_SpecCube0_BoxMin; // .w holds lerp value for blending
|
||||
#endif
|
||||
#ifdef UNITY_SPECCUBE_BOX_PROJECTION
|
||||
d.boxMax[0] = unity_SpecCube0_BoxMax;
|
||||
d.probePosition[0] = unity_SpecCube0_ProbePosition;
|
||||
d.boxMax[1] = unity_SpecCube1_BoxMax;
|
||||
d.boxMin[1] = unity_SpecCube1_BoxMin;
|
||||
d.probePosition[1] = unity_SpecCube1_ProbePosition;
|
||||
#endif
|
||||
|
||||
if(reflections)
|
||||
{
|
||||
Unity_GlossyEnvironmentData g = UnityGlossyEnvironmentSetup(s.smoothness, -s.eyeVec, s.normalWorld, s.specColor);
|
||||
// Replace the reflUVW if it has been compute in Vertex shader. Note: the compiler will optimize the calcul in UnityGlossyEnvironmentSetup itself
|
||||
#if UNITY_STANDARD_SIMPLE
|
||||
g.reflUVW = s.reflUVW;
|
||||
#endif
|
||||
|
||||
return UnityGlobalIllumination (d, occlusion, s.normalWorld, g);
|
||||
}
|
||||
else
|
||||
{
|
||||
return UnityGlobalIllumination (d, occlusion, s.normalWorld);
|
||||
}
|
||||
}
|
||||
|
||||
inline UnityGI FragmentGI (FragmentCommonData s, half occlusion, half4 i_ambientOrLightmapUV, half atten, UnityLight light)
|
||||
{
|
||||
return FragmentGI(s, occlusion, i_ambientOrLightmapUV, atten, light, true);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
half4 OutputForward (half4 output, half alphaFromSurface)
|
||||
{
|
||||
#if defined(_ALPHABLEND_ON) || defined(_ALPHAPREMULTIPLY_ON)
|
||||
output.a = alphaFromSurface;
|
||||
#else
|
||||
UNITY_OPAQUE_ALPHA(output.a);
|
||||
#endif
|
||||
return output;
|
||||
}
|
||||
|
||||
inline half4 VertexGIForward(VertexInput v, float3 posWorld, half3 normalWorld)
|
||||
{
|
||||
half4 ambientOrLightmapUV = 0;
|
||||
// Static lightmaps
|
||||
#ifdef LIGHTMAP_ON
|
||||
ambientOrLightmapUV.xy = v.uv1.xy * unity_LightmapST.xy + unity_LightmapST.zw;
|
||||
ambientOrLightmapUV.zw = 0;
|
||||
// Sample light probe for Dynamic objects only (no static or dynamic lightmaps)
|
||||
#elif UNITY_SHOULD_SAMPLE_SH
|
||||
#ifdef VERTEXLIGHT_ON
|
||||
// Approximated illumination from non-important point lights
|
||||
ambientOrLightmapUV.rgb = Shade4PointLights (
|
||||
unity_4LightPosX0, unity_4LightPosY0, unity_4LightPosZ0,
|
||||
unity_LightColor[0].rgb, unity_LightColor[1].rgb, unity_LightColor[2].rgb, unity_LightColor[3].rgb,
|
||||
unity_4LightAtten0, posWorld, normalWorld);
|
||||
#endif
|
||||
|
||||
ambientOrLightmapUV.rgb = ShadeSHPerVertex (normalWorld, ambientOrLightmapUV.rgb);
|
||||
#endif
|
||||
|
||||
#ifdef DYNAMICLIGHTMAP_ON
|
||||
ambientOrLightmapUV.zw = v.uv2.xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw;
|
||||
#endif
|
||||
|
||||
return ambientOrLightmapUV;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Base forward pass (directional light, emission, lightmaps, ...)
|
||||
|
||||
struct VertexOutputForwardBase
|
||||
{
|
||||
UNITY_POSITION(pos);
|
||||
float4 tex : TEXCOORD0;
|
||||
float4 eyeVec : TEXCOORD1; // eyeVec.xyz | fogCoord
|
||||
float4 tangentToWorldAndPackedData[3] : TEXCOORD2; // [3x3:tangentToWorld | 1x3:viewDirForParallax or worldPos]
|
||||
half4 ambientOrLightmapUV : TEXCOORD5; // SH or Lightmap UV
|
||||
UNITY_LIGHTING_COORDS(6,7)
|
||||
|
||||
// next ones would not fit into SM2.0 limits, but they are always for SM3.0+
|
||||
#if UNITY_REQUIRE_FRAG_WORLDPOS && !UNITY_PACK_WORLDPOS_WITH_TANGENT
|
||||
float3 posWorld : TEXCOORD8;
|
||||
#endif
|
||||
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
VertexOutputForwardBase vertForwardBase (VertexInput v)
|
||||
{
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
VertexOutputForwardBase o;
|
||||
UNITY_INITIALIZE_OUTPUT(VertexOutputForwardBase, o);
|
||||
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
float4 posWorld = mul(unity_ObjectToWorld, v.vertex);
|
||||
#if UNITY_REQUIRE_FRAG_WORLDPOS
|
||||
#if UNITY_PACK_WORLDPOS_WITH_TANGENT
|
||||
o.tangentToWorldAndPackedData[0].w = posWorld.x;
|
||||
o.tangentToWorldAndPackedData[1].w = posWorld.y;
|
||||
o.tangentToWorldAndPackedData[2].w = posWorld.z;
|
||||
#else
|
||||
o.posWorld = posWorld.xyz;
|
||||
#endif
|
||||
#endif
|
||||
o.pos = UnityObjectToClipPos(v.vertex);
|
||||
|
||||
o.tex = TexCoords(v);
|
||||
o.eyeVec.xyz = NormalizePerVertexNormal(posWorld.xyz - _WorldSpaceCameraPos);
|
||||
float3 normalWorld = UnityObjectToWorldNormal(v.normal);
|
||||
#ifdef _TANGENT_TO_WORLD
|
||||
float4 tangentWorld = float4(UnityObjectToWorldDir(v.tangent.xyz), v.tangent.w);
|
||||
|
||||
float3x3 tangentToWorld = CreateTangentToWorldPerVertex(normalWorld, tangentWorld.xyz, tangentWorld.w);
|
||||
o.tangentToWorldAndPackedData[0].xyz = tangentToWorld[0];
|
||||
o.tangentToWorldAndPackedData[1].xyz = tangentToWorld[1];
|
||||
o.tangentToWorldAndPackedData[2].xyz = tangentToWorld[2];
|
||||
#else
|
||||
o.tangentToWorldAndPackedData[0].xyz = 0;
|
||||
o.tangentToWorldAndPackedData[1].xyz = 0;
|
||||
o.tangentToWorldAndPackedData[2].xyz = normalWorld;
|
||||
#endif
|
||||
|
||||
//We need this for shadow receving
|
||||
UNITY_TRANSFER_LIGHTING(o, v.uv1);
|
||||
|
||||
o.ambientOrLightmapUV = VertexGIForward(v, posWorld, normalWorld);
|
||||
|
||||
#ifdef _PARALLAXMAP
|
||||
TANGENT_SPACE_ROTATION;
|
||||
half3 viewDirForParallax = mul (rotation, ObjSpaceViewDir(v.vertex));
|
||||
o.tangentToWorldAndPackedData[0].w = viewDirForParallax.x;
|
||||
o.tangentToWorldAndPackedData[1].w = viewDirForParallax.y;
|
||||
o.tangentToWorldAndPackedData[2].w = viewDirForParallax.z;
|
||||
#endif
|
||||
|
||||
UNITY_TRANSFER_FOG_COMBINED_WITH_EYE_VEC(o,o.pos);
|
||||
return o;
|
||||
}
|
||||
|
||||
half4 fragForwardBaseInternal (VertexOutputForwardBase i)
|
||||
{
|
||||
UNITY_APPLY_DITHER_CROSSFADE(i.pos.xy);
|
||||
|
||||
FRAGMENT_SETUP(s)
|
||||
|
||||
UNITY_SETUP_INSTANCE_ID(i);
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
|
||||
UnityLight mainLight = MainLight ();
|
||||
UNITY_LIGHT_ATTENUATION(atten, i, s.posWorld);
|
||||
|
||||
half occlusion = Occlusion(i.tex.xy);
|
||||
UnityGI gi = FragmentGI (s, occlusion, i.ambientOrLightmapUV, atten, mainLight);
|
||||
|
||||
half4 c = UNITY_BRDF_PBS (s.diffColor, s.specColor, s.oneMinusReflectivity, s.smoothness, s.normalWorld, -s.eyeVec, gi.light, gi.indirect);
|
||||
c.rgb += VideoEmission(i.tex.xy);
|
||||
|
||||
UNITY_EXTRACT_FOG_FROM_EYE_VEC(i);
|
||||
UNITY_APPLY_FOG(_unity_fogCoord, c.rgb);
|
||||
return OutputForward (c, s.alpha);
|
||||
}
|
||||
|
||||
half4 fragForwardBase (VertexOutputForwardBase i) : SV_Target // backward compatibility (this used to be the fragment entry function)
|
||||
{
|
||||
return fragForwardBaseInternal(i);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Additive forward pass (one light per pass)
|
||||
|
||||
struct VertexOutputForwardAdd
|
||||
{
|
||||
UNITY_POSITION(pos);
|
||||
float4 tex : TEXCOORD0;
|
||||
float4 eyeVec : TEXCOORD1; // eyeVec.xyz | fogCoord
|
||||
float4 tangentToWorldAndLightDir[3] : TEXCOORD2; // [3x3:tangentToWorld | 1x3:lightDir]
|
||||
float3 posWorld : TEXCOORD5;
|
||||
UNITY_LIGHTING_COORDS(6, 7)
|
||||
|
||||
// next ones would not fit into SM2.0 limits, but they are always for SM3.0+
|
||||
#if defined(_PARALLAXMAP)
|
||||
half3 viewDirForParallax : TEXCOORD8;
|
||||
#endif
|
||||
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
VertexOutputForwardAdd vertForwardAdd (VertexInput v)
|
||||
{
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
VertexOutputForwardAdd o;
|
||||
UNITY_INITIALIZE_OUTPUT(VertexOutputForwardAdd, o);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
float4 posWorld = mul(unity_ObjectToWorld, v.vertex);
|
||||
o.pos = UnityObjectToClipPos(v.vertex);
|
||||
|
||||
o.tex = TexCoords(v);
|
||||
o.eyeVec.xyz = NormalizePerVertexNormal(posWorld.xyz - _WorldSpaceCameraPos);
|
||||
o.posWorld = posWorld.xyz;
|
||||
float3 normalWorld = UnityObjectToWorldNormal(v.normal);
|
||||
#ifdef _TANGENT_TO_WORLD
|
||||
float4 tangentWorld = float4(UnityObjectToWorldDir(v.tangent.xyz), v.tangent.w);
|
||||
|
||||
float3x3 tangentToWorld = CreateTangentToWorldPerVertex(normalWorld, tangentWorld.xyz, tangentWorld.w);
|
||||
o.tangentToWorldAndLightDir[0].xyz = tangentToWorld[0];
|
||||
o.tangentToWorldAndLightDir[1].xyz = tangentToWorld[1];
|
||||
o.tangentToWorldAndLightDir[2].xyz = tangentToWorld[2];
|
||||
#else
|
||||
o.tangentToWorldAndLightDir[0].xyz = 0;
|
||||
o.tangentToWorldAndLightDir[1].xyz = 0;
|
||||
o.tangentToWorldAndLightDir[2].xyz = normalWorld;
|
||||
#endif
|
||||
//We need this for shadow receiving and lighting
|
||||
UNITY_TRANSFER_LIGHTING(o, v.uv1);
|
||||
|
||||
float3 lightDir = _WorldSpaceLightPos0.xyz - posWorld.xyz * _WorldSpaceLightPos0.w;
|
||||
#ifndef USING_DIRECTIONAL_LIGHT
|
||||
lightDir = NormalizePerVertexNormal(lightDir);
|
||||
#endif
|
||||
o.tangentToWorldAndLightDir[0].w = lightDir.x;
|
||||
o.tangentToWorldAndLightDir[1].w = lightDir.y;
|
||||
o.tangentToWorldAndLightDir[2].w = lightDir.z;
|
||||
|
||||
#ifdef _PARALLAXMAP
|
||||
TANGENT_SPACE_ROTATION;
|
||||
o.viewDirForParallax = mul (rotation, ObjSpaceViewDir(v.vertex));
|
||||
#endif
|
||||
|
||||
UNITY_TRANSFER_FOG_COMBINED_WITH_EYE_VEC(o, o.pos);
|
||||
return o;
|
||||
}
|
||||
|
||||
half4 fragForwardAddInternal (VertexOutputForwardAdd i)
|
||||
{
|
||||
UNITY_APPLY_DITHER_CROSSFADE(i.pos.xy);
|
||||
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
|
||||
FRAGMENT_SETUP_FWDADD(s)
|
||||
|
||||
UNITY_LIGHT_ATTENUATION(atten, i, s.posWorld)
|
||||
UnityLight light = AdditiveLight (IN_LIGHTDIR_FWDADD(i), atten);
|
||||
UnityIndirect noIndirect = ZeroIndirect ();
|
||||
|
||||
half4 c = UNITY_BRDF_PBS (s.diffColor, s.specColor, s.oneMinusReflectivity, s.smoothness, s.normalWorld, -s.eyeVec, light, noIndirect);
|
||||
|
||||
UNITY_EXTRACT_FOG_FROM_EYE_VEC(i);
|
||||
UNITY_APPLY_FOG_COLOR(_unity_fogCoord, c.rgb, half4(0,0,0,0)); // fog towards black in additive pass
|
||||
return OutputForward (c, s.alpha);
|
||||
}
|
||||
|
||||
half4 fragForwardAdd (VertexOutputForwardAdd i) : SV_Target // backward compatibility (this used to be the fragment entry function)
|
||||
{
|
||||
return fragForwardAddInternal(i);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Deferred pass
|
||||
|
||||
struct VertexOutputDeferred
|
||||
{
|
||||
UNITY_POSITION(pos);
|
||||
float4 tex : TEXCOORD0;
|
||||
float3 eyeVec : TEXCOORD1;
|
||||
float4 tangentToWorldAndPackedData[3] : TEXCOORD2; // [3x3:tangentToWorld | 1x3:viewDirForParallax or worldPos]
|
||||
half4 ambientOrLightmapUV : TEXCOORD5; // SH or Lightmap UVs
|
||||
|
||||
#if UNITY_REQUIRE_FRAG_WORLDPOS && !UNITY_PACK_WORLDPOS_WITH_TANGENT
|
||||
float3 posWorld : TEXCOORD6;
|
||||
#endif
|
||||
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
|
||||
VertexOutputDeferred vertDeferred (VertexInput v)
|
||||
{
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
VertexOutputDeferred o;
|
||||
UNITY_INITIALIZE_OUTPUT(VertexOutputDeferred, o);
|
||||
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
float4 posWorld = mul(unity_ObjectToWorld, v.vertex);
|
||||
#if UNITY_REQUIRE_FRAG_WORLDPOS
|
||||
#if UNITY_PACK_WORLDPOS_WITH_TANGENT
|
||||
o.tangentToWorldAndPackedData[0].w = posWorld.x;
|
||||
o.tangentToWorldAndPackedData[1].w = posWorld.y;
|
||||
o.tangentToWorldAndPackedData[2].w = posWorld.z;
|
||||
#else
|
||||
o.posWorld = posWorld.xyz;
|
||||
#endif
|
||||
#endif
|
||||
o.pos = UnityObjectToClipPos(v.vertex);
|
||||
|
||||
o.tex = TexCoords(v);
|
||||
o.eyeVec = NormalizePerVertexNormal(posWorld.xyz - _WorldSpaceCameraPos);
|
||||
float3 normalWorld = UnityObjectToWorldNormal(v.normal);
|
||||
#ifdef _TANGENT_TO_WORLD
|
||||
float4 tangentWorld = float4(UnityObjectToWorldDir(v.tangent.xyz), v.tangent.w);
|
||||
|
||||
float3x3 tangentToWorld = CreateTangentToWorldPerVertex(normalWorld, tangentWorld.xyz, tangentWorld.w);
|
||||
o.tangentToWorldAndPackedData[0].xyz = tangentToWorld[0];
|
||||
o.tangentToWorldAndPackedData[1].xyz = tangentToWorld[1];
|
||||
o.tangentToWorldAndPackedData[2].xyz = tangentToWorld[2];
|
||||
#else
|
||||
o.tangentToWorldAndPackedData[0].xyz = 0;
|
||||
o.tangentToWorldAndPackedData[1].xyz = 0;
|
||||
o.tangentToWorldAndPackedData[2].xyz = normalWorld;
|
||||
#endif
|
||||
|
||||
o.ambientOrLightmapUV = 0;
|
||||
#ifdef LIGHTMAP_ON
|
||||
o.ambientOrLightmapUV.xy = v.uv1.xy * unity_LightmapST.xy + unity_LightmapST.zw;
|
||||
#elif UNITY_SHOULD_SAMPLE_SH
|
||||
o.ambientOrLightmapUV.rgb = ShadeSHPerVertex (normalWorld, o.ambientOrLightmapUV.rgb);
|
||||
#endif
|
||||
#ifdef DYNAMICLIGHTMAP_ON
|
||||
o.ambientOrLightmapUV.zw = v.uv2.xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw;
|
||||
#endif
|
||||
|
||||
#ifdef _PARALLAXMAP
|
||||
TANGENT_SPACE_ROTATION;
|
||||
half3 viewDirForParallax = mul (rotation, ObjSpaceViewDir(v.vertex));
|
||||
o.tangentToWorldAndPackedData[0].w = viewDirForParallax.x;
|
||||
o.tangentToWorldAndPackedData[1].w = viewDirForParallax.y;
|
||||
o.tangentToWorldAndPackedData[2].w = viewDirForParallax.z;
|
||||
#endif
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
void fragDeferred (
|
||||
VertexOutputDeferred i,
|
||||
out half4 outGBuffer0 : SV_Target0,
|
||||
out half4 outGBuffer1 : SV_Target1,
|
||||
out half4 outGBuffer2 : SV_Target2,
|
||||
out half4 outEmission : SV_Target3 // RT3: emission (rgb), --unused-- (a)
|
||||
#if defined(SHADOWS_SHADOWMASK) && (UNITY_ALLOWED_MRT_COUNT > 4)
|
||||
,out half4 outShadowMask : SV_Target4 // RT4: shadowmask (rgba)
|
||||
#endif
|
||||
)
|
||||
{
|
||||
#if (SHADER_TARGET < 30)
|
||||
outGBuffer0 = 1;
|
||||
outGBuffer1 = 1;
|
||||
outGBuffer2 = 0;
|
||||
outEmission = 0;
|
||||
#if defined(SHADOWS_SHADOWMASK) && (UNITY_ALLOWED_MRT_COUNT > 4)
|
||||
outShadowMask = 1;
|
||||
#endif
|
||||
return;
|
||||
#endif
|
||||
|
||||
UNITY_APPLY_DITHER_CROSSFADE(i.pos.xy);
|
||||
|
||||
FRAGMENT_SETUP(s)
|
||||
UNITY_SETUP_INSTANCE_ID(i);
|
||||
|
||||
// no analytic lights in this pass
|
||||
UnityLight dummyLight = DummyLight ();
|
||||
half atten = 1;
|
||||
|
||||
// only GI
|
||||
half occlusion = Occlusion(i.tex.xy);
|
||||
#if UNITY_ENABLE_REFLECTION_BUFFERS
|
||||
bool sampleReflectionsInDeferred = false;
|
||||
#else
|
||||
bool sampleReflectionsInDeferred = true;
|
||||
#endif
|
||||
|
||||
UnityGI gi = FragmentGI (s, occlusion, i.ambientOrLightmapUV, atten, dummyLight, sampleReflectionsInDeferred);
|
||||
|
||||
half3 emissiveColor = UNITY_BRDF_PBS (s.diffColor, s.specColor, s.oneMinusReflectivity, s.smoothness, s.normalWorld, -s.eyeVec, gi.light, gi.indirect).rgb;
|
||||
|
||||
#ifdef _EMISSION
|
||||
emissiveColor += VideoEmission (i.tex.xy);
|
||||
#endif
|
||||
|
||||
#ifndef UNITY_HDR_ON
|
||||
emissiveColor.rgb = exp2(-emissiveColor.rgb);
|
||||
#endif
|
||||
|
||||
UnityStandardData data;
|
||||
data.diffuseColor = s.diffColor;
|
||||
data.occlusion = occlusion;
|
||||
data.specularColor = s.specColor;
|
||||
data.smoothness = s.smoothness;
|
||||
data.normalWorld = s.normalWorld;
|
||||
|
||||
UnityStandardDataToGbuffer(data, outGBuffer0, outGBuffer1, outGBuffer2);
|
||||
|
||||
// Emissive lighting buffer
|
||||
outEmission = half4(emissiveColor, 1);
|
||||
|
||||
// Baked direct lighting occlusion if any
|
||||
#if defined(SHADOWS_SHADOWMASK) && (UNITY_ALLOWED_MRT_COUNT > 4)
|
||||
outShadowMask = UnityGetRawBakedOcclusions(i.ambientOrLightmapUV.xy, IN_WORLDPOS(i));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Old FragmentGI signature. Kept only for backward compatibility and will be removed soon
|
||||
//
|
||||
|
||||
inline UnityGI FragmentGI(
|
||||
float3 posWorld,
|
||||
half occlusion, half4 i_ambientOrLightmapUV, half atten, half smoothness, half3 normalWorld, half3 eyeVec,
|
||||
UnityLight light,
|
||||
bool reflections)
|
||||
{
|
||||
// we init only fields actually used
|
||||
FragmentCommonData s = (FragmentCommonData)0;
|
||||
s.smoothness = smoothness;
|
||||
s.normalWorld = normalWorld;
|
||||
s.eyeVec = eyeVec;
|
||||
s.posWorld = posWorld;
|
||||
return FragmentGI(s, occlusion, i_ambientOrLightmapUV, atten, light, reflections);
|
||||
}
|
||||
inline UnityGI FragmentGI (
|
||||
float3 posWorld,
|
||||
half occlusion, half4 i_ambientOrLightmapUV, half atten, half smoothness, half3 normalWorld, half3 eyeVec,
|
||||
UnityLight light)
|
||||
{
|
||||
return FragmentGI (posWorld, occlusion, i_ambientOrLightmapUV, atten, smoothness, normalWorld, eyeVec, light, true);
|
||||
}
|
||||
|
||||
#endif // UNITY_STANDARD_CORE_INCLUDED
|
||||
|
||||
#ifndef VIDEO_STANDARD_CORE_FORWARD_INCLUDED
|
||||
#define VIDEO_STANDARD_CORE_FORWARD_INCLUDED
|
||||
|
||||
#if defined(UNITY_NO_FULL_STANDARD_SHADER)
|
||||
# define UNITY_STANDARD_SIMPLE 1
|
||||
#endif
|
||||
|
||||
#include "UnityStandardConfig.cginc"
|
||||
|
||||
#if UNITY_STANDARD_SIMPLE
|
||||
VertexOutputBaseSimple vertBase(VertexInput v) { return vertForwardBaseSimple(v); }
|
||||
VertexOutputForwardAddSimple vertAdd(VertexInput v) { return vertForwardAddSimple(v); }
|
||||
half4 fragBase(VertexOutputBaseSimple i) : SV_Target{ return fragForwardBaseSimpleInternal(i); }
|
||||
half4 fragAdd(VertexOutputForwardAddSimple i) : SV_Target{ return fragForwardAddSimpleInternal(i); }
|
||||
#else
|
||||
VertexOutputForwardBase vertBase(VertexInput v) { return vertForwardBase(v); }
|
||||
VertexOutputForwardAdd vertAdd(VertexInput v) { return vertForwardAdd(v); }
|
||||
half4 fragBase(VertexOutputForwardBase i) : SV_Target{ return fragForwardBaseInternal(i); }
|
||||
half4 fragAdd(VertexOutputForwardAdd i) : SV_Target{ return fragForwardAddInternal(i); }
|
||||
#endif
|
||||
|
||||
#endif // UNITY_STANDARD_CORE_FORWARD_INCLUDED
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 76a7aa8c79ff223498ae45adb92cf437
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,420 @@
|
||||
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
|
||||
// Copy of the Unity standard shader with tweakable realtime GI emissive seperate from the visible emissive
|
||||
|
||||
Shader "Merlin/World/Standard Video Emission"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_Color("Color", Color) = (1,1,1,1)
|
||||
_MainTex("Albedo", 2D) = "white" {}
|
||||
|
||||
_Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
|
||||
|
||||
_Glossiness("Smoothness", Range(0.0, 1.0)) = 0.5
|
||||
_GlossMapScale("Smoothness Scale", Range(0.0, 1.0)) = 1.0
|
||||
[Enum(Metallic Alpha,0,Albedo Alpha,1)] _SmoothnessTextureChannel("Smoothness texture channel", Float) = 0
|
||||
|
||||
[Gamma] _Metallic("Metallic", Range(0.0, 1.0)) = 0.0
|
||||
_MetallicGlossMap("Metallic", 2D) = "white" {}
|
||||
|
||||
[ToggleOff] _SpecularHighlights("Specular Highlights", Float) = 1.0
|
||||
[ToggleOff] _GlossyReflections("Glossy Reflections", Float) = 1.0
|
||||
|
||||
_BumpScale("Scale", Float) = 1.0
|
||||
_BumpMap("Normal Map", 2D) = "bump" {}
|
||||
|
||||
_Parallax("Height Scale", Range(0.005, 0.08)) = 0.02
|
||||
_ParallaxMap("Height Map", 2D) = "black" {}
|
||||
|
||||
_OcclusionStrength("Strength", Range(0.0, 1.0)) = 1.0
|
||||
_OcclusionMap("Occlusion", 2D) = "white" {}
|
||||
|
||||
_EmissionColor("Color", Color) = (0,0,0)
|
||||
_EmissionMap("Emission", 2D) = "white" {}
|
||||
|
||||
_DetailMask("Detail Mask", 2D) = "white" {}
|
||||
|
||||
_DetailAlbedoMap("Detail Albedo x2", 2D) = "grey" {}
|
||||
_DetailNormalMapScale("Scale", Float) = 1.0
|
||||
_DetailNormalMap("Normal Map", 2D) = "bump" {}
|
||||
|
||||
[Enum(UV0,0,UV1,1)] _UVSec("UV Set for secondary textures", Float) = 0
|
||||
|
||||
|
||||
// Blending state
|
||||
[HideInInspector] _Mode("__mode", Float) = 0.0
|
||||
[HideInInspector] _SrcBlend("__src", Float) = 1.0
|
||||
[HideInInspector] _DstBlend("__dst", Float) = 0.0
|
||||
[HideInInspector] _ZWrite("__zw", Float) = 1.0
|
||||
|
||||
_MetaPassEmissiveBoost("Meta Pass Emissive Boost", Float) = 1.0
|
||||
_TargetAspectRatio("Target Aspect Ratio", Float) = 1.7777777
|
||||
[Toggle(_)]_IsAVProInput("Is AV Pro Input", Int) = 0
|
||||
}
|
||||
|
||||
CGINCLUDE
|
||||
#define UNITY_SETUP_BRDF_INPUT MetallicSetup
|
||||
ENDCG
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType" = "Opaque" "PerformanceChecks" = "False" }
|
||||
LOD 300
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Base forward pass (directional light, emission, lightmaps, ...)
|
||||
Pass
|
||||
{
|
||||
Name "FORWARD"
|
||||
Tags { "LightMode" = "ForwardBase" }
|
||||
|
||||
Blend[_SrcBlend][_DstBlend]
|
||||
ZWrite[_ZWrite]
|
||||
|
||||
CGPROGRAM
|
||||
#pragma target 3.0
|
||||
|
||||
// -------------------------------------
|
||||
|
||||
#pragma shader_feature _NORMALMAP
|
||||
#pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
|
||||
#pragma shader_feature _EMISSION
|
||||
#pragma shader_feature _METALLICGLOSSMAP
|
||||
#pragma shader_feature ___ _DETAIL_MULX2
|
||||
#pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
#pragma shader_feature _ _SPECULARHIGHLIGHTS_OFF
|
||||
#pragma shader_feature _ _GLOSSYREFLECTIONS_OFF
|
||||
#pragma shader_feature _PARALLAXMAP
|
||||
|
||||
#pragma multi_compile_fwdbase
|
||||
#pragma multi_compile_fog
|
||||
#pragma multi_compile_instancing
|
||||
// Uncomment the following line to enable dithering LOD crossfade. Note: there are more in the file to uncomment for other passes.
|
||||
//#pragma multi_compile _ LOD_FADE_CROSSFADE
|
||||
|
||||
#pragma vertex vertBase
|
||||
#pragma fragment fragBase
|
||||
#include "StandardVideoCore.cginc"
|
||||
|
||||
ENDCG
|
||||
}
|
||||
// ------------------------------------------------------------------
|
||||
// Additive forward pass (one light per pass)
|
||||
Pass
|
||||
{
|
||||
Name "FORWARD_DELTA"
|
||||
Tags { "LightMode" = "ForwardAdd" }
|
||||
Blend[_SrcBlend] One
|
||||
Fog { Color(0,0,0,0) } // in additive pass fog should be black
|
||||
ZWrite Off
|
||||
ZTest LEqual
|
||||
|
||||
CGPROGRAM
|
||||
#pragma target 3.0
|
||||
|
||||
// -------------------------------------
|
||||
|
||||
|
||||
#pragma shader_feature _NORMALMAP
|
||||
#pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
|
||||
#pragma shader_feature _METALLICGLOSSMAP
|
||||
#pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
#pragma shader_feature _ _SPECULARHIGHLIGHTS_OFF
|
||||
#pragma shader_feature ___ _DETAIL_MULX2
|
||||
#pragma shader_feature _PARALLAXMAP
|
||||
|
||||
#pragma multi_compile_fwdadd_fullshadows
|
||||
#pragma multi_compile_fog
|
||||
// Uncomment the following line to enable dithering LOD crossfade. Note: there are more in the file to uncomment for other passes.
|
||||
//#pragma multi_compile _ LOD_FADE_CROSSFADE
|
||||
|
||||
#pragma vertex vertAdd
|
||||
#pragma fragment fragAdd
|
||||
#include "StandardVideoCore.cginc"
|
||||
|
||||
ENDCG
|
||||
}
|
||||
// ------------------------------------------------------------------
|
||||
// Shadow rendering pass
|
||||
Pass {
|
||||
Name "ShadowCaster"
|
||||
Tags { "LightMode" = "ShadowCaster" }
|
||||
|
||||
ZWrite On ZTest LEqual
|
||||
|
||||
CGPROGRAM
|
||||
#pragma target 3.0
|
||||
|
||||
// -------------------------------------
|
||||
|
||||
|
||||
#pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
|
||||
#pragma shader_feature _METALLICGLOSSMAP
|
||||
#pragma shader_feature _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
#pragma shader_feature _PARALLAXMAP
|
||||
#pragma multi_compile_shadowcaster
|
||||
#pragma multi_compile_instancing
|
||||
// Uncomment the following line to enable dithering LOD crossfade. Note: there are more in the file to uncomment for other passes.
|
||||
//#pragma multi_compile _ LOD_FADE_CROSSFADE
|
||||
|
||||
#pragma vertex vertShadowCaster
|
||||
#pragma fragment fragShadowCaster
|
||||
|
||||
#include "UnityStandardShadow.cginc"
|
||||
|
||||
ENDCG
|
||||
}
|
||||
// ------------------------------------------------------------------
|
||||
// Deferred pass
|
||||
Pass
|
||||
{
|
||||
Name "DEFERRED"
|
||||
Tags { "LightMode" = "Deferred" }
|
||||
|
||||
CGPROGRAM
|
||||
#pragma target 3.0
|
||||
#pragma exclude_renderers nomrt
|
||||
|
||||
|
||||
// -------------------------------------
|
||||
|
||||
#pragma shader_feature _NORMALMAP
|
||||
#pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
|
||||
#pragma shader_feature _EMISSION
|
||||
#pragma shader_feature _METALLICGLOSSMAP
|
||||
#pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
#pragma shader_feature _ _SPECULARHIGHLIGHTS_OFF
|
||||
#pragma shader_feature ___ _DETAIL_MULX2
|
||||
#pragma shader_feature _PARALLAXMAP
|
||||
|
||||
#pragma multi_compile_prepassfinal
|
||||
#pragma multi_compile_instancing
|
||||
// Uncomment the following line to enable dithering LOD crossfade. Note: there are more in the file to uncomment for other passes.
|
||||
//#pragma multi_compile _ LOD_FADE_CROSSFADE
|
||||
|
||||
#pragma vertex vertDeferred
|
||||
#pragma fragment fragDeferred
|
||||
|
||||
#include "StandardVideoCore.cginc"
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Extracts information for lightmapping, GI (emission, albedo, ...)
|
||||
// This pass it not used during regular rendering.
|
||||
Pass
|
||||
{
|
||||
Name "META"
|
||||
Tags { "LightMode" = "Meta" }
|
||||
|
||||
Cull Off
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert_meta
|
||||
#pragma fragment frag_meta
|
||||
|
||||
#pragma shader_feature _EMISSION
|
||||
#pragma shader_feature _METALLICGLOSSMAP
|
||||
#pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
#pragma shader_feature ___ _DETAIL_MULX2
|
||||
#pragma shader_feature EDITOR_VISUALIZATION
|
||||
#include "UnityCG.cginc"
|
||||
#include "UnityStandardInput.cginc"
|
||||
#include "UnityMetaPass.cginc"
|
||||
#include "StandardVideoCore.cginc"
|
||||
|
||||
struct v2f_meta
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float4 uv : TEXCOORD0;
|
||||
#ifdef EDITOR_VISUALIZATION
|
||||
float2 vizUV : TEXCOORD1;
|
||||
float4 lightCoord : TEXCOORD2;
|
||||
#endif
|
||||
};
|
||||
|
||||
float _MetaPassEmissiveBoost;
|
||||
|
||||
v2f_meta vert_meta (VertexInput v)
|
||||
{
|
||||
v2f_meta o;
|
||||
o.pos = UnityMetaVertexPosition(v.vertex, v.uv1.xy, v.uv2.xy, unity_LightmapST, unity_DynamicLightmapST);
|
||||
o.uv = TexCoords(v);
|
||||
#ifdef EDITOR_VISUALIZATION
|
||||
o.vizUV = 0;
|
||||
o.lightCoord = 0;
|
||||
if (unity_VisualizationMode == EDITORVIZ_TEXTURE)
|
||||
o.vizUV = UnityMetaVizUV(unity_EditorViz_UVIndex, v.uv0.xy, v.uv1.xy, v.uv2.xy, unity_EditorViz_Texture_ST);
|
||||
else if (unity_VisualizationMode == EDITORVIZ_SHOWLIGHTMASK)
|
||||
{
|
||||
o.vizUV = v.uv1.xy * unity_LightmapST.xy + unity_LightmapST.zw;
|
||||
o.lightCoord = mul(unity_EditorViz_WorldToLight, mul(unity_ObjectToWorld, float4(v.vertex.xyz, 1)));
|
||||
}
|
||||
#endif
|
||||
return o;
|
||||
}
|
||||
|
||||
// Albedo for lightmapping should basically be diffuse color.
|
||||
// But rough metals (black diffuse) still scatter quite a lot of light around, so
|
||||
// we want to take some of that into account too.
|
||||
half3 UnityLightmappingAlbedo (half3 diffuse, half3 specular, half smoothness)
|
||||
{
|
||||
half roughness = SmoothnessToRoughness(smoothness);
|
||||
half3 res = diffuse;
|
||||
res += specular * roughness * 0.5;
|
||||
return res;
|
||||
}
|
||||
|
||||
float4 frag_meta (v2f_meta i) : SV_Target
|
||||
{
|
||||
// we're interested in diffuse & specular colors,
|
||||
// and surface roughness to produce final albedo.
|
||||
FragmentCommonData data = UNITY_SETUP_BRDF_INPUT (i.uv);
|
||||
|
||||
UnityMetaInput o;
|
||||
UNITY_INITIALIZE_OUTPUT(UnityMetaInput, o);
|
||||
|
||||
#ifdef EDITOR_VISUALIZATION
|
||||
o.Albedo = data.diffColor;
|
||||
o.VizUV = i.vizUV;
|
||||
o.LightCoord = i.lightCoord;
|
||||
#else
|
||||
o.Albedo = UnityLightmappingAlbedo (data.diffColor, data.specColor, data.smoothness);
|
||||
#endif
|
||||
o.SpecularColor = data.specColor;
|
||||
o.Emission = VideoEmission(i.uv.xy) * _MetaPassEmissiveBoost;
|
||||
|
||||
return UnityMetaFragment(o);
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType" = "Opaque" "PerformanceChecks" = "False" }
|
||||
LOD 150
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Base forward pass (directional light, emission, lightmaps, ...)
|
||||
Pass
|
||||
{
|
||||
Name "FORWARD"
|
||||
Tags { "LightMode" = "ForwardBase" }
|
||||
|
||||
Blend[_SrcBlend][_DstBlend]
|
||||
ZWrite[_ZWrite]
|
||||
|
||||
CGPROGRAM
|
||||
#pragma target 2.0
|
||||
|
||||
#pragma shader_feature _NORMALMAP
|
||||
#pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
|
||||
#pragma shader_feature _EMISSION
|
||||
#pragma shader_feature _METALLICGLOSSMAP
|
||||
#pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
#pragma shader_feature _ _SPECULARHIGHLIGHTS_OFF
|
||||
#pragma shader_feature _ _GLOSSYREFLECTIONS_OFF
|
||||
// SM2.0: NOT SUPPORTED shader_feature ___ _DETAIL_MULX2
|
||||
// SM2.0: NOT SUPPORTED shader_feature _PARALLAXMAP
|
||||
|
||||
#pragma skip_variants SHADOWS_SOFT DIRLIGHTMAP_COMBINED
|
||||
|
||||
#pragma multi_compile_fwdbase
|
||||
#pragma multi_compile_fog
|
||||
|
||||
#pragma vertex vertBase
|
||||
#pragma fragment fragBase
|
||||
#include "StandardVideoCore.cginc"
|
||||
|
||||
ENDCG
|
||||
}
|
||||
// ------------------------------------------------------------------
|
||||
// Additive forward pass (one light per pass)
|
||||
Pass
|
||||
{
|
||||
Name "FORWARD_DELTA"
|
||||
Tags { "LightMode" = "ForwardAdd" }
|
||||
Blend[_SrcBlend] One
|
||||
Fog { Color(0,0,0,0) } // in additive pass fog should be black
|
||||
ZWrite Off
|
||||
ZTest LEqual
|
||||
|
||||
CGPROGRAM
|
||||
#pragma target 2.0
|
||||
|
||||
#pragma shader_feature _NORMALMAP
|
||||
#pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
|
||||
#pragma shader_feature _METALLICGLOSSMAP
|
||||
#pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
#pragma shader_feature _ _SPECULARHIGHLIGHTS_OFF
|
||||
#pragma shader_feature ___ _DETAIL_MULX2
|
||||
// SM2.0: NOT SUPPORTED shader_feature _PARALLAXMAP
|
||||
#pragma skip_variants SHADOWS_SOFT
|
||||
|
||||
#pragma multi_compile_fwdadd_fullshadows
|
||||
#pragma multi_compile_fog
|
||||
|
||||
#pragma vertex vertAdd
|
||||
#pragma fragment fragAdd
|
||||
#include "UnityStandardCoreForward.cginc"
|
||||
|
||||
ENDCG
|
||||
}
|
||||
// ------------------------------------------------------------------
|
||||
// Shadow rendering pass
|
||||
Pass {
|
||||
Name "ShadowCaster"
|
||||
Tags { "LightMode" = "ShadowCaster" }
|
||||
|
||||
ZWrite On ZTest LEqual
|
||||
|
||||
CGPROGRAM
|
||||
#pragma target 2.0
|
||||
|
||||
#pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
|
||||
#pragma shader_feature _METALLICGLOSSMAP
|
||||
#pragma shader_feature _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
#pragma skip_variants SHADOWS_SOFT
|
||||
#pragma multi_compile_shadowcaster
|
||||
|
||||
#pragma vertex vertShadowCaster
|
||||
#pragma fragment fragShadowCaster
|
||||
|
||||
#include "UnityStandardShadow.cginc"
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Extracts information for lightmapping, GI (emission, albedo, ...)
|
||||
// This pass it not used during regular rendering.
|
||||
Pass
|
||||
{
|
||||
Name "META"
|
||||
Tags { "LightMode" = "Meta" }
|
||||
|
||||
Cull Off
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert_meta
|
||||
#pragma fragment frag_meta
|
||||
|
||||
#pragma shader_feature _EMISSION
|
||||
#pragma shader_feature _METALLICGLOSSMAP
|
||||
#pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
#pragma shader_feature ___ _DETAIL_MULX2
|
||||
#pragma shader_feature EDITOR_VISUALIZATION
|
||||
|
||||
#include "UnityStandardMeta.cginc"
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
FallBack "VertexLit"
|
||||
CustomEditor "StandardVideoEmissiveShaderGUI"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 412ea878efbed224d97338aed34a773c
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,141 @@
|
||||
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
|
||||
// Quick modification of the Unity builtin UI shader to fix MSAA falling out of bounds on interpolating text quads - Merlin, also MIT license
|
||||
|
||||
Shader "UI/MUI"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
|
||||
[HDR]_Color ("Tint", Color) = (1,1,1,1)
|
||||
|
||||
_StencilComp ("Stencil Comparison", Float) = 8
|
||||
_Stencil ("Stencil ID", Float) = 0
|
||||
_StencilOp ("Stencil Operation", Float) = 0
|
||||
_StencilWriteMask ("Stencil Write Mask", Float) = 255
|
||||
_StencilReadMask ("Stencil Read Mask", Float) = 255
|
||||
|
||||
_ColorMask ("Color Mask", Float) = 15
|
||||
|
||||
[Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"Queue"="Transparent"
|
||||
"IgnoreProjector"="True"
|
||||
"RenderType"="Transparent"
|
||||
"PreviewType"="Plane"
|
||||
"CanUseSpriteAtlas"="True"
|
||||
}
|
||||
|
||||
Stencil
|
||||
{
|
||||
Ref [_Stencil]
|
||||
Comp [_StencilComp]
|
||||
Pass [_StencilOp]
|
||||
ReadMask [_StencilReadMask]
|
||||
WriteMask [_StencilWriteMask]
|
||||
}
|
||||
|
||||
Cull Off
|
||||
Lighting Off
|
||||
ZWrite Off
|
||||
ZTest [unity_GUIZTestMode]
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
ColorMask [_ColorMask]
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "Default"
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
// Target 3.5 for centroid support on OpenGL ES
|
||||
#pragma target 3.5
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "UnityUI.cginc"
|
||||
|
||||
#pragma multi_compile __ UNITY_UI_CLIP_RECT
|
||||
#pragma multi_compile __ UNITY_UI_ALPHACLIP
|
||||
|
||||
struct appdata_t
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
float4 worldPosition : TEXCOORD1;
|
||||
float2 generatedtexcoord : TEXCOORD2;
|
||||
centroid float2 centroidtexcoord : TEXCOORD3;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
fixed4 _Color;
|
||||
fixed4 _TextureSampleAdd;
|
||||
float4 _ClipRect;
|
||||
|
||||
v2f vert(appdata_t v, uint vertID : SV_VertexID)
|
||||
{
|
||||
v2f OUT;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
|
||||
OUT.worldPosition = v.vertex;
|
||||
OUT.vertex = UnityObjectToClipPos(OUT.worldPosition);
|
||||
|
||||
OUT.texcoord = v.texcoord;
|
||||
OUT.centroidtexcoord = v.texcoord;
|
||||
|
||||
OUT.color = v.color * _Color;
|
||||
|
||||
const float2 generatedCoords[4] = {
|
||||
float2(0, 0),
|
||||
float2(1, 0),
|
||||
float2(1, 1),
|
||||
float2(0, 1),
|
||||
};
|
||||
|
||||
OUT.generatedtexcoord = generatedCoords[vertID % 4];
|
||||
|
||||
return OUT;
|
||||
}
|
||||
|
||||
sampler2D _MainTex;
|
||||
|
||||
half4 frag(v2f IN) : SV_Target
|
||||
{
|
||||
float2 texcoord = IN.texcoord;
|
||||
|
||||
// Use Valve method of falling back to centroid interpolation if you fall out of valid interpolation range
|
||||
// Based on slide 44 of http://media.steampowered.com/apps/valve/2015/Alex_Vlachos_Advanced_VR_Rendering_GDC2015.pdf
|
||||
if (any(IN.generatedtexcoord > 1.0) || any(IN.generatedtexcoord < 0.0) )
|
||||
texcoord = IN.centroidtexcoord;
|
||||
|
||||
half4 color = (tex2D(_MainTex, texcoord) + _TextureSampleAdd) * IN.color;
|
||||
|
||||
#ifdef UNITY_UI_CLIP_RECT
|
||||
color.a *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect);
|
||||
#endif
|
||||
|
||||
#ifdef UNITY_UI_ALPHACLIP
|
||||
clip (color.a - 0.001);
|
||||
#endif
|
||||
|
||||
return color;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
Fallback "UI/Default"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9d61949da4bd1b545b4fdacba6dfb5da
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user