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:
@@ -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"
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user