Compare commits
4 Commits
5218513a22
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| fd6e3f4e5e | |||
|
|
ff41df25cd | ||
|
|
1c60dfabba | ||
|
|
0777676dbd |
4
.vscode/settings.json
vendored
4
.vscode/settings.json
vendored
@@ -60,12 +60,12 @@
|
|||||||
"*.asset": "yaml",
|
"*.asset": "yaml",
|
||||||
"*.meta": "yaml",
|
"*.meta": "yaml",
|
||||||
"*.prefab": "yaml",
|
"*.prefab": "yaml",
|
||||||
"*.unity": "yaml",
|
"*.unity": "yaml"
|
||||||
},
|
},
|
||||||
"explorer.fileNesting.enabled": true,
|
"explorer.fileNesting.enabled": true,
|
||||||
"explorer.fileNesting.patterns": {
|
"explorer.fileNesting.patterns": {
|
||||||
"*.sln": "*.csproj",
|
"*.sln": "*.csproj",
|
||||||
"*.slnx": "*.csproj"
|
"*.slnx": "*.csproj"
|
||||||
},
|
},
|
||||||
"dotnet.defaultSolution": "FueraDeEscala-DinaLabs.slnx"
|
"dotnet.defaultSolution": "FueraDeEscala.slnx"
|
||||||
}
|
}
|
||||||
@@ -11,7 +11,9 @@ Material:
|
|||||||
m_Shader: {fileID: 4800000, guid: 8d2bb70cbf9db8d4da26e15b26e74248, type: 3}
|
m_Shader: {fileID: 4800000, guid: 8d2bb70cbf9db8d4da26e15b26e74248, type: 3}
|
||||||
m_Parent: {fileID: 0}
|
m_Parent: {fileID: 0}
|
||||||
m_ModifiedSerializedProperties: 0
|
m_ModifiedSerializedProperties: 0
|
||||||
m_ValidKeywords: []
|
m_ValidKeywords:
|
||||||
|
- _GLOSSINESS_FROM_BASE_ALPHA
|
||||||
|
- _SPECULAR_COLOR
|
||||||
m_InvalidKeywords: []
|
m_InvalidKeywords: []
|
||||||
m_LightmapFlags: 4
|
m_LightmapFlags: 4
|
||||||
m_EnableInstancingVariants: 0
|
m_EnableInstancingVariants: 0
|
||||||
@@ -38,7 +40,7 @@ Material:
|
|||||||
m_Scale: {x: 1, y: 1}
|
m_Scale: {x: 1, y: 1}
|
||||||
m_Offset: {x: 0, y: 0}
|
m_Offset: {x: 0, y: 0}
|
||||||
- _MainTex:
|
- _MainTex:
|
||||||
m_Texture: {fileID: 2800000, guid: 152f7d9ecfcc59443a15265bb32c8be8, type: 3}
|
m_Texture: {fileID: 0}
|
||||||
m_Scale: {x: 1, y: 1}
|
m_Scale: {x: 1, y: 1}
|
||||||
m_Offset: {x: 0, y: 0}
|
m_Offset: {x: 0, y: 0}
|
||||||
- _SpecGlossMap:
|
- _SpecGlossMap:
|
||||||
@@ -80,7 +82,6 @@ Material:
|
|||||||
- _SrcBlend: 1
|
- _SrcBlend: 1
|
||||||
- _SrcBlendAlpha: 1
|
- _SrcBlendAlpha: 1
|
||||||
- _Surface: 0
|
- _Surface: 0
|
||||||
- _XRMotionVectorsPass: 1
|
|
||||||
- _ZWrite: 1
|
- _ZWrite: 1
|
||||||
m_Colors:
|
m_Colors:
|
||||||
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
|
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
|||||||
@@ -24,7 +24,9 @@ Material:
|
|||||||
m_Shader: {fileID: 4800000, guid: 8d2bb70cbf9db8d4da26e15b26e74248, type: 3}
|
m_Shader: {fileID: 4800000, guid: 8d2bb70cbf9db8d4da26e15b26e74248, type: 3}
|
||||||
m_Parent: {fileID: 0}
|
m_Parent: {fileID: 0}
|
||||||
m_ModifiedSerializedProperties: 0
|
m_ModifiedSerializedProperties: 0
|
||||||
m_ValidKeywords: []
|
m_ValidKeywords:
|
||||||
|
- _GLOSSINESS_FROM_BASE_ALPHA
|
||||||
|
- _SPECULAR_COLOR
|
||||||
m_InvalidKeywords: []
|
m_InvalidKeywords: []
|
||||||
m_LightmapFlags: 4
|
m_LightmapFlags: 4
|
||||||
m_EnableInstancingVariants: 0
|
m_EnableInstancingVariants: 0
|
||||||
@@ -51,7 +53,7 @@ Material:
|
|||||||
m_Scale: {x: 1, y: 1}
|
m_Scale: {x: 1, y: 1}
|
||||||
m_Offset: {x: 0, y: 0}
|
m_Offset: {x: 0, y: 0}
|
||||||
- _MainTex:
|
- _MainTex:
|
||||||
m_Texture: {fileID: 2800000, guid: 5a39d0c1acfa2b54c8585459f5c8ac2f, type: 3}
|
m_Texture: {fileID: 0}
|
||||||
m_Scale: {x: 1, y: 1}
|
m_Scale: {x: 1, y: 1}
|
||||||
m_Offset: {x: 0, y: 0}
|
m_Offset: {x: 0, y: 0}
|
||||||
- _SpecGlossMap:
|
- _SpecGlossMap:
|
||||||
@@ -93,7 +95,6 @@ Material:
|
|||||||
- _SrcBlend: 1
|
- _SrcBlend: 1
|
||||||
- _SrcBlendAlpha: 1
|
- _SrcBlendAlpha: 1
|
||||||
- _Surface: 0
|
- _Surface: 0
|
||||||
- _XRMotionVectorsPass: 1
|
|
||||||
- _ZWrite: 1
|
- _ZWrite: 1
|
||||||
m_Colors:
|
m_Colors:
|
||||||
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
|
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
|||||||
@@ -24,7 +24,9 @@ Material:
|
|||||||
m_Shader: {fileID: 4800000, guid: 8d2bb70cbf9db8d4da26e15b26e74248, type: 3}
|
m_Shader: {fileID: 4800000, guid: 8d2bb70cbf9db8d4da26e15b26e74248, type: 3}
|
||||||
m_Parent: {fileID: 0}
|
m_Parent: {fileID: 0}
|
||||||
m_ModifiedSerializedProperties: 0
|
m_ModifiedSerializedProperties: 0
|
||||||
m_ValidKeywords: []
|
m_ValidKeywords:
|
||||||
|
- _GLOSSINESS_FROM_BASE_ALPHA
|
||||||
|
- _SPECULAR_COLOR
|
||||||
m_InvalidKeywords: []
|
m_InvalidKeywords: []
|
||||||
m_LightmapFlags: 4
|
m_LightmapFlags: 4
|
||||||
m_EnableInstancingVariants: 0
|
m_EnableInstancingVariants: 0
|
||||||
@@ -51,7 +53,7 @@ Material:
|
|||||||
m_Scale: {x: 1, y: 1}
|
m_Scale: {x: 1, y: 1}
|
||||||
m_Offset: {x: 0, y: 0}
|
m_Offset: {x: 0, y: 0}
|
||||||
- _MainTex:
|
- _MainTex:
|
||||||
m_Texture: {fileID: 2800000, guid: 4781c29e835ab4543b0668066a4b2abf, type: 3}
|
m_Texture: {fileID: 0}
|
||||||
m_Scale: {x: 1, y: 1}
|
m_Scale: {x: 1, y: 1}
|
||||||
m_Offset: {x: 0, y: 0}
|
m_Offset: {x: 0, y: 0}
|
||||||
- _SpecGlossMap:
|
- _SpecGlossMap:
|
||||||
@@ -93,7 +95,6 @@ Material:
|
|||||||
- _SrcBlend: 1
|
- _SrcBlend: 1
|
||||||
- _SrcBlendAlpha: 1
|
- _SrcBlendAlpha: 1
|
||||||
- _Surface: 0
|
- _Surface: 0
|
||||||
- _XRMotionVectorsPass: 1
|
|
||||||
- _ZWrite: 1
|
- _ZWrite: 1
|
||||||
m_Colors:
|
m_Colors:
|
||||||
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
|
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
|||||||
@@ -1,356 +1,410 @@
|
|||||||
// ProBuilder Standard Vertex Color - rewritten for URP (Universal Render Pipeline)
|
/**
|
||||||
// Preserves original feature set: Base Texture * Color Tint * Vertex Color, Normal Map, Metallic/Gloss PBR
|
* This shader was created with Shaderforge but contains multiple manual edits.
|
||||||
|
* If you modify this shader make sure to go through and pack uv1 and uv2 channels
|
||||||
|
* into a single float4 to save on registers (on penalty of compile error)
|
||||||
|
*/
|
||||||
|
// Shader created with Shader Forge v1.38
|
||||||
|
// Shader Forge (c) Neat Corporation / Joachim Holmer - http://www.acegikmo.com/shaderforge/
|
||||||
|
// Note: Manually altering this data may prevent you from opening it in Shader Forge
|
||||||
|
// Uncomment (just the //) this line to edit with ShaderForge
|
||||||
|
// /*SF_DATA;ver:1.38;sub:START;pass:START;ps:flbk:Standard,iptp:0,cusa:False,bamd:0,cgin:,lico:1,lgpr:1,limd:3,spmd:1,trmd:0,grmd:1,uamb:True,mssp:True,bkdf:True,hqlp:False,rprd:True,enco:False,rmgx:True,imps:True,rpth:0,vtps:0,hqsc:True,nrmq:1,nrsp:0,vomd:0,spxs:False,tesm:0,olmd:1,culm:0,bsrc:0,bdst:1,dpts:2,wrdp:True,dith:0,atcv:False,rfrpo:True,rfrpn:Refraction,coma:15,ufog:True,aust:True,igpj:False,qofs:0,qpre:1,rntp:1,fgom:False,fgoc:False,fgod:False,fgor:False,fgmd:0,fgcr:0.5,fgcg:0.5,fgcb:0.5,fgca:1,fgde:0.01,fgrn:0,fgrf:300,stcl:False,atwp:False,stva:128,stmr:255,stmw:255,stcp:6,stps:0,stfa:0,stfz:0,ofsf:0,ofsu:0,f2p0:False,fnsp:False,fnfb:False,fsmp:False;n:type:ShaderForge.SFN_Final,id:2865,x:32719,y:32712,varname:node_2865,prsc:2|diff-6343-OUT,spec-358-OUT,gloss-1813-OUT,normal-5964-RGB;n:type:ShaderForge.SFN_Multiply,id:6343,x:32114,y:32712,varname:node_6343,prsc:2|A-7736-RGB,B-6665-RGB,C-3150-RGB;n:type:ShaderForge.SFN_Color,id:6665,x:31921,y:32805,ptovrint:False,ptlb:Color,ptin:_Color,varname:_Color,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,c1:1,c2:1,c3:1,c4:1;n:type:ShaderForge.SFN_Tex2d,id:7736,x:31921,y:32620,ptovrint:True,ptlb:Base Color,ptin:_MainTex,varname:_MainTex,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,ntxv:0,isnm:False;n:type:ShaderForge.SFN_Tex2d,id:5964,x:32407,y:32978,ptovrint:True,ptlb:Normal Map,ptin:_BumpMap,varname:_BumpMap,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,ntxv:3,isnm:True;n:type:ShaderForge.SFN_Slider,id:358,x:32250,y:32780,ptovrint:False,ptlb:Metallic,ptin:_Metallic,varname:node_358,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:0,cur:0,max:1;n:type:ShaderForge.SFN_Slider,id:1813,x:32250,y:32882,ptovrint:False,ptlb:Gloss,ptin:_Gloss,varname:_Metallic_copy,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:0,cur:0.8,max:1;n:type:ShaderForge.SFN_VertexColor,id:3150,x:31921,y:32967,varname:node_3150,prsc:2;proporder:5964-6665-7736-358-1813;pass:END;sub:END;*/
|
||||||
|
|
||||||
Shader "ProBuilder/Standard Vertex Color" {
|
Shader "ProBuilder/Standard Vertex Color" {
|
||||||
Properties {
|
Properties {
|
||||||
_MainTex ("Base Color", 2D) = "white" {}
|
_MainTex ("Base Color", 2D) = "white" {}
|
||||||
_BumpMap ("Normal Map", 2D) = "bump" {}
|
_BumpMap ("Normal Map", 2D) = "bump" {}
|
||||||
_Color ("Color", Color) = (1,1,1,1)
|
_Color ("Color", Color) = (1,1,1,1)
|
||||||
_Metallic ("Metallic", Range(0, 1)) = 0
|
_Metallic ("Metallic", Range(0, 1)) = 0
|
||||||
_Gloss ("Gloss", Range(0, 1)) = 0.8
|
_Gloss ("Gloss", Range(0, 1)) = 0.8
|
||||||
}
|
}
|
||||||
SubShader {
|
SubShader {
|
||||||
Tags {
|
Tags {
|
||||||
"RenderType" = "Opaque"
|
"RenderType"="Opaque"
|
||||||
"RenderPipeline" = "UniversalPipeline"
|
|
||||||
"Queue" = "Geometry"
|
|
||||||
}
|
}
|
||||||
LOD 300
|
|
||||||
|
|
||||||
// ─────────────────────────────────────────────────────────────────
|
|
||||||
// UniversalForward – main PBR pass
|
|
||||||
// ─────────────────────────────────────────────────────────────────
|
|
||||||
Pass {
|
Pass {
|
||||||
Name "UniversalForward"
|
Name "FORWARD"
|
||||||
Tags { "LightMode" = "UniversalForward" }
|
Tags {
|
||||||
|
"LightMode"="ForwardBase"
|
||||||
|
}
|
||||||
|
|
||||||
HLSLPROGRAM
|
CGPROGRAM
|
||||||
#pragma vertex vert
|
#pragma vertex vert
|
||||||
#pragma fragment frag
|
#pragma fragment frag
|
||||||
|
#define UNITY_PASS_FORWARDBASE
|
||||||
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN
|
#define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) )
|
||||||
#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
|
#define _GLOSSYENV 1
|
||||||
#pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS
|
#include "UnityCG.cginc"
|
||||||
#pragma multi_compile_fragment _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH
|
#include "AutoLight.cginc"
|
||||||
#pragma multi_compile _ LIGHTMAP_SHADOW_MIXING
|
#include "Lighting.cginc"
|
||||||
#pragma multi_compile _ SHADOWS_SHADOWMASK
|
#include "UnityPBSLighting.cginc"
|
||||||
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
|
#include "UnityStandardBRDF.cginc"
|
||||||
#pragma multi_compile _ LIGHTMAP_ON
|
#pragma multi_compile_fwdbase_fullshadows
|
||||||
|
#pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON
|
||||||
|
#pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED DIRLIGHTMAP_SEPARATE
|
||||||
|
#pragma multi_compile DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON
|
||||||
#pragma multi_compile_fog
|
#pragma multi_compile_fog
|
||||||
#pragma multi_compile_instancing
|
#pragma target 3.0
|
||||||
|
uniform float4 _Color;
|
||||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
uniform sampler2D _MainTex; uniform float4 _MainTex_ST;
|
||||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
uniform sampler2D _BumpMap; uniform float4 _BumpMap_ST;
|
||||||
|
uniform float _Metallic;
|
||||||
TEXTURE2D(_MainTex); SAMPLER(sampler_MainTex);
|
uniform float _Gloss;
|
||||||
TEXTURE2D(_BumpMap); SAMPLER(sampler_BumpMap);
|
struct VertexInput {
|
||||||
|
float4 vertex : POSITION;
|
||||||
CBUFFER_START(UnityPerMaterial)
|
float3 normal : NORMAL;
|
||||||
float4 _MainTex_ST;
|
float4 tangent : TANGENT;
|
||||||
float4 _BumpMap_ST;
|
float2 texcoord0 : TEXCOORD0;
|
||||||
half4 _Color;
|
float2 texcoord1 : TEXCOORD1;
|
||||||
half _Metallic;
|
float2 texcoord2 : TEXCOORD2;
|
||||||
half _Gloss;
|
float4 vertexColor : COLOR;
|
||||||
CBUFFER_END
|
|
||||||
|
|
||||||
struct Attributes {
|
|
||||||
float4 positionOS : POSITION;
|
|
||||||
float3 normalOS : NORMAL;
|
|
||||||
float4 tangentOS : TANGENT;
|
|
||||||
float2 uv : TEXCOORD0;
|
|
||||||
float2 lightmapUV : TEXCOORD1;
|
|
||||||
half4 vertexColor : COLOR;
|
|
||||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
||||||
};
|
};
|
||||||
|
struct VertexOutput {
|
||||||
struct Varyings {
|
float4 pos : SV_POSITION;
|
||||||
float4 positionCS : SV_POSITION;
|
float2 uv0 : TEXCOORD0;
|
||||||
float2 uv : TEXCOORD0;
|
float4 uv1 : TEXCOORD1;
|
||||||
float2 uvBump : TEXCOORD1;
|
float4 posWorld : TEXCOORD3;
|
||||||
float3 positionWS : TEXCOORD2;
|
float3 normalDir : TEXCOORD4;
|
||||||
float3 normalWS : TEXCOORD3;
|
float3 tangentDir : TEXCOORD5;
|
||||||
float4 tangentWS : TEXCOORD4; // xyz: tangent, w: sign
|
float3 bitangentDir : TEXCOORD6;
|
||||||
half4 vertexColor : COLOR;
|
float4 vertexColor : COLOR;
|
||||||
DECLARE_LIGHTMAP_OR_SH(staticLightmapUV, vertexSH, 5);
|
LIGHTING_COORDS(7,8)
|
||||||
half4 fogFactorAndVertexLight : TEXCOORD6; // x: fog, yzw: vertex lights
|
UNITY_FOG_COORDS(9)
|
||||||
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
|
#if defined(LIGHTMAP_ON) || defined(UNITY_SHOULD_SAMPLE_SH)
|
||||||
float4 shadowCoord : TEXCOORD7;
|
float4 ambientOrLightmapUV : TEXCOORD10;
|
||||||
#endif
|
#endif
|
||||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
||||||
UNITY_VERTEX_OUTPUT_STEREO
|
|
||||||
};
|
};
|
||||||
|
VertexOutput vert (VertexInput v) {
|
||||||
Varyings vert(Attributes v) {
|
VertexOutput o = (VertexOutput)0;
|
||||||
Varyings o = (Varyings)0;
|
o.uv0 = v.texcoord0;
|
||||||
UNITY_SETUP_INSTANCE_ID(v);
|
o.uv1 = float4(v.texcoord1, v.texcoord2);
|
||||||
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
|
||||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
|
||||||
|
|
||||||
VertexPositionInputs posInputs = GetVertexPositionInputs(v.positionOS.xyz);
|
|
||||||
VertexNormalInputs normInputs = GetVertexNormalInputs(v.normalOS, v.tangentOS);
|
|
||||||
|
|
||||||
o.positionCS = posInputs.positionCS;
|
|
||||||
o.positionWS = posInputs.positionWS;
|
|
||||||
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
|
|
||||||
o.uvBump = TRANSFORM_TEX(v.uv, _BumpMap);
|
|
||||||
o.normalWS = normInputs.normalWS;
|
|
||||||
o.tangentWS = float4(normInputs.tangentWS, v.tangentOS.w * GetOddNegativeScale());
|
|
||||||
o.vertexColor = v.vertexColor;
|
o.vertexColor = v.vertexColor;
|
||||||
|
#ifdef LIGHTMAP_ON
|
||||||
OUTPUT_LIGHTMAP_UV(v.lightmapUV, unity_LightmapST, o.staticLightmapUV);
|
o.ambientOrLightmapUV.xy = v.texcoord1.xy * unity_LightmapST.xy + unity_LightmapST.zw;
|
||||||
OUTPUT_SH(o.normalWS.xyz, o.vertexSH);
|
o.ambientOrLightmapUV.zw = 0;
|
||||||
|
#elif UNITY_SHOULD_SAMPLE_SH
|
||||||
half3 vertexLight = VertexLighting(posInputs.positionWS, normInputs.normalWS);
|
|
||||||
half fogFactor = ComputeFogFactor(posInputs.positionCS.z);
|
|
||||||
o.fogFactorAndVertexLight = half4(fogFactor, vertexLight);
|
|
||||||
|
|
||||||
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
|
|
||||||
o.shadowCoord = GetShadowCoord(posInputs);
|
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef DYNAMICLIGHTMAP_ON
|
||||||
|
o.ambientOrLightmapUV.zw = v.texcoord2.xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw;
|
||||||
|
#endif
|
||||||
|
o.normalDir = UnityObjectToWorldNormal(v.normal);
|
||||||
|
o.tangentDir = normalize( mul( unity_ObjectToWorld, float4( v.tangent.xyz, 0.0 ) ).xyz );
|
||||||
|
o.bitangentDir = normalize(cross(o.normalDir, o.tangentDir) * v.tangent.w);
|
||||||
|
o.posWorld = mul(unity_ObjectToWorld, v.vertex);
|
||||||
|
float3 lightColor = _LightColor0.rgb;
|
||||||
|
o.pos = UnityObjectToClipPos( v.vertex );
|
||||||
|
UNITY_TRANSFER_FOG(o,o.pos);
|
||||||
|
TRANSFER_VERTEX_TO_FRAGMENT(o)
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
float4 frag(VertexOutput i) : COLOR {
|
||||||
half4 frag(Varyings i) : SV_Target {
|
i.normalDir = normalize(i.normalDir);
|
||||||
UNITY_SETUP_INSTANCE_ID(i);
|
float3x3 tangentTransform = float3x3( i.tangentDir, i.bitangentDir, i.normalDir);
|
||||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
|
||||||
|
float3 _BumpMap_var = UnpackNormal(tex2D(_BumpMap,TRANSFORM_TEX(i.uv0, _BumpMap)));
|
||||||
// Albedo = texture * color tint * vertex color (matches original logic)
|
float3 normalLocal = _BumpMap_var.rgb;
|
||||||
half4 albedoSample = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uv);
|
float3 normalDirection = normalize(mul( normalLocal, tangentTransform )); // Perturbed normals
|
||||||
half3 albedo = albedoSample.rgb * _Color.rgb * i.vertexColor.rgb;
|
float3 viewReflectDirection = reflect( -viewDirection, normalDirection );
|
||||||
|
float3 lightDirection = normalize(_WorldSpaceLightPos0.xyz);
|
||||||
// Normal map
|
float3 lightColor = _LightColor0.rgb;
|
||||||
half4 normalSample = SAMPLE_TEXTURE2D(_BumpMap, sampler_BumpMap, i.uvBump);
|
float3 halfDirection = normalize(viewDirection+lightDirection);
|
||||||
half3 normalTS = UnpackNormal(normalSample);
|
////// Lighting:
|
||||||
float3 bitangentWS = cross(i.normalWS, i.tangentWS.xyz) * i.tangentWS.w;
|
float attenuation = LIGHT_ATTENUATION(i);
|
||||||
float3 normalWS = TransformTangentToWorld(normalTS,
|
float3 attenColor = attenuation * _LightColor0.xyz;
|
||||||
float3x3(i.tangentWS.xyz, bitangentWS, i.normalWS));
|
float Pi = 3.141592654;
|
||||||
normalWS = NormalizeNormalPerPixel(normalWS);
|
float InvPi = 0.31830988618;
|
||||||
|
///////// Gloss:
|
||||||
// Shadow coordinate
|
float gloss = 1.0 - _Gloss; // Convert roughness to gloss
|
||||||
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
|
float perceptualRoughness = _Gloss;
|
||||||
float4 shadowCoord = i.shadowCoord;
|
float roughness = perceptualRoughness * perceptualRoughness;
|
||||||
#elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
|
float specPow = exp2( gloss * 10.0 + 1.0 );
|
||||||
float4 shadowCoord = TransformWorldToShadowCoord(i.positionWS);
|
/////// GI Data:
|
||||||
|
UnityLight light;
|
||||||
|
#ifdef LIGHTMAP_OFF
|
||||||
|
light.color = lightColor;
|
||||||
|
light.dir = lightDirection;
|
||||||
|
light.ndotl = LambertTerm (normalDirection, light.dir);
|
||||||
#else
|
#else
|
||||||
float4 shadowCoord = float4(0, 0, 0, 0);
|
light.color = half3(0.f, 0.f, 0.f);
|
||||||
|
light.ndotl = 0.0f;
|
||||||
|
light.dir = half3(0.f, 0.f, 0.f);
|
||||||
#endif
|
#endif
|
||||||
|
UnityGIInput d;
|
||||||
// Build URP surface / input structs
|
d.light = light;
|
||||||
SurfaceData surfaceData = (SurfaceData)0;
|
d.worldPos = i.posWorld.xyz;
|
||||||
surfaceData.albedo = albedo;
|
d.worldViewDir = viewDirection;
|
||||||
surfaceData.metallic = _Metallic;
|
d.atten = attenuation;
|
||||||
surfaceData.smoothness = _Gloss;
|
#if defined(LIGHTMAP_ON) || defined(DYNAMICLIGHTMAP_ON)
|
||||||
surfaceData.normalTS = normalTS;
|
d.ambient = 0;
|
||||||
surfaceData.occlusion = 1.0h;
|
d.lightmapUV = i.ambientOrLightmapUV;
|
||||||
surfaceData.alpha = 1.0h;
|
|
||||||
|
|
||||||
InputData inputData = (InputData)0;
|
|
||||||
inputData.positionWS = i.positionWS;
|
|
||||||
inputData.normalWS = normalWS;
|
|
||||||
inputData.viewDirectionWS = GetWorldSpaceNormalizeViewDir(i.positionWS);
|
|
||||||
inputData.shadowCoord = shadowCoord;
|
|
||||||
inputData.fogCoord = i.fogFactorAndVertexLight.x;
|
|
||||||
inputData.vertexLighting = i.fogFactorAndVertexLight.yzw;
|
|
||||||
inputData.bakedGI = SAMPLE_GI(i.staticLightmapUV, i.vertexSH, inputData.normalWS);
|
|
||||||
inputData.normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(i.positionCS);
|
|
||||||
inputData.shadowMask = SAMPLE_SHADOWMASK(i.staticLightmapUV);
|
|
||||||
|
|
||||||
half4 color = UniversalFragmentPBR(inputData, surfaceData);
|
|
||||||
color.rgb = MixFog(color.rgb, inputData.fogCoord);
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
ENDHLSL
|
|
||||||
}
|
|
||||||
|
|
||||||
// ─────────────────────────────────────────────────────────────────
|
|
||||||
// ShadowCaster
|
|
||||||
// ─────────────────────────────────────────────────────────────────
|
|
||||||
Pass {
|
|
||||||
Name "ShadowCaster"
|
|
||||||
Tags { "LightMode" = "ShadowCaster" }
|
|
||||||
|
|
||||||
ZWrite On
|
|
||||||
ZTest LEqual
|
|
||||||
ColorMask 0
|
|
||||||
Cull Back
|
|
||||||
|
|
||||||
HLSLPROGRAM
|
|
||||||
#pragma vertex shadowVert
|
|
||||||
#pragma fragment shadowFrag
|
|
||||||
#pragma multi_compile_instancing
|
|
||||||
#pragma multi_compile_vertex _ _CASTING_PUNCTUAL_LIGHT_SHADOW
|
|
||||||
|
|
||||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
|
||||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Shadows.hlsl"
|
|
||||||
|
|
||||||
CBUFFER_START(UnityPerMaterial)
|
|
||||||
float4 _MainTex_ST;
|
|
||||||
float4 _BumpMap_ST;
|
|
||||||
half4 _Color;
|
|
||||||
half _Metallic;
|
|
||||||
half _Gloss;
|
|
||||||
CBUFFER_END
|
|
||||||
|
|
||||||
float3 _LightDirection;
|
|
||||||
float3 _LightPosition;
|
|
||||||
|
|
||||||
struct ShadowAttributes {
|
|
||||||
float4 positionOS : POSITION;
|
|
||||||
float3 normalOS : NORMAL;
|
|
||||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ShadowVaryings {
|
|
||||||
float4 positionCS : SV_POSITION;
|
|
||||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
||||||
};
|
|
||||||
|
|
||||||
ShadowVaryings shadowVert(ShadowAttributes v) {
|
|
||||||
ShadowVaryings o;
|
|
||||||
UNITY_SETUP_INSTANCE_ID(v);
|
|
||||||
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
|
||||||
|
|
||||||
float3 positionWS = TransformObjectToWorld(v.positionOS.xyz);
|
|
||||||
float3 normalWS = TransformObjectToWorldNormal(v.normalOS);
|
|
||||||
|
|
||||||
#if defined(_CASTING_PUNCTUAL_LIGHT_SHADOW)
|
|
||||||
float3 lightDir = normalize(_LightPosition - positionWS);
|
|
||||||
#else
|
#else
|
||||||
float3 lightDir = _LightDirection;
|
d.ambient = i.ambientOrLightmapUV;
|
||||||
#endif
|
#endif
|
||||||
|
#if UNITY_SPECCUBE_BLENDING || UNITY_SPECCUBE_BOX_PROJECTION
|
||||||
o.positionCS = TransformWorldToHClip(ApplyShadowBias(positionWS, normalWS, lightDir));
|
d.boxMin[0] = unity_SpecCube0_BoxMin;
|
||||||
#if UNITY_REVERSED_Z
|
d.boxMin[1] = unity_SpecCube1_BoxMin;
|
||||||
o.positionCS.z = min(o.positionCS.z, UNITY_NEAR_CLIP_VALUE);
|
#endif
|
||||||
|
#if UNITY_SPECCUBE_BOX_PROJECTION
|
||||||
|
d.boxMax[0] = unity_SpecCube0_BoxMax;
|
||||||
|
d.boxMax[1] = unity_SpecCube1_BoxMax;
|
||||||
|
d.probePosition[0] = unity_SpecCube0_ProbePosition;
|
||||||
|
d.probePosition[1] = unity_SpecCube1_ProbePosition;
|
||||||
|
#endif
|
||||||
|
d.probeHDR[0] = unity_SpecCube0_HDR;
|
||||||
|
d.probeHDR[1] = unity_SpecCube1_HDR;
|
||||||
|
Unity_GlossyEnvironmentData ugls_en_data;
|
||||||
|
ugls_en_data.roughness = 1.0 - gloss;
|
||||||
|
ugls_en_data.reflUVW = viewReflectDirection;
|
||||||
|
UnityGI gi = UnityGlobalIllumination(d, 1, normalDirection, ugls_en_data );
|
||||||
|
lightDirection = gi.light.dir;
|
||||||
|
lightColor = gi.light.color;
|
||||||
|
////// Specular:
|
||||||
|
float NdotL = saturate(dot( normalDirection, lightDirection ));
|
||||||
|
float LdotH = saturate(dot(lightDirection, halfDirection));
|
||||||
|
float3 specularColor = _Metallic;
|
||||||
|
float specularMonochrome;
|
||||||
|
float4 _MainTex_var = tex2D(_MainTex,TRANSFORM_TEX(i.uv0, _MainTex));
|
||||||
|
float3 diffuseColor = (_MainTex_var.rgb*_Color.rgb*i.vertexColor.rgb); // Need this for specular when using metallic
|
||||||
|
diffuseColor = DiffuseAndSpecularFromMetallic( diffuseColor, specularColor, specularColor, specularMonochrome );
|
||||||
|
specularMonochrome = 1.0-specularMonochrome;
|
||||||
|
float NdotV = abs(dot( normalDirection, viewDirection ));
|
||||||
|
float NdotH = saturate(dot( normalDirection, halfDirection ));
|
||||||
|
float VdotH = saturate(dot( viewDirection, halfDirection ));
|
||||||
|
float visTerm = SmithJointGGXVisibilityTerm( NdotL, NdotV, roughness );
|
||||||
|
float normTerm = GGXTerm(NdotH, roughness);
|
||||||
|
float specularPBL = (visTerm*normTerm) * UNITY_PI;
|
||||||
|
#ifdef UNITY_COLORSPACE_GAMMA
|
||||||
|
specularPBL = sqrt(max(1e-4h, specularPBL));
|
||||||
|
#endif
|
||||||
|
specularPBL = max(0, specularPBL * NdotL);
|
||||||
|
#if defined(_SPECULARHIGHLIGHTS_OFF)
|
||||||
|
specularPBL = 0.0;
|
||||||
|
#endif
|
||||||
|
half surfaceReduction;
|
||||||
|
#ifdef UNITY_COLORSPACE_GAMMA
|
||||||
|
surfaceReduction = 1.0-0.28*roughness*perceptualRoughness;
|
||||||
#else
|
#else
|
||||||
o.positionCS.z = max(o.positionCS.z, UNITY_NEAR_CLIP_VALUE);
|
surfaceReduction = 1.0/(roughness*roughness + 1.0);
|
||||||
#endif
|
#endif
|
||||||
return o;
|
specularPBL *= any(specularColor) ? 1.0 : 0.0;
|
||||||
|
float3 directSpecular = attenColor*specularPBL*FresnelTerm(specularColor, LdotH);
|
||||||
|
half grazingTerm = saturate( gloss + specularMonochrome );
|
||||||
|
float3 indirectSpecular = (gi.indirect.specular);
|
||||||
|
indirectSpecular *= FresnelLerp (specularColor, grazingTerm, NdotV);
|
||||||
|
indirectSpecular *= surfaceReduction;
|
||||||
|
float3 specular = (directSpecular + indirectSpecular);
|
||||||
|
/////// Diffuse:
|
||||||
|
NdotL = max(0.0,dot( normalDirection, lightDirection ));
|
||||||
|
half fd90 = 0.5 + 2 * LdotH * LdotH * (1-gloss);
|
||||||
|
float nlPow5 = Pow5(1-NdotL);
|
||||||
|
float nvPow5 = Pow5(1-NdotV);
|
||||||
|
float3 directDiffuse = ((1 +(fd90 - 1)*nlPow5) * (1 + (fd90 - 1)*nvPow5) * NdotL) * attenColor;
|
||||||
|
float3 indirectDiffuse = float3(0,0,0);
|
||||||
|
indirectDiffuse += gi.indirect.diffuse;
|
||||||
|
float3 diffuse = (directDiffuse + indirectDiffuse) * diffuseColor;
|
||||||
|
/// Final Color:
|
||||||
|
float3 finalColor = diffuse + specular;
|
||||||
|
fixed4 finalRGBA = fixed4(finalColor,1);
|
||||||
|
UNITY_APPLY_FOG(i.fogCoord, finalRGBA);
|
||||||
|
return finalRGBA;
|
||||||
}
|
}
|
||||||
|
ENDCG
|
||||||
half4 shadowFrag(ShadowVaryings i) : SV_Target { return 0; }
|
|
||||||
ENDHLSL
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─────────────────────────────────────────────────────────────────
|
|
||||||
// DepthOnly
|
|
||||||
// ─────────────────────────────────────────────────────────────────
|
|
||||||
Pass {
|
Pass {
|
||||||
Name "DepthOnly"
|
Name "FORWARD_DELTA"
|
||||||
Tags { "LightMode" = "DepthOnly" }
|
Tags {
|
||||||
|
"LightMode"="ForwardAdd"
|
||||||
|
}
|
||||||
|
Blend One One
|
||||||
|
|
||||||
ZWrite On
|
CGPROGRAM
|
||||||
ColorMask R
|
#pragma vertex vert
|
||||||
Cull Back
|
#pragma fragment frag
|
||||||
|
#define UNITY_PASS_FORWARDADD
|
||||||
HLSLPROGRAM
|
#define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) )
|
||||||
#pragma vertex depthVert
|
#define _GLOSSYENV 1
|
||||||
#pragma fragment depthFrag
|
#include "UnityCG.cginc"
|
||||||
#pragma multi_compile_instancing
|
#include "AutoLight.cginc"
|
||||||
|
#include "Lighting.cginc"
|
||||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
#include "UnityPBSLighting.cginc"
|
||||||
|
#include "UnityStandardBRDF.cginc"
|
||||||
CBUFFER_START(UnityPerMaterial)
|
#pragma multi_compile_fwdadd_fullshadows
|
||||||
float4 _MainTex_ST;
|
#pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON
|
||||||
float4 _BumpMap_ST;
|
#pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED DIRLIGHTMAP_SEPARATE
|
||||||
half4 _Color;
|
#pragma multi_compile DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON
|
||||||
half _Metallic;
|
#pragma multi_compile_fog
|
||||||
half _Gloss;
|
#pragma target 3.0
|
||||||
CBUFFER_END
|
uniform float4 _Color;
|
||||||
|
uniform sampler2D _MainTex; uniform float4 _MainTex_ST;
|
||||||
struct DepthAttributes {
|
uniform sampler2D _BumpMap; uniform float4 _BumpMap_ST;
|
||||||
float4 positionOS : POSITION;
|
uniform float _Metallic;
|
||||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
uniform float _Gloss;
|
||||||
|
struct VertexInput {
|
||||||
|
float4 vertex : POSITION;
|
||||||
|
float3 normal : NORMAL;
|
||||||
|
float4 tangent : TANGENT;
|
||||||
|
float2 texcoord0 : TEXCOORD0;
|
||||||
|
float2 texcoord1 : TEXCOORD1;
|
||||||
|
float2 texcoord2 : TEXCOORD2;
|
||||||
|
float4 vertexColor : COLOR;
|
||||||
};
|
};
|
||||||
|
struct VertexOutput {
|
||||||
struct DepthVaryings {
|
float4 pos : SV_POSITION;
|
||||||
float4 positionCS : SV_POSITION;
|
float2 uv0 : TEXCOORD0;
|
||||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
float4 uv1 : TEXCOORD1;
|
||||||
UNITY_VERTEX_OUTPUT_STEREO
|
float4 posWorld : TEXCOORD3;
|
||||||
|
float3 normalDir : TEXCOORD4;
|
||||||
|
float3 tangentDir : TEXCOORD5;
|
||||||
|
float3 bitangentDir : TEXCOORD6;
|
||||||
|
float4 vertexColor : COLOR;
|
||||||
|
LIGHTING_COORDS(7,8)
|
||||||
|
UNITY_FOG_COORDS(9)
|
||||||
};
|
};
|
||||||
|
VertexOutput vert (VertexInput v) {
|
||||||
DepthVaryings depthVert(DepthAttributes v) {
|
VertexOutput o = (VertexOutput)0;
|
||||||
DepthVaryings o;
|
o.uv0 = v.texcoord0;
|
||||||
UNITY_SETUP_INSTANCE_ID(v);
|
o.uv1 = float4(v.texcoord1, v.texcoord2);
|
||||||
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
o.vertexColor = v.vertexColor;
|
||||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
o.normalDir = UnityObjectToWorldNormal(v.normal);
|
||||||
o.positionCS = TransformObjectToHClip(v.positionOS.xyz);
|
o.tangentDir = normalize( mul( unity_ObjectToWorld, float4( v.tangent.xyz, 0.0 ) ).xyz );
|
||||||
|
o.bitangentDir = normalize(cross(o.normalDir, o.tangentDir) * v.tangent.w);
|
||||||
|
o.posWorld = mul(unity_ObjectToWorld, v.vertex);
|
||||||
|
float3 lightColor = _LightColor0.rgb;
|
||||||
|
o.pos = UnityObjectToClipPos( v.vertex );
|
||||||
|
UNITY_TRANSFER_FOG(o,o.pos);
|
||||||
|
TRANSFER_VERTEX_TO_FRAGMENT(o)
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
float4 frag(VertexOutput i) : COLOR {
|
||||||
half depthFrag(DepthVaryings i) : SV_Target { return i.positionCS.z; }
|
i.normalDir = normalize(i.normalDir);
|
||||||
ENDHLSL
|
float3x3 tangentTransform = float3x3( i.tangentDir, i.bitangentDir, i.normalDir);
|
||||||
|
float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
|
||||||
|
float3 _BumpMap_var = UnpackNormal(tex2D(_BumpMap,TRANSFORM_TEX(i.uv0, _BumpMap)));
|
||||||
|
float3 normalLocal = _BumpMap_var.rgb;
|
||||||
|
float3 normalDirection = normalize(mul( normalLocal, tangentTransform )); // Perturbed normals
|
||||||
|
float3 lightDirection = normalize(lerp(_WorldSpaceLightPos0.xyz, _WorldSpaceLightPos0.xyz - i.posWorld.xyz,_WorldSpaceLightPos0.w));
|
||||||
|
float3 lightColor = _LightColor0.rgb;
|
||||||
|
float3 halfDirection = normalize(viewDirection+lightDirection);
|
||||||
|
////// Lighting:
|
||||||
|
float attenuation = LIGHT_ATTENUATION(i);
|
||||||
|
float3 attenColor = attenuation * _LightColor0.xyz;
|
||||||
|
float Pi = 3.141592654;
|
||||||
|
float InvPi = 0.31830988618;
|
||||||
|
///////// Gloss:
|
||||||
|
float gloss = 1.0 - _Gloss; // Convert roughness to gloss
|
||||||
|
float perceptualRoughness = _Gloss;
|
||||||
|
float roughness = perceptualRoughness * perceptualRoughness;
|
||||||
|
float specPow = exp2( gloss * 10.0 + 1.0 );
|
||||||
|
////// Specular:
|
||||||
|
float NdotL = saturate(dot( normalDirection, lightDirection ));
|
||||||
|
float LdotH = saturate(dot(lightDirection, halfDirection));
|
||||||
|
float3 specularColor = _Metallic;
|
||||||
|
float specularMonochrome;
|
||||||
|
float4 _MainTex_var = tex2D(_MainTex,TRANSFORM_TEX(i.uv0, _MainTex));
|
||||||
|
float3 diffuseColor = (_MainTex_var.rgb*_Color.rgb*i.vertexColor.rgb); // Need this for specular when using metallic
|
||||||
|
diffuseColor = DiffuseAndSpecularFromMetallic( diffuseColor, specularColor, specularColor, specularMonochrome );
|
||||||
|
specularMonochrome = 1.0-specularMonochrome;
|
||||||
|
float NdotV = abs(dot( normalDirection, viewDirection ));
|
||||||
|
float NdotH = saturate(dot( normalDirection, halfDirection ));
|
||||||
|
float VdotH = saturate(dot( viewDirection, halfDirection ));
|
||||||
|
float visTerm = SmithJointGGXVisibilityTerm( NdotL, NdotV, roughness );
|
||||||
|
float normTerm = GGXTerm(NdotH, roughness);
|
||||||
|
float specularPBL = (visTerm*normTerm) * UNITY_PI;
|
||||||
|
#ifdef UNITY_COLORSPACE_GAMMA
|
||||||
|
specularPBL = sqrt(max(1e-4h, specularPBL));
|
||||||
|
#endif
|
||||||
|
specularPBL = max(0, specularPBL * NdotL);
|
||||||
|
#if defined(_SPECULARHIGHLIGHTS_OFF)
|
||||||
|
specularPBL = 0.0;
|
||||||
|
#endif
|
||||||
|
specularPBL *= any(specularColor) ? 1.0 : 0.0;
|
||||||
|
float3 directSpecular = attenColor*specularPBL*FresnelTerm(specularColor, LdotH);
|
||||||
|
float3 specular = directSpecular;
|
||||||
|
/////// Diffuse:
|
||||||
|
NdotL = max(0.0,dot( normalDirection, lightDirection ));
|
||||||
|
half fd90 = 0.5 + 2 * LdotH * LdotH * (1-gloss);
|
||||||
|
float nlPow5 = Pow5(1-NdotL);
|
||||||
|
float nvPow5 = Pow5(1-NdotV);
|
||||||
|
float3 directDiffuse = ((1 +(fd90 - 1)*nlPow5) * (1 + (fd90 - 1)*nvPow5) * NdotL) * attenColor;
|
||||||
|
float3 diffuse = directDiffuse * diffuseColor;
|
||||||
|
/// Final Color:
|
||||||
|
float3 finalColor = diffuse + specular;
|
||||||
|
fixed4 finalRGBA = fixed4(finalColor * 1,0);
|
||||||
|
UNITY_APPLY_FOG(i.fogCoord, finalRGBA);
|
||||||
|
return finalRGBA;
|
||||||
|
}
|
||||||
|
ENDCG
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─────────────────────────────────────────────────────────────────
|
|
||||||
// DepthNormals – needed by SSAO and other URP effects
|
|
||||||
// ─────────────────────────────────────────────────────────────────
|
|
||||||
Pass {
|
Pass {
|
||||||
Name "DepthNormals"
|
Name "Meta"
|
||||||
Tags { "LightMode" = "DepthNormals" }
|
Tags {
|
||||||
|
"LightMode"="Meta"
|
||||||
|
}
|
||||||
|
Cull Off
|
||||||
|
|
||||||
ZWrite On
|
CGPROGRAM
|
||||||
Cull Back
|
#pragma vertex vert
|
||||||
|
#pragma fragment frag
|
||||||
HLSLPROGRAM
|
#define UNITY_PASS_META 1
|
||||||
#pragma vertex depthNormalsVert
|
#define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) )
|
||||||
#pragma fragment depthNormalsFrag
|
#define _GLOSSYENV 1
|
||||||
#pragma multi_compile_instancing
|
#include "UnityCG.cginc"
|
||||||
|
#include "Lighting.cginc"
|
||||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
#include "UnityPBSLighting.cginc"
|
||||||
|
#include "UnityStandardBRDF.cginc"
|
||||||
TEXTURE2D(_BumpMap); SAMPLER(sampler_BumpMap);
|
#include "UnityMetaPass.cginc"
|
||||||
|
#pragma fragmentoption ARB_precision_hint_fastest
|
||||||
CBUFFER_START(UnityPerMaterial)
|
#pragma multi_compile_shadowcaster
|
||||||
float4 _MainTex_ST;
|
#pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON
|
||||||
float4 _BumpMap_ST;
|
#pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED DIRLIGHTMAP_SEPARATE
|
||||||
half4 _Color;
|
#pragma multi_compile DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON
|
||||||
half _Metallic;
|
#pragma multi_compile_fog
|
||||||
half _Gloss;
|
#pragma target 3.0
|
||||||
CBUFFER_END
|
uniform float4 _Color;
|
||||||
|
uniform sampler2D _MainTex; uniform float4 _MainTex_ST;
|
||||||
struct DNAttributes {
|
uniform float _Metallic;
|
||||||
float4 positionOS : POSITION;
|
uniform float _Gloss;
|
||||||
float3 normalOS : NORMAL;
|
struct VertexInput {
|
||||||
float4 tangentOS : TANGENT;
|
float4 vertex : POSITION;
|
||||||
float2 uv : TEXCOORD0;
|
float2 texcoord0 : TEXCOORD0;
|
||||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
float2 texcoord1 : TEXCOORD1;
|
||||||
|
float2 texcoord2 : TEXCOORD2;
|
||||||
|
float4 vertexColor : COLOR;
|
||||||
};
|
};
|
||||||
|
struct VertexOutput {
|
||||||
struct DNVaryings {
|
float4 pos : SV_POSITION;
|
||||||
float4 positionCS : SV_POSITION;
|
float2 uv0 : TEXCOORD0;
|
||||||
float2 uvBump : TEXCOORD0;
|
float4 uv1 : TEXCOORD1;
|
||||||
float3 normalWS : TEXCOORD1;
|
float4 posWorld : TEXCOORD3;
|
||||||
float4 tangentWS : TEXCOORD2;
|
float4 vertexColor : COLOR;
|
||||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
||||||
UNITY_VERTEX_OUTPUT_STEREO
|
|
||||||
};
|
};
|
||||||
|
VertexOutput vert (VertexInput v) {
|
||||||
DNVaryings depthNormalsVert(DNAttributes v) {
|
VertexOutput o = (VertexOutput)0;
|
||||||
DNVaryings o = (DNVaryings)0;
|
o.uv0 = v.texcoord0;
|
||||||
UNITY_SETUP_INSTANCE_ID(v);
|
o.uv1 = float4(v.texcoord1, v.texcoord2);
|
||||||
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
o.vertexColor = v.vertexColor;
|
||||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
o.posWorld = mul(unity_ObjectToWorld, v.vertex);
|
||||||
VertexNormalInputs normInputs = GetVertexNormalInputs(v.normalOS, v.tangentOS);
|
o.pos = UnityMetaVertexPosition(v.vertex, v.texcoord1.xy, v.texcoord2.xy, unity_LightmapST, unity_DynamicLightmapST );
|
||||||
o.positionCS = TransformObjectToHClip(v.positionOS.xyz);
|
|
||||||
o.uvBump = TRANSFORM_TEX(v.uv, _BumpMap);
|
|
||||||
o.normalWS = normInputs.normalWS;
|
|
||||||
o.tangentWS = float4(normInputs.tangentWS, v.tangentOS.w * GetOddNegativeScale());
|
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
float4 frag(VertexOutput i) : SV_Target {
|
||||||
|
float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
|
||||||
|
UnityMetaInput o;
|
||||||
|
UNITY_INITIALIZE_OUTPUT( UnityMetaInput, o );
|
||||||
|
|
||||||
float4 depthNormalsFrag(DNVaryings i) : SV_Target {
|
o.Emission = 0;
|
||||||
half4 normalSample = SAMPLE_TEXTURE2D(_BumpMap, sampler_BumpMap, i.uvBump);
|
|
||||||
half3 normalTS = UnpackNormal(normalSample);
|
float4 _MainTex_var = tex2D(_MainTex,TRANSFORM_TEX(i.uv0, _MainTex));
|
||||||
float3 bitangentWS = cross(i.normalWS, i.tangentWS.xyz) * i.tangentWS.w;
|
float3 diffColor = (_MainTex_var.rgb*_Color.rgb*i.vertexColor.rgb);
|
||||||
float3 normalWS = TransformTangentToWorld(normalTS,
|
float specularMonochrome;
|
||||||
float3x3(i.tangentWS.xyz, bitangentWS, i.normalWS));
|
float3 specColor;
|
||||||
normalWS = NormalizeNormalPerPixel(normalWS);
|
diffColor = DiffuseAndSpecularFromMetallic( diffColor, _Metallic, specColor, specularMonochrome );
|
||||||
return float4(normalWS * 0.5 + 0.5, 0.0);
|
float roughness = _Gloss;
|
||||||
|
o.Albedo = diffColor + specColor * roughness * roughness * 0.5;
|
||||||
|
|
||||||
|
return UnityMetaFragment( o );
|
||||||
}
|
}
|
||||||
ENDHLSL
|
ENDCG
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FallBack "Universal Render Pipeline/Lit"
|
FallBack "Standard"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ Material:
|
|||||||
m_ValidKeywords:
|
m_ValidKeywords:
|
||||||
- _ALPHAPREMULTIPLY_ON
|
- _ALPHAPREMULTIPLY_ON
|
||||||
- _EMISSION
|
- _EMISSION
|
||||||
|
- _SPECULAR_COLOR
|
||||||
- _SURFACE_TYPE_TRANSPARENT
|
- _SURFACE_TYPE_TRANSPARENT
|
||||||
m_InvalidKeywords: []
|
m_InvalidKeywords: []
|
||||||
m_LightmapFlags: 1
|
m_LightmapFlags: 1
|
||||||
@@ -25,7 +26,6 @@ Material:
|
|||||||
disabledShaderPasses:
|
disabledShaderPasses:
|
||||||
- MOTIONVECTORS
|
- MOTIONVECTORS
|
||||||
- DepthOnly
|
- DepthOnly
|
||||||
- SHADOWCASTER
|
|
||||||
m_LockedProperties:
|
m_LockedProperties:
|
||||||
m_SavedProperties:
|
m_SavedProperties:
|
||||||
serializedVersion: 3
|
serializedVersion: 3
|
||||||
@@ -55,7 +55,7 @@ Material:
|
|||||||
m_Scale: {x: 1, y: 1}
|
m_Scale: {x: 1, y: 1}
|
||||||
m_Offset: {x: 0, y: 0}
|
m_Offset: {x: 0, y: 0}
|
||||||
- _MainTex:
|
- _MainTex:
|
||||||
m_Texture: {fileID: 2800000, guid: 435eb10ee7c8e0b41812b2dd39ca7e2b, type: 3}
|
m_Texture: {fileID: 0}
|
||||||
m_Scale: {x: 1, y: 1}
|
m_Scale: {x: 1, y: 1}
|
||||||
m_Offset: {x: 0, y: 0}
|
m_Offset: {x: 0, y: 0}
|
||||||
- _MetallicGlossMap:
|
- _MetallicGlossMap:
|
||||||
@@ -116,11 +116,10 @@ Material:
|
|||||||
- _SrcBlendAlpha: 1
|
- _SrcBlendAlpha: 1
|
||||||
- _Surface: 1
|
- _Surface: 1
|
||||||
- _UVSec: 0
|
- _UVSec: 0
|
||||||
- _XRMotionVectorsPass: 1
|
|
||||||
- _ZWrite: 0
|
- _ZWrite: 0
|
||||||
m_Colors:
|
m_Colors:
|
||||||
- _BaseColor: {r: 0.28275868, g: 0, b: 1, a: 1}
|
- _BaseColor: {r: 0.28275868, g: 0, b: 1, a: 1}
|
||||||
- _Color: {r: 0.28275865, g: 0, b: 1, a: 1}
|
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||||
- _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1}
|
- _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1}
|
||||||
m_BuildTextureStacks: []
|
m_BuildTextureStacks: []
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ Material:
|
|||||||
m_Parent: {fileID: 0}
|
m_Parent: {fileID: 0}
|
||||||
m_ModifiedSerializedProperties: 0
|
m_ModifiedSerializedProperties: 0
|
||||||
m_ValidKeywords:
|
m_ValidKeywords:
|
||||||
- _ALPHAPREMULTIPLY_ON
|
|
||||||
- _COLORCOLOR_ON
|
- _COLORCOLOR_ON
|
||||||
- _SURFACE_TYPE_TRANSPARENT
|
- _SURFACE_TYPE_TRANSPARENT
|
||||||
m_InvalidKeywords:
|
m_InvalidKeywords:
|
||||||
@@ -21,13 +20,11 @@ Material:
|
|||||||
m_LightmapFlags: 0
|
m_LightmapFlags: 0
|
||||||
m_EnableInstancingVariants: 0
|
m_EnableInstancingVariants: 0
|
||||||
m_DoubleSidedGI: 0
|
m_DoubleSidedGI: 0
|
||||||
m_CustomRenderQueue: 3000
|
m_CustomRenderQueue: -1
|
||||||
stringTagMap:
|
stringTagMap:
|
||||||
RenderType: Transparent
|
RenderType: Opaque
|
||||||
disabledShaderPasses:
|
disabledShaderPasses:
|
||||||
- ALWAYS
|
- ALWAYS
|
||||||
- DepthOnly
|
|
||||||
- SHADOWCASTER
|
|
||||||
m_LockedProperties:
|
m_LockedProperties:
|
||||||
m_SavedProperties:
|
m_SavedProperties:
|
||||||
serializedVersion: 3
|
serializedVersion: 3
|
||||||
@@ -70,8 +67,8 @@ Material:
|
|||||||
- _DistortionEnabled: 0
|
- _DistortionEnabled: 0
|
||||||
- _DistortionStrength: 1
|
- _DistortionStrength: 1
|
||||||
- _DistortionStrengthScaled: 0
|
- _DistortionStrengthScaled: 0
|
||||||
- _DstBlend: 1
|
- _DstBlend: 0
|
||||||
- _DstBlendAlpha: 1
|
- _DstBlendAlpha: 0
|
||||||
- _EmissionEnabled: 0
|
- _EmissionEnabled: 0
|
||||||
- _FlipbookBlending: 0
|
- _FlipbookBlending: 0
|
||||||
- _FlipbookMode: 0
|
- _FlipbookMode: 0
|
||||||
@@ -89,7 +86,7 @@ Material:
|
|||||||
- _SrcBlend: 1
|
- _SrcBlend: 1
|
||||||
- _SrcBlendAlpha: 1
|
- _SrcBlendAlpha: 1
|
||||||
- _Surface: 1
|
- _Surface: 1
|
||||||
- _ZWrite: 0
|
- _ZWrite: 1
|
||||||
m_Colors:
|
m_Colors:
|
||||||
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
|
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
|
||||||
- _BaseColorAddSubDiff: {r: 0, g: 0, b: 0, a: 0}
|
- _BaseColorAddSubDiff: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ Material:
|
|||||||
m_ModifiedSerializedProperties: 0
|
m_ModifiedSerializedProperties: 0
|
||||||
m_ValidKeywords:
|
m_ValidKeywords:
|
||||||
- _EMISSION
|
- _EMISSION
|
||||||
|
- _GLOSSINESS_FROM_BASE_ALPHA
|
||||||
|
- _SPECULAR_COLOR
|
||||||
m_InvalidKeywords: []
|
m_InvalidKeywords: []
|
||||||
m_LightmapFlags: 1
|
m_LightmapFlags: 1
|
||||||
m_EnableInstancingVariants: 0
|
m_EnableInstancingVariants: 0
|
||||||
@@ -47,8 +49,8 @@ Material:
|
|||||||
m_Scale: {x: 1, y: 1}
|
m_Scale: {x: 1, y: 1}
|
||||||
m_Offset: {x: 0, y: 0}
|
m_Offset: {x: 0, y: 0}
|
||||||
- _MainTex:
|
- _MainTex:
|
||||||
m_Texture: {fileID: 2800000, guid: 900e49f80a88714429ddb6e43b813ef6, type: 3}
|
m_Texture: {fileID: 0}
|
||||||
m_Scale: {x: 5, y: 5}
|
m_Scale: {x: 1, y: 1}
|
||||||
m_Offset: {x: 0, y: 0}
|
m_Offset: {x: 0, y: 0}
|
||||||
- _ParallaxMap:
|
- _ParallaxMap:
|
||||||
m_Texture: {fileID: 0}
|
m_Texture: {fileID: 0}
|
||||||
@@ -95,7 +97,6 @@ Material:
|
|||||||
- _SrcBlend: 1
|
- _SrcBlend: 1
|
||||||
- _SrcBlendAlpha: 1
|
- _SrcBlendAlpha: 1
|
||||||
- _Surface: 0
|
- _Surface: 0
|
||||||
- _XRMotionVectorsPass: 1
|
|
||||||
- _ZWrite: 1
|
- _ZWrite: 1
|
||||||
m_Colors:
|
m_Colors:
|
||||||
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
|
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user