반응형
Shader "Custom/HDRPAurora"
{
Properties
{
_NoiseTexture ("Noise Texture", 2D) = "white" {}
}
HLSLINCLUDE
#pragma target 4.5
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
TEXTURE2D(_NoiseTexture);
SAMPLER(sampler_NoiseTexture);
ENDHLSL
SubShader
{
Tags { "RenderType"="Opaque" "RenderPipeline"="HDRenderPipeline" }
Pass
{
Name "AuroraPass"
Tags { "LightMode" = "ForwardOnly" }
HLSLPROGRAM
#pragma vertex Vert
#pragma fragment Frag
struct Attributes
{
float4 positionOS : POSITION;
float2 uv : TEXCOORD0;
};
struct Varyings
{
float4 positionCS : SV_POSITION;
float2 uv : TEXCOORD0;
};
Varyings Vert(Attributes input)
{
Varyings output;
output.positionCS = TransformObjectToHClip(input.positionOS.xyz);
output.uv = input.uv;
return output;
}
float4 Frag(Varyings input) : SV_Target
{
float2 F = input.uv * _ScreenSize.xy;
float3 A = _ScreenSize;
float4 O = float4(0, 0, 0, 0);
float3 p;
float u = 0, R = 0, o, r, a = _Time.y;
for (; u < 44.; u++) {
p = R * normalize(float3(F + F - A.xy, A.y));
p.z -= 2.;
r = length(p);
p /= r * 0.1;
p.xz = mul(p.xz, float2x2(cos(a * 0.2), sin(a * 0.2), -sin(a * 0.2), cos(a * 0.2)));
R += o = min(r - 0.3, SAMPLE_TEXTURE2D(_NoiseTexture, sampler_NoiseTexture, F / 1024.).r * 0.1) + 0.1;
O += 0.05 / (0.4 + o)
* lerp(smoothstep(0.5, 0.7, sin(p.x + cos(p.y) * cos(p.z)) * sin(p.z + sin(p.y) * cos(p.x + a))),
1., 0.15 / r / r)
* smoothstep(5., 0., r)
* (1. + cos(R * 3. + float4(0, 1, 2, 0)));
}
return O;
}
ENDHLSL
}
}
}
반응형
'개발 > Unity3D' 카테고리의 다른 글
Unity Busy for... 버그? 오류 해결방법을 찾아보다. (0) | 2024.04.24 |
---|---|
오브젝트 드래그/드롭 기능에 스냅을 붙여 퍼즐 만들기 (0) | 2024.04.23 |
Unity3D 전역변수 사용방법 3가지 (0) | 2024.04.22 |
동적 UI와 정적 UI의 정의 (0) | 2024.04.21 |
유니티(Unity) 시리얼(RS232) <-> Unity (0) | 2024.04.17 |