当前位置:网站首页>Alpha conversion from gamma space to linner space under URP (II) -- multi alpha map superposition
Alpha conversion from gamma space to linner space under URP (II) -- multi alpha map superposition
2022-07-05 17:23:00 【euphorias】
List of articles
Conduct post-treatment once GammaToLinner Transformation , Can achieve the correct effect
URP Next, uncheck the map SRGB,


Post processing script
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
public class CameraFeature : ScriptableRendererFeature
{
public Material Material; //UniversalRenderPipelineAsset_Renderer panel , Set the material
private MyVolumeFeaturePass myPass;
public override void Create()
{
myPass = new MyVolumeFeaturePass();
myPass.renderPassEvent = RenderPassEvent.AfterRenderingTransparents;
}
public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
{
renderer.EnqueuePass(myPass);
myPass.SetValue(renderer.cameraColorTarget, Material); // Transfer camera images , And materials , to Pass Handle
}
public class MyVolumeFeaturePass : ScriptableRenderPass
{
// This method is called before executing the render pass.
// It can be used to configure render targets and their clear state. Also to create temporary render target textures.
// When empty this render pass will render to the active camera render target.
// You should never call CommandBuffer.SetRenderTarget. Instead call <c>ConfigureTarget</c> and <c>ConfigureClear</c>.
// The render pipeline will ensure target setup and clearing happens in a performant manner.
public override void OnCameraSetup(CommandBuffer cmd, ref RenderingData renderingData)
{
}
private Material Material;// Accept from Feature Material of panel settings
private RenderTargetIdentifier source;// Accept camera images
public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
{
//if (renderingData.cameraData.camera.name != "UIMainCamera")
//{
// return;
//}
// Post execution processing
if (Material == null)
{
return;
}
CommandBuffer cmd = CommandBufferPool.Get();
//source // The source image
var dec = renderingData.cameraData.cameraTargetDescriptor; // Target image
RenderTargetHandle tempTargetHandle = new RenderTargetHandle();
cmd.GetTemporaryRT(tempTargetHandle.id, dec);
cmd.Blit(source, tempTargetHandle.Identifier(), Material);
// Core command CommandBuffer
cmd.Blit(tempTargetHandle.Identifier(), source); // amount to Graphics.Blit
context.ExecuteCommandBuffer(cmd);
CommandBufferPool.Release(cmd);
}
public void SetValue(RenderTargetIdentifier source, Material material)
{
Material = material; // Accept panel material
this.source = source;
}
}
}
Multiple post-processing problems

Because it is not specified UI The camera , Cause all camera pictures to be converted repeatedly , Need to specify only UI The camera performs GammaToLinner transformation ( The image can also be rendered once after all GammaToLinner transformation )
stay Execute The camera name exposed in the function is filled in on the panel , Determine whether it is the designated camera , Not a designated camera , No post-treatment
// Determine whether it is the designated camera
if (renderingData.cameraData.camera.name != cameraName)
{
return;
}
stay Redner Feature Fill in the camera name on the panel

Effect comparison

Complete reference code
CameraFeature
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
public class CameraFeature : ScriptableRendererFeature
{
public Material Material; //UniversalRenderPipelineAsset_Renderer panel , Set the material
private MyVolumeFeaturePass myPass;
public string CameraName="";
public override void Create()
{
myPass = new MyVolumeFeaturePass();
myPass.renderPassEvent = RenderPassEvent.AfterRenderingTransparents;
}
public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
{
renderer.EnqueuePass(myPass);
myPass.SetValue(renderer.cameraColorTarget, Material, CameraName); // Transfer camera images , And materials , to Pass Handle
}
public class MyVolumeFeaturePass : ScriptableRenderPass
{
// This method is called before executing the render pass.
// It can be used to configure render targets and their clear state. Also to create temporary render target textures.
// When empty this render pass will render to the active camera render target.
// You should never call CommandBuffer.SetRenderTarget. Instead call <c>ConfigureTarget</c> and <c>ConfigureClear</c>.
// The render pipeline will ensure target setup and clearing happens in a performant manner.
public override void OnCameraSetup(CommandBuffer cmd, ref RenderingData renderingData)
{
}
private Material material;// Accept from Feature Material of panel settings
private RenderTargetIdentifier source;// Accept camera images
private string cameraName;
public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
{
// Determine whether it is the designated camera
if (renderingData.cameraData.camera.name != cameraName)
{
return;
}
// Post execution processing
if (material == null)
{
return;
}
CommandBuffer cmd = CommandBufferPool.Get();
//source // The source image
var dec = renderingData.cameraData.cameraTargetDescriptor; // Target image
RenderTargetHandle tempTargetHandle = new RenderTargetHandle();
cmd.GetTemporaryRT(tempTargetHandle.id, dec);
cmd.Blit(source, tempTargetHandle.Identifier(), material);
// Core command CommandBuffer
cmd.Blit(tempTargetHandle.Identifier(), source); // amount to Graphics.Blit
context.ExecuteCommandBuffer(cmd);
CommandBufferPool.Release(cmd);
}
public void SetValue(RenderTargetIdentifier source, Material material, string cameraName)
{
this.material = material; // Accept panel material
this.source = source;
this.cameraName = cameraName;
}
}
}
PostGammaToLinner Shader
Use Amplify Even one , among _MainTex Is a must 
边栏推荐
猜你喜欢

Error in composer installation: no composer lock file present.

7. Scala class

机器学习02:模型评估
In depth understanding of redis memory obsolescence strategy

国内首家 EMQ 加入亚马逊云科技「初创加速-全球合作伙伴网络计划」

URP下Alpha从Gamma空间到Linner空间转换(二)——多Alpha贴图叠加

CMake教程Step4(安装和测试)

npm安装

Application of threshold homomorphic encryption in privacy Computing: Interpretation

The two ways of domestic chip industry chain go hand in hand. ASML really panicked and increased cooperation on a large scale
随机推荐
Example tutorial of SQL deduplication
PHP talent recruitment system development source code recruitment website source code secondary development
张平安:加快云上数字创新,共建产业智慧生态
Is it safe and reliable to open futures accounts on koufu.com? How to distinguish whether the platform is safe?
CMake教程Step1(基本起点)
ternary operator
What are the precautions for MySQL group by
Machine learning compilation lesson 2: tensor program abstraction
In depth understanding of redis memory obsolescence strategy
How can C TCP set heartbeat packets to be elegant?
ClickHouse(03)ClickHouse怎么安装和部署
Matery主题自定义(一)黑夜模式
深耕5G,芯讯通持续推动5G应用百花齐放
Function sub file writing
Oracle缩表空间的完整解决实例
高数 | 旋转体体积计算方法汇总、二重积分计算旋转体体积
Embedded UC (UNIX System Advanced Programming) -1
easyNmon使用汇总
Embedded-c language-6
项目引入jar从私服Nexus 拉去遇到的一个问题