-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* docs: remove unity version from package.json * fix: update deprecated colorTarget * build: add package requirement to URP shader * return material on render and use Blitter for SRP implementations * fix: fix URP fullscreen shader and add built-in shader pass * fix(urp): move cmd clear * refactor: split render shader to multiple pipeline specific shaders * docs: update readme --------- Co-authored-by: Till Davin <[email protected]> Co-authored-by: Till Davin <>
- Loading branch information
1 parent
0d4459c
commit 6fb79a9
Showing
16 changed files
with
186 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ If in doubt try to import the sample you want to use and start from there. | |
|
||
1. Setup the rendering implementation for your chosen pipeline: | ||
- **High-Definition Render Pipeline:** Create a [Custom Pass volume](https://docs.unity3d.com/Packages/[email protected]/manual/Custom-Pass-Creating.html) and add `OitRenderPass` to it. | ||
- **Universal Render Pipeline:** Add the renderer feature `Order Independent Transparency Renderer` to your Universal Renderer Asset. _Note: URP documentation only describes a [fullscreen Blit](https://docs.unity3d.com/Packages/[email protected]/manual/renderer-features/how-to-fullscreen-blit.html) which only works in Game view. If you know whether a fullscreen Blit in URP in Scene view as well as in Game view is possible, help would be very much appreciated._ | ||
- **Universal Render Pipeline:** Add the renderer feature `Order Independent Transparency Renderer` to your Universal Renderer Asset. | ||
- **Post-Processing Stack v2:** Add the post-processing override `Order Independent Transparency` to a post-processing volume in your scene. | ||
|
||
2. Change the material of every object that shall be rendered with order-independent transparency. They have to be rendered with a shader writing to the buffer used by the order-independent transparency implementation. Two sample shaders that you can use are included in this project: `OrderIndependentTransparency/Unlit` for all pipelines and additionally `OrderIndependentTransparency/Standard` for the built-in pipeline. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
Shader "Hidden/OitRenderHDRP" | ||
{ | ||
Properties{ | ||
_MainTex("Main Texture", 2DArray) = "white" {} | ||
} | ||
SubShader | ||
{ | ||
PackageRequirements { | ||
"com.unity.render-pipelines.high-definition" | ||
} | ||
Tags { "RenderPipeline" = "HDRenderPipeline" } | ||
Pass { | ||
Name "HDRP Order-Independent Transparency Pass" | ||
ZTest Always | ||
ZWrite Off | ||
Blend Off | ||
Cull Off | ||
|
||
HLSLPROGRAM | ||
#pragma fragment frag | ||
#pragma vertex Vert | ||
#pragma target 5.0 | ||
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch | ||
#pragma require randomwrite | ||
// #pragma enable_d3d11_debug_symbols | ||
|
||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPassCommon.hlsl" | ||
#include "../LinkedListRendering.hlsl" | ||
|
||
float4 frag(Varyings input, uint uSampleIndex : SV_SampleIndex) : SV_Target | ||
{ | ||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); | ||
|
||
float4 col = float4 (0, 1, 0, 1); | ||
float depth = LoadCameraDepth(input.positionCS.xy); | ||
PositionInputs posInput = GetPositionInput(input.positionCS.xy, _ScreenSize.zw, depth, UNITY_MATRIX_I_VP, UNITY_MATRIX_V); | ||
// Load the camera color buffer at the mip 0 if we're not at the before rendering injection point | ||
if (_CustomPassInjectionPoint != CUSTOMPASSINJECTIONPOINT_BEFORE_RENDERING) | ||
col = float4(CustomPassSampleCameraColor(posInput.positionNDC.xy, 0), 1); | ||
|
||
return renderLinkedList(col, input.positionCS.xy, uSampleIndex); | ||
} | ||
ENDHLSL | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
Shader "Hidden/OitRenderPPv2" | ||
{ | ||
Properties{ | ||
_MainTex("Main Texture", 2DArray) = "white" {} | ||
} | ||
SubShader | ||
{ | ||
Pass { | ||
ZTest Always | ||
ZWrite Off | ||
Cull Off | ||
Blend Off | ||
|
||
HLSLPROGRAM | ||
#pragma vertex vert | ||
#pragma fragment frag | ||
#pragma target 5.0 | ||
#pragma require randomwrite | ||
// #pragma enable_d3d11_debug_symbols | ||
|
||
#include "UnityCG.cginc" | ||
#include "../LinkedListRendering.hlsl" | ||
|
||
struct appdata { | ||
float4 vertex : POSITION; | ||
float2 texcoord : TEXCOORD0; | ||
}; | ||
struct v2f { | ||
float2 uv : TEXCOORD0; | ||
float4 vertex : SV_POSITION; | ||
}; | ||
|
||
sampler2D _MainTex; | ||
float4 _MainTex_ST; | ||
|
||
v2f vert(appdata v) | ||
{ | ||
v2f o; | ||
o.vertex = UnityObjectToClipPos(v.vertex); | ||
o.uv = TRANSFORM_TEX(v.texcoord, _MainTex); | ||
return o; | ||
} | ||
|
||
//Pixel function returns a solid color for each point. | ||
fixed4 frag(v2f i, uint uSampleIndex : SV_SampleIndex) : SV_Target | ||
{ | ||
// Retrieve current color from background texture | ||
float4 col = tex2D(_MainTex, i.uv); | ||
|
||
return renderLinkedList(col, i.vertex.xy, uSampleIndex); | ||
} | ||
ENDHLSL | ||
} | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
Shader "Hidden/OitRenderURP" | ||
{ | ||
SubShader | ||
{ | ||
PackageRequirements { | ||
"com.unity.render-pipelines.universal" | ||
} | ||
Tags { "RenderPipeline" = "UniversalRenderPipeline" } | ||
Pass { | ||
Name "URP Order-Independent Transparency Pass" | ||
ZTest Always | ||
ZWrite Off | ||
Cull Off | ||
Blend Off | ||
|
||
HLSLPROGRAM | ||
#pragma vertex Vert | ||
#pragma fragment frag | ||
#pragma target 5.0 | ||
#pragma require randomwrite | ||
// #pragma enable_d3d11_debug_symbols | ||
|
||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" | ||
#include "Packages/com.unity.render-pipelines.core/Runtime/Utilities/Blit.hlsl" | ||
#include "../LinkedListRendering.hlsl" | ||
|
||
TEXTURE2D_X(_CameraOpaqueTexture); | ||
SAMPLER(sampler_CameraOpaqueTexture); | ||
|
||
//Pixel function returns a solid color for each point. | ||
half4 frag(Varyings input, uint uSampleIndex: SV_SampleIndex) : SV_Target | ||
{ | ||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); | ||
// Retrieve current color from background texture | ||
float4 col = SAMPLE_TEXTURE2D_X(_CameraOpaqueTexture, sampler_CameraOpaqueTexture, input.texcoord); | ||
|
||
return renderLinkedList(col, input.positionCS.xy, uSampleIndex); | ||
} | ||
ENDHLSL | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
using UnityEngine; | ||
using UnityEngine.Rendering; | ||
|
||
namespace OrderIndependentTransparency | ||
{ | ||
public interface IOrderIndependentTransparency | ||
{ | ||
void PreRender(CommandBuffer command); | ||
void Render(CommandBuffer command, RenderTargetIdentifier src, RenderTargetIdentifier dest); | ||
Material Render(CommandBuffer command, RenderTargetIdentifier src, RenderTargetIdentifier dest); | ||
void Release(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.