您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
218 行
9.1 KiB
218 行
9.1 KiB
Shader "HDRenderPipeline/Unlit"
|
|
{
|
|
Properties
|
|
{
|
|
// Be careful, do not change the name here to _Color. It will conflict with the "fake" parameters (see end of properties) required for GI.
|
|
_UnlitColor("Color", Color) = (1,1,1,1)
|
|
_UnlitColorMap("ColorMap", 2D) = "white" {}
|
|
|
|
_EmissiveColor("EmissiveColor", Color) = (1, 1, 1)
|
|
_EmissiveColorMap("EmissiveColorMap", 2D) = "white" {}
|
|
_EmissiveIntensity("EmissiveIntensity", Float) = 0
|
|
|
|
_DistortionVectorMap("DistortionVectorMap", 2D) = "black" {}
|
|
[ToggleUI] _DistortionEnable("Enable Distortion", Float) = 0.0
|
|
[ToggleUI] _DistortionOnly("Distortion Only", Float) = 0.0
|
|
[ToggleUI] _DistortionDepthTest("Distortion Depth Test Enable", Float) = 1.0
|
|
[Enum(Add, 0, Multiply, 1)] _DistortionBlendMode("Distortion Blend Mode", Int) = 0
|
|
[HideInInspector] _DistortionSrcBlend("Distortion Blend Src", Int) = 0
|
|
[HideInInspector] _DistortionDstBlend("Distortion Blend Dst", Int) = 0
|
|
[HideInInspector] _DistortionBlurSrcBlend("Distortion Blur Blend Src", Int) = 0
|
|
[HideInInspector] _DistortionBlurDstBlend("Distortion Blur Blend Dst", Int) = 0
|
|
[HideInInspector] _DistortionBlurBlendMode("Distortion Blur Blend Mode", Int) = 0
|
|
_DistortionScale("Distortion Scale", Float) = 1
|
|
_DistortionVectorScale("Distortion Vector Scale", Float) = 2
|
|
_DistortionVectorBias("Distortion Vector Bias", Float) = -1
|
|
_DistortionBlurScale("Distortion Blur Scale", Float) = 1
|
|
_DistortionBlurRemapMin("DistortionBlurRemapMin", Float) = 0.0
|
|
_DistortionBlurRemapMax("DistortionBlurRemapMax", Float) = 1.0
|
|
|
|
// Transparency
|
|
[ToggleUI] _PreRefractionPass("PreRefractionPass", Float) = 0.0
|
|
|
|
[ToggleUI] _AlphaCutoffEnable("Alpha Cutoff Enable", Float) = 0.0
|
|
_AlphaCutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
|
|
_TransparentSortPriority("_TransparentSortPriority", Float) = 0
|
|
|
|
// Blending state
|
|
[HideInInspector] _SurfaceType("__surfacetype", Float) = 0.0
|
|
[HideInInspector] _BlendMode("__blendmode", Float) = 0.0
|
|
[HideInInspector] _SrcBlend("__src", Float) = 1.0
|
|
[HideInInspector] _DstBlend("__dst", Float) = 0.0
|
|
[HideInInspector] _ZWrite("__zw", Float) = 1.0
|
|
[HideInInspector] _CullMode("__cullmode", Float) = 2.0
|
|
[HideInInspector] _ZTestModeDistortion("_ZTestModeDistortion", Int) = 8
|
|
|
|
[ToggleUI] _EnableFogOnTransparent("Enable Fog", Float) = 0.0
|
|
[ToggleUI] _DoubleSidedEnable("Double sided enable", Float) = 0.0
|
|
|
|
// Stencil state
|
|
[HideInInspector] _StencilRef("_StencilRef", Int) = 2 // StencilLightingUsage.RegularLighting (fixed at compile time)
|
|
[HideInInspector] _StencilWriteMask("_StencilWriteMask", Int) = 7 // StencilMask.Lighting (fixed at compile time)
|
|
[HideInInspector] _StencilRefMV("_StencilRefMV", Int) = 128 // StencilLightingUsage.RegularLighting (fixed at compile time)
|
|
[HideInInspector] _StencilWriteMaskMV("_StencilWriteMaskMV", Int) = 128 // StencilMask.ObjectsVelocity (fixed at compile time)
|
|
|
|
// Caution: C# code in BaseLitUI.cs call LightmapEmissionFlagsProperty() which assume that there is an existing "_EmissionColor"
|
|
// value that exist to identify if the GI emission need to be enabled.
|
|
// In our case we don't use such a mechanism but need to keep the code quiet. We declare the value and always enable it.
|
|
// TODO: Fix the code in legacy unity so we can customize the beahvior for GI
|
|
_EmissionColor("Color", Color) = (1, 1, 1)
|
|
|
|
// HACK: GI Baking system relies on some properties existing in the shader ("_MainTex", "_Cutoff" and "_Color") for opacity handling, so we need to store our version of those parameters in the hard-coded name the GI baking system recognizes.
|
|
_MainTex("Albedo", 2D) = "white" {}
|
|
_Color("Color", Color) = (1,1,1,1)
|
|
_Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
|
|
}
|
|
|
|
HLSLINCLUDE
|
|
|
|
#pragma target 4.5
|
|
#pragma only_renderers d3d11 ps4 xboxone vulkan metal switch
|
|
|
|
//-------------------------------------------------------------------------------------
|
|
// Variant
|
|
//-------------------------------------------------------------------------------------
|
|
|
|
#pragma shader_feature _ALPHATEST_ON
|
|
// #pragma shader_feature _DOUBLESIDED_ON - We have no lighting, so no need to have this combination for shader, the option will just disable backface culling
|
|
|
|
#pragma shader_feature _EMISSIVE_COLOR_MAP
|
|
|
|
// Keyword for transparent
|
|
#pragma shader_feature _SURFACE_TYPE_TRANSPARENT
|
|
#pragma shader_feature _ _BLENDMODE_ALPHA _BLENDMODE_ADD _BLENDMODE_PRE_MULTIPLY
|
|
#pragma shader_feature _ENABLE_FOG_ON_TRANSPARENT
|
|
|
|
//enable GPU instancing support
|
|
#pragma multi_compile_instancing
|
|
|
|
//-------------------------------------------------------------------------------------
|
|
// Define
|
|
//-------------------------------------------------------------------------------------
|
|
|
|
#define UNITY_MATERIAL_UNLIT // Need to be define before including Material.hlsl
|
|
|
|
//-------------------------------------------------------------------------------------
|
|
// Include
|
|
//-------------------------------------------------------------------------------------
|
|
|
|
#include "CoreRP/ShaderLibrary/Common.hlsl"
|
|
#include "../../ShaderVariables.hlsl"
|
|
#include "../../ShaderPass/FragInputs.hlsl"
|
|
#include "../../ShaderPass/ShaderPass.cs.hlsl"
|
|
|
|
//-------------------------------------------------------------------------------------
|
|
// variable declaration
|
|
//-------------------------------------------------------------------------------------
|
|
|
|
#include "../../Material/Unlit/UnlitProperties.hlsl"
|
|
|
|
// All our shaders use same name for entry point
|
|
#pragma vertex Vert
|
|
#pragma fragment Frag
|
|
|
|
ENDHLSL
|
|
|
|
SubShader
|
|
{
|
|
// This tags allow to use the shader replacement features
|
|
Tags{ "RenderPipeline" = "HDRenderPipeline" "RenderType" = "HDUnlitShader" }
|
|
|
|
// Caution: The outline selection in the editor use the vertex shader/hull/domain shader of the first pass declare. So it should not be the meta pass.
|
|
|
|
Pass
|
|
{
|
|
Name "Depth prepass"
|
|
Tags{ "LightMode" = "DepthForwardOnly" }
|
|
|
|
Cull[_CullMode]
|
|
|
|
ZWrite On
|
|
|
|
HLSLPROGRAM
|
|
|
|
#define SHADERPASS SHADERPASS_DEPTH_ONLY
|
|
#include "../../Material/Material.hlsl"
|
|
#include "ShaderPass/UnlitDepthPass.hlsl"
|
|
#include "UnlitData.hlsl"
|
|
#include "../../ShaderPass/ShaderPassDepthOnly.hlsl"
|
|
|
|
ENDHLSL
|
|
}
|
|
|
|
// Unlit shader always render in forward
|
|
Pass
|
|
{
|
|
Name "Forward Unlit"
|
|
Tags { "LightMode" = "ForwardOnly" }
|
|
|
|
Blend [_SrcBlend] [_DstBlend]
|
|
ZWrite [_ZWrite]
|
|
Cull [_CullMode]
|
|
|
|
HLSLPROGRAM
|
|
|
|
#pragma multi_compile _ DEBUG_DISPLAY
|
|
|
|
#ifdef DEBUG_DISPLAY
|
|
#include "../../Debug/DebugDisplay.hlsl"
|
|
#endif
|
|
|
|
#define SHADERPASS SHADERPASS_FORWARD_UNLIT
|
|
#include "../../Material/Material.hlsl"
|
|
#include "ShaderPass/UnlitSharePass.hlsl"
|
|
#include "UnlitData.hlsl"
|
|
#include "../../ShaderPass/ShaderPassForwardUnlit.hlsl"
|
|
|
|
ENDHLSL
|
|
}
|
|
|
|
// Extracts information for lightmapping, GI (emission, albedo, ...)
|
|
// This pass it not used during regular rendering.
|
|
Pass
|
|
{
|
|
Name "META"
|
|
Tags{ "LightMode" = "Meta" }
|
|
|
|
Cull Off
|
|
|
|
HLSLPROGRAM
|
|
|
|
// Lightmap memo
|
|
// DYNAMICLIGHTMAP_ON is used when we have an "enlighten lightmap" ie a lightmap updated at runtime by enlighten.This lightmap contain indirect lighting from realtime lights and realtime emissive material.Offline baked lighting(from baked material / light,
|
|
// both direct and indirect lighting) will hand up in the "regular" lightmap->LIGHTMAP_ON.
|
|
|
|
#define SHADERPASS SHADERPASS_LIGHT_TRANSPORT
|
|
#include "../../Material/Material.hlsl"
|
|
#include "ShaderPass/UnlitSharePass.hlsl"
|
|
#include "UnlitData.hlsl"
|
|
#include "../../ShaderPass/ShaderPassLightTransport.hlsl"
|
|
|
|
ENDHLSL
|
|
}
|
|
|
|
Pass
|
|
{
|
|
Name "Distortion" // Name is not used
|
|
Tags { "LightMode" = "DistortionVectors" } // This will be only for transparent object based on the RenderQueue index
|
|
|
|
Blend [_DistortionSrcBlend] [_DistortionDstBlend], [_DistortionBlurSrcBlend] [_DistortionBlurDstBlend]
|
|
BlendOp Add, [_DistortionBlurBlendOp]
|
|
ZTest [_ZTestModeDistortion]
|
|
ZWrite off
|
|
Cull [_CullMode]
|
|
|
|
HLSLPROGRAM
|
|
|
|
#define SHADERPASS SHADERPASS_DISTORTION
|
|
#include "../../Material/Material.hlsl"
|
|
#include "ShaderPass/UnlitDistortionPass.hlsl"
|
|
#include "UnlitData.hlsl"
|
|
#include "../../ShaderPass/ShaderPassDistortion.hlsl"
|
|
|
|
ENDHLSL
|
|
}
|
|
}
|
|
|
|
CustomEditor "Experimental.Rendering.HDPipeline.UnlitGUI"
|
|
}
|