效果:
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/23fb32b45556a7da024cbc8f7a3c4f19.png)
第一步:先创建一个照相机可以在内部照相的白色固体
代码:
Shader "TYX/09SphericalFog"
{
Properties
{
_FogCenter("Fog Center/Radius", Vector)=(0,0,0,0.5)
_FogColor("Fog Color",Color) =(1,1,1,1)
_InnerRatio("Inner Ratio",Range(0.0,0.9))=0.5
_Density("Density",Range(0.0,1.0))=0.5
}
SubShader
{
Tags{
"Queue"="Transparent"}
Blend SrcAlpha OneMinusSrcAlpha
Cull Off Lighting Off ZWrite Off
ZTest Always
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct v2f
{
float3 view : TEXCOORD0;
float4 pos : SV_POSITION;
float4 projPos:TEXCOORD1;
};
float4 _FogCenter;
fixed4 _FogColor;
float _InnerRatio;
float _Density;
sampler2D _CameraDepthTexture;
v2f vert (appdata_base v)
{
v2f o;
float4 wPos=mul(unity_ObjectToWorld,v.vertex);
o.pos = UnityObjectToClipPos(v