Migrate shaders to URP and add loading screen

Reworks multiple shaders and materials for URP compatibility and adds a Loading screen/scene and a few model imports. Key changes:
- Converted ProBuilder standard vertex-color shader and several particle/surface shaders to URP HLSL passes (UniversalForward, ShadowCaster, Depth, DepthNormals) preserving base texture * tint * vertex color, normal map and PBR parameters.
- Updated particle SurfaceShader_VC to a URP forward pass and simplified lighting to use URP shader library helpers.
- Updated materials (landMark, tile) to point to project textures, adjust keywords/flags (e.g. XRMotionVectorsPass, disable ShadowCaster for one), tweak tiling and base color values.
- Added a Loading screen UI (UXML, USS) and LoadingScreenController.cs plus a new Loading scene and scene metadata.
- Imported new FBX assets (T-Pose, Untitled) and updated Editor build settings / project settings to include the new Loading scene.
These changes migrate rendering code to the Universal Render Pipeline and add a basic loading UI/scene, while updating materials and project settings accordingly.
This commit is contained in:
Robii Aragon
2026-02-23 21:47:59 -08:00
parent 31ada61565
commit 0e961ba4b1
37 changed files with 2867 additions and 1155 deletions

View File

@@ -1,410 +1,356 @@
/**
* 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;*/
// 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
Shader "ProBuilder/Standard Vertex Color" {
Properties {
_MainTex ("Base Color", 2D) = "white" {}
_BumpMap ("Normal Map", 2D) = "bump" {}
_Color ("Color", Color) = (1,1,1,1)
_Metallic ("Metallic", Range(0, 1)) = 0
_Gloss ("Gloss", Range(0, 1)) = 0.8
_MainTex ("Base Color", 2D) = "white" {}
_BumpMap ("Normal Map", 2D) = "bump" {}
_Color ("Color", Color) = (1,1,1,1)
_Metallic ("Metallic", Range(0, 1)) = 0
_Gloss ("Gloss", Range(0, 1)) = 0.8
}
SubShader {
Tags {
"RenderType"="Opaque"
"RenderType" = "Opaque"
"RenderPipeline" = "UniversalPipeline"
"Queue" = "Geometry"
}
Pass {
Name "FORWARD"
Tags {
"LightMode"="ForwardBase"
}
LOD 300
CGPROGRAM
#pragma vertex vert
// ─────────────────────────────────────────────────────────────────
// UniversalForward – main PBR pass
// ─────────────────────────────────────────────────────────────────
Pass {
Name "UniversalForward"
Tags { "LightMode" = "UniversalForward" }
HLSLPROGRAM
#pragma vertex vert
#pragma fragment frag
#define UNITY_PASS_FORWARDBASE
#define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) )
#define _GLOSSYENV 1
#include "UnityCG.cginc"
#include "AutoLight.cginc"
#include "Lighting.cginc"
#include "UnityPBSLighting.cginc"
#include "UnityStandardBRDF.cginc"
#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 _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN
#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
#pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS
#pragma multi_compile_fragment _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH
#pragma multi_compile _ LIGHTMAP_SHADOW_MIXING
#pragma multi_compile _ SHADOWS_SHADOWMASK
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
#pragma multi_compile _ LIGHTMAP_ON
#pragma multi_compile_fog
#pragma target 3.0
uniform float4 _Color;
uniform sampler2D _MainTex; uniform float4 _MainTex_ST;
uniform sampler2D _BumpMap; uniform float4 _BumpMap_ST;
uniform float _Metallic;
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;
#pragma multi_compile_instancing
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
TEXTURE2D(_MainTex); SAMPLER(sampler_MainTex);
TEXTURE2D(_BumpMap); SAMPLER(sampler_BumpMap);
CBUFFER_START(UnityPerMaterial)
float4 _MainTex_ST;
float4 _BumpMap_ST;
half4 _Color;
half _Metallic;
half _Gloss;
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 {
float4 pos : SV_POSITION;
float2 uv0 : TEXCOORD0;
float4 uv1 : TEXCOORD1;
float4 posWorld : TEXCOORD3;
float3 normalDir : TEXCOORD4;
float3 tangentDir : TEXCOORD5;
float3 bitangentDir : TEXCOORD6;
float4 vertexColor : COLOR;
LIGHTING_COORDS(7,8)
UNITY_FOG_COORDS(9)
#if defined(LIGHTMAP_ON) || defined(UNITY_SHOULD_SAMPLE_SH)
float4 ambientOrLightmapUV : TEXCOORD10;
struct Varyings {
float4 positionCS : SV_POSITION;
float2 uv : TEXCOORD0;
float2 uvBump : TEXCOORD1;
float3 positionWS : TEXCOORD2;
float3 normalWS : TEXCOORD3;
float4 tangentWS : TEXCOORD4; // xyz: tangent, w: sign
half4 vertexColor : COLOR;
DECLARE_LIGHTMAP_OR_SH(staticLightmapUV, vertexSH, 5);
half4 fogFactorAndVertexLight : TEXCOORD6; // x: fog, yzw: vertex lights
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
float4 shadowCoord : TEXCOORD7;
#endif
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
VertexOutput vert (VertexInput v) {
VertexOutput o = (VertexOutput)0;
o.uv0 = v.texcoord0;
o.uv1 = float4(v.texcoord1, v.texcoord2);
Varyings vert(Attributes v) {
Varyings o = (Varyings)0;
UNITY_SETUP_INSTANCE_ID(v);
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;
#ifdef LIGHTMAP_ON
o.ambientOrLightmapUV.xy = v.texcoord1.xy * unity_LightmapST.xy + unity_LightmapST.zw;
o.ambientOrLightmapUV.zw = 0;
#elif UNITY_SHOULD_SAMPLE_SH
OUTPUT_LIGHTMAP_UV(v.lightmapUV, unity_LightmapST, o.staticLightmapUV);
OUTPUT_SH(o.normalWS.xyz, o.vertexSH);
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
#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;
}
float4 frag(VertexOutput i) : COLOR {
i.normalDir = normalize(i.normalDir);
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 viewReflectDirection = reflect( -viewDirection, normalDirection );
float3 lightDirection = normalize(_WorldSpaceLightPos0.xyz);
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 );
/////// GI Data:
UnityLight light;
#ifdef LIGHTMAP_OFF
light.color = lightColor;
light.dir = lightDirection;
light.ndotl = LambertTerm (normalDirection, light.dir);
#else
light.color = half3(0.f, 0.f, 0.f);
light.ndotl = 0.0f;
light.dir = half3(0.f, 0.f, 0.f);
#endif
UnityGIInput d;
d.light = light;
d.worldPos = i.posWorld.xyz;
d.worldViewDir = viewDirection;
d.atten = attenuation;
#if defined(LIGHTMAP_ON) || defined(DYNAMICLIGHTMAP_ON)
d.ambient = 0;
d.lightmapUV = i.ambientOrLightmapUV;
#else
d.ambient = i.ambientOrLightmapUV;
#endif
#if UNITY_SPECCUBE_BLENDING || UNITY_SPECCUBE_BOX_PROJECTION
d.boxMin[0] = unity_SpecCube0_BoxMin;
d.boxMin[1] = unity_SpecCube1_BoxMin;
#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
surfaceReduction = 1.0/(roughness*roughness + 1.0);
#endif
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
}
Pass {
Name "FORWARD_DELTA"
Tags {
"LightMode"="ForwardAdd"
}
Blend One One
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#define UNITY_PASS_FORWARDADD
#define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) )
#define _GLOSSYENV 1
#include "UnityCG.cginc"
#include "AutoLight.cginc"
#include "Lighting.cginc"
#include "UnityPBSLighting.cginc"
#include "UnityStandardBRDF.cginc"
#pragma multi_compile_fwdadd_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 target 3.0
uniform float4 _Color;
uniform sampler2D _MainTex; uniform float4 _MainTex_ST;
uniform sampler2D _BumpMap; uniform float4 _BumpMap_ST;
uniform float _Metallic;
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;
half4 frag(Varyings i) : SV_Target {
UNITY_SETUP_INSTANCE_ID(i);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
// Albedo = texture * color tint * vertex color (matches original logic)
half4 albedoSample = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uv);
half3 albedo = albedoSample.rgb * _Color.rgb * i.vertexColor.rgb;
// Normal map
half4 normalSample = SAMPLE_TEXTURE2D(_BumpMap, sampler_BumpMap, i.uvBump);
half3 normalTS = UnpackNormal(normalSample);
float3 bitangentWS = cross(i.normalWS, i.tangentWS.xyz) * i.tangentWS.w;
float3 normalWS = TransformTangentToWorld(normalTS,
float3x3(i.tangentWS.xyz, bitangentWS, i.normalWS));
normalWS = NormalizeNormalPerPixel(normalWS);
// Shadow coordinate
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
float4 shadowCoord = i.shadowCoord;
#elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
float4 shadowCoord = TransformWorldToShadowCoord(i.positionWS);
#else
float4 shadowCoord = float4(0, 0, 0, 0);
#endif
// Build URP surface / input structs
SurfaceData surfaceData = (SurfaceData)0;
surfaceData.albedo = albedo;
surfaceData.metallic = _Metallic;
surfaceData.smoothness = _Gloss;
surfaceData.normalTS = normalTS;
surfaceData.occlusion = 1.0h;
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 VertexOutput {
float4 pos : SV_POSITION;
float2 uv0 : TEXCOORD0;
float4 uv1 : TEXCOORD1;
float4 posWorld : TEXCOORD3;
float3 normalDir : TEXCOORD4;
float3 tangentDir : TEXCOORD5;
float3 bitangentDir : TEXCOORD6;
float4 vertexColor : COLOR;
LIGHTING_COORDS(7,8)
UNITY_FOG_COORDS(9)
struct ShadowVaryings {
float4 positionCS : SV_POSITION;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
VertexOutput vert (VertexInput v) {
VertexOutput o = (VertexOutput)0;
o.uv0 = v.texcoord0;
o.uv1 = float4(v.texcoord1, v.texcoord2);
o.vertexColor = v.vertexColor;
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)
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
float3 lightDir = _LightDirection;
#endif
o.positionCS = TransformWorldToHClip(ApplyShadowBias(positionWS, normalWS, lightDir));
#if UNITY_REVERSED_Z
o.positionCS.z = min(o.positionCS.z, UNITY_NEAR_CLIP_VALUE);
#else
o.positionCS.z = max(o.positionCS.z, UNITY_NEAR_CLIP_VALUE);
#endif
return o;
}
float4 frag(VertexOutput i) : COLOR {
i.normalDir = normalize(i.normalDir);
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
}
Pass {
Name "Meta"
Tags {
"LightMode"="Meta"
}
Cull Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#define UNITY_PASS_META 1
#define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) )
#define _GLOSSYENV 1
#include "UnityCG.cginc"
#include "Lighting.cginc"
#include "UnityPBSLighting.cginc"
#include "UnityStandardBRDF.cginc"
#include "UnityMetaPass.cginc"
#pragma fragmentoption ARB_precision_hint_fastest
#pragma multi_compile_shadowcaster
#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 target 3.0
uniform float4 _Color;
uniform sampler2D _MainTex; uniform float4 _MainTex_ST;
uniform float _Metallic;
uniform float _Gloss;
struct VertexInput {
float4 vertex : POSITION;
float2 texcoord0 : TEXCOORD0;
float2 texcoord1 : TEXCOORD1;
float2 texcoord2 : TEXCOORD2;
float4 vertexColor : COLOR;
half4 shadowFrag(ShadowVaryings i) : SV_Target { return 0; }
ENDHLSL
}
// ─────────────────────────────────────────────────────────────────
// DepthOnly
// ─────────────────────────────────────────────────────────────────
Pass {
Name "DepthOnly"
Tags { "LightMode" = "DepthOnly" }
ZWrite On
ColorMask R
Cull Back
HLSLPROGRAM
#pragma vertex depthVert
#pragma fragment depthFrag
#pragma multi_compile_instancing
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
CBUFFER_START(UnityPerMaterial)
float4 _MainTex_ST;
float4 _BumpMap_ST;
half4 _Color;
half _Metallic;
half _Gloss;
CBUFFER_END
struct DepthAttributes {
float4 positionOS : POSITION;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct VertexOutput {
float4 pos : SV_POSITION;
float2 uv0 : TEXCOORD0;
float4 uv1 : TEXCOORD1;
float4 posWorld : TEXCOORD3;
float4 vertexColor : COLOR;
struct DepthVaryings {
float4 positionCS : SV_POSITION;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
VertexOutput vert (VertexInput v) {
VertexOutput o = (VertexOutput)0;
o.uv0 = v.texcoord0;
o.uv1 = float4(v.texcoord1, v.texcoord2);
o.vertexColor = v.vertexColor;
o.posWorld = mul(unity_ObjectToWorld, v.vertex);
o.pos = UnityMetaVertexPosition(v.vertex, v.texcoord1.xy, v.texcoord2.xy, unity_LightmapST, unity_DynamicLightmapST );
DepthVaryings depthVert(DepthAttributes v) {
DepthVaryings o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.positionCS = TransformObjectToHClip(v.positionOS.xyz);
return o;
}
float4 frag(VertexOutput i) : SV_Target {
float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
UnityMetaInput o;
UNITY_INITIALIZE_OUTPUT( UnityMetaInput, o );
o.Emission = 0;
half depthFrag(DepthVaryings i) : SV_Target { return i.positionCS.z; }
ENDHLSL
}
float4 _MainTex_var = tex2D(_MainTex,TRANSFORM_TEX(i.uv0, _MainTex));
float3 diffColor = (_MainTex_var.rgb*_Color.rgb*i.vertexColor.rgb);
float specularMonochrome;
float3 specColor;
diffColor = DiffuseAndSpecularFromMetallic( diffColor, _Metallic, specColor, specularMonochrome );
float roughness = _Gloss;
o.Albedo = diffColor + specColor * roughness * roughness * 0.5;
// ─────────────────────────────────────────────────────────────────
// DepthNormals – needed by SSAO and other URP effects
// ─────────────────────────────────────────────────────────────────
Pass {
Name "DepthNormals"
Tags { "LightMode" = "DepthNormals" }
return UnityMetaFragment( o );
ZWrite On
Cull Back
HLSLPROGRAM
#pragma vertex depthNormalsVert
#pragma fragment depthNormalsFrag
#pragma multi_compile_instancing
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
TEXTURE2D(_BumpMap); SAMPLER(sampler_BumpMap);
CBUFFER_START(UnityPerMaterial)
float4 _MainTex_ST;
float4 _BumpMap_ST;
half4 _Color;
half _Metallic;
half _Gloss;
CBUFFER_END
struct DNAttributes {
float4 positionOS : POSITION;
float3 normalOS : NORMAL;
float4 tangentOS : TANGENT;
float2 uv : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct DNVaryings {
float4 positionCS : SV_POSITION;
float2 uvBump : TEXCOORD0;
float3 normalWS : TEXCOORD1;
float4 tangentWS : TEXCOORD2;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
DNVaryings depthNormalsVert(DNAttributes v) {
DNVaryings o = (DNVaryings)0;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
VertexNormalInputs normInputs = GetVertexNormalInputs(v.normalOS, v.tangentOS);
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;
}
ENDCG
float4 depthNormalsFrag(DNVaryings i) : SV_Target {
half4 normalSample = SAMPLE_TEXTURE2D(_BumpMap, sampler_BumpMap, i.uvBump);
half3 normalTS = UnpackNormal(normalSample);
float3 bitangentWS = cross(i.normalWS, i.tangentWS.xyz) * i.tangentWS.w;
float3 normalWS = TransformTangentToWorld(normalTS,
float3x3(i.tangentWS.xyz, bitangentWS, i.normalWS));
normalWS = NormalizeNormalPerPixel(normalWS);
return float4(normalWS * 0.5 + 0.5, 0.0);
}
ENDHLSL
}
}
FallBack "Standard"
FallBack "Universal Render Pipeline/Lit"
}

View File

@@ -14,7 +14,6 @@ Material:
m_ValidKeywords:
- _ALPHAPREMULTIPLY_ON
- _EMISSION
- _SPECULAR_COLOR
- _SURFACE_TYPE_TRANSPARENT
m_InvalidKeywords: []
m_LightmapFlags: 1
@@ -26,6 +25,7 @@ Material:
disabledShaderPasses:
- MOTIONVECTORS
- DepthOnly
- SHADOWCASTER
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
@@ -55,7 +55,7 @@ Material:
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 435eb10ee7c8e0b41812b2dd39ca7e2b, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
@@ -116,10 +116,11 @@ Material:
- _SrcBlendAlpha: 1
- _Surface: 1
- _UVSec: 0
- _XRMotionVectorsPass: 1
- _ZWrite: 0
m_Colors:
- _BaseColor: {r: 0.28275868, g: 0, b: 1, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 0.28275865, g: 0, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1}
m_BuildTextureStacks: []

View File

@@ -13,8 +13,6 @@ Material:
m_ModifiedSerializedProperties: 0
m_ValidKeywords:
- _EMISSION
- _GLOSSINESS_FROM_BASE_ALPHA
- _SPECULAR_COLOR
m_InvalidKeywords: []
m_LightmapFlags: 1
m_EnableInstancingVariants: 0
@@ -49,8 +47,8 @@ Material:
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Texture: {fileID: 2800000, guid: 900e49f80a88714429ddb6e43b813ef6, type: 3}
m_Scale: {x: 5, y: 5}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
@@ -97,6 +95,7 @@ Material:
- _SrcBlend: 1
- _SrcBlendAlpha: 1
- _Surface: 0
- _XRMotionVectorsPass: 1
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}

View File

@@ -1,47 +1,91 @@
Shader "Custom/SurfaceShader_VC" {
Properties{
Shader "Custom/URP_SurfaceShader_VC"
{
Properties
{
_Color("Color", Color) = (1,1,1,1)
_MainTex("Albedo (RGB)", 2D) = "white" {}
_Normal("Normap Map", 2D) = "bump" {}
_Normal("Normal Map", 2D) = "bump" {}
}
SubShader{
Tags{ "Queue" = "Transparent" "RenderType" = "Transparent" }
SubShader
{
Tags { "Queue" = "Transparent" "RenderType" = "Transparent" }
LOD 200
Blend One OneMinusSrcAlpha
CGPROGRAM
// Physically based Standard lighting model, and enable shadows on all light types
#pragma surface surf Standard fullforwardshadows vertex:vert alpha:fade
Pass
{
Name "FORWARD"
Tags { "LightMode" = "UniversalForward" }
// Use shader model 3.0 target, to get nicer looking lighting
#pragma target 3.0
HLSLPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fog
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
sampler2D _MainTex;
sampler2D _Normal;
struct Attributes
{
float4 positionOS : POSITION;
float2 uv : TEXCOORD0;
float4 color : COLOR;
float3 normalOS : NORMAL;
float4 tangentOS : TANGENT;
};
struct Input {
float2 uv_MainTex;
float4 vertex : SV_POSITION;
float4 color : COLOR;
};
struct Varyings
{
float4 positionHCS : SV_POSITION;
float2 uv : TEXCOORD0;
float4 color : COLOR;
float3 normalWS : TEXCOORD1;
float3 tangentWS : TEXCOORD2;
float3 bitangentWS : TEXCOORD3;
float fogFactor : TEXCOORD4;
};
void vert(inout appdata_full v, out Input o)
{
UNITY_INITIALIZE_OUTPUT(Input, o);
o.color = v.color;
CBUFFER_START(UnityPerMaterial)
float4 _Color;
CBUFFER_END
TEXTURE2D(_MainTex); SAMPLER(sampler_MainTex);
TEXTURE2D(_Normal); SAMPLER(sampler_Normal);
Varyings vert(Attributes IN)
{
Varyings OUT;
OUT.positionHCS = TransformObjectToHClip(IN.positionOS.xyz);
OUT.uv = IN.uv;
OUT.color = IN.color;
float3 normalWS = TransformObjectToWorldNormal(IN.normalOS);
float3 tangentWS = TransformObjectToWorldDir(IN.tangentOS.xyz);
float3 bitangentWS = cross(normalWS, tangentWS) * IN.tangentOS.w;
OUT.normalWS = normalWS;
OUT.tangentWS = tangentWS;
OUT.bitangentWS = bitangentWS;
OUT.fogFactor = ComputeFogFactor(OUT.positionHCS.z / OUT.positionHCS.w);
return OUT;
}
float4 frag(Varyings IN) : SV_Target
{
float4 albedo = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, IN.uv) * _Color;
float3 normalTS = UnpackNormal(SAMPLE_TEXTURE2D(_Normal, sampler_Normal, IN.uv));
float3x3 TBN = float3x3(IN.tangentWS, IN.bitangentWS, IN.normalWS);
float3 normalWS = normalize(mul(normalTS, TBN));
float3 viewDirWS = normalize(_WorldSpaceCameraPos - IN.positionHCS.xyz);
float3 lightDirWS = normalize(_MainLightPosition.xyz);
float3 lightColor = _MainLightColor.rgb;
float NdotL = saturate(dot(normalWS, lightDirWS));
float3 diffuse = albedo.rgb * lightColor * NdotL * IN.color.rgb;
float alpha = albedo.a * IN.color.a;
diffuse = MixFog(diffuse, IN.fogFactor);
return float4(diffuse, alpha);
}
ENDHLSL
}
}
fixed4 _Color;
void surf(Input IN, inout SurfaceOutputStandard o) {
// Albedo comes from a texture tinted by color
fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
o.Albedo = c.rgb*IN.color;
o.Normal = UnpackNormal(tex2D(_Normal, IN.uv_MainTex));
o.Alpha = c.a*IN.color.a;
}
ENDCG
}
FallBack "Diffuse"
FallBack "Universal Forward"
}

View File

@@ -1,59 +1,79 @@
Shader "Custom/Dissolve"
Shader "Custom/URP_Dissolve"
{
Properties {
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Glossiness ("Smoothness", Range(0,1)) = 0.5
_Metallic ("Metallic", Range(0,1)) = 0.0
_DissolveTexture("Dissolve Texture", 2D) = "white" {}
_DissolveTexture("Dissolve Texture", 2D) = "white" {}
_Amount("Amount", Range(0,1)) = 0
_DissolveColor ("Disolve Color", Color) = (1,1,1,1)
_DissolveColor ("Dissolve Color", Color) = (1,1,1,1)
_DissolveColorAlpha ("Dissolve Color Alpha", Range(0,1)) = 0.0
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
Cull Off
CGPROGRAM
#pragma surface surf Standard fullforwardshadows
Pass {
Name "FORWARD"
Tags { "LightMode" = "UniversalForward" }
#pragma target 3.0
HLSLPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fog
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
sampler2D _MainTex;
struct Attributes {
float4 positionOS : POSITION;
float2 uv : TEXCOORD0;
};
struct Input {
float2 uv_MainTex;
};
struct Varyings {
float4 positionHCS : SV_POSITION;
float2 uv : TEXCOORD0;
float fogFactor : TEXCOORD1;
};
half _Glossiness;
half _Metallic;
fixed4 _Color;
fixed3 _DissolveColor;
half _DissolveColorAlpha;
CBUFFER_START(UnityPerMaterial)
float4 _Color;
float _Glossiness;
float _Metallic;
float4 _DissolveColor;
float _DissolveColorAlpha;
float _Amount;
CBUFFER_END
//Dissolve properties
sampler2D _DissolveTexture;
half _Amount;
TEXTURE2D(_MainTex); SAMPLER(sampler_MainTex);
TEXTURE2D(_DissolveTexture); SAMPLER(sampler_DissolveTexture);
void surf (Input IN, inout SurfaceOutputStandard o) {
Varyings vert(Attributes IN)
{
Varyings OUT;
OUT.positionHCS = TransformObjectToHClip(IN.positionOS.xyz);
OUT.uv = IN.uv;
OUT.fogFactor = ComputeFogFactor(OUT.positionHCS.z / OUT.positionHCS.w);
return OUT;
}
//Dissolve function
half dissolve_value = tex2D(_DissolveTexture, IN.uv_MainTex).r;
clip(dissolve_value - _Amount);
float4 frag(Varyings IN) : SV_Target
{
float dissolve_value = SAMPLE_TEXTURE2D(_DissolveTexture, sampler_DissolveTexture, IN.uv).r;
clip(dissolve_value - _Amount);
//Basic shader function
fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
float4 albedo = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, IN.uv) * _Color;
o.Albedo = c.rgb;
o.Metallic = _Metallic;
o.Smoothness = _Glossiness;
o.Alpha = c.a;
o.Emission = fixed3(_DissolveColor.r, _DissolveColor.g, _DissolveColor.b) * step( dissolve_value - _Amount, _DissolveColorAlpha); //emits white color with 0.05 border size
// Simple metallic/smoothness (not PBR, but for effect)
float3 emission = _DissolveColor.rgb * step(dissolve_value - _Amount, _DissolveColorAlpha);
float3 color = albedo.rgb + emission;
float alpha = albedo.a;
color = MixFog(color, IN.fogFactor);
return float4(color, alpha);
}
ENDHLSL
}
ENDCG
}
FallBack "Diffuse"
FallBack "Universal Forward"
}

View File

@@ -2,19 +2,24 @@
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
serializedVersion: 8
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Foot Dust Particles
m_Shader: {fileID: 203, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords:
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
@@ -54,6 +59,7 @@ Material:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
@@ -75,4 +81,6 @@ Material:
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _TintColor: {r: 0.74264705, g: 0.5023789, b: 0.5023789, a: 0.5}
- _TintColor: {r: 0.3490566, g: 0.3490566, b: 0.3490566, a: 0.5}
m_BuildTextureStacks: []
m_AllowLocking: 1

View File

@@ -1,61 +1,73 @@
Shader "Custom/Glow Shader" {
Properties {
_Color ("Color", Color) = (1,1,1,1)
_Size ("Atmosphere Size Multiplier", Range(0,16)) = 4
_Rim ("Fade Power", Range(0,8)) = 4
_Light ("Lighting Power", Range(0,10)) = 1.4
_Ambient ("Ambient Power", Range (0,6)) = 0.8
}
SubShader {
Tags { "RenderType"="Transparent" }
LOD 200
Cull Front
CGPROGRAM
// Physically based Standard lighting model, and enable shadows on all light types
#pragma surface surf NegativeLambert fullforwardshadows alpha:fade
#pragma vertex vert
// Use shader model 3.0 target, to get nicer looking lighting
#pragma target 3.0
struct Input {
float3 viewDir;
};
half _Size;
half _Rim;
half _Light;
half _Ambient;
fixed4 _Color;
void vert (inout appdata_full v) {
v.vertex.xyz += v.vertex.xyz * _Size / 10;
v.normal *= -1;
}
half4 LightingNegativeLambert (SurfaceOutput s, half3 lightDir, half3 viewDir, half atten) {
s.Normal = normalize (s.Normal);
half diff = max (0, dot (-s.Normal, lightDir)) * _Light + _Ambient;
half4 c;
c.rgb = (s.Albedo * _LightColor0 * diff) * atten;
c.a = s.Alpha;
return c;
}
void surf (Input IN, inout SurfaceOutput o) {
half rim = saturate (dot (normalize (IN.viewDir), o.Normal));
// Albedo comes from a texture tinted by color
fixed4 c = _Color;
o.Albedo = c.rgb;
o.Alpha = lerp (0, 1, pow (rim, _Rim));
}
ENDCG
}
FallBack "Diffuse"
Shader "Custom/URP_GlowShader"
{
Properties {
_Color ("Color", Color) = (1,1,1,1)
_Size ("Atmosphere Size Multiplier", Range(0,16)) = 4
_Rim ("Fade Power", Range(0,8)) = 4
_Light ("Lighting Power", Range(0,10)) = 1.4
_Ambient ("Ambient Power", Range (0,6)) = 0.8
}
SubShader {
Tags { "RenderType"="Transparent" }
LOD 200
Cull Front
Pass {
Name "FORWARD"
Tags { "LightMode" = "UniversalForward" }
HLSLPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fog
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
struct Attributes {
float4 positionOS : POSITION;
float3 normalOS : NORMAL;
};
struct Varyings {
float4 positionHCS : SV_POSITION;
float3 normalWS : TEXCOORD0;
float3 viewDirWS : TEXCOORD1;
float fogFactor : TEXCOORD2;
};
CBUFFER_START(UnityPerMaterial)
float4 _Color;
float _Size;
float _Rim;
float _Light;
float _Ambient;
CBUFFER_END
Varyings vert(Attributes IN)
{
Varyings OUT;
float3 scaled = IN.positionOS.xyz + IN.positionOS.xyz * (_Size / 10.0);
OUT.positionHCS = TransformObjectToHClip(scaled);
float3 normalWS = TransformObjectToWorldNormal(-IN.normalOS); // Invert normal
OUT.normalWS = normalWS;
OUT.viewDirWS = normalize(_WorldSpaceCameraPos - TransformObjectToWorld(scaled));
OUT.fogFactor = ComputeFogFactor(OUT.positionHCS.z / OUT.positionHCS.w);
return OUT;
}
float4 frag(Varyings IN) : SV_Target
{
float rim = saturate(dot(normalize(IN.viewDirWS), IN.normalWS));
float alpha = lerp(0, 1, pow(rim, _Rim));
// Lighting: simple negative lambert
float3 lightDir = normalize(_MainLightPosition.xyz);
float diff = max(0, dot(-IN.normalWS, lightDir)) * _Light + _Ambient;
float3 color = _Color.rgb * _MainLightColor.rgb * diff;
color = MixFog(color, IN.fogFactor);
return float4(color, alpha * _Color.a);
}
ENDHLSL
}
}
FallBack "Universal Forward"
}

View File

@@ -1,80 +1,83 @@
Shader "Custom/Transparent Diffuse Stipple" {
Shader "Custom/URP Transparent Diffuse" {
Properties {
_MainTex("Base (RGB)", 2D) = "white" { }
_Color("Main Color", Color) = (1, 1, 1, 1)
_Glossiness ("Smoothness", Range(0,1)) = 0.5
_Metallic ("Metallic", Range(0,1)) = 0.0
_BumpMap ("Normalmap", 2D) = "bump" {}
_MainTex("Base (RGB)", 2D) = "white" {}
_Color("Main Color", Color) = (1,1,1,1)
_Glossiness("Smoothness", Range(0,1)) = 0.5
_Metallic("Metallic", Range(0,1)) = 0.0
_BumpMap("Normalmap", 2D) = "bump" {}
_TransparentAmount("Transparent Amount", Float) = 1
_StippleSize("Stipple Size", Float) = 1
}
SubShader {
Tags { "RenderType"="Opaque" }
Tags { "RenderType"="Transparent" "Queue"="Transparent" }
LOD 200
Cull Off
Blend SrcAlpha OneMinusSrcAlpha
Pass {
Name "FORWARD"
HLSLPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fog
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
CGPROGRAM
#pragma surface surf Standard fullforwardshadows
struct Attributes {
float4 positionOS : POSITION;
float2 uv : TEXCOORD0;
float2 uv2 : TEXCOORD1;
float3 normalOS : NORMAL;
float4 tangentOS : TANGENT;
};
#pragma target 3.0
struct Varyings {
float4 positionCS : SV_POSITION;
float2 uv : TEXCOORD0;
float2 uv2 : TEXCOORD1;
float3 normalWS : TEXCOORD2;
float4 screenPos : TEXCOORD3;
float3 tangentWS : TEXCOORD4;
float3 bitangentWS : TEXCOORD5;
};
float _TransparentAmount;
CBUFFER_START(UnityPerMaterial)
float4 _MainTex_ST;
float4 _Color;
float _Glossiness;
float _Metallic;
float _TransparentAmount;
float _StippleSize;
CBUFFER_END
sampler2D _MainTex;
TEXTURE2D(_MainTex); SAMPLER(sampler_MainTex);
TEXTURE2D(_BumpMap); SAMPLER(sampler_BumpMap);
fixed4 _Color;
Varyings vert(Attributes IN) {
Varyings OUT;
OUT.positionCS = TransformObjectToHClip(IN.positionOS.xyz);
OUT.uv = TRANSFORM_TEX(IN.uv, _MainTex);
OUT.uv2 = IN.uv2;
OUT.normalWS = TransformObjectToWorldNormal(IN.normalOS);
OUT.tangentWS = TransformObjectToWorldDir(IN.tangentOS.xyz);
OUT.bitangentWS = cross(OUT.normalWS, OUT.tangentWS) * IN.tangentOS.w;
OUT.screenPos = ComputeScreenPos(OUT.positionCS);
return OUT;
}
sampler2D _BumpMap;
float4 frag(Varyings IN) : SV_Target {
float4 albedo = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, IN.uv) * _Color;
float3 normalTS = UnpackNormal(SAMPLE_TEXTURE2D(_BumpMap, sampler_BumpMap, IN.uv));
float3x3 TBN = float3x3(normalize(IN.tangentWS), normalize(IN.bitangentWS), normalize(IN.normalWS));
float3 normalWS = mul(normalTS, TBN);
float _StippleSize;
float alpha = albedo.a * _TransparentAmount;
if (alpha <= 0.01)
discard;
half _Glossiness;
half _Metallic;
static const float4x4 kThresholdMatrix = {
1.0 / 17.0, 9.0 / 17.0, 3.0 / 17.0, 11.0 / 17.0,
13.0 / 17.0, 5.0 / 17.0, 15.0 / 17.0, 7.0 / 17.0,
4.0 / 17.0, 12.0 / 17.0, 2.0 / 17.0, 10.0 / 17.0,
16.0 / 17.0, 8.0 / 17.0, 14.0 / 17.0, 6.0 / 17.0
};
static const float4x4 kKernelMatrix = {
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1
};
struct Input {
float2 uv_MainTex;
float4 screenPos;
float3 worldPos;
float2 uv_BumpMap;
};
void surf (Input IN, inout SurfaceOutputStandard o) {
fixed4 c = tex2D(_MainTex, IN.uv_MainTex)* _Color;
o.Albedo = c.rgb;
o.Alpha = c.a;
o.Metallic = _Metallic;
o.Smoothness = _Glossiness;
o.Normal = UnpackNormal (tex2D (_BumpMap, IN.uv_BumpMap));
// Unproject the screen pixel coordiante
float2 pos = IN.screenPos.xy / IN.screenPos.w;
pos *= _ScreenParams.xy * _StippleSize;
// Clip pixel within [start, end] distance from camera
float interpDist = _TransparentAmount;
clip(interpDist - kThresholdMatrix[fmod(pos.x, 4)] * kKernelMatrix[fmod(pos.y, 4)]);
float3 color = albedo.rgb;
return float4(color, alpha);
}
ENDHLSL
}
ENDCG
}
FallBack "Diffuse"
FallBack "Universal Forward"
}

View File

@@ -1,109 +1,223 @@
Shader "Outlined/Diffuse" {
Properties {
_Color ("Main Color", Color) = (.5,.5,.5,1)
_OutlineColor ("Outline Color", Color) = (0,0,0,1)
_Outline ("Outline width", Range (0, 1)) = .1
_MainTex ("Base (RGB)", 2D) = "white" { }
}
CGINCLUDE
#include "UnityCG.cginc"
struct appdata {
float4 vertex : POSITION;
float3 normal : NORMAL;
};
struct v2f {
float4 pos : POSITION;
float4 color : COLOR;
};
uniform float _Outline;
uniform float4 _OutlineColor;
v2f vert(appdata v) {
// just make a copy of incoming vertex data but scaled according to normal direction
v2f o;
Shader "Custom/URP_Outline_Lit"
{
Properties
{
[Header(Main)]
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Color ("Base Color", Color) = (1,1,1,1)
v.vertex *= ( 1 + _Outline);
[Header(Outline)]
_OutlineColor ("Outline Color", Color) = (0,0,0,1)
_OutlineWidth ("Outline Width", Range(0, 0.2)) = 0.02
}
o.pos = UnityObjectToClipPos(v.vertex);
//float3 norm = normalize(mul ((float3x3)UNITY_MATRIX_IT_MV, v.normal));
//float2 offset = TransformViewToProjection(norm.xy);
SubShader
{
// CAMBIO 1: Cambiamos a Opaque para que reciba sombras correctamente
Tags
{
"RenderType" = "Opaque"
"RenderPipeline" = "UniversalPipeline"
"Queue" = "Geometry"
}
o.color = _OutlineColor;
return o;
}
ENDCG
SubShader {
//Tags {"Queue" = "Geometry+100" }
CGPROGRAM
#pragma surface surf Lambert
sampler2D _MainTex;
fixed4 _Color;
struct Input {
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutput o) {
fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
// note that a vertex shader is specified here but its using the one above
Pass {
Name "OUTLINE"
Tags { "LightMode" = "Always" }
Cull Front
ZWrite On
ColorMask RGB
Blend SrcAlpha OneMinusSrcAlpha
//Offset 50,50
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
half4 frag(v2f i) :COLOR { return i.color; }
ENDCG
}
}
SubShader {
CGPROGRAM
#pragma surface surf Lambert
sampler2D _MainTex;
fixed4 _Color;
struct Input {
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutput o) {
fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
Pass {
Name "OUTLINE"
Tags { "LightMode" = "Always" }
Cull Front
ZWrite On
ColorMask RGB
Blend SrcAlpha OneMinusSrcAlpha
SetTexture [_MainTex] { combine primary }
}
}
Fallback "Diffuse"
// ─────────────────────────────────────────────────────────────
// PASS 1 Main (Tu código original)
// ─────────────────────────────────────────────────────────────
Pass
{
Name "ForwardLit"
Tags { "LightMode" = "UniversalForward" }
Cull Back
ZWrite On
ZTest LEqual
// CAMBIO 2: Desactivamos la transparencia del material principal
Blend One Zero
// Tu lógica perfecta de Stencil para que el outline no se raye por dentro
Stencil
{
Ref 1
Comp Always
Pass Replace
}
HLSLPROGRAM
#pragma vertex MainVert
#pragma fragment MainFrag
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN
#pragma multi_compile_fragment _ _SHADOWS_SOFT
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
TEXTURE2D(_MainTex);
SAMPLER(sampler_MainTex);
CBUFFER_START(UnityPerMaterial)
float4 _MainTex_ST;
float4 _Color;
float4 _OutlineColor;
float _OutlineWidth;
CBUFFER_END
struct Attributes
{
float4 positionOS : POSITION;
float3 normalOS : NORMAL;
float2 uv : TEXCOORD0;
};
struct Varyings
{
float4 positionHCS : SV_POSITION;
float3 positionWS : TEXCOORD1;
float3 normalWS : NORMAL;
float2 uv : TEXCOORD0;
};
Varyings MainVert(Attributes IN)
{
Varyings OUT;
OUT.positionHCS = TransformObjectToHClip(IN.positionOS.xyz);
OUT.positionWS = TransformObjectToWorld(IN.positionOS.xyz);
OUT.normalWS = TransformObjectToWorldNormal(IN.normalOS);
OUT.uv = TRANSFORM_TEX(IN.uv, _MainTex);
return OUT;
}
half4 MainFrag(Varyings IN) : SV_Target
{
half4 albedo = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, IN.uv) * _Color;
float4 shadowCoord = TransformWorldToShadowCoord(IN.positionWS);
Light mainLight = GetMainLight(shadowCoord);
half NdotL = saturate(dot(normalize(IN.normalWS), mainLight.direction));
half3 diffuse = mainLight.color * (NdotL * mainLight.shadowAttenuation);
half3 ambient = SampleSH(IN.normalWS);
half3 finalColor = albedo.rgb * (diffuse + ambient);
return half4(finalColor, albedo.a);
}
ENDHLSL
}
// ─────────────────────────────────────────────────────────────
// PASS 2 ShadowCaster (Para proyectar sombras)
// ─────────────────────────────────────────────────────────────
Pass
{
Name "ShadowCaster"
Tags{"LightMode" = "ShadowCaster"}
ZWrite On
ZTest LEqual
ColorMask 0
Cull Back
HLSLPROGRAM
#pragma vertex ShadowPassVertex
#pragma fragment ShadowPassFragment
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Shadows.hlsl"
struct Attributes
{
float4 positionOS : POSITION;
float3 normalOS : NORMAL;
};
struct Varyings
{
float4 positionCS : SV_POSITION;
};
Varyings ShadowPassVertex(Attributes input)
{
Varyings output;
float3 positionWS = TransformObjectToWorld(input.positionOS.xyz);
float3 normalWS = TransformObjectToWorldNormal(input.normalOS);
// CAMBIO 3: Usamos la posición de la luz principal para que no dé errores
float3 lightDir = _MainLightPosition.xyz;
output.positionCS = TransformWorldToHClip(ApplyShadowBias(positionWS, normalWS, lightDir));
return output;
}
half4 ShadowPassFragment(Varyings input) : SV_TARGET
{
return 0;
}
ENDHLSL
}
// ─────────────────────────────────────────────────────────────
// PASS 3 Outline (Tu código original intacto)
// ─────────────────────────────────────────────────────────────
Pass
{
Name "Outline"
Tags { "LightMode" = "SRPDefaultUnlit" }
Cull Front
ZWrite Off
ZTest LEqual
Blend SrcAlpha OneMinusSrcAlpha
Stencil
{
Ref 1
Comp NotEqual
}
HLSLPROGRAM
#pragma vertex OutlineVert
#pragma fragment OutlineFrag
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
CBUFFER_START(UnityPerMaterial)
float4 _MainTex_ST;
float4 _Color;
float4 _OutlineColor;
float _OutlineWidth;
CBUFFER_END
struct Attributes
{
float4 positionOS : POSITION;
float3 normalOS : NORMAL;
};
struct Varyings
{
float4 positionHCS : SV_POSITION;
};
Varyings OutlineVert(Attributes IN)
{
Varyings OUT;
OUT.positionHCS = TransformObjectToHClip(IN.positionOS.xyz);
float3 normalWS = TransformObjectToWorldNormal(IN.normalOS);
float3 normalCS = mul((float3x3)UNITY_MATRIX_VP, normalWS);
float2 offset = normalize(normalCS.xy) * (_OutlineWidth * OUT.positionHCS.w);
OUT.positionHCS.xy += offset;
return OUT;
}
half4 OutlineFrag(Varyings IN) : SV_Target
{
return _OutlineColor;
}
ENDHLSL
}
}
FallBack "Hidden/Universal Render Pipeline/FallbackError"
}

View File

@@ -1,10 +1,11 @@
Shader "Custom/Projector" {
Shader "Custom/URP_Projector"
{
Properties {
_Color ("Tint Color", Color) = (1,1,1,1)
_Attenuation ("Falloff", Range(0.0, 1.0)) = 1.0
_ShadowTex ("Cookie", 2D) = "gray" {}
}
Subshader {
SubShader {
Tags {"Queue"="Transparent"}
Pass {
ZWrite Off
@@ -12,41 +13,51 @@
Blend SrcAlpha One // Additive blending
Offset -1, -1
CGPROGRAM
HLSLPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct v2f {
float4 uvShadow : TEXCOORD0;
float4 pos : SV_POSITION;
#pragma multi_compile_fog
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
struct Attributes {
float4 positionOS : POSITION;
};
struct Varyings {
float4 positionHCS : SV_POSITION;
float4 uvShadow : TEXCOORD0;
float fogFactor : TEXCOORD1;
};
CBUFFER_START(UnityPerMaterial)
float4 _Color;
float _Attenuation;
CBUFFER_END
TEXTURE2D(_ShadowTex); SAMPLER(sampler_ShadowTex);
float4x4 unity_Projector;
float4x4 unity_ProjectorClip;
v2f vert (float4 vertex : POSITION)
Varyings vert(Attributes IN)
{
v2f o;
o.pos = UnityObjectToClipPos (vertex);
o.uvShadow = mul (unity_Projector, vertex);
return o;
Varyings OUT;
OUT.positionHCS = TransformObjectToHClip(IN.positionOS.xyz);
OUT.uvShadow = mul(unity_Projector, IN.positionOS);
OUT.fogFactor = ComputeFogFactor(OUT.positionHCS.z / OUT.positionHCS.w);
return OUT;
}
sampler2D _ShadowTex;
fixed4 _Color;
float _Attenuation;
fixed4 frag (v2f i) : SV_Target
float4 frag(Varyings IN) : SV_Target
{
// Apply alpha mask
fixed4 texCookie = tex2Dproj (_ShadowTex, UNITY_PROJ_COORD(i.uvShadow));
fixed4 outColor = _Color * texCookie.a;
// Attenuation
float depth = i.uvShadow.z; // [-1 (near), 1 (far)]
return outColor * clamp(1.0 - abs(depth) + _Attenuation, 0.0, 1.0);
float2 projUV = IN.uvShadow.xy / IN.uvShadow.w;
float4 texCookie = SAMPLE_TEXTURE2D(_ShadowTex, sampler_ShadowTex, projUV);
float4 outColor = _Color * texCookie.a;
float depth = IN.uvShadow.z;
float atten = clamp(1.0 - abs(depth) + _Attenuation, 0.0, 1.0);
float3 color = outColor.rgb * atten;
color = MixFog(color, IN.fogFactor);
return float4(color, outColor.a);
}
ENDCG
ENDHLSL
}
}
}

View File

@@ -1,164 +1,76 @@
Shader "Custom/Simple Blur Shader" {
Shader "Custom/URP_SimpleBlurShader"
{
Properties {
_Size ("Blur", Range(0, 30)) = 1
[HideInInspector] _MainTex ("Texture (RGB)", 2D) = "white" {}
// _TintColor ("Tint Color", Color) = (1,1,1,1)
}
Category {
// We must be transparent, so other objects are drawn before this one.
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Opaque" }
SubShader
{
ZWrite Off
// Horizontal blur
GrabPass
{
"_HBlur"
}
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma fragmentoption ARB_precision_hint_fastest
#include "UnityCG.cginc"
struct appdata_t {
float4 vertex : POSITION;
float2 texcoord: TEXCOORD0;
float4 color : COLOR;
};
struct v2f {
float4 vertex : POSITION;
float4 uvgrab : TEXCOORD0;
float2 uvmain : TEXCOORD1;
float4 color : COLOR;
};
sampler2D _MainTex;
float4 _MainTex_ST;
v2f vert (appdata_t v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
#if UNITY_UV_STARTS_AT_TOP
float scale = -1.0;
#else
float scale = 1.0;
#endif
o.uvgrab.xy = (float2(o.vertex.x, o.vertex.y * scale) + o.vertex.w) * 0.5;
o.uvgrab.zw = o.vertex.zw;
o.uvmain = TRANSFORM_TEX(v.texcoord, _MainTex);
o.color = v.color;
return o;
}
sampler2D _HBlur;
float4 _HBlur_TexelSize;
SubShader {
Tags { "Queue"="Transparent" "RenderType"="Transparent" }
LOD 100
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
Pass {
Name "FORWARD"
HLSLPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fog
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
struct Attributes {
float4 positionOS : POSITION;
float2 uv : TEXCOORD0;
float4 color : COLOR;
};
struct Varyings {
float4 positionHCS : SV_POSITION;
float2 uv : TEXCOORD0;
float4 color : COLOR;
float fogFactor : TEXCOORD1;
};
CBUFFER_START(UnityPerMaterial)
float _Size;
half4 frag( v2f i ) : COLOR
{
float alpha = tex2D(_MainTex, i.uvmain).a * i.color.a;
half4 sum = half4(0,0,0,0);
#define GRABPIXEL(weight,kernelx) tex2Dproj( _HBlur, UNITY_PROJ_COORD(float4(i.uvgrab.x + _HBlur_TexelSize.x * kernelx * _Size * alpha, i.uvgrab.y, i.uvgrab.z, i.uvgrab.w))) * weight
sum += GRABPIXEL(0.05, -4.0);
sum += GRABPIXEL(0.09, -3.0);
sum += GRABPIXEL(0.12, -2.0);
sum += GRABPIXEL(0.15, -1.0);
sum += GRABPIXEL(0.18, 0.0);
sum += GRABPIXEL(0.15, +1.0);
sum += GRABPIXEL(0.12, +2.0);
sum += GRABPIXEL(0.09, +3.0);
sum += GRABPIXEL(0.05, +4.0);
return sum ;
}
ENDCG
}
// Vertical blur
GrabPass
CBUFFER_END
TEXTURE2D(_MainTex); SAMPLER(sampler_MainTex);
TEXTURE2D(_CameraOpaqueTexture); SAMPLER(sampler_CameraOpaqueTexture);
float4 _MainTex_ST;
Varyings vert(Attributes IN)
{
"_VBlur"
Varyings OUT;
OUT.positionHCS = TransformObjectToHClip(IN.positionOS.xyz);
OUT.uv = TRANSFORM_TEX(IN.uv, _MainTex);
OUT.color = IN.color;
OUT.fogFactor = ComputeFogFactor(OUT.positionHCS.z / OUT.positionHCS.w);
return OUT;
}
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma fragmentoption ARB_precision_hint_fastest
#include "UnityCG.cginc"
struct appdata_t {
float4 vertex : POSITION;
float2 texcoord: TEXCOORD0;
float4 color : COLOR;
};
struct v2f {
float4 vertex : POSITION;
float4 uvgrab : TEXCOORD0;
float2 uvmain : TEXCOORD1;
float4 color : COLOR;
};
sampler2D _MainTex;
float4 _MainTex_ST;
v2f vert (appdata_t v) {
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
#if UNITY_UV_STARTS_AT_TOP
float scale = -1.0;
#else
float scale = 1.0;
#endif
o.uvgrab.xy = (float2(o.vertex.x, o.vertex.y * scale) + o.vertex.w) * 0.5;
o.uvgrab.zw = o.vertex.zw;
o.uvmain = TRANSFORM_TEX(v.texcoord, _MainTex);
o.color = v.color;
return o;
}
sampler2D _VBlur;
float4 _VBlur_TexelSize;
float _Size;
//fixed4 _TintColor;
half4 frag( v2f i ) : COLOR
{
float alpha = tex2D(_MainTex, i.uvmain).a * i.color.a;
half4 sum = half4(0,0,0,0);
#define GRABPIXEL(weight,kernely) tex2Dproj( _VBlur, UNITY_PROJ_COORD(float4(i.uvgrab.x, i.uvgrab.y + _VBlur_TexelSize.y * kernely * _Size * alpha, i.uvgrab.z, i.uvgrab.w))) * weight
sum += GRABPIXEL(0.05, -4.0);
sum += GRABPIXEL(0.09, -3.0);
sum += GRABPIXEL(0.12, -2.0);
sum += GRABPIXEL(0.15, -1.0);
sum += GRABPIXEL(0.18, 0.0);
sum += GRABPIXEL(0.15, +1.0);
sum += GRABPIXEL(0.12, +2.0);
sum += GRABPIXEL(0.09, +3.0);
sum += GRABPIXEL(0.05, +4.0);
return sum + i.color * alpha;
}
ENDCG
float4 frag(Varyings IN) : SV_Target
{
float2 uv = IN.uv;
float alpha = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, uv).a * IN.color.a;
float2 texelSize = float2(1.0/_ScreenParams.x, 1.0/_ScreenParams.y);
float4 sum = float4(0,0,0,0);
// Horizontal blur
sum += SAMPLE_TEXTURE2D(_CameraOpaqueTexture, sampler_CameraOpaqueTexture, uv + float2(-4.0, 0.0) * texelSize * _Size * alpha) * 0.05;
sum += SAMPLE_TEXTURE2D(_CameraOpaqueTexture, sampler_CameraOpaqueTexture, uv + float2(-3.0, 0.0) * texelSize * _Size * alpha) * 0.09;
sum += SAMPLE_TEXTURE2D(_CameraOpaqueTexture, sampler_CameraOpaqueTexture, uv + float2(-2.0, 0.0) * texelSize * _Size * alpha) * 0.12;
sum += SAMPLE_TEXTURE2D(_CameraOpaqueTexture, sampler_CameraOpaqueTexture, uv + float2(-1.0, 0.0) * texelSize * _Size * alpha) * 0.15;
sum += SAMPLE_TEXTURE2D(_CameraOpaqueTexture, sampler_CameraOpaqueTexture, uv) * 0.18;
sum += SAMPLE_TEXTURE2D(_CameraOpaqueTexture, sampler_CameraOpaqueTexture, uv + float2(1.0, 0.0) * texelSize * _Size * alpha) * 0.15;
sum += SAMPLE_TEXTURE2D(_CameraOpaqueTexture, sampler_CameraOpaqueTexture, uv + float2(2.0, 0.0) * texelSize * _Size * alpha) * 0.12;
sum += SAMPLE_TEXTURE2D(_CameraOpaqueTexture, sampler_CameraOpaqueTexture, uv + float2(3.0, 0.0) * texelSize * _Size * alpha) * 0.09;
sum += SAMPLE_TEXTURE2D(_CameraOpaqueTexture, sampler_CameraOpaqueTexture, uv + float2(4.0, 0.0) * texelSize * _Size * alpha) * 0.05;
sum.rgb = MixFog(sum.rgb, IN.fogFactor);
return sum;
}
ENDHLSL
}
}
}

View File

@@ -1,62 +1,69 @@
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
Shader "Custom/additive" {
Properties {
Shader "Custom/URP_Additive"
{
Properties
{
_MainTex ("Base", 2D) = "white" {}
_TintColor ("TintColor", Color) = (1.0, 1.0, 1.0, 1.0)
}
CGINCLUDE
#include "UnityCG.cginc"
sampler2D _MainTex;
fixed4 _TintColor;
half4 _MainTex_ST;
struct v2f {
half4 pos : SV_POSITION;
half2 uv : TEXCOORD0;
fixed4 vertexColor : COLOR;
};
v2f vert(appdata_full v) {
v2f o;
o.pos = UnityObjectToClipPos (v.vertex);
o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
o.vertexColor = v.color * _TintColor;
return o;
}
fixed4 frag( v2f i ) : COLOR {
return tex2D (_MainTex, i.uv.xy) * i.vertexColor;
}
ENDCG
SubShader {
Tags { "RenderType" = "Transparent" "Queue" = "Transparent"}
SubShader
{
Tags { "RenderType" = "Transparent" "Queue" = "Transparent" }
LOD 100
Cull Off
Lighting Off
ZWrite Off
Fog { Mode Off }
Blend One One
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma fragmentoption ARB_precision_hint_fastest
ENDCG
Pass
{
Name "FORWARD"
Tags { "LightMode" = "UniversalForward" }
HLSLPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fog
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
struct Attributes
{
float4 positionOS : POSITION;
float2 uv : TEXCOORD0;
float4 color : COLOR;
};
struct Varyings
{
float4 positionHCS : SV_POSITION;
float2 uv : TEXCOORD0;
float4 color : COLOR;
float fogFactor : TEXCOORD1;
};
CBUFFER_START(UnityPerMaterial)
float4 _TintColor;
CBUFFER_END
TEXTURE2D(_MainTex); SAMPLER(sampler_MainTex);
Varyings vert(Attributes IN)
{
Varyings OUT;
OUT.positionHCS = TransformObjectToHClip(IN.positionOS.xyz);
OUT.uv = IN.uv;
OUT.color = IN.color * _TintColor;
OUT.fogFactor = ComputeFogFactor(OUT.positionHCS.z / OUT.positionHCS.w);
return OUT;
}
float4 frag(Varyings IN) : SV_Target
{
float4 tex = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, IN.uv);
float4 col = tex * IN.color;
col.rgb = MixFog(col.rgb, IN.fogFactor);
return col;
}
ENDHLSL
}
}
}
FallBack Off
}

View File

@@ -1,59 +1,61 @@
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
Shader "Custom/laserShader" {
Shader "Custom/URP_LaserShader"
{
Properties {
_MainTex ("Base", 2D) = "white" {}
_TintColor ("TintColor", Color) = (0.5, 0.5, 0.5, 0.5)
}
CGINCLUDE
#include "UnityCG.cginc"
sampler2D _MainTex;
fixed4 _TintColor;
struct v2f {
half4 pos : SV_POSITION;
half2 uv : TEXCOORD0;
};
v2f vert(appdata_full v) {
v2f o;
o.pos = UnityObjectToClipPos (v.vertex);
o.uv.xy = v.texcoord.xy;
return o;
}
fixed4 frag( v2f i ) : COLOR {
return tex2D (_MainTex, i.uv.xy) * _TintColor;
}
ENDCG
SubShader {
Tags { "RenderType" = "Transparent" "Queue" = "Transparent"}
Tags { "RenderType" = "Transparent" "Queue" = "Transparent" }
LOD 100
Cull Off
Lighting Off
ZWrite Off
Fog { Mode Off }
Blend SrcAlpha One
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma fragmentoption ARB_precision_hint_fastest
ENDCG
Pass {
Name "FORWARD"
Tags { "LightMode" = "UniversalForward" }
HLSLPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fog
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
struct Attributes {
float4 positionOS : POSITION;
float2 uv : TEXCOORD0;
};
struct Varyings {
float4 positionHCS : SV_POSITION;
float2 uv : TEXCOORD0;
float fogFactor : TEXCOORD1;
};
CBUFFER_START(UnityPerMaterial)
float4 _TintColor;
CBUFFER_END
TEXTURE2D(_MainTex); SAMPLER(sampler_MainTex);
Varyings vert(Attributes IN)
{
Varyings OUT;
OUT.positionHCS = TransformObjectToHClip(IN.positionOS.xyz);
OUT.uv = IN.uv;
OUT.fogFactor = ComputeFogFactor(OUT.positionHCS.z / OUT.positionHCS.w);
return OUT;
}
float4 frag(Varyings IN) : SV_Target
{
float4 tex = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, IN.uv);
float4 col = tex * _TintColor;
col.rgb = MixFog(col.rgb, IN.fogFactor);
return col;
}
ENDHLSL
}
}
}
FallBack Off
}

View File

@@ -1,34 +1,66 @@
Shader "Custom/prueba" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_SpecColor ("Spec Color", Color) = (1,1,1,0)
_Emission ("Emissive Color", Color) = (0,0,0,0)
_Shininess ("Shininess", Range (0.1, 1)) = 0.7
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
}
SubShader {
Tags {"RenderType"="Transparent" "Queue"="Transparent"}
// Render into depth buffer only
Shader "Custom/URP_prueba"
{
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_SpecColor ("Spec Color", Color) = (1,1,1,0)
_Emission ("Emissive Color", Color) = (0,0,0,0)
_Shininess ("Shininess", Range (0.1, 1)) = 0.7
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
}
SubShader {
Tags {"RenderType"="Transparent" "Queue"="Transparent"}
LOD 200
Pass {
ColorMask 0
}
// Render normally
Pass {
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
ColorMask RGB
Material {
Diffuse [_Color]
Ambient [_Color]
Shininess [_Shininess]
Specular [_SpecColor]
Emission [_Emission]
}
Lighting On
SetTexture [_MainTex] {
Combine texture * primary DOUBLE, texture * primary
Name "FORWARD"
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
ColorMask RGB
HLSLPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fog
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
struct Attributes {
float4 positionOS : POSITION;
float2 uv : TEXCOORD0;
};
struct Varyings {
float4 positionHCS : SV_POSITION;
float2 uv : TEXCOORD0;
float fogFactor : TEXCOORD1;
};
CBUFFER_START(UnityPerMaterial)
float4 _Color;
float4 _SpecColor;
float4 _Emission;
float _Shininess;
CBUFFER_END
TEXTURE2D(_MainTex); SAMPLER(sampler_MainTex);
Varyings vert(Attributes IN)
{
Varyings OUT;
OUT.positionHCS = TransformObjectToHClip(IN.positionOS.xyz);
OUT.uv = IN.uv;
OUT.fogFactor = ComputeFogFactor(OUT.positionHCS.z / OUT.positionHCS.w);
return OUT;
}
float4 frag(Varyings IN) : SV_Target
{
float4 albedo = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, IN.uv) * _Color;
float3 emission = _Emission.rgb;
float3 specular = _SpecColor.rgb * _Shininess;
float3 color = albedo.rgb + emission + specular;
float alpha = albedo.a;
color = MixFog(color, IN.fogFactor);
return float4(color, alpha);
}
ENDHLSL
}
}
}
}

View File

@@ -1,17 +1,58 @@
Shader "Custom/textShader" {
Shader "Custom/URP_textShader"
{
Properties {
_MainTex ("Font Texture", 2D) = "white" {}
_Color ("Text Color", Color) = (1,1,1,1)
}
SubShader {
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
Lighting Off Cull Off ZWrite Off Fog { Mode Off }
Blend SrcAlpha OneMinusSrcAlpha
Pass{
Color [_Color]
SetTexture [_MainTex] {
combine primary, texture * primary
}
}
}
_MainTex ("Font Texture", 2D) = "white" {}
_Color ("Text Color", Color) = (1,1,1,1)
}
SubShader {
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
LOD 100
Cull Off
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
Pass {
Name "FORWARD"
HLSLPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fog
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
struct Attributes {
float4 positionOS : POSITION;
float2 uv : TEXCOORD0;
};
struct Varyings {
float4 positionHCS : SV_POSITION;
float2 uv : TEXCOORD0;
float fogFactor : TEXCOORD1;
};
CBUFFER_START(UnityPerMaterial)
float4 _Color;
CBUFFER_END
TEXTURE2D(_MainTex); SAMPLER(sampler_MainTex);
Varyings vert(Attributes IN)
{
Varyings OUT;
OUT.positionHCS = TransformObjectToHClip(IN.positionOS.xyz);
OUT.uv = IN.uv;
OUT.fogFactor = ComputeFogFactor(OUT.positionHCS.z / OUT.positionHCS.w);
return OUT;
}
float4 frag(Varyings IN) : SV_Target
{
float4 tex = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, IN.uv);
float4 col = tex * _Color;
col.rgb = MixFog(col.rgb, IN.fogFactor);
return col;
}
ENDHLSL
}
}
}