当前位置:网站首页>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
边栏推荐
- In depth understanding of redis memory obsolescence strategy
- Embedded-c Language-5
- Precision epidemic prevention has a "sharp weapon" | smart core helps digital sentinels escort the resumption of the city
- 调查显示传统数据安全工具面对勒索软件攻击的失败率高达 60%
- Copy mode DMA
- 腾讯音乐上线新产品“曲易买”,提供音乐商用版权授权
- 7. Scala class
- MySql 查询符合条件的最新数据行
- The third lesson of EasyX learning
- Judge whether a string is a full letter sentence
猜你喜欢
7.Scala类
飞桨EasyDL实操范例:工业零件划痕自动识别
一个满分的项目文档是如何书写的|得物技术
[Web attack and Defense] WAF detection technology map
ternary operator
腾讯音乐上线新产品“曲易买”,提供音乐商用版权授权
33:第三章:开发通行证服务:16:使用Redis缓存用户信息;(以减轻数据库的压力)
MySql 查询符合条件的最新数据行
Precision epidemic prevention has a "sharp weapon" | smart core helps digital sentinels escort the resumption of the city
一文了解MySQL事务隔离级别
随机推荐
浏览器渲染原理以及重排与重绘
VBA驱动SAP GUI实现办公自动化(二):判断元素是否存在
CMake教程Step2(添加库)
Machine learning compilation lesson 2: tensor program abstraction
Etcd 构建高可用Etcd集群
C# TCP如何设置心跳数据包,才显得优雅呢?
URP下Alpha从Gamma空间到Linner空间转换(二)——多Alpha贴图叠加
[Jianzhi offer] 62 The last remaining number in the circle
Embedded UC (UNIX System Advanced Programming) -3
机器学习01:绪论
33:第三章:开发通行证服务:16:使用Redis缓存用户信息;(以减轻数据库的压力)
国内首家 EMQ 加入亚马逊云科技「初创加速-全球合作伙伴网络计划」
兰空图床苹果快捷指令
【testlink】TestLink1.9.18常见问题解决方法
Timestamp strtotime the day before or after the date
[Jianzhi offer] 61 Shunzi in playing cards
[wechat applet] read the life cycle and route jump of the applet
Embedded UC (UNIX System Advanced Programming) -2
C#(Winform) 当前线程不在单线程单元中,因此无法实例化 ActiveX 控件
Is it safe and reliable to open futures accounts on koufu.com? How to distinguish whether the platform is safe?