Browse Source
Replaced previous Lightmapped shader with a generic Quake uber-shader, which is based on the Simple Unlit shader and allows choosing between lightmapped or blinn/phong lit, as well as emissive properties. Applied this to both the Entity and World materials, which is another step towards creating a unified and authentic look.
readme
Replaced previous Lightmapped shader with a generic Quake uber-shader, which is based on the Simple Unlit shader and allows choosing between lightmapped or blinn/phong lit, as well as emissive properties. Applied this to both the Entity and World materials, which is another step towards creating a unified and authentic look.
readme
11 changed files with 339 additions and 343 deletions
-
9Assets/Scripts/VisualStyle.cs
-
303Assets/Shaders/Lightmapped.shader
-
28Assets/Shaders/LightmappedInput.hlsl
-
121Assets/Shaders/Quake.shader
-
2Assets/Shaders/Quake.shader.meta
-
140Assets/Shaders/QuakeForwardPass.hlsl
-
2Assets/Shaders/QuakeForwardPass.hlsl.meta
-
50Assets/Shaders/QuakeInput.hlsl
-
10Assets/Shaders/QuakeInput.hlsl.meta
-
13Assets/Styles/GLQuake/Materials/GLQuake_Entity.mat
-
4Assets/Styles/GLQuake/Materials/GLQuake_World.mat
@ -1,303 +0,0 @@ |
|||
Shader "UniQuake/Lightmapped" |
|||
{ |
|||
Properties |
|||
{ |
|||
[MainTexture] _BaseMap("Texture", 2D) = "white" {} |
|||
[MainColor] _BaseColor("Color", Color) = (1, 1, 1, 1) |
|||
_Cutoff("AlphaCutout", Range(0.0, 1.0)) = 0.5 |
|||
|
|||
[NoScaleOffset] _LightMap("Lightmap", 2D) = "white" {} |
|||
|
|||
// BlendMode |
|||
[HideInInspector] _Surface("__surface", Float) = 0.0 |
|||
[HideInInspector] _Blend("__blend", Float) = 0.0 |
|||
[HideInInspector] _AlphaClip("__clip", Float) = 0.0 |
|||
[HideInInspector] _SrcBlend("Src", Float) = 1.0 |
|||
[HideInInspector] _DstBlend("Dst", Float) = 0.0 |
|||
[HideInInspector] _ZWrite("ZWrite", Float) = 1.0 |
|||
[HideInInspector] _Cull("__cull", Float) = 2.0 |
|||
|
|||
// Editmode props |
|||
[HideInInspector] _QueueOffset("Queue offset", Float) = 0.0 |
|||
|
|||
// ObsoleteProperties |
|||
[HideInInspector] _MainTex("BaseMap", 2D) = "white" {} |
|||
[HideInInspector] _Color("Base Color", Color) = (0.5, 0.5, 0.5, 1) |
|||
[HideInInspector] _SampleGI("SampleGI", float) = 0.0 // needed from bakedlit |
|||
} |
|||
SubShader |
|||
{ |
|||
Tags {"RenderType" = "Opaque" "IgnoreProjector" = "True" "RenderPipeline" = "UniversalPipeline" "ShaderModel"="4.5"} |
|||
LOD 100 |
|||
|
|||
Blend [_SrcBlend][_DstBlend] |
|||
ZWrite [_ZWrite] |
|||
Cull [_Cull] |
|||
|
|||
Pass |
|||
{ |
|||
Name "Lightmapped" |
|||
|
|||
HLSLPROGRAM |
|||
#pragma exclude_renderers gles gles3 glcore |
|||
#pragma target 4.5 |
|||
|
|||
#pragma vertex vert |
|||
#pragma fragment frag |
|||
#pragma shader_feature_local_fragment _ALPHATEST_ON |
|||
#pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON |
|||
|
|||
// ------------------------------------- |
|||
// Unity defined keywords |
|||
#pragma multi_compile_fog |
|||
#pragma multi_compile_instancing |
|||
#pragma multi_compile _ DOTS_INSTANCING_ON |
|||
|
|||
#include "LightmappedInput.hlsl" |
|||
|
|||
struct Attributes |
|||
{ |
|||
float4 positionOS : POSITION; |
|||
float2 uv : TEXCOORD0; |
|||
float2 uv2 : TEXCOORD1; |
|||
UNITY_VERTEX_INPUT_INSTANCE_ID |
|||
}; |
|||
|
|||
struct Varyings |
|||
{ |
|||
float2 uv : TEXCOORD0; |
|||
float2 uv2 : TEXCOORD1; |
|||
float4 vertex : SV_POSITION; |
|||
|
|||
UNITY_VERTEX_INPUT_INSTANCE_ID |
|||
UNITY_VERTEX_OUTPUT_STEREO |
|||
}; |
|||
|
|||
Varyings vert(Attributes input) |
|||
{ |
|||
Varyings output = (Varyings)0; |
|||
|
|||
UNITY_SETUP_INSTANCE_ID(input); |
|||
UNITY_TRANSFER_INSTANCE_ID(input, output); |
|||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); |
|||
|
|||
VertexPositionInputs vertexInput = GetVertexPositionInputs(input.positionOS.xyz); |
|||
output.vertex = vertexInput.positionCS; |
|||
output.uv = TRANSFORM_TEX(input.uv, _BaseMap); |
|||
output.uv2 = TRANSFORM_TEX(input.uv2, _LightMap); |
|||
//output.fogCoord = ComputeFogFactor(vertexInput.positionCS.z); |
|||
|
|||
return output; |
|||
} |
|||
|
|||
half4 frag(Varyings input) : SV_Target |
|||
{ |
|||
UNITY_SETUP_INSTANCE_ID(input); |
|||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); |
|||
|
|||
half2 uv = input.uv; |
|||
half4 texColor = SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, uv); |
|||
half3 color = texColor.rgb * _BaseColor.rgb; |
|||
half alpha = texColor.a * _BaseColor.a; |
|||
AlphaDiscard(alpha, _Cutoff); |
|||
|
|||
half4 lightmapColor = SAMPLE_TEXTURE2D(_LightMap, sampler_LightMap, input.uv2); |
|||
color.rgb = color.rgb * lightmapColor.rgb * 2.0f; |
|||
//color.rgb = lightmapColor.rgb; |
|||
|
|||
#ifdef _ALPHAPREMULTIPLY_ON |
|||
color *= alpha; |
|||
#endif |
|||
|
|||
//color = MixFog(color, input.fogCoord); |
|||
|
|||
return half4(color, alpha); |
|||
} |
|||
ENDHLSL |
|||
} |
|||
Pass |
|||
{ |
|||
Name "DepthOnly" |
|||
Tags{"LightMode" = "DepthOnly"} |
|||
|
|||
ZWrite On |
|||
ColorMask 0 |
|||
|
|||
HLSLPROGRAM |
|||
#pragma exclude_renderers gles gles3 glcore |
|||
#pragma target 4.5 |
|||
|
|||
#pragma vertex DepthOnlyVertex |
|||
#pragma fragment DepthOnlyFragment |
|||
|
|||
// ------------------------------------- |
|||
// Material Keywords |
|||
#pragma shader_feature_local_fragment _ALPHATEST_ON |
|||
|
|||
//-------------------------------------- |
|||
// GPU Instancing |
|||
#pragma multi_compile_instancing |
|||
#pragma multi_compile _ DOTS_INSTANCING_ON |
|||
|
|||
#include "LightmappedInput.hlsl" |
|||
#include "Packages/com.unity.render-pipelines.universal/Shaders/DepthOnlyPass.hlsl" |
|||
ENDHLSL |
|||
} |
|||
|
|||
// This pass it not used during regular rendering, only for lightmap baking. |
|||
Pass |
|||
{ |
|||
Name "Meta" |
|||
Tags{"LightMode" = "Meta"} |
|||
|
|||
Cull Off |
|||
|
|||
HLSLPROGRAM |
|||
#pragma exclude_renderers gles gles3 glcore |
|||
#pragma target 4.5 |
|||
|
|||
#pragma vertex UniversalVertexMeta |
|||
#pragma fragment UniversalFragmentMetaUnlit |
|||
|
|||
#include "LightmappedInput.hlsl" |
|||
#include "Packages/com.unity.render-pipelines.universal/Shaders/UnlitMetaPass.hlsl" |
|||
|
|||
ENDHLSL |
|||
} |
|||
} |
|||
|
|||
SubShader |
|||
{ |
|||
Tags {"RenderType" = "Opaque" "IgnoreProjector" = "True" "RenderPipeline" = "UniversalPipeline" "ShaderModel"="2.0"} |
|||
LOD 100 |
|||
|
|||
Blend [_SrcBlend][_DstBlend] |
|||
ZWrite [_ZWrite] |
|||
Cull [_Cull] |
|||
|
|||
Pass |
|||
{ |
|||
Name "Lightmapped" |
|||
HLSLPROGRAM |
|||
#pragma only_renderers gles gles3 glcore d3d11 |
|||
#pragma target 2.0 |
|||
|
|||
#pragma vertex vert |
|||
#pragma fragment frag |
|||
#pragma shader_feature_local_fragment _ALPHATEST_ON |
|||
#pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON |
|||
|
|||
// ------------------------------------- |
|||
// Unity defined keywords |
|||
#pragma multi_compile_fog |
|||
#pragma multi_compile_instancing |
|||
|
|||
#include "LightmappedInput.hlsl" |
|||
|
|||
struct Attributes |
|||
{ |
|||
float4 positionOS : POSITION; |
|||
float2 uv : TEXCOORD0; |
|||
UNITY_VERTEX_INPUT_INSTANCE_ID |
|||
}; |
|||
|
|||
struct Varyings |
|||
{ |
|||
float2 uv : TEXCOORD0; |
|||
float fogCoord : TEXCOORD1; |
|||
float4 vertex : SV_POSITION; |
|||
|
|||
UNITY_VERTEX_INPUT_INSTANCE_ID |
|||
UNITY_VERTEX_OUTPUT_STEREO |
|||
}; |
|||
|
|||
Varyings vert(Attributes input) |
|||
{ |
|||
Varyings output = (Varyings)0; |
|||
|
|||
UNITY_SETUP_INSTANCE_ID(input); |
|||
UNITY_TRANSFER_INSTANCE_ID(input, output); |
|||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); |
|||
|
|||
VertexPositionInputs vertexInput = GetVertexPositionInputs(input.positionOS.xyz); |
|||
output.vertex = vertexInput.positionCS; |
|||
output.uv = TRANSFORM_TEX(input.uv, _BaseMap); |
|||
output.fogCoord = ComputeFogFactor(vertexInput.positionCS.z); |
|||
|
|||
return output; |
|||
} |
|||
|
|||
half4 frag(Varyings input) : SV_Target |
|||
{ |
|||
UNITY_SETUP_INSTANCE_ID(input); |
|||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); |
|||
|
|||
half2 uv = input.uv; |
|||
half4 texColor = SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, uv); |
|||
half3 color = texColor.rgb * _BaseColor.rgb; |
|||
half alpha = texColor.a * _BaseColor.a; |
|||
AlphaDiscard(alpha, _Cutoff); |
|||
|
|||
#ifdef _ALPHAPREMULTIPLY_ON |
|||
color *= alpha; |
|||
#endif |
|||
|
|||
color = MixFog(color, input.fogCoord); |
|||
alpha = OutputAlpha(alpha, _Surface); |
|||
|
|||
return half4(color, alpha); |
|||
} |
|||
ENDHLSL |
|||
} |
|||
Pass |
|||
{ |
|||
Name "DepthOnly" |
|||
Tags{"LightMode" = "DepthOnly"} |
|||
|
|||
ZWrite On |
|||
ColorMask 0 |
|||
|
|||
HLSLPROGRAM |
|||
#pragma only_renderers gles gles3 glcore d3d11 |
|||
#pragma target 2.0 |
|||
|
|||
#pragma vertex DepthOnlyVertex |
|||
#pragma fragment DepthOnlyFragment |
|||
|
|||
// ------------------------------------- |
|||
// Material Keywords |
|||
#pragma shader_feature_local_fragment _ALPHATEST_ON |
|||
|
|||
//-------------------------------------- |
|||
// GPU Instancing |
|||
#pragma multi_compile_instancing |
|||
|
|||
#include "LightmappedInput.hlsl" |
|||
#include "Packages/com.unity.render-pipelines.universal/Shaders/DepthOnlyPass.hlsl" |
|||
ENDHLSL |
|||
} |
|||
|
|||
// This pass it not used during regular rendering, only for lightmap baking. |
|||
Pass |
|||
{ |
|||
Name "Meta" |
|||
Tags{"LightMode" = "Meta"} |
|||
|
|||
Cull Off |
|||
|
|||
HLSLPROGRAM |
|||
#pragma only_renderers gles gles3 glcore d3d11 |
|||
#pragma target 2.0 |
|||
|
|||
#pragma vertex UniversalVertexMeta |
|||
#pragma fragment UniversalFragmentMetaUnlit |
|||
|
|||
#include "LightmappedInput.hlsl" |
|||
#include "Packages/com.unity.render-pipelines.universal/Shaders/UnlitMetaPass.hlsl" |
|||
|
|||
ENDHLSL |
|||
} |
|||
} |
|||
FallBack "Hidden/Universal Render Pipeline/FallbackError" |
|||
//CustomEditor "UnityEditor.Rendering.Universal.ShaderGUI.UnlitShader" |
|||
} |
|||
@ -1,28 +0,0 @@ |
|||
#ifndef UNIVERSAL_UNLIT_INPUT_INCLUDED |
|||
#define UNIVERSAL_UNLIT_INPUT_INCLUDED |
|||
|
|||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/SurfaceInput.hlsl" |
|||
|
|||
TEXTURE2D(_LightMap); SAMPLER(sampler_LightMap); |
|||
|
|||
CBUFFER_START(UnityPerMaterial) |
|||
float4 _BaseMap_ST; |
|||
float4 _LightMap_ST; |
|||
half4 _BaseColor; |
|||
half _Cutoff; |
|||
half _Surface; |
|||
CBUFFER_END |
|||
|
|||
#ifdef UNITY_DOTS_INSTANCING_ENABLED |
|||
UNITY_DOTS_INSTANCING_START(MaterialPropertyMetadata) |
|||
UNITY_DOTS_INSTANCED_PROP(float4, _BaseColor) |
|||
UNITY_DOTS_INSTANCED_PROP(float , _Cutoff) |
|||
UNITY_DOTS_INSTANCED_PROP(float , _Surface) |
|||
UNITY_DOTS_INSTANCING_END(MaterialPropertyMetadata) |
|||
|
|||
#define _BaseColor UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float4 , Metadata__BaseColor) |
|||
#define _Cutoff UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float , Metadata__Cutoff) |
|||
#define _Surface UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float , Metadata__Surface) |
|||
#endif |
|||
|
|||
#endif |
|||
@ -0,0 +1,121 @@ |
|||
// Shader targeted for low end devices. Single Pass Forward Rendering. |
|||
Shader "UniQuake/Quake" |
|||
{ |
|||
Properties |
|||
{ |
|||
[MainTexture] _BaseMap("Base Map (RGB) Alpha (A)", 2D) = "white" {} |
|||
[MainColor] _BaseColor("Base Color", Color) = (1, 1, 1, 1) |
|||
|
|||
[NoScaleOffset] _LightMap("Lightmap (RGBA)", 2D) = "white" {} |
|||
|
|||
_Cutoff("Alpha Clipping", Range(0.0, 1.0)) = 0.666 |
|||
|
|||
[HDR] _EmissionColor("Emission Color", Color) = (0,0,0) |
|||
[NoScaleOffset]_EmissionMap("Emission Map", 2D) = "white" {} |
|||
|
|||
// Blending state |
|||
[HideInInspector] _Surface("__surface", Float) = 0.0 |
|||
[HideInInspector] _Blend("__blend", Float) = 0.0 |
|||
[HideInInspector] _AlphaClip("__clip", Float) = 0.0 |
|||
[HideInInspector] _SrcBlend("__src", Float) = 1.0 |
|||
[HideInInspector] _DstBlend("__dst", Float) = 0.0 |
|||
[HideInInspector] _ZWrite("__zw", Float) = 1.0 |
|||
[HideInInspector] _Cull("__cull", Float) = 2.0 |
|||
} |
|||
|
|||
SubShader |
|||
{ |
|||
Tags { "RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline" "UniversalMaterialType" = "SimpleLit" "IgnoreProjector" = "True" "ShaderModel"="4.5"} |
|||
LOD 300 |
|||
|
|||
Pass |
|||
{ |
|||
Name "ForwardLit" |
|||
Tags { "LightMode" = "UniversalForward" } |
|||
|
|||
// Use same blending / depth states as Standard shader |
|||
Blend[_SrcBlend][_DstBlend] |
|||
ZWrite[_ZWrite] |
|||
Cull[_Cull] |
|||
|
|||
HLSLPROGRAM |
|||
#pragma exclude_renderers gles gles3 glcore |
|||
#pragma target 4.5 |
|||
|
|||
// ------------------------------------- |
|||
// Material Keywords |
|||
#pragma shader_feature_local_fragment _ALPHATEST_ON |
|||
#pragma shader_feature_local_fragment _EMISSION |
|||
#pragma shader_feature_local _QLIGHTMAP_ON |
|||
|
|||
// ------------------------------------- |
|||
// Universal Pipeline keywords |
|||
#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS |
|||
|
|||
// ------------------------------------- |
|||
// Unity defined keywords |
|||
#pragma multi_compile_fog |
|||
|
|||
#pragma vertex LitPassVertexSimple |
|||
#pragma fragment LitPassFragmentSimple |
|||
#define BUMP_SCALE_NOT_SUPPORTED 1 |
|||
|
|||
#include "QuakeInput.hlsl" |
|||
#include "QuakeForwardPass.hlsl" |
|||
ENDHLSL |
|||
} |
|||
|
|||
Pass |
|||
{ |
|||
Name "DepthOnly" |
|||
Tags{"LightMode" = "DepthOnly"} |
|||
|
|||
ZWrite On |
|||
ColorMask 0 |
|||
Cull[_Cull] |
|||
|
|||
HLSLPROGRAM |
|||
#pragma exclude_renderers gles gles3 glcore |
|||
#pragma target 4.5 |
|||
|
|||
#pragma vertex DepthOnlyVertex |
|||
#pragma fragment DepthOnlyFragment |
|||
|
|||
// ------------------------------------- |
|||
// Material Keywords |
|||
#pragma shader_feature_local_fragment _ALPHATEST_ON |
|||
|
|||
#include "QuakeInput.hlsl" |
|||
#include "Packages/com.unity.render-pipelines.universal/Shaders/DepthOnlyPass.hlsl" |
|||
ENDHLSL |
|||
} |
|||
|
|||
// This pass is used when drawing to a _CameraNormalsTexture texture |
|||
Pass |
|||
{ |
|||
Name "DepthNormals" |
|||
Tags{"LightMode" = "DepthNormals"} |
|||
|
|||
ZWrite On |
|||
Cull[_Cull] |
|||
|
|||
HLSLPROGRAM |
|||
#pragma exclude_renderers gles gles3 glcore |
|||
#pragma target 4.5 |
|||
|
|||
#pragma vertex DepthNormalsVertex |
|||
#pragma fragment DepthNormalsFragment |
|||
|
|||
// ------------------------------------- |
|||
// Material Keywords |
|||
#pragma shader_feature_local_fragment _ALPHATEST_ON |
|||
|
|||
#include "QuakeInput.hlsl" |
|||
#include "Packages/com.unity.render-pipelines.universal/Shaders/DepthNormalsPass.hlsl" |
|||
ENDHLSL |
|||
} |
|||
} |
|||
|
|||
Fallback "Hidden/Universal Render Pipeline/FallbackError" |
|||
//CustomEditor "UnityEditor.Rendering.Universal.ShaderGUI.SimpleLitShader" |
|||
} |
|||
@ -1,5 +1,5 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 91d80b5043d41db478595fab96d6e2c2 |
|||
guid: eb7abeca30cd4fb4cb8be05eca69f850 |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
@ -0,0 +1,140 @@ |
|||
#ifndef UNIVERSAL_SIMPLE_LIT_PASS_INCLUDED |
|||
#define UNIVERSAL_SIMPLE_LIT_PASS_INCLUDED |
|||
|
|||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" |
|||
|
|||
struct Attributes |
|||
{ |
|||
float4 positionOS : POSITION; |
|||
float3 normalOS : NORMAL; |
|||
float4 tangentOS : TANGENT; |
|||
float2 texcoord : TEXCOORD0; |
|||
#ifdef _QLIGHTMAP_ON |
|||
float2 lightmapUV : TEXCOORD1; |
|||
#endif |
|||
UNITY_VERTEX_INPUT_INSTANCE_ID |
|||
}; |
|||
|
|||
struct Varyings |
|||
{ |
|||
float2 uv : TEXCOORD0; |
|||
#ifdef _QLIGHTMAP_ON |
|||
float2 lightmapUV : TEXCOORD1; |
|||
#else |
|||
half3 vertexSH : TEXCOORD1; |
|||
#endif |
|||
|
|||
float3 posWS : TEXCOORD2; // xyz: posWS |
|||
|
|||
float3 normal : TEXCOORD3; |
|||
float3 viewDir : TEXCOORD4; |
|||
|
|||
half4 fogFactorAndVertexLight : TEXCOORD6; // x: fogFactor, yzw: vertex light |
|||
|
|||
float4 positionCS : SV_POSITION; |
|||
UNITY_VERTEX_INPUT_INSTANCE_ID |
|||
UNITY_VERTEX_OUTPUT_STEREO |
|||
}; |
|||
|
|||
void InitializeInputData(Varyings input, out InputData inputData) |
|||
{ |
|||
inputData.positionWS = input.posWS; |
|||
|
|||
half3 viewDirWS = input.viewDir; |
|||
inputData.normalWS = input.normal; |
|||
|
|||
inputData.normalWS = NormalizeNormalPerPixel(inputData.normalWS); |
|||
viewDirWS = SafeNormalize(viewDirWS); |
|||
|
|||
inputData.viewDirectionWS = viewDirWS; |
|||
|
|||
inputData.shadowCoord = float4(0, 0, 0, 0); |
|||
|
|||
inputData.fogCoord = input.fogFactorAndVertexLight.x; |
|||
inputData.vertexLighting = input.fogFactorAndVertexLight.yzw; |
|||
#ifdef _QLIGHTMAP_ON |
|||
inputData.bakedGI = 0.0; |
|||
#else |
|||
inputData.bakedGI = SampleSHPixel(input.vertexSH, inputData.normalWS); |
|||
#endif |
|||
inputData.normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(input.positionCS); |
|||
inputData.shadowMask = 0.0; |
|||
} |
|||
|
|||
/////////////////////////////////////////////////////////////////////////////// |
|||
// Vertex and Fragment functions // |
|||
/////////////////////////////////////////////////////////////////////////////// |
|||
|
|||
// Used in Standard (Simple Lighting) shader |
|||
Varyings LitPassVertexSimple(Attributes input) |
|||
{ |
|||
Varyings output = (Varyings)0; |
|||
|
|||
UNITY_SETUP_INSTANCE_ID(input); |
|||
UNITY_TRANSFER_INSTANCE_ID(input, output); |
|||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); |
|||
|
|||
VertexPositionInputs vertexInput = GetVertexPositionInputs(input.positionOS.xyz); |
|||
VertexNormalInputs normalInput = GetVertexNormalInputs(input.normalOS, input.tangentOS); |
|||
half3 viewDirWS = GetWorldSpaceViewDir(vertexInput.positionWS); |
|||
half3 vertexLight = VertexLighting(vertexInput.positionWS, normalInput.normalWS); |
|||
half fogFactor = ComputeFogFactor(vertexInput.positionCS.z); |
|||
|
|||
output.uv = TRANSFORM_TEX(input.texcoord, _BaseMap); |
|||
output.posWS.xyz = vertexInput.positionWS; |
|||
output.positionCS = vertexInput.positionCS; |
|||
|
|||
output.normal = NormalizeNormalPerVertex(normalInput.normalWS); |
|||
output.viewDir = viewDirWS; |
|||
|
|||
#ifdef _QLIGHTMAP_ON |
|||
output.lightmapUV.xy = input.lightmapUV.xy; |
|||
#else |
|||
output.vertexSH.xyz = SampleSHVertex(output.normal.xyz); |
|||
#endif |
|||
|
|||
output.fogFactorAndVertexLight = half4(fogFactor, vertexLight); |
|||
|
|||
return output; |
|||
} |
|||
|
|||
// Used for StandardSimpleLighting shader |
|||
half4 LitPassFragmentSimple(Varyings input) : SV_Target |
|||
{ |
|||
UNITY_SETUP_INSTANCE_ID(input); |
|||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); |
|||
|
|||
float2 uv = input.uv; |
|||
half4 diffuseAlpha = SampleAlbedoAlpha(uv, TEXTURE2D_ARGS(_BaseMap, sampler_BaseMap)); |
|||
half3 diffuse = diffuseAlpha.rgb * _BaseColor.rgb; |
|||
|
|||
half alpha = diffuseAlpha.a * _BaseColor.a; |
|||
AlphaDiscard(alpha, _Cutoff); |
|||
|
|||
InputData inputData; |
|||
InitializeInputData(input, inputData); |
|||
|
|||
#ifdef _QLIGHTMAP_ON |
|||
half4 lightmapColor = SAMPLE_TEXTURE2D(_LightMap, sampler_LightMap, input.lightmapUV); |
|||
half3 finalColor = diffuse * lightmapColor.rgb * 2.0f; |
|||
#else |
|||
// Specular and smoothness are some bogus values just to make models not appear completely black on one side |
|||
half3 finalColor = UniversalFragmentBlinnPhong(inputData, diffuse, half4(0.2, 0.2, 0.2, 1), 0.5, 0.0, alpha).rgb; |
|||
// Light light = GetMainLight(); |
|||
// half3 diffuseColor = LightingLambert(light.color, light.direction, inputData.normalWS); |
|||
// half3 finalColor = diffuse * diffuseColor; |
|||
#endif |
|||
|
|||
#ifdef _EMISSION |
|||
finalColor += SampleEmission(uv, _EmissionColor.rgb, TEXTURE2D_ARGS(_EmissionMap, sampler_EmissionMap)); |
|||
#endif |
|||
|
|||
half4 color = half4(finalColor, alpha); |
|||
|
|||
color.rgb = MixFog(color.rgb, inputData.fogCoord); |
|||
color.a = OutputAlpha(color.a, _Surface); |
|||
|
|||
return color; |
|||
} |
|||
|
|||
#endif |
|||
@ -1,5 +1,5 @@ |
|||
fileFormatVersion: 2 |
|||
guid: fe2f7d54113588c42925192dff3809e9 |
|||
guid: 6aa574d369884d24e8f28b300a86fcb3 |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
@ -0,0 +1,50 @@ |
|||
#ifndef UNIVERSAL_SIMPLE_LIT_INPUT_INCLUDED |
|||
#define UNIVERSAL_SIMPLE_LIT_INPUT_INCLUDED |
|||
|
|||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" |
|||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/SurfaceInput.hlsl" |
|||
|
|||
CBUFFER_START(UnityPerMaterial) |
|||
float4 _BaseMap_ST; |
|||
float4 _LightMap_ST; |
|||
half4 _BaseColor; |
|||
half4 _EmissionColor; |
|||
half _Cutoff; |
|||
half _Surface; |
|||
CBUFFER_END |
|||
|
|||
#ifdef UNITY_DOTS_INSTANCING_ENABLED |
|||
UNITY_DOTS_INSTANCING_START(MaterialPropertyMetadata) |
|||
UNITY_DOTS_INSTANCED_PROP(float4, _BaseColor) |
|||
UNITY_DOTS_INSTANCED_PROP(float4, _EmissionColor) |
|||
UNITY_DOTS_INSTANCED_PROP(float , _Cutoff) |
|||
UNITY_DOTS_INSTANCED_PROP(float , _Surface) |
|||
UNITY_DOTS_INSTANCING_END(MaterialPropertyMetadata) |
|||
|
|||
#define _BaseColor UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float4 , Metadata__BaseColor) |
|||
#define _EmissionColor UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float4 , Metadata__EmissionColor) |
|||
#define _Cutoff UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float , Metadata__Cutoff) |
|||
#define _Surface UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float , Metadata__Surface) |
|||
#endif |
|||
|
|||
TEXTURE2D(_LightMap); SAMPLER(sampler_LightMap); |
|||
|
|||
inline void InitializeSimpleLitSurfaceData(float2 uv, out SurfaceData outSurfaceData) |
|||
{ |
|||
outSurfaceData = (SurfaceData)0; |
|||
|
|||
half4 albedoAlpha = SampleAlbedoAlpha(uv, TEXTURE2D_ARGS(_BaseMap, sampler_BaseMap)); |
|||
outSurfaceData.alpha = albedoAlpha.a * _BaseColor.a; |
|||
AlphaDiscard(outSurfaceData.alpha, _Cutoff); |
|||
|
|||
outSurfaceData.albedo = albedoAlpha.rgb * _BaseColor.rgb; |
|||
|
|||
outSurfaceData.metallic = 0.0; // unused |
|||
outSurfaceData.specular = 0.0; // unused |
|||
outSurfaceData.smoothness = 0.0; // unused |
|||
//outSurfaceData.normalTS = SampleNormal(uv, TEXTURE2D_ARGS(_BumpMap, sampler_BumpMap)); |
|||
outSurfaceData.occlusion = 1.0; // unused |
|||
outSurfaceData.emission = SampleEmission(uv, _EmissionColor.rgb, TEXTURE2D_ARGS(_EmissionMap, sampler_EmissionMap)); |
|||
} |
|||
|
|||
#endif |
|||
@ -0,0 +1,10 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 209b8f66e5d711946ba4c4ccb9e0a9b4 |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
preprocessorOverride: 0 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue