当前位置:网站首页>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
边栏推荐
- [first lecture on robot coordinate system]
- 域名解析,反向域名解析nbtstat
- Use JDBC technology and MySQL database management system to realize the function of course management, including adding, modifying, querying and deleting course information.
- thinkphp3.2.3
- Is it safe for qiniu business school to open a stock account? Is it reliable?
- EasyX second lesson
- easyNmon使用汇总
- Copy mode DMA
- 【beanshell】数据写入本地多种方法
- [Jianzhi offer] 62 The last remaining number in the circle
猜你喜欢
Etcd 构建高可用Etcd集群
Rider 设置选中单词侧边高亮,去除警告建议高亮
CMake教程Step1(基本起点)
[Web attack and Defense] WAF detection technology map
ECU introduction
精准防疫有“利器”| 芯讯通助力数字哨兵护航复市
【机器人坐标系第一讲】
Embedded -arm (bare board development) -2
33:第三章:开发通行证服务:16:使用Redis缓存用户信息;(以减轻数据库的压力)
WR | Jufeng group of West Lake University revealed the impact of microplastics pollution on the flora and denitrification function of constructed wetlands
随机推荐
Using C language to realize palindrome number
Is it safe to open futures accounts online? Will there be more liars online? Doesn't feel very reliable?
Embedded-c language-6
MySql 查询符合条件的最新数据行
云安全日报220705:红帽PHP解释器发现执行任意代码漏洞,需要尽快升级
【微信小程序】一文读懂小程序的生命周期和路由跳转
VBA驱动SAP GUI实现办公自动化(二):判断元素是否存在
CMake教程Step2(添加库)
ClickHouse(03)ClickHouse怎么安装和部署
Machine learning 01: Introduction
C language to get program running time
goto Statement
拷贝方式之DMA
The first EMQ in China joined Amazon cloud technology's "startup acceleration - global partner network program"
MYSQL group by 有哪些注意事项
【性能测试】全链路压测
Timestamp strtotime the day before or after the date
【二叉树】根到叶路径上的不足节点
In depth understanding of redis memory obsolescence strategy
Three traversal methods of binary tree