bug fix
This commit is contained in:
@@ -0,0 +1,340 @@
|
||||
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
|
||||
|
||||
// Derived from DefaultResourcesExtra\Standard.shader.
|
||||
// Available as part of the "Built in shaders" download from https://unity3d.com/get-unity/download/archive
|
||||
// Changes include:
|
||||
// Excluding _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A from all ShadowCaster passes
|
||||
// Removing many Properties not relevant to this shader's logic (and rename visible strings for others)
|
||||
// Using a CustomEditor GUI for the shader configuration
|
||||
// Adding and respecting the _Cull property to support double-sided materials
|
||||
// Forwarding calls through VetexColor.cginc's vert_vcol/frag_vcol (instead of directly to UnityStandardCoreForward.cginc's vertBase/fragBase) to add VertexColor support
|
||||
|
||||
Shader "GLTF/PbrMetallicRoughness"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_Color("Base Color Factor", Color) = (1,1,1,1)
|
||||
_MainTex("Base Color Texture", 2D) = "white" {}
|
||||
|
||||
[Toggle(_VERTEX_COLORS)] _VertexColors("Vertex Colors", Float) = 1.0
|
||||
|
||||
_Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
|
||||
|
||||
_Glossiness("Roughness Factor", Range(0.0, 1.0)) = 1.0
|
||||
|
||||
_Metallic("Metallic Factor", Range(0.0, 1.0)) = 0.0
|
||||
_MetallicGlossMap("Metal Rough Texture", 2D) = "white" {}
|
||||
|
||||
_BumpScale("Normal Scale", Float) = 1.0
|
||||
_BumpMap("Normal Map", 2D) = "bump" {}
|
||||
|
||||
_OcclusionStrength("Occlusion Strength", Range(0.0, 1.0)) = 1.0
|
||||
_OcclusionMap("Occlusion Texture", 2D) = "white" {}
|
||||
|
||||
[HDR]
|
||||
_EmissionColor("Emissive Factor", Color) = (0,0,0)
|
||||
_EmissionMap("Emissive Texture", 2D) = "white" {}
|
||||
|
||||
_Cull("Cull", Int) = 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
|
||||
}
|
||||
|
||||
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]
|
||||
Cull [_Cull]
|
||||
|
||||
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
|
||||
|
||||
#pragma vertex vert_vcol
|
||||
#pragma fragment frag_vcol
|
||||
#pragma shader_feature _VERTEX_COLORS
|
||||
#include "VertexColor.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
|
||||
Cull [_Cull]
|
||||
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
|
||||
|
||||
#pragma vertex vertAdd
|
||||
#pragma fragment fragAdd
|
||||
#include "UnityStandardInput.cginc"
|
||||
#include "UnityStandardCoreForward.cginc"
|
||||
|
||||
ENDCG
|
||||
}
|
||||
// ------------------------------------------------------------------
|
||||
// Shadow rendering pass
|
||||
Pass {
|
||||
Name "ShadowCaster"
|
||||
Tags { "LightMode" = "ShadowCaster" }
|
||||
Cull [_Cull]
|
||||
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 _PARALLAXMAP
|
||||
#pragma multi_compile_shadowcaster
|
||||
#pragma multi_compile_instancing
|
||||
|
||||
#pragma vertex vertShadowCaster
|
||||
#pragma fragment fragShadowCaster
|
||||
|
||||
#include "UnityStandardShadow.cginc"
|
||||
|
||||
ENDCG
|
||||
}
|
||||
// ------------------------------------------------------------------
|
||||
// Deferred pass
|
||||
Pass
|
||||
{
|
||||
Name "DEFERRED"
|
||||
Tags { "LightMode" = "Deferred" }
|
||||
Cull [_Cull]
|
||||
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
|
||||
|
||||
#pragma vertex vertDeferred
|
||||
#pragma fragment fragDeferred
|
||||
#include "UnityStandardInput.cginc"
|
||||
#include "UnityStandardCore.cginc"
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Extracts information for lightmapping, GI (emission, albedo, ...)
|
||||
// This pass it not used during regular rendering.
|
||||
Pass
|
||||
{
|
||||
Name "META"
|
||||
Tags { "LightMode"="Meta" }
|
||||
|
||||
Cull [_Cull]
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType"="Opaque" "PerformanceChecks"="False" }
|
||||
LOD 150
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Base forward pass (directional light, emission, lightmaps, ...)
|
||||
Pass
|
||||
{
|
||||
Name "FORWARD"
|
||||
Tags { "LightMode" = "ForwardBase" }
|
||||
Cull [_Cull]
|
||||
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 vert_vcol
|
||||
#pragma fragment frag_vcol
|
||||
#pragma shader_feature _VERTEX_COLORS
|
||||
#include "VertexColor.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
|
||||
Cull [_Cull]
|
||||
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 "UnityStandardInput.cginc"
|
||||
#include "UnityStandardCoreForward.cginc"
|
||||
|
||||
ENDCG
|
||||
}
|
||||
// ------------------------------------------------------------------
|
||||
// Shadow rendering pass
|
||||
Pass {
|
||||
Name "ShadowCaster"
|
||||
Tags { "LightMode" = "ShadowCaster" }
|
||||
|
||||
ZWrite On ZTest LEqual
|
||||
Cull [_Cull]
|
||||
CGPROGRAM
|
||||
#pragma target 2.0
|
||||
|
||||
#pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
|
||||
#pragma shader_feature _METALLICGLOSSMAP
|
||||
#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 [_Cull]
|
||||
|
||||
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 "PbrShaderGUI"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9836e4430eb58204086d7d1440e16a4f
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,350 @@
|
||||
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
|
||||
|
||||
Shader "GLTF/PbrSpecularGlossiness"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_Color("Base Color Factor", Color) = (1,1,1,1)
|
||||
_MainTex("Base Color Texture", 2D) = "white" {}
|
||||
|
||||
[Toggle(_VERTEX_COLORS)] _VertexColors("Vertex Colors", Float) = 1.0
|
||||
|
||||
_Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
|
||||
|
||||
_Glossiness("Glossiness Factor", Range(0.0, 1.0)) = 0.5
|
||||
[HideInInspector] _SmoothnessTextureChannel ("Smoothness texture channel", Float) = 0
|
||||
|
||||
_SpecColor("Specular Factor", Color) = (0.2,0.2,0.2)
|
||||
_SpecGlossMap("Spec Gloss Texture", 2D) = "white" {}
|
||||
[HideInInspector] _SpecularHighlights("Specular Highlights", Float) = 1.0
|
||||
[HideInInspector] _GlossyReflections("Glossy Reflections", Float) = 1.0
|
||||
|
||||
_BumpScale("Normal Scale", Float) = 1.0
|
||||
_BumpMap("Normal Map", 2D) = "bump" {}
|
||||
|
||||
[HideInInspector] _Parallax ("Height Scale", Range (0.005, 0.08)) = 0.02
|
||||
[HideInInspector] _ParallaxMap ("Height Map", 2D) = "black" {}
|
||||
|
||||
_OcclusionStrength("Occlusion Strength", Range(0.0, 1.0)) = 1.0
|
||||
_OcclusionMap("Occlusion Texture", 2D) = "white" {}
|
||||
|
||||
_EmissionColor("Emissive Factor", Color) = (0,0,0)
|
||||
_EmissionMap("Emissive Texture", 2D) = "white" {}
|
||||
|
||||
_Cull("Cull", Int) = 0
|
||||
|
||||
[HideInInspector] _DetailMask("Detail Mask", 2D) = "white" {}
|
||||
|
||||
[HideInInspector] _DetailAlbedoMap("Detail Albedo x2", 2D) = "grey" {}
|
||||
[HideInInspector] _DetailNormalMapScale("Scale", Float) = 1.0
|
||||
[HideInInspector] _DetailNormalMap("Normal Map", 2D) = "bump" {}
|
||||
|
||||
[HideInInspector] _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
|
||||
}
|
||||
|
||||
CGINCLUDE
|
||||
#define UNITY_SETUP_BRDF_INPUT SpecularSetup
|
||||
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]
|
||||
|
||||
Cull [_Cull]
|
||||
|
||||
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 _SPECGLOSSMAP
|
||||
#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
|
||||
|
||||
#pragma vertex vert_vcol
|
||||
#pragma fragment frag_vcol
|
||||
#pragma shader_feature _VERTEX_COLORS
|
||||
#include "VertexColor.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
|
||||
Cull[_Cull]
|
||||
|
||||
CGPROGRAM
|
||||
#pragma target 3.0
|
||||
|
||||
// -------------------------------------
|
||||
|
||||
#pragma shader_feature _NORMALMAP
|
||||
#pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
|
||||
#pragma shader_feature _SPECGLOSSMAP
|
||||
#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
|
||||
|
||||
#pragma vertex vertAdd
|
||||
#pragma fragment fragAdd
|
||||
#include "UnityStandardInput.cginc"
|
||||
#include "UnityStandardCoreForward.cginc"
|
||||
|
||||
ENDCG
|
||||
}
|
||||
// ------------------------------------------------------------------
|
||||
// Shadow rendering pass
|
||||
Pass {
|
||||
Name "ShadowCaster"
|
||||
Tags { "LightMode" = "ShadowCaster" }
|
||||
|
||||
ZWrite On ZTest LEqual
|
||||
Cull[_Cull]
|
||||
|
||||
CGPROGRAM
|
||||
#pragma target 3.0
|
||||
|
||||
// -------------------------------------
|
||||
|
||||
|
||||
#pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
|
||||
#pragma shader_feature _SPECGLOSSMAP
|
||||
#pragma shader_feature _PARALLAXMAP
|
||||
#pragma multi_compile_shadowcaster
|
||||
#pragma multi_compile_instancing
|
||||
|
||||
#pragma vertex vertShadowCaster
|
||||
#pragma fragment fragShadowCaster
|
||||
|
||||
#include "UnityStandardShadow.cginc"
|
||||
|
||||
ENDCG
|
||||
}
|
||||
// ------------------------------------------------------------------
|
||||
// Deferred pass
|
||||
Pass
|
||||
{
|
||||
Name "DEFERRED"
|
||||
Tags { "LightMode" = "Deferred" }
|
||||
Cull[_Cull]
|
||||
|
||||
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 _SPECGLOSSMAP
|
||||
#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
|
||||
|
||||
#pragma vertex vertDeferred
|
||||
#pragma fragment fragDeferred
|
||||
|
||||
#include "UnityStandardCore.cginc"
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Extracts information for lightmapping, GI (emission, albedo, ...)
|
||||
// This pass it not used during regular rendering.
|
||||
Pass
|
||||
{
|
||||
Name "META"
|
||||
Tags { "LightMode"="Meta" }
|
||||
|
||||
Cull[_Cull]
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert_meta
|
||||
#pragma fragment frag_meta
|
||||
|
||||
#pragma shader_feature _EMISSION
|
||||
#pragma shader_feature _SPECGLOSSMAP
|
||||
#pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
#pragma shader_feature ___ _DETAIL_MULX2
|
||||
#pragma shader_feature EDITOR_VISUALIZATION
|
||||
|
||||
#include "UnityStandardMeta.cginc"
|
||||
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]
|
||||
Cull[_Cull]
|
||||
|
||||
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 _SPECGLOSSMAP
|
||||
#pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
#pragma shader_feature _ _SPECULARHIGHLIGHTS_OFF
|
||||
#pragma shader_feature _ _GLOSSYREFLECTIONS_OFF
|
||||
#pragma shader_feature ___ _DETAIL_MULX2
|
||||
// SM2.0: NOT SUPPORTED shader_feature _PARALLAXMAP
|
||||
|
||||
#pragma skip_variants SHADOWS_SOFT DYNAMICLIGHTMAP_ON DIRLIGHTMAP_COMBINED
|
||||
|
||||
#pragma multi_compile_fwdbase
|
||||
#pragma multi_compile_fog
|
||||
|
||||
#pragma vertex vert_vcol
|
||||
#pragma fragment frag_vcol
|
||||
#pragma shader_feature _VERTEX_COLORS
|
||||
#include "VertexColor.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
|
||||
Cull[_Cull]
|
||||
|
||||
CGPROGRAM
|
||||
#pragma target 2.0
|
||||
|
||||
#pragma shader_feature _NORMALMAP
|
||||
#pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
|
||||
#pragma shader_feature _SPECGLOSSMAP
|
||||
#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 "UnityStandardInput.cginc"
|
||||
#include "UnityStandardCoreForward.cginc"
|
||||
|
||||
ENDCG
|
||||
}
|
||||
// ------------------------------------------------------------------
|
||||
// Shadow rendering pass
|
||||
Pass {
|
||||
Name "ShadowCaster"
|
||||
Tags { "LightMode" = "ShadowCaster" }
|
||||
|
||||
ZWrite On ZTest LEqual
|
||||
Cull[_Cull]
|
||||
|
||||
CGPROGRAM
|
||||
#pragma target 2.0
|
||||
|
||||
#pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
|
||||
#pragma shader_feature _SPECGLOSSMAP
|
||||
#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[_Cull]
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert_meta
|
||||
#pragma fragment frag_meta
|
||||
|
||||
#pragma shader_feature _EMISSION
|
||||
#pragma shader_feature _SPECGLOSSMAP
|
||||
#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 "PbrShaderGUI"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0ffe2976cdefd434c8fcd886ffa69322
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6e32829a2d4263447b87ba7c367e5410
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 036670886f7d6664b84a5053642f0ad0
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8bc739b14fe811644abb82057b363ba8
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: fe431e399c52971408121c6c40cde979, type: 3}
|
||||
sourceShader: {fileID: -6465566751694194690, guid: 478ce3626be7a5f4ea58d6b13f05a2e4, type: 3}
|
||||
upgradeShader: {fileID: 4800000, guid: 86f94ec63222e22449b77b92fcf1edc8, type: 3}
|
||||
forceTransparent: 0
|
||||
forceDoublesided: 1
|
||||
hideShader: 1
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 54352a53405971b41a6587615f947085
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: fe431e399c52971408121c6c40cde979, type: 3}
|
||||
sourceShader: {fileID: -6465566751694194690, guid: 478ce3626be7a5f4ea58d6b13f05a2e4, type: 3}
|
||||
upgradeShader: {fileID: 4800000, guid: 86f94ec63222e22449b77b92fcf1edc8, type: 3}
|
||||
forceTransparent: 1
|
||||
forceDoublesided: 1
|
||||
hideShader: 1
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0a931320a74ca574b91d2d7d4557dcf1
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: fe431e399c52971408121c6c40cde979, type: 3}
|
||||
sourceShader: {fileID: -6465566751694194690, guid: 478ce3626be7a5f4ea58d6b13f05a2e4, type: 3}
|
||||
upgradeShader: {fileID: 4800000, guid: 86f94ec63222e22449b77b92fcf1edc8, type: 3}
|
||||
forceTransparent: 1
|
||||
forceDoublesided: 0
|
||||
hideShader: 1
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 33ee70a7f505ddb4e80d235c3d70766d
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: fe431e399c52971408121c6c40cde979, type: 3}
|
||||
sourceShader: {fileID: -6465566751694194690, guid: 59541e6caf586ca4f96ccf48a4813a51, type: 3}
|
||||
upgradeShader: {fileID: 4800000, guid: 86f94ec63222e22449b77b92fcf1edc8, type: 3}
|
||||
forceTransparent: 0
|
||||
forceDoublesided: 1
|
||||
hideShader: 1
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8a8841b4fb2f63644896f4e2b36bc06d
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: fe431e399c52971408121c6c40cde979, type: 3}
|
||||
sourceShader: {fileID: -6465566751694194690, guid: 59541e6caf586ca4f96ccf48a4813a51, type: 3}
|
||||
upgradeShader: {fileID: 4800000, guid: 86f94ec63222e22449b77b92fcf1edc8, type: 3}
|
||||
forceTransparent: 1
|
||||
forceDoublesided: 1
|
||||
hideShader: 1
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 83f2caca07949794fb997734c4b0520f
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: fe431e399c52971408121c6c40cde979, type: 3}
|
||||
sourceShader: {fileID: -6465566751694194690, guid: 59541e6caf586ca4f96ccf48a4813a51, type: 3}
|
||||
upgradeShader: {fileID: 4800000, guid: 86f94ec63222e22449b77b92fcf1edc8, type: 3}
|
||||
forceTransparent: 1
|
||||
forceDoublesided: 0
|
||||
hideShader: 1
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 478ce3626be7a5f4ea58d6b13f05a2e4
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3}
|
||||
@@ -0,0 +1,119 @@
|
||||
#ifndef UNITY_DECLARE_OPAQUE_TEXTURE_INCLUDED_2
|
||||
#define UNITY_DECLARE_OPAQUE_TEXTURE_INCLUDED_2
|
||||
#ifdef SHADERGRAPH_PREVIEW
|
||||
|
||||
void SampleSceneColor2_float(float2 uv, float lod, out float3 color)
|
||||
{
|
||||
color = float3(1,1,1);
|
||||
}
|
||||
|
||||
void SampleSceneColor2_half(half2 uv, half lod, out half3 color)
|
||||
{
|
||||
color = half3(1,1,1);
|
||||
}
|
||||
|
||||
#else
|
||||
// Needed to comment this out due to IN-4055 - can't build with this include being present here
|
||||
// For code changes, comment this out so autocomplete etc. work, but remember to comment it again
|
||||
// #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
|
||||
// TODO figure out how we can differentiate between BiRP/URP/HDRP here
|
||||
#define USE_CAMERA_OPAQUE
|
||||
|
||||
#if defined(USE_CAMERA_OPAQUE)
|
||||
float4 _CameraOpaqueTexture_TexelSize;
|
||||
TEXTURE2D_X(_CameraOpaqueTexture);
|
||||
SAMPLER(sampler_CameraOpaqueTexture);
|
||||
#endif
|
||||
|
||||
// for future use
|
||||
// float applyIorToRoughness( const in float roughness, const in float ior ) {
|
||||
// // Scale roughness with IOR so that an IOR of 1.0 results in no microfacet refraction and
|
||||
// // an IOR of 1.5 results in the default amount of microfacet refraction.
|
||||
// return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
|
||||
// }
|
||||
|
||||
void SampleSceneColor_float(float2 uv, float lod, out float3 color)
|
||||
{
|
||||
#define REQUIRE_OPAQUE_TEXTURE // seems we need to define this ourselves? HDSceneColorNode does that as well
|
||||
|
||||
#if defined(USE_CAMERA_OPAQUE)
|
||||
color = SAMPLE_TEXTURE2D_X_LOD(_CameraOpaqueTexture, sampler_CameraOpaqueTexture, UnityStereoTransformScreenSpaceTex(uv), lod).rgb;
|
||||
#else
|
||||
// For HDRP, from HDSceneColorNode
|
||||
#if defined(REQUIRE_OPAQUE_TEXTURE) && defined(_SURFACE_TYPE_TRANSPARENT) && defined(SHADERPASS) && (SHADERPASS != SHADERPASS_LIGHT_TRANSPORT) && (SHADERPASS != SHADERPASS_PATH_TRACING) && (SHADERPASS != SHADERPASS_RAYTRACING_VISIBILITY) && (SHADERPASS != SHADERPASS_RAYTRACING_FORWARD)
|
||||
color = SampleCameraColor(uv, lod) * 1.0; // GetInverseCurrentExposureMultiplier()
|
||||
#else
|
||||
color = float3(0.0, 0.0, 0.0);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void SampleSceneColor_half(float2 uv, float lod, out float3 color)
|
||||
{
|
||||
SampleSceneColor_float(uv, lod, color);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void Refract_float(float3 v, float3 n, float ior, out float3 refractionVector)
|
||||
{
|
||||
refractionVector = refract( - v, normalize( n ), 1 / ior );
|
||||
}
|
||||
|
||||
void Refract_half(half3 v, half3 n, half ior, out half3 refractionVector)
|
||||
{
|
||||
refractionVector = refract( - v, normalize( n ), 1 / ior );
|
||||
}
|
||||
|
||||
inline half3 bump3y (half3 x, half3 yoffset)
|
||||
{
|
||||
float3 y = 1 - x * x;
|
||||
y = saturate(y-yoffset);
|
||||
return y;
|
||||
}
|
||||
|
||||
void Spectral_float(float wavelength, out half3 color)
|
||||
{
|
||||
// Based on GPU Gems
|
||||
// Optimised by Alan Zucconi
|
||||
// w: [400, 700]
|
||||
// x: [0, 1]
|
||||
half x = ((wavelength - 400.0)/ 300.0) % 1.0;
|
||||
|
||||
const float3 c1 = float3(3.54585104, 2.93225262, 2.41593945);
|
||||
const float3 x1 = float3(0.69549072, 0.49228336, 0.27699880);
|
||||
const float3 y1 = float3(0.02312639, 0.15225084, 0.52607955);
|
||||
|
||||
const float3 c2 = float3(3.90307140, 3.21182957, 3.96587128);
|
||||
const float3 x2 = float3(0.11748627, 0.86755042, 0.66077860);
|
||||
const float3 y2 = float3(0.84897130, 0.88445281, 0.73949448);
|
||||
|
||||
color =
|
||||
bump3y(c1 * (x - x1), y1) +
|
||||
bump3y(c2 * (x - x2), y2) ;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void WorkaroundTilingOffset_float(UnityTexture2D Tex, float4 LegacyST, out float4 TilingOffset, out float4 TilingOffsetOther)
|
||||
{
|
||||
#if UNITY_VERSION >= 202120
|
||||
TilingOffset = float4(1,1,0,0);
|
||||
TilingOffsetOther = Tex.scaleTranslate.xyzw;
|
||||
#else
|
||||
TilingOffset = LegacyST;
|
||||
TilingOffsetOther = LegacyST;
|
||||
#endif
|
||||
}
|
||||
|
||||
void WorkaroundTilingOffset_half(UnityTexture2D Tex, half4 LegacyST, out half4 TilingOffset, out half4 TilingOffsetOther)
|
||||
{
|
||||
#if UNITY_VERSION >= 202120
|
||||
TilingOffset = half4(1,1,0,0);
|
||||
TilingOffsetOther = Tex.scaleTranslate.xyzw;
|
||||
#else
|
||||
TilingOffset = LegacyST;
|
||||
TilingOffsetOther = LegacyST;
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 885a3662fbaba7c47979790356264411
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+2267
File diff suppressed because it is too large
Load Diff
+10
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8ecb70019a63796448768b1124086ef5
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 60072b568d64c40a485e0fc55012dc9f, type: 3}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 59541e6caf586ca4f96ccf48a4813a51
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3}
|
||||
@@ -0,0 +1,272 @@
|
||||
// Upgrade NOTE: replaced 'UNITY_INSTANCE_ID' with 'UNITY_VERTEX_INPUT_INSTANCE_ID'
|
||||
|
||||
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
|
||||
|
||||
#ifndef UNITY_STANDARD_INPUT_INCLUDED
|
||||
#define UNITY_STANDARD_INPUT_INCLUDED
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "UnityStandardConfig.cginc"
|
||||
#include "UnityPBSLighting.cginc" // TBD: remove
|
||||
#include "UnityStandardUtils.cginc"
|
||||
|
||||
//---------------------------------------
|
||||
// Directional lightmaps & Parallax require tangent space too
|
||||
#if (_NORMALMAP || DIRLIGHTMAP_COMBINED || _PARALLAXMAP)
|
||||
#define _TANGENT_TO_WORLD 1
|
||||
#endif
|
||||
|
||||
#if (_DETAIL_MULX2 || _DETAIL_MUL || _DETAIL_ADD || _DETAIL_LERP)
|
||||
#define _DETAIL 1
|
||||
#endif
|
||||
|
||||
//---------------------------------------
|
||||
half4 _Color;
|
||||
half _Cutoff;
|
||||
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_ST;
|
||||
|
||||
sampler2D _DetailAlbedoMap;
|
||||
float4 _DetailAlbedoMap_ST;
|
||||
|
||||
sampler2D _BumpMap;
|
||||
half _BumpScale;
|
||||
|
||||
sampler2D _DetailMask;
|
||||
sampler2D _DetailNormalMap;
|
||||
half _DetailNormalMapScale;
|
||||
|
||||
sampler2D _SpecGlossMap;
|
||||
sampler2D _MetallicGlossMap;
|
||||
half _Metallic;
|
||||
half _Glossiness;
|
||||
|
||||
sampler2D _OcclusionMap;
|
||||
half _OcclusionStrength;
|
||||
|
||||
sampler2D _ParallaxMap;
|
||||
half _Parallax;
|
||||
half _UVSec;
|
||||
|
||||
half4 _EmissionColor;
|
||||
sampler2D _EmissionMap;
|
||||
float4 _EmissionMap_ST;
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
// Input functions
|
||||
|
||||
struct VertexInput
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
half3 normal : NORMAL;
|
||||
float2 uv0 : TEXCOORD0;
|
||||
float2 uv1 : TEXCOORD1;
|
||||
#if defined(DYNAMICLIGHTMAP_ON) || defined(UNITY_PASS_META)
|
||||
float2 uv2 : TEXCOORD2;
|
||||
#endif
|
||||
#ifdef _TANGENT_TO_WORLD
|
||||
half4 tangent : TANGENT;
|
||||
#endif
|
||||
#if defined(UNITY_VERTEX_INPUT_INSTANCE_ID)
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
#else
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
#endif
|
||||
};
|
||||
|
||||
float4 TexCoords(VertexInput v)
|
||||
{
|
||||
float4 texcoord;
|
||||
texcoord.xy = TRANSFORM_TEX(v.uv0, _MainTex); // Always source from uv0
|
||||
texcoord.zw = TRANSFORM_TEX(((_UVSec == 0) ? v.uv0 : v.uv1), _DetailAlbedoMap);
|
||||
return texcoord;
|
||||
}
|
||||
|
||||
half DetailMask(float2 uv)
|
||||
{
|
||||
return tex2D (_DetailMask, uv).a;
|
||||
}
|
||||
|
||||
#if defined(VERTEX_COLOR_ON)
|
||||
half3 Albedo(float4 texcoords, half4 color)
|
||||
#else
|
||||
half3 Albedo(float4 texcoords)
|
||||
#endif
|
||||
{
|
||||
half3 albedo = _Color.rgb * tex2D(_MainTex, texcoords.xy).rgb;
|
||||
|
||||
#if _DETAIL
|
||||
#if (SHADER_TARGET < 30)
|
||||
// SM20: instruction count limitation
|
||||
// SM20: no detail mask
|
||||
half mask = 1;
|
||||
#else
|
||||
half mask = DetailMask(texcoords.xy);
|
||||
#endif
|
||||
half3 detailAlbedo = tex2D (_DetailAlbedoMap, texcoords.zw).rgb;
|
||||
#if _DETAIL_MULX2
|
||||
albedo *= LerpWhiteTo (detailAlbedo * unity_ColorSpaceDouble.rgb, mask);
|
||||
#elif _DETAIL_MUL
|
||||
albedo *= LerpWhiteTo (detailAlbedo, mask);
|
||||
#elif _DETAIL_ADD
|
||||
albedo += detailAlbedo * mask;
|
||||
#elif _DETAIL_LERP
|
||||
albedo = lerp (albedo, detailAlbedo, mask);
|
||||
#endif
|
||||
#endif
|
||||
return albedo;
|
||||
}
|
||||
|
||||
half Alpha(float2 uv)
|
||||
{
|
||||
#if defined(_SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A)
|
||||
return _Color.a;
|
||||
#else
|
||||
return tex2D(_MainTex, uv).a * _Color.a;
|
||||
#endif
|
||||
}
|
||||
|
||||
half Occlusion(float2 uv)
|
||||
{
|
||||
#if (SHADER_TARGET < 30)
|
||||
// SM20: instruction count limitation
|
||||
// SM20: simpler occlusion
|
||||
return tex2D(_OcclusionMap, uv).r;
|
||||
#else
|
||||
half occ = tex2D(_OcclusionMap, uv).r;
|
||||
return LerpOneTo (occ, _OcclusionStrength);
|
||||
#endif
|
||||
}
|
||||
|
||||
half4 SpecularGloss(float2 uv)
|
||||
{
|
||||
half4 sg;
|
||||
#ifdef _SPECGLOSSMAP
|
||||
#if defined(_SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A)
|
||||
sg.rgb = tex2D(_SpecGlossMap, uv).rgb;
|
||||
sg.a = tex2D(_MainTex, uv).a;
|
||||
#else
|
||||
sg = tex2D(_SpecGlossMap, uv);
|
||||
#endif
|
||||
sg *= half4(_SpecColor.rgb, _Glossiness);
|
||||
#else
|
||||
sg.rgb = _SpecColor.rgb;
|
||||
#ifdef _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
sg.a = tex2D(_MainTex, uv).a * _Glossiness;
|
||||
#else
|
||||
sg.a = _Glossiness;
|
||||
#endif
|
||||
#endif
|
||||
return sg;
|
||||
}
|
||||
|
||||
half2 MetallicGloss(float2 uv)
|
||||
{
|
||||
half2 mg;
|
||||
|
||||
#ifdef _METALLICGLOSSMAP
|
||||
#ifdef _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
mg.r = tex2D(_MetallicGlossMap, uv).b;
|
||||
mg.g = tex2D(_MainTex, uv).a;
|
||||
#else
|
||||
mg = tex2D(_MetallicGlossMap, uv).bg;
|
||||
#endif
|
||||
mg *= half2(_Metallic, _Glossiness);
|
||||
#else
|
||||
mg.r = _Metallic;
|
||||
#ifdef _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
mg.g = tex2D(_MainTex, uv).a * _Glossiness;
|
||||
#else
|
||||
mg.g = _Glossiness;
|
||||
#endif
|
||||
#endif
|
||||
// it's roughness, not glossiness. invert it
|
||||
mg.g = 1.0f - mg.g;
|
||||
return mg;
|
||||
}
|
||||
|
||||
half2 MetallicRough(float2 uv)
|
||||
{
|
||||
half2 mg;
|
||||
|
||||
#if UNITY_SETUP_BRDF_INPUT == MetallicSetup
|
||||
#ifdef _METALLICGLOSSMAP
|
||||
mg = half2(_Metallic, _Glossiness) * tex2D(_MetallicGlossMap, uv).bg;
|
||||
#else
|
||||
mg = half2(_Metallic, _Glossiness);
|
||||
#endif
|
||||
#else
|
||||
#ifdef _SPECGLOSSMAP
|
||||
mg.r = _Metallic;
|
||||
mg.g = 1.0f - _Glossiness * tex2D(_SpecGlossMap, uv).a;
|
||||
#else
|
||||
mg = half2(Metallic, 1.0f - _Glossiness);
|
||||
#endif
|
||||
#endif
|
||||
return mg;
|
||||
}
|
||||
|
||||
half3 Emission(float2 uv)
|
||||
{
|
||||
#ifndef _EMISSION
|
||||
return 0;
|
||||
#else
|
||||
return tex2D(_EmissionMap, TRANSFORM_TEX(uv, _EmissionMap)).rgb * _EmissionColor.rgb;
|
||||
#endif
|
||||
}
|
||||
|
||||
// see this link regarding unpacking instructions:
|
||||
// https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/schema/material.normalTextureInfo.schema.json#L13
|
||||
half3 UnpackScaleNormalGLTF(half4 packednormal, half bumpScale)
|
||||
{
|
||||
float3 normal = packednormal.xyz * 2.0 - 1.0;
|
||||
normal.xy *= bumpScale;
|
||||
return normalize(normal);
|
||||
}
|
||||
|
||||
#ifdef _NORMALMAP
|
||||
half3 NormalInTangentSpace(float4 texcoords)
|
||||
{
|
||||
half3 normalTangent = UnpackScaleNormalGLTF(tex2D (_BumpMap, texcoords.xy), _BumpScale);
|
||||
|
||||
#if _DETAIL && defined(UNITY_ENABLE_DETAIL_NORMALMAP)
|
||||
half mask = DetailMask(texcoords.xy);
|
||||
half3 detailNormalTangent = UnpackScaleNormal(tex2D (_DetailNormalMap, texcoords.zw), _DetailNormalMapScale);
|
||||
#if _DETAIL_LERP
|
||||
normalTangent = lerp(
|
||||
normalTangent,
|
||||
detailNormalTangent,
|
||||
mask);
|
||||
#else
|
||||
normalTangent = lerp(
|
||||
normalTangent,
|
||||
BlendNormals(normalTangent, detailNormalTangent),
|
||||
mask);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return normalTangent;
|
||||
}
|
||||
#endif
|
||||
|
||||
float4 Parallax (float4 texcoords, half3 viewDir)
|
||||
{
|
||||
// D3D9/SM30 supports up to 16 samplers, skip the parallax map in case we exceed the limit
|
||||
#define EXCEEDS_D3D9_SM3_MAX_SAMPLER_COUNT (defined(LIGHTMAP_ON) && defined(SHADOWS_SHADOWMASK) && defined(SHADOWS_SCREEN) && defined(_NORMALMAP) && \
|
||||
defined(_EMISSION) && defined(_DETAIL) && (defined(_METALLICGLOSSMAP) || defined(_SPECGLOSSMAP)))
|
||||
|
||||
#if !defined(_PARALLAXMAP) || (SHADER_TARGET < 30) || (defined(SHADER_API_D3D9) && EXCEEDS_D3D9_SM3_MAX_SAMPLER_COUNT)
|
||||
// SM20: instruction count limitation
|
||||
// SM20: no parallax
|
||||
return texcoords;
|
||||
#else
|
||||
half h = tex2D (_ParallaxMap, texcoords.xy).g;
|
||||
float2 offset = ParallaxOffset1Step (h, _Parallax, viewDir);
|
||||
return float4(texcoords.xy + offset, texcoords.zw + offset);
|
||||
#endif
|
||||
|
||||
#undef EXCEEDS_D3D9_SM3_MAX_SAMPLER_COUNT
|
||||
}
|
||||
|
||||
#endif // UNITY_STANDARD_INPUT_INCLUDED
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2e41f417e6564ab40b7c213e7ebe5183
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,191 @@
|
||||
// Upgrade NOTE: replaced 'UNITY_INSTANCE_ID' with 'UNITY_VERTEX_INPUT_INSTANCE_ID'
|
||||
|
||||
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
|
||||
|
||||
#ifndef UNITY_STANDARD_SHADOW_INCLUDED
|
||||
#define UNITY_STANDARD_SHADOW_INCLUDED
|
||||
|
||||
// NOTE: had to split shadow functions into separate file,
|
||||
// otherwise compiler gives trouble with LIGHTING_COORDS macro (in UnityStandardCore.cginc)
|
||||
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "UnityStandardConfig.cginc"
|
||||
#include "UnityStandardUtils.cginc"
|
||||
|
||||
#if (defined(_ALPHABLEND_ON) || defined(_ALPHAPREMULTIPLY_ON)) && defined(UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS)
|
||||
#define UNITY_STANDARD_USE_DITHER_MASK 1
|
||||
#endif
|
||||
|
||||
// Need to output UVs in shadow caster, since we need to sample texture and do clip/dithering based on it
|
||||
#if defined(_ALPHATEST_ON) || defined(_ALPHABLEND_ON) || defined(_ALPHAPREMULTIPLY_ON)
|
||||
#define UNITY_STANDARD_USE_SHADOW_UVS 1
|
||||
#endif
|
||||
|
||||
// Has a non-empty shadow caster output struct (it's an error to have empty structs on some platforms...)
|
||||
#if !defined(V2F_SHADOW_CASTER_NOPOS_IS_EMPTY) || defined(UNITY_STANDARD_USE_SHADOW_UVS)
|
||||
#define UNITY_STANDARD_USE_SHADOW_OUTPUT_STRUCT 1
|
||||
#endif
|
||||
|
||||
#ifdef UNITY_STEREO_INSTANCING_ENABLED
|
||||
#define UNITY_STANDARD_USE_STEREO_SHADOW_OUTPUT_STRUCT 1
|
||||
#endif
|
||||
|
||||
|
||||
half4 _Color;
|
||||
half _Cutoff;
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_ST;
|
||||
#ifdef UNITY_STANDARD_USE_DITHER_MASK
|
||||
sampler3D _DitherMaskLOD;
|
||||
#endif
|
||||
|
||||
// Handle PremultipliedAlpha from Fade or Transparent shading mode
|
||||
half4 _SpecColor;
|
||||
half _Metallic;
|
||||
#ifdef _SPECGLOSSMAP
|
||||
sampler2D _SpecGlossMap;
|
||||
#endif
|
||||
#ifdef _METALLICGLOSSMAP
|
||||
sampler2D _MetallicGlossMap;
|
||||
#endif
|
||||
|
||||
#if defined(UNITY_STANDARD_USE_SHADOW_UVS) && defined(_PARALLAXMAP)
|
||||
sampler2D _ParallaxMap;
|
||||
half _Parallax;
|
||||
#endif
|
||||
|
||||
half MetallicSetup_ShadowGetOneMinusReflectivity(half2 uv)
|
||||
{
|
||||
half metallicity = _Metallic;
|
||||
#ifdef _METALLICGLOSSMAP
|
||||
metallicity *= tex2D(_MetallicGlossMap, uv).b;
|
||||
#endif
|
||||
return OneMinusReflectivityFromMetallic(metallicity);
|
||||
}
|
||||
|
||||
half SpecularSetup_ShadowGetOneMinusReflectivity(half2 uv)
|
||||
{
|
||||
half3 specColor = _SpecColor.rgb;
|
||||
#ifdef _SPECGLOSSMAP
|
||||
specColor *= tex2D(_SpecGlossMap, uv).rgb;
|
||||
#endif
|
||||
return (1 - SpecularStrength(specColor));
|
||||
}
|
||||
|
||||
// SHADOW_ONEMINUSREFLECTIVITY(): workaround to get one minus reflectivity based on UNITY_SETUP_BRDF_INPUT
|
||||
#define SHADOW_JOIN2(a, b) a##b
|
||||
#define SHADOW_JOIN(a, b) SHADOW_JOIN2(a,b)
|
||||
#define SHADOW_ONEMINUSREFLECTIVITY SHADOW_JOIN(UNITY_SETUP_BRDF_INPUT, _ShadowGetOneMinusReflectivity)
|
||||
|
||||
struct VertexInput
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
float2 uv0 : TEXCOORD0;
|
||||
#if defined(UNITY_STANDARD_USE_SHADOW_UVS) && defined(_PARALLAXMAP)
|
||||
half4 tangent : TANGENT;
|
||||
#endif
|
||||
#if defined(UNITY_VERTEX_INPUT_INSTANCE_ID)
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
#else
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef UNITY_STANDARD_USE_SHADOW_OUTPUT_STRUCT
|
||||
struct VertexOutputShadowCaster
|
||||
{
|
||||
V2F_SHADOW_CASTER_NOPOS
|
||||
#if defined(UNITY_STANDARD_USE_SHADOW_UVS)
|
||||
float2 tex : TEXCOORD1;
|
||||
|
||||
#if defined(_PARALLAXMAP)
|
||||
half4 tangentToWorldAndParallax[3]: TEXCOORD2; // [3x3:tangentToWorld | 1x3:viewDirForParallax]
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef UNITY_STANDARD_USE_STEREO_SHADOW_OUTPUT_STRUCT
|
||||
struct VertexOutputStereoShadowCaster
|
||||
{
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
#endif
|
||||
|
||||
// We have to do these dances of outputting SV_POSITION separately from the vertex shader,
|
||||
// and inputting VPOS in the pixel shader, since they both map to "POSITION" semantic on
|
||||
// some platforms, and then things don't go well.
|
||||
|
||||
|
||||
void vertShadowCaster (VertexInput v,
|
||||
#ifdef UNITY_STANDARD_USE_SHADOW_OUTPUT_STRUCT
|
||||
out VertexOutputShadowCaster o,
|
||||
#endif
|
||||
#ifdef UNITY_STANDARD_USE_STEREO_SHADOW_OUTPUT_STRUCT
|
||||
out VertexOutputStereoShadowCaster os,
|
||||
#endif
|
||||
out float4 opos : SV_POSITION)
|
||||
{
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
#ifdef UNITY_STANDARD_USE_STEREO_SHADOW_OUTPUT_STRUCT
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(os);
|
||||
#endif
|
||||
TRANSFER_SHADOW_CASTER_NOPOS(o,opos)
|
||||
#if defined(UNITY_STANDARD_USE_SHADOW_UVS)
|
||||
o.tex = TRANSFORM_TEX(v.uv0, _MainTex);
|
||||
|
||||
#ifdef _PARALLAXMAP
|
||||
TANGENT_SPACE_ROTATION;
|
||||
half3 viewDirForParallax = mul (rotation, ObjSpaceViewDir(v.vertex));
|
||||
o.tangentToWorldAndParallax[0].w = viewDirForParallax.x;
|
||||
o.tangentToWorldAndParallax[1].w = viewDirForParallax.y;
|
||||
o.tangentToWorldAndParallax[2].w = viewDirForParallax.z;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
half4 fragShadowCaster (
|
||||
#ifdef UNITY_STANDARD_USE_SHADOW_OUTPUT_STRUCT
|
||||
VertexOutputShadowCaster i
|
||||
#endif
|
||||
#ifdef UNITY_STANDARD_USE_DITHER_MASK
|
||||
, UNITY_VPOS_TYPE vpos : VPOS
|
||||
#endif
|
||||
) : SV_Target
|
||||
{
|
||||
#if defined(UNITY_STANDARD_USE_SHADOW_UVS)
|
||||
#if defined(_PARALLAXMAP) && (SHADER_TARGET >= 30)
|
||||
//On d3d9 parallax can also be disabled on the fwd pass when too many sampler are used. See EXCEEDS_D3D9_SM3_MAX_SAMPLER_COUNT. Ideally we should account for that here as well.
|
||||
half3 viewDirForParallax = normalize( half3(i.tangentToWorldAndParallax[0].w,i.tangentToWorldAndParallax[1].w,i.tangentToWorldAndParallax[2].w) );
|
||||
fixed h = tex2D (_ParallaxMap, i.tex.xy).g;
|
||||
half2 offset = ParallaxOffset1Step (h, _Parallax, viewDirForParallax);
|
||||
i.tex.xy += offset;
|
||||
#endif
|
||||
|
||||
half alpha = tex2D(_MainTex, i.tex).a * _Color.a;
|
||||
#if defined(_ALPHATEST_ON)
|
||||
clip (alpha - _Cutoff);
|
||||
#endif
|
||||
#if defined(_ALPHABLEND_ON) || defined(_ALPHAPREMULTIPLY_ON)
|
||||
#if defined(_ALPHAPREMULTIPLY_ON)
|
||||
half outModifiedAlpha;
|
||||
PreMultiplyAlpha(half3(0, 0, 0), alpha, SHADOW_ONEMINUSREFLECTIVITY(i.tex), outModifiedAlpha);
|
||||
alpha = outModifiedAlpha;
|
||||
#endif
|
||||
#if defined(UNITY_STANDARD_USE_DITHER_MASK)
|
||||
// Use dither mask for alpha blended shadows, based on pixel position xy
|
||||
// and alpha level. Our dither texture is 4x4x16.
|
||||
half alphaRef = tex3D(_DitherMaskLOD, float3(vpos.xy*0.25,alpha*0.9375)).a;
|
||||
clip (alphaRef - 0.01);
|
||||
#else
|
||||
clip (alpha - _Cutoff);
|
||||
#endif
|
||||
#endif
|
||||
#endif // #if defined(UNITY_STANDARD_USE_SHADOW_UVS)
|
||||
|
||||
SHADOW_CASTER_FRAGMENT(i)
|
||||
}
|
||||
|
||||
#endif // UNITY_STANDARD_SHADOW_INCLUDED
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 186b7b45309a8964e99df9437a41271e
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,63 @@
|
||||
Shader "GLTF/Unlit"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_Color("Base Color Factor", Color) = (1,1,1,1)
|
||||
_MainTex("Base Color Texture", 2D) = "white" {}
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
|
||||
|
||||
Lighting Off
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile_fog
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 color : COLOR;
|
||||
UNITY_FOG_COORDS(1)
|
||||
float4 vertex : SV_POSITION;
|
||||
};
|
||||
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_ST;
|
||||
float4 _Color;
|
||||
|
||||
v2f vert (appdata v)
|
||||
{
|
||||
v2f o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
|
||||
o.color = v.color;
|
||||
UNITY_TRANSFER_FOG(o,o.vertex);
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target
|
||||
{
|
||||
fixed4 col = tex2D(_MainTex, i.uv) * _Color * i.color;
|
||||
UNITY_APPLY_FOG(i.fogCoord, col);
|
||||
return col;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
FallBack "Unlit/Color"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4d20effaf200f604db8b73f8e6a2e386
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,134 @@
|
||||
#ifndef VERTEX_COLOR_INCLUDED
|
||||
#define VERTEX_COLOR_INCLUDED
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "UnityStandardInput.cginc"
|
||||
#include "UnityStandardCoreForward.cginc"
|
||||
|
||||
// Structure for holding the return type of vertBase and the color information. For vertBase definition see
|
||||
// C:\Program Files\Unity\Hub\Editor\2018.4.14f1\Editor\Data\CGIncludes\UnityStandardCoreForward.cginc
|
||||
struct WrappedVertexOutput {
|
||||
#if UNITY_STANDARD_SIMPLE
|
||||
VertexOutputBaseSimple innerValue;
|
||||
#else
|
||||
VertexOutputForwardBase innerValue;
|
||||
#endif
|
||||
fixed4 color : COLOR;
|
||||
};
|
||||
|
||||
// Simple replacement for vertBase that captures the additional color information needed later
|
||||
WrappedVertexOutput vert_vcol(appdata_full v)
|
||||
{
|
||||
// Save the color information
|
||||
WrappedVertexOutput o;
|
||||
o.color = v.color;
|
||||
|
||||
// Forward this call to the default vertBase
|
||||
VertexInput vi
|
||||
UNITY_TRANSFER_INSTANCE_ID(v, vi);
|
||||
vi.vertex = v.vertex;
|
||||
vi.normal = v.normal;
|
||||
vi.uv0 = v.texcoord;
|
||||
vi.uv1 = v.texcoord1;
|
||||
#if defined(DYNAMICLIGHTMAP_ON) || defined(UNITY_PASS_META)
|
||||
vi.uv2 = v.tetcoord2;
|
||||
#endif
|
||||
#ifdef _TANGENT_TO_WORLD
|
||||
vi.tangent = v.tangent;
|
||||
#endif
|
||||
o.innerValue = vertBase(vi);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
#if UNITY_STANDARD_SIMPLE
|
||||
half4 frag_vcol(WrappedVertexOutput wvo) : SV_Target
|
||||
{
|
||||
// Put the original output from vertBase in a variable called 'i' so the code can be cleanly
|
||||
// copy/pasted, as well as for any macros (e.g. FRAGMENT_SETUP) that assume that naming convention.
|
||||
VertexOutputBaseSimple i = wvo.innerValue;
|
||||
|
||||
// The following section is copied from the fragBase implementation, found in
|
||||
// C:\Program Files\Unity\Hub\Editor\2018.4.14f1\Editor\Data\CGIncludes\UnityStandardCoreForwardSimple.cginc,
|
||||
// with the name fragForwardBaseSimpleInternal. It has been modified to
|
||||
// include a section to modify the diffColor after it is calculated but before
|
||||
// it is used in the remaining calculations.
|
||||
UNITY_APPLY_DITHER_CROSSFADE(i.pos.xy);
|
||||
|
||||
FragmentCommonData s = FragmentSetupSimple(i);
|
||||
|
||||
UnityLight mainLight = MainLightSimple(i, s);
|
||||
|
||||
#if !defined(LIGHTMAP_ON) && defined(_NORMALMAP)
|
||||
half ndotl = saturate(dot(s.tangentSpaceNormal, i.tangentSpaceLightDir));
|
||||
#else
|
||||
half ndotl = saturate(dot(s.normalWorld, mainLight.dir));
|
||||
#endif
|
||||
|
||||
//we can't have worldpos here (not enough interpolator on SM 2.0) so no shadow fade in that case.
|
||||
half shadowMaskAttenuation = UnitySampleBakedOcclusion(i.ambientOrLightmapUV, 0);
|
||||
half realtimeShadowAttenuation = SHADOW_ATTENUATION(i);
|
||||
half atten = UnityMixRealtimeAndBakedShadows(realtimeShadowAttenuation, shadowMaskAttenuation, 0);
|
||||
|
||||
// Start: Modified section
|
||||
s.diffColor.x *= wvo.color.x;
|
||||
s.diffColor.y *= wvo.color.y;
|
||||
s.diffColor.z *= wvo.color.z;
|
||||
s.alpha *= wvo.color.a;
|
||||
// End: Modified section
|
||||
|
||||
half occlusion = Occlusion(i.tex.xy);
|
||||
half rl = dot(REFLECTVEC_FOR_SPECULAR(i, s), LightDirForSpecular(i, mainLight));
|
||||
|
||||
UnityGI gi = FragmentGI(s, occlusion, i.ambientOrLightmapUV, atten, mainLight);
|
||||
half3 attenuatedLightColor = gi.light.color * ndotl;
|
||||
|
||||
half3 c = BRDF3_Indirect(s.diffColor, s.specColor, gi.indirect, PerVertexGrazingTerm(i, s), PerVertexFresnelTerm(i));
|
||||
c += BRDF3DirectSimple(s.diffColor, s.specColor, s.smoothness, rl) * attenuatedLightColor;
|
||||
c += Emission(i.tex.xy);
|
||||
|
||||
UNITY_APPLY_FOG(i.fogCoord, c);
|
||||
|
||||
return OutputForward(half4(c, 1), s.alpha);
|
||||
}
|
||||
#else
|
||||
half4 frag_vcol(WrappedVertexOutput wvo) : SV_Target
|
||||
{
|
||||
// Put the original output from vertBase in a variable called 'i' so the code can be cleanly
|
||||
// copy/pasted, as well as for any macros (e.g. FRAGMENT_SETUP) that assume that naming convention.
|
||||
VertexOutputForwardBase i = wvo.innerValue;
|
||||
|
||||
// The following section is copied from the fragBase implementation, found in
|
||||
// C:\Program Files\Unity\Hub\Editor\2018.4.14f1\Editor\Data\CGIncludes\UnityStandardCore.cginc,
|
||||
// with the name fragForwardBaseInternal. It has been modified to
|
||||
// include a section to modify the diffColor after it is calculated but before
|
||||
// it is used in the remaining calculations.
|
||||
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);
|
||||
|
||||
// Start: Modified section
|
||||
s.diffColor.x *= wvo.color.x;
|
||||
s.diffColor.y *= wvo.color.y;
|
||||
s.diffColor.z *= wvo.color.z;
|
||||
s.alpha *= wvo.color.a;
|
||||
// End: Modified section
|
||||
|
||||
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 += Emission(i.tex.xy);
|
||||
|
||||
UNITY_EXTRACT_FOG_FROM_EYE_VEC(i);
|
||||
UNITY_APPLY_FOG(_unity_fogCoord, c.rgb);
|
||||
return OutputForward(c, s.alpha);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a7df7fe42cec8834bbf64612f5d683b0
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user