Skip to content

Commit

Permalink
fix(URP): fix missing shader on URP build (#30)
Browse files Browse the repository at this point in the history
* fix(URP): fix missing shader on URP build

* docs: bump Unity package version

* fix(URP): don't blit on null material
  • Loading branch information
happy-turtle authored Apr 26, 2024
1 parent 863657d commit 91cdcf8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Shaders/Resources/OitRenderURP.shader
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Shader "Hidden/OitRenderURP"
PackageRequirements {
"com.unity.render-pipelines.universal"
}
Tags { "RenderPipeline" = "UniversalRenderPipeline" }
Tags { "RenderPipeline" = "UniversalPipeline" }
Pass {
Name "URP Order-Independent Transparency Pass"
ZTest Always
Expand Down
4 changes: 4 additions & 0 deletions Shared/OitLinkedList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ public void PreRender(CommandBuffer command)
public Material Render(CommandBuffer command, RenderTargetIdentifier src, RenderTargetIdentifier dest)
{
command.ClearRandomWriteTargets();
if (linkedListMaterial == null)
{
return null;
}
// blend linked list
linkedListMaterial.SetBuffer(fragmentLinkBufferId, fragmentLinkBuffer);
linkedListMaterial.SetBuffer(startOffsetBufferId, startOffsetBuffer);
Expand Down
7 changes: 5 additions & 2 deletions URP/Runtime/OitPass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@ public override void Execute(ScriptableRenderContext context, ref RenderingData
CommandBuffer cmd = CommandBufferPool.Get("Order Independent Transparency");
var mat = orderIndependentTransparency.Render(cmd, renderingData.cameraData.renderer.cameraColorTargetHandle,
renderingData.cameraData.renderer.cameraColorTargetHandle);
Blitter.BlitCameraTexture(cmd, renderingData.cameraData.renderer.cameraColorTargetHandle,
renderingData.cameraData.renderer.cameraColorTargetHandle, mat, 0);
if (mat != null)
{
Blitter.BlitCameraTexture(cmd, renderingData.cameraData.renderer.cameraColorTargetHandle,
renderingData.cameraData.renderer.cameraColorTargetHandle, mat, 0);
}
context.ExecuteCommandBuffer(cmd);
cmd.Clear();
CommandBufferPool.Release(cmd);
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "org.happy-turtle.order-independent-transparency",
"version": "5.0.0",
"unity": "2021.2",
"unity": "2022.3",
"displayName": "Order-independent Transparency",
"description": "This is an implementation of order-independent transparency for the Built-In Pipeline. It uses Per-Pixel Linked Lists, implemented with RWStructuredBuffers. This is a feature requiring Shader Model 5.0 with ComputeBuffers, see the Unity Manual for supported platforms.",
"author": {
"name": "Till Davin",
"email": "code@tilldavin.de"
},
"dependencies": {},
"dependencies": { },
"samples": [
{
"displayName": "Post Process Demo",
Expand Down

0 comments on commit 91cdcf8

Please sign in to comment.