105 lines
4.4 KiB
Plaintext
105 lines
4.4 KiB
Plaintext
Shader "Custom/JupiterAtmosphereLayer"
|
|
{
|
|
Properties
|
|
{
|
|
_MainTex("Main Texture", 2D) = "white" {}
|
|
_SecondTex("Second Texture", 2D) = "white" {}
|
|
_RimColor("Rim Color", Color) = (0.8, 0.5, 0.2, 1.0)
|
|
_CoreColor("Core Color", Color) = (0.6, 0.3, 0.1, 0.3)
|
|
_RimPower("Rim Power", Range(0.5, 8.0)) = 1.5
|
|
_RimIntensity("Rim Intensity", Range(0.0, 5.0)) = 2.5
|
|
_CoreIntensity("Core Intensity", Range(0.0, 2.0)) = 0.4
|
|
_ScrollSpeed1("Scroll Speed 1", Range(-1.0, 1.0)) = 0.02
|
|
_ScrollSpeed2("Scroll Speed 2", Range(-1.0, 1.0)) = -0.01
|
|
_PulseSpeed("Pulse Speed", Range(0.0, 3.0)) = 0.8
|
|
_PulseStrength("Pulse Strength", Range(0.0, 1.0)) = 0.15
|
|
_TextureBlend("Texture Blend", Range(0.0, 1.0)) = 0.5
|
|
_TextureInfluence("Texture Influence", Range(0.0, 1.0)) = 0.6
|
|
}
|
|
SubShader
|
|
{
|
|
Tags { "Queue" = "Transparent" "RenderType" = "Transparent" "RenderPipeline" = "UniversalPipeline" }
|
|
Blend SrcAlpha OneMinusSrcAlpha
|
|
ZWrite Off
|
|
Cull Back
|
|
Pass
|
|
{
|
|
HLSLPROGRAM
|
|
#pragma vertex vert
|
|
#pragma fragment frag
|
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
|
|
|
struct Attributes
|
|
{
|
|
float4 positionOS : POSITION;
|
|
float3 normalOS : NORMAL;
|
|
float2 uv : TEXCOORD0;
|
|
};
|
|
|
|
struct Varyings
|
|
{
|
|
float4 positionHCS : SV_POSITION;
|
|
float3 normalWS : TEXCOORD0;
|
|
float3 viewDirWS : TEXCOORD1;
|
|
float3 positionWS : TEXCOORD2;
|
|
float2 uv : TEXCOORD3;
|
|
};
|
|
|
|
TEXTURE2D(_MainTex);
|
|
SAMPLER(sampler_MainTex);
|
|
TEXTURE2D(_SecondTex);
|
|
SAMPLER(sampler_SecondTex);
|
|
|
|
CBUFFER_START(UnityPerMaterial)
|
|
float4 _MainTex_ST;
|
|
float4 _SecondTex_ST;
|
|
half4 _RimColor;
|
|
half4 _CoreColor;
|
|
float _RimPower;
|
|
float _RimIntensity;
|
|
float _CoreIntensity;
|
|
float _ScrollSpeed1;
|
|
float _ScrollSpeed2;
|
|
float _PulseSpeed;
|
|
float _PulseStrength;
|
|
float _TextureBlend;
|
|
float _TextureInfluence;
|
|
CBUFFER_END
|
|
|
|
Varyings vert(Attributes IN)
|
|
{
|
|
Varyings OUT;
|
|
OUT.positionHCS = TransformObjectToHClip(IN.positionOS.xyz);
|
|
OUT.normalWS = TransformObjectToWorldNormal(IN.normalOS);
|
|
OUT.positionWS = TransformObjectToWorld(IN.positionOS.xyz);
|
|
OUT.viewDirWS = normalize(_WorldSpaceCameraPos - OUT.positionWS);
|
|
OUT.uv = TRANSFORM_TEX(IN.uv, _MainTex);
|
|
return OUT;
|
|
}
|
|
|
|
half4 frag(Varyings IN) : SV_Target
|
|
{
|
|
float2 uv1 = IN.uv + float2(_ScrollSpeed1 * _Time.y, 0);
|
|
float2 uv2 = IN.uv + float2(_ScrollSpeed2 * _Time.y, 0);
|
|
|
|
half4 tex1 = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, uv1);
|
|
half4 tex2 = SAMPLE_TEXTURE2D(_SecondTex, sampler_SecondTex, uv2);
|
|
half4 texBlended = lerp(tex1, tex2, _TextureBlend);
|
|
|
|
float3 normal = normalize(IN.normalWS);
|
|
float3 viewDir = normalize(IN.viewDirWS);
|
|
float fresnel = 1.0 - saturate(dot(normal, viewDir));
|
|
float pulse = 1.0 + sin(_Time.y * _PulseSpeed) * _PulseStrength;
|
|
float rim = pow(fresnel, _RimPower) * _RimIntensity * pulse;
|
|
float core = (1.0 - fresnel) * _CoreIntensity;
|
|
|
|
half3 baseCol = lerp(_CoreColor.rgb * core, _RimColor.rgb * rim, fresnel);
|
|
half3 finalCol = lerp(baseCol, texBlended.rgb * rim, _TextureInfluence);
|
|
|
|
float alpha = saturate(rim * 0.8 + core * _CoreColor.a);
|
|
return half4(finalCol, alpha);
|
|
}
|
|
ENDHLSL
|
|
}
|
|
}
|
|
} |