Files
FueraDeEscala/Assets/Game Kit Controller/Shaders/Others/See Through Surfaces 2.shader
2026-03-29 23:03:14 -07:00

112 lines
3.2 KiB
Plaintext

Shader "Custom/URP/SeeThroughSurfaces2"
{
Properties
{
_BaseColor ("Color", Color) = (1,1,1,1)
_BaseMap ("Albedo", 2D) = "white" {}
_Smoothness ("Smoothness", Range(0,1)) = 0.5
_Metallic ("Metallic", Range(0,1)) = 0.0
}
SubShader
{
Tags
{
"RenderPipeline"="UniversalRenderPipeline"
"RenderType"="Opaque"
"Queue"="Geometry+2"
}
Stencil
{
Ref 1
Comp NotEqual
}
Pass
{
Name "ForwardLit"
Tags { "LightMode"="UniversalForward" }
HLSLPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS
#pragma multi_compile _ _ADDITIONAL_LIGHTS
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
struct Attributes
{
float4 positionOS : POSITION;
float3 normalOS : NORMAL;
float2 uv : TEXCOORD0;
};
struct Varyings
{
float4 positionHCS : SV_POSITION;
float3 positionWS : TEXCOORD0;
float3 normalWS : TEXCOORD1;
float2 uv : TEXCOORD2;
};
TEXTURE2D(_BaseMap);
SAMPLER(sampler_BaseMap);
CBUFFER_START(UnityPerMaterial)
float4 _BaseColor;
float _Metallic;
float _Smoothness;
CBUFFER_END
Varyings vert (Attributes IN)
{
Varyings OUT;
OUT.positionWS = TransformObjectToWorld(IN.positionOS.xyz);
OUT.positionHCS = TransformWorldToHClip(OUT.positionWS);
OUT.normalWS = TransformObjectToWorldNormal(IN.normalOS);
OUT.uv = IN.uv;
return OUT;
}
half4 frag (Varyings IN) : SV_Target
{
float4 tex = SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, IN.uv);
float3 albedo = tex.rgb * _BaseColor.rgb;
float alpha = tex.a * _BaseColor.a;
float3 normal = normalize(IN.normalWS);
SurfaceData surfaceData = (SurfaceData)0;
surfaceData.albedo = albedo;
surfaceData.alpha = alpha;
surfaceData.metallic = _Metallic;
surfaceData.smoothness = _Smoothness;
surfaceData.normalTS = float3(0,0,1);
surfaceData.occlusion = 1;
surfaceData.emission = 0;
surfaceData.specular = 0;
InputData inputData = (InputData)0;
inputData.positionWS = IN.positionWS;
inputData.normalWS = normal;
inputData.viewDirectionWS = GetWorldSpaceViewDir(IN.positionWS);
inputData.shadowCoord = TransformWorldToShadowCoord(IN.positionWS);
inputData.bakedGI = SampleSH(normal);
return UniversalFragmentPBR(inputData, surfaceData);
}
ENDHLSL
}
}
}