84 lines
2.8 KiB
Plaintext
84 lines
2.8 KiB
Plaintext
Shader "2Ginge/Potion/URP_Glass"
|
|
{
|
|
Properties
|
|
{
|
|
_MainTex ("Main Texture", 2D) = "white" {}
|
|
_TintColor ("Tint Color", Color) = (0.5,0.5,0.5,1)
|
|
_FresnelTightness ("Fresnel Tightness", Float) = 0
|
|
[HideInInspector]_Cutoff ("Alpha Cutoff", Range(0,1)) = 0.5
|
|
}
|
|
|
|
SubShader
|
|
{
|
|
Tags { "Queue"="Transparent" "RenderPipeline"="UniversalRenderPipeline" "RenderType"="Transparent" }
|
|
Blend SrcAlpha OneMinusSrcAlpha
|
|
ZWrite Off
|
|
Cull Back
|
|
|
|
Pass
|
|
{
|
|
Name "ForwardLit"
|
|
Tags { "LightMode"="UniversalForward" }
|
|
|
|
HLSLPROGRAM
|
|
#pragma vertex vert
|
|
#pragma fragment frag
|
|
|
|
#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;
|
|
float4 color : COLOR;
|
|
};
|
|
|
|
struct Varyings
|
|
{
|
|
float4 positionHCS : SV_POSITION;
|
|
float2 uv : TEXCOORD0;
|
|
float3 normalWS : TEXCOORD1;
|
|
float3 viewDirWS : TEXCOORD2;
|
|
float4 color : COLOR;
|
|
};
|
|
|
|
TEXTURE2D(_MainTex);
|
|
SAMPLER(sampler_MainTex);
|
|
|
|
CBUFFER_START(UnityPerMaterial)
|
|
float4 _MainTex_ST;
|
|
float4 _TintColor;
|
|
float _FresnelTightness;
|
|
CBUFFER_END
|
|
|
|
Varyings vert(Attributes IN)
|
|
{
|
|
Varyings OUT;
|
|
OUT.positionHCS = TransformObjectToHClip(IN.positionOS.xyz);
|
|
OUT.uv = TRANSFORM_TEX(IN.uv, _MainTex);
|
|
OUT.normalWS = TransformObjectToWorldNormal(IN.normalOS);
|
|
OUT.viewDirWS = GetWorldSpaceViewDir(TransformObjectToWorld(IN.positionOS.xyz));
|
|
OUT.color = IN.color;
|
|
return OUT;
|
|
}
|
|
|
|
half4 frag(Varyings IN) : SV_Target
|
|
{
|
|
IN.normalWS = normalize(IN.normalWS);
|
|
float3 viewDir = normalize(IN.viewDirWS);
|
|
|
|
float4 texColor = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, IN.uv);
|
|
float fresnel = pow(1.0 - saturate(dot(IN.normalWS, viewDir)), _FresnelTightness);
|
|
|
|
float3 emissive = texColor.rgb * IN.color.rgb * _TintColor.rgb * 2.0;
|
|
float alpha = (texColor.a * IN.color.a * _TintColor.a) + fresnel;
|
|
|
|
return float4(emissive, alpha);
|
|
}
|
|
ENDHLSL
|
|
}
|
|
}
|
|
}
|