Unity/shader
유니티 스카이박스 관련
모카쨩
2023. 1. 16. 21:41
Shader "Skybox/Sample"
{
Properties
{
[NoScaleOffset] _Tex ("Cubemap (HDR)", Cube) = "grey" {}
}
SubShader
{
Tags { "Queue"="Background" "RenderType"="Background" "PreviewType"="Skybox" }
LOD 100
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 vertex : SV_POSITION;
float3 texcoord : TEXCOORD0;
UNITY_VERTEX_OUTPUT_STEREO
};
samplerCUBE _Tex;
half4 _Tex_HDR;
v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.vertex = UnityObjectToClipPos(v.vertex);
o.texcoord = v.vertex.xyz;
return o;
}
fixed4 frag (v2f i) : SV_Target
{
half4 tex = texCUBE (_Tex, i.texcoord);
fixed3 col = DecodeHDR (tex, _Tex_HDR);
return half4(col, 1);
}
ENDCG
}
}
}
샘플코드