I currently simulating a skybox on the inside of four inverted planes. My goal is to render a depth texture similar to one automatically made with Unity's built in Camera, but on the render probe. I want to recreate both fog and FoV post processing effects with this. Here are pictures for people to wrap their heads around what my current state is. I am trying to create a depth buffer from the reflection probe the same way that the Unity camera automatically makes one. The shader I have on the planes is so: Code (CSharp): Shader "Custom/ReflectionDisplay"{ Properties{ [NoScaleOffset] _IBL ("IBL cube map", Cube) = "black" {} } SubShader{ Tags { "LightMode"="ForwardBase" } Cull Back Pass{ CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" #include "Lighting.cginc" #define SPECULAR_MIP_STEPS 4 sampler2D _CameraDepthTexture; samplerCUBE _IBL; float3 _probePosition; struct appdata{ float4 planePosition : POSITION; float3 normal : NORMAL; float2 uv : TEXCOORD0; }; struct v2f{ float2 uv : TEXCOORD0; float4 planePosition : SV_POSITION; float3 normal : TEXCOORD1; float3 worldPlanePos : TEXCOORD2; }; v2f vert (appdata v){ v2f o; o.normal = UnityObjectToWorldNormal(v.normal); o.planePosition = UnityObjectToClipPos(v.planePosition); o.uv = v.uv; o.worldPlanePos = mul(unity_ObjectToWorld,v.planePosition); return o; } fixed4 frag (v2f i) : SV_Target{ float mip = 0; float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.worldPlanePos); float3 indirectSpecular = texCUBElod(_IBL, float4(-viewDirection,mip)); float3 color = indirectSpecular; return float4(color,1); } ENDCG } } } I also have this script on a parent which all the planes are attached: Code (CSharp): using System.Collections; using System.Collections.Generic; using UnityEngine; [ExecuteInEditMode] public class ReflectionProbeCommunication : MonoBehaviour { public List<Material> renderMaterials = new List<Material>(); public ReflectionProbe reflectionProbe; Transform probeTransform; void Awake() { reflectionProbe.RenderProbe(); probeTransform = reflectionProbe.gameObject.transform; } //TODO: Should this be update or fixed update? I'm guessing we'd want it to change based on the user's frame rate, but am unsure. void Update() { UpdateMaterials(); } ///<<Summary>>Goes through materials for planes and updates accordingly.<<Summary>> void UpdateMaterials() { foreach (Material m in renderMaterials) { UpdateRenderImage(m); UpdateDepthData(m); } } ///<<Summary>>This function updates the visuals of the six planes according to the real time reflection probe moving above the city.<<Summary>> void UpdateRenderImage(Material m) { m.SetTexture("_IBL", reflectionProbe.realtimeTexture); } ///<<Summary>>This function tells generates a depth field for the reflection probe output shader via gpu.<<Summary>> void UpdateDepthData(Material m) { m.SetVector("_probePosition", probeTransform.position); } } Do anyone have any ideas on how to create a depth buffer that I could utilize on the given shader? Thanks, Cabbages
i have similiar needs as you, perhaps this helps you, i havent tried it yet though https://answers.unity.com/questions/1162593/how-to-generate-cubemap-with-color-depth-values.html