336 lines
9.6 KiB
Plaintext
336 lines
9.6 KiB
Plaintext
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
|
|
// This code in no way belongs to BrainFailProductions. I have just made a small change to make
|
|
// it work with texture arrays
|
|
|
|
Shader "BatchFewStandardSpecular"
|
|
{
|
|
Properties
|
|
{
|
|
_AttrImg("Attributes Texture/Image", 2D) = "black" {}
|
|
|
|
|
|
_MainTex("Albedo", 2DArray) = "white" {}
|
|
|
|
[Enum(Specular Alpha,0,Albedo Alpha,1)] _SmoothnessTextureChannel ("Smoothness texture channel", Float) = 0
|
|
|
|
_SpecGlossMap("Specular", 2DArray) = "white" {}
|
|
[ToggleOff] _SpecularHighlights("Specular Highlights", Float) = 1.0
|
|
[ToggleOff] _GlossyReflections("Glossy Reflections", Float) = 1.0
|
|
|
|
_BumpMap("Normal Map", 2DArray) = "bump" {}
|
|
|
|
[Enum(None,0,Offset,1, Deep, 2)] _ParallaxMode ("None, Parallax Offset Mapping, or Parallax Occlusion Mapping", Float) = 0
|
|
_ParallaxMap ("Height Map", 2DArray) = "black" {}
|
|
_ParallaxSteps("Parallax Steps", Range(8, 128)) = 32
|
|
|
|
_OcclusionMap("Occlusion", 2DArray) = "white" {}
|
|
|
|
[Enum(None,0,Color,1,Array,2)] _EmissionMode ("No emission, use color value, or use the array", Float) = 0
|
|
_EmissionMap("Emission", 2DArray) = "white" {}
|
|
|
|
_DetailMask("Detail Mask", 2DArray) = "white" {}
|
|
|
|
_DetailAlbedoMap("Detail Albedo x2", 2D) = "grey" {}
|
|
_DetailNormalMap("Normal Map", 2DArray) = "bump" {}
|
|
|
|
_DetailAlbedoSingle("Detail Albedo x2", 2D) = "grey" {}
|
|
_DetailNormalSingle("Normal Map", 2D) = "bump" {}
|
|
|
|
[Enum(UV0,0,UV1,1)] _UVSec ("UV Set for secondary textures", Float) = 0
|
|
|
|
[Enum(Array,0,Single,1)] _DetailMode ("Use a texture array for detail textures, or a single set of 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]
|
|
|
|
CGPROGRAM
|
|
#pragma target 3.0
|
|
|
|
// -------------------------------------
|
|
|
|
#pragma shader_feature _NORMALMAP
|
|
#pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
|
|
#pragma shader_feature _ _EMISSION _EMISSION_COLOR
|
|
#pragma shader_feature _SPECGLOSSMAP
|
|
#pragma shader_feature ___ _DETAIL_MULX2 _DETAIL_SINGLE
|
|
#pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
|
#pragma shader_feature _ _SPECULARHIGHLIGHTS_OFF
|
|
#pragma shader_feature _ _GLOSSYREFLECTIONS_OFF
|
|
#pragma shader_feature _PARALLAXMAP _POM
|
|
|
|
#pragma multi_compile_fwdbase
|
|
#pragma multi_compile_fog
|
|
#pragma multi_compile_instancing
|
|
|
|
#pragma vertex vertBase
|
|
#pragma fragment fragBase
|
|
#include "Includes/BatchFewStandardCoreForward.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 _SPECGLOSSMAP
|
|
#pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
|
#pragma shader_feature _ _SPECULARHIGHLIGHTS_OFF
|
|
#pragma shader_feature ___ _DETAIL_MULX2 _DETAIL_SINGLE
|
|
#pragma shader_feature _PARALLAXMAP _POM
|
|
|
|
#pragma multi_compile_fwdadd_fullshadows
|
|
#pragma multi_compile_fog
|
|
|
|
#pragma vertex vertAdd
|
|
#pragma fragment fragAdd
|
|
#include "Includes/BatchFewStandardCoreForward.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 _SPECGLOSSMAP
|
|
#pragma shader_feature _PARALLAXMAP _POM
|
|
#pragma multi_compile_shadowcaster
|
|
#pragma multi_compile_instancing
|
|
|
|
#pragma vertex vertShadowCaster
|
|
#pragma fragment fragShadowCaster
|
|
|
|
#include "Includes/BatchFewStandardShadow.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 _EMISSION_COLOR
|
|
#pragma shader_feature _SPECGLOSSMAP
|
|
#pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
|
#pragma shader_feature _ _SPECULARHIGHLIGHTS_OFF
|
|
#pragma shader_feature ___ _DETAIL_MULX2 _DETAIL_SINGLE
|
|
#pragma shader_feature _PARALLAXMAP _POM
|
|
|
|
#pragma multi_compile_prepassfinal
|
|
#pragma multi_compile_instancing
|
|
|
|
#pragma vertex vertDeferred
|
|
#pragma fragment fragDeferred
|
|
|
|
#include "Includes/BatchFewStandardCore.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 _EMISSION_COLOR
|
|
#pragma shader_feature _SPECGLOSSMAP
|
|
#pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
|
#pragma shader_feature ___ _DETAIL_MULX2 _DETAIL_SINGLE
|
|
#pragma shader_feature EDITOR_VISUALIZATION
|
|
|
|
#include "Includes/BatchFewStandardMeta.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]
|
|
|
|
CGPROGRAM
|
|
#pragma target 2.0
|
|
|
|
#pragma shader_feature _NORMALMAP
|
|
#pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
|
|
#pragma shader_feature _ _EMISSION _EMISSION_COLOR
|
|
#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 _DETAIL_SINGLE
|
|
// 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 vertBase
|
|
#pragma fragment fragBase
|
|
#include "Includes/BatchFewStandardCoreForward.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 _SPECGLOSSMAP
|
|
#pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
|
#pragma shader_feature _ _SPECULARHIGHLIGHTS_OFF
|
|
#pragma shader_feature ___ _DETAIL_MULX2 _DETAIL_SINGLE
|
|
// 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 "Includes/BatchFewStandardCoreForward.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 _SPECGLOSSMAP
|
|
#pragma skip_variants SHADOWS_SOFT
|
|
#pragma multi_compile_shadowcaster
|
|
|
|
#pragma vertex vertShadowCaster
|
|
#pragma fragment fragShadowCaster
|
|
|
|
#include "Includes/BatchFewStandardShadow.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 _EMISSION_COLOR
|
|
#pragma shader_feature _SPECGLOSSMAP
|
|
#pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
|
#pragma shader_feature ___ _DETAIL_MULX2 _DETAIL_SINGLE
|
|
#pragma shader_feature EDITOR_VISUALIZATION
|
|
|
|
#include "Includes/BatchFewStandardMeta.cginc"
|
|
ENDCG
|
|
}
|
|
}
|
|
|
|
FallBack "VertexLit"
|
|
CustomEditor "BrainFailProductions.BatchFew.BatchFewShaderGUI"
|
|
}
|