Shader "Hidden/OIT/LLOITRender" { SubShader { Tags { "RenderPipeline" = "UniversalPipeline" } Pass { ZTest Always ZWrite Off Cull Back Blend Off HLSLPROGRAM #pragma vertex vert #pragma fragment frag #pragma target 5.0 #pragma enable_d3d11_debug_symbols #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" #include "LinkedListRendering.hlsl" struct v2f { float2 uv : TEXCOORD0; float4 vertex : SV_POSITION; }; v2f vert(uint vertexID: SV_VertexID) { v2f o; float2 uv = float2((vertexID << 1) & 2, vertexID & 2); float4 pos = float4(uv * 2.0 - 1.0, UNITY_NEAR_CLIP_VALUE, 1.0); #ifdef UNITY_PRETRANSFORM_TO_DISPLAY_ORIENTATION pos = ApplyPretransformRotation(pos); #endif #if UNITY_UV_STARTS_AT_TOP uv = float2((vertexID << 1) & 2, 1.0 - (vertexID & 2)); #endif o.vertex = pos; o.uv = uv; return o; } sampler2D _CameraColorTex_LLOIT; void frag(v2f input, out half4 col : SV_Target, uint uSampleIndex: SV_SampleIndex) { float4 screenColor = tex2D(_CameraColorTex_LLOIT, input.uv); col = renderLinkedList(screenColor, input.vertex.xy, uSampleIndex); } // gles、metal // void frag(v2f input, inout half4 col : SV_Target, uint uSampleIndex: SV_SampleIndex) // void frag(v2f input, inout half4 col : CoLoR, uint uSampleIndex: SV_SampleIndex) // { // col.b = 0; // // col = renderLinkedList(col, input.uv, uSampleIndex); // } // RWTexture2D _CameraColorTex; // dx12 运行同时作为 rtv uav,但是 Unity 无法设置 uav // void frag(v2f input, out half4 col : SV_Target, uint uSampleIndex: SV_SampleIndex) // { // float4 screenColor = _CameraColorTex[uint2(input.uv * _ScreenParams.xy)]; // tex2D(_MainTex, input.uv); // col = renderLinkedList(screenColor, input.vertex.xy, uSampleIndex); // } // vulkan、metal unity 无法同时读写(vk 扩展 VK_EXT_rasterization_order_attachment_access) // FRAMEBUFFER_INPUT_HALF(0); // void frag(v2f input, out half4 col : SV_Target, uint uSampleIndex: SV_SampleIndex) // { // col = LOAD_FRAMEBUFFER_INPUT(0, input.vertex.xy); // // col = renderLinkedList(col, input.uv, uSampleIndex); // } ENDHLSL } } }