Added UtsEvaluateAngelRing;

Added UTSTonemapping;
This commit is contained in:
Misaki
2025-01-30 22:54:43 +09:00
parent d8b12a0ca9
commit 181a53a3b2
17 changed files with 246 additions and 159 deletions

View File

@@ -0,0 +1,48 @@
using System;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
[Serializable, VolumeComponentMenu("Post-processing/UTS Tonemapping")]
public sealed class UTSTonemapping : CustomPostProcessVolumeComponent, IPostProcessComponent
{
[Tooltip("Controls the intensity of the effect.")]
public BoolParameter state = new BoolParameter(true, BoolParameter.DisplayType.EnumPopup);
private Material _material;
public bool IsActive() => _material != null && state.value;
// Do not forget to add this post process in the Custom Post Process Orders list (Project Settings > Graphics > HDRP Global Settings).
public override CustomPostProcessInjectionPoint injectionPoint => CustomPostProcessInjectionPoint.AfterPostProcess;
const string Shader_Name = "Hidden/Shader/UTSTonemapping";
public override void Setup()
{
if (Shader.Find(Shader_Name) != null)
{
_material = CoreUtils.CreateEngineMaterial(Shader_Name);
}
else
{
Debug.LogError($"Unable to find shader '{Shader_Name}'. Post Process Volume UTSToonmapping is unable to load. To fix this, please edit the 'kShaderName' constant in UTSToonmapping.cs or change the name of your custom post process shader.");
}
}
public override void Render(CommandBuffer cmd, HDCamera camera, RTHandle source, RTHandle destination)
{
if (_material == null || !state.value)
{
return;
}
_material.SetTexture("_MainTex", source);
HDUtils.DrawFullScreen(cmd, _material, destination, shaderPassId: 0);
}
public override void Cleanup()
{
CoreUtils.Destroy(_material);
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 44c60e0af0b15b8419fb621925bc41f4

View File

@@ -0,0 +1,86 @@
Shader "Hidden/Shader/UTSTonemapping"
{
Properties
{
// This property is necessary to make the CommandBuffer.Blit bind the source texture to _MainTex
_MainTex("Main Texture", 2DArray) = "grey" {}
}
HLSLINCLUDE
#pragma target 4.5
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/FXAA.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/RTUpscale.hlsl"
struct Attributes
{
uint vertexID : SV_VertexID;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct Varyings
{
float4 positionCS : SV_POSITION;
float2 texcoord : TEXCOORD0;
UNITY_VERTEX_OUTPUT_STEREO
};
Varyings Vert(Attributes input)
{
Varyings output;
UNITY_SETUP_INSTANCE_ID(input);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
output.positionCS = GetFullScreenTriangleVertexPosition(input.vertexID);
output.texcoord = GetFullScreenTriangleTexCoord(input.vertexID);
return output;
}
TEXTURE2D_X(_MainTex);
inline float3 UTSToonmap(float3 x)
{
// See https://www.desmos.com/calculator/j4tpqazyfw
return (x * (2.63 * x + 0.03)) / (x * (2.11 * x + 0.72) + 0.31);
}
float4 CustomPostProcess(Varyings input) : SV_Target
{
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
// Note that if HDUtils.DrawFullScreen is not used to render the post process, you don't need to call ClampAndScaleUVForBilinearPostProcessTexture.
float3 sourceColor = SAMPLE_TEXTURE2D_X(_MainTex, s_linear_clamp_sampler, ClampAndScaleUVForBilinearPostProcessTexture(input.texcoord.xy)).rgb;
float whiteScale = 1.0 / UTSToonmap(5.3);
float3 color = UTSToonmap(sourceColor * whiteScale);
color *= whiteScale;
return float4(color, 1);
}
ENDHLSL
SubShader
{
Tags{ "RenderPipeline" = "HDRenderPipeline" }
Pass
{
Name "UTSToonmapping"
ZWrite Off
ZTest Always
Blend Off
Cull Off
HLSLPROGRAM
#pragma fragment CustomPostProcess
#pragma vertex Vert
ENDHLSL
}
}
Fallback Off
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 7f1e1745716de164d8f4837e7ee587e6
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant: