当前位置:网站首页>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
边栏推荐
- CMake教程Step1(基本起点)
- ECU introduction
- The third lesson of EasyX learning
- Detailed explanation of printf() and scanf() functions of C language
- Iphone14 with pill screen may trigger a rush for Chinese consumers
- mysql5.6解析JSON字符串方式(支持复杂的嵌套格式)
- Is it safe for qiniu business school to open a stock account? Is it reliable?
- The two ways of domestic chip industry chain go hand in hand. ASML really panicked and increased cooperation on a large scale
- Embedded -arm (bare board development) -1
- 【testlink】TestLink1.9.18常见问题解决方法
猜你喜欢
Embedded-c Language-2
激动人心!2022开放原子全球开源峰会报名火热开启!
First day of learning C language
The two ways of domestic chip industry chain go hand in hand. ASML really panicked and increased cooperation on a large scale
【机器人坐标系第一讲】
American chips are no longer proud, and Chinese chips have successfully won the first place in emerging fields
mysql中取出json字段的小技巧
Machine learning compilation lesson 2: tensor program abstraction
国内首家 EMQ 加入亚马逊云科技「初创加速-全球合作伙伴网络计划」
dried food! Semi supervised pre training dialogue model space
随机推荐
VBA驱动SAP GUI实现办公自动化(二):判断元素是否存在
Embedded-c Language-3
【beanshell】数据写入本地多种方法
手机开证券账户安全吗?怎么买股票详细步骤
Error in compiling libssh2. OpenSSL cannot be found
ECU introduction
兰空图床苹果快捷指令
Is it safe to open futures accounts online? Will there be more liars online? Doesn't feel very reliable?
How MySQL uses JSON_ Extract() takes JSON value
Use of ThinkPHP template
Three traversal methods of binary tree
深耕5G,芯讯通持续推动5G应用百花齐放
激动人心!2022开放原子全球开源峰会报名火热开启!
Embedded-c language-6
Design of electronic clock based on 51 single chip microcomputer
It is forbidden to copy content JS code on the website page
Embedded-c Language-4
[7.7 live broadcast preview] the lecturer of "typical architecture of SaaS cloud native applications" teaches you to easily build cloud native SaaS applications. Once the problem is solved, Huawei's s
腾讯音乐上线新产品“曲易买”,提供音乐商用版权授权
机器学习02:模型评估