Writing to RWTexture3D<float4> in Pixel Shader

It seems like writing to a RWTexture2D in a pixel shader is possible; I have succeeded in doing this. But when it comes to writing to a RWTexture3D, it doesn’t seem to work at all.

Shader "Custom/RenderToVolume"
{
	Properties 
	{
		_MainTex ("Diffuse (RGBA)", 2D) = "white" {}
	}

	SubShader 
	{
		Pass 
		{
			Tags { "RenderType"="Opaque" }
			Cull Off ZWrite Off ZTest Always Fog { Mode Off }

			CGPROGRAM
			#pragma target 5.0
			#pragma vertex vert
			#pragma fragment frag
			#pragma exclude_renderers flash gles opengl

			#include "UnityCG.cginc"


			sampler2D _MainTex;

			RWTexture3D<float4> volumeTex;
			float volumeResolution;
			float4 volumeParams;

			struct ApplicationToVertex 
			{
				float4 vertex : POSITION;
				float4 texcoord : TEXCOORD0;
			};

			struct VertexToFragment 
			{
				float4 pos : SV_POSITION;
				float4 wPos : TEXCOORD0;
				float2 uv : TEXCOORD1;
			};

			void vert(ApplicationToVertex input, out VertexToFragment output)
			{
				output.pos = mul (UNITY_MATRIX_MVP, input.vertex);
				output.wPos = mul(_Object2World, input.vertex);
				output.uv = input.texcoord.xy;
			}

			void frag(VertexToFragment input)
			{
				float4 color = tex2D(_MainTex, input.uv);
				
				float3 volumePos = ((input.wPos.xyz - volumeParams.xyz) / volumeParams.w) * volumeResolution;

				int3 volumeCoords;
				volumeCoords.x = int(volumePos.x); 
				volumeCoords.y = int(volumePos.y); 
				volumeCoords.z = int(volumePos.z); 
				
				volumeTex[volumeCoords] = color;
			}
			ENDCG
		}
	}
	Fallback Off
}

This is what I am trying to do, and it doesn’t seem to work, but if I try and write to a 2D texture, it does. Not sure where I am messing it up.

Bump

may i ask what a 3d array of float4’s would be for?
i only just found out about 3d pics from here: Unity3d Compute Shader Simplex3d - Pastebin.com

I will be rendering a scene into a 3D texture. This then can be used in volume rendering.

So, I was able to contact Aras (Unity Graphics Dev), and he believes that there is not currently support for writing to RWTexture3D in shaders, but you CAN write to them in Compute Shaders. You can also write to ComputeBuffers in shaders. I will have to write to ComputeBuffer in my shader, and then use a Compute Shader to copy the contents into a Texture3D with RWTexture3D.