wip: EnkiBillalFulscreen shader

This commit is contained in:
Alexandre Coirier
2026-05-25 14:58:13 +02:00
parent ad8d8ec2a9
commit 69303cd43c
6 changed files with 534 additions and 2 deletions
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8c646f2b6d1146f40bfe460c1c06b96e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,74 @@
#ifndef ENKI_BILLAL_FULLSCREEN_INCLUDED
#define ENKI_BILLAL_FULLSCREEN_INCLUDED
#include "Assets/_Content/Shaders/Include/Noises.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareOpaqueTexture.hlsl"
// Gaussian blur on scene color
// blurRadius controls the spread in pixels — adjust to taste
float3 SampleSceneColorBlurred(float2 uv, float blurRadius)
{
float3 result = 0;
float totalWeight = 0;
// Gaussian weights for 5 samples (sigma ~ 1.0)
float weights[5] = { 0.0625, 0.25, 0.375, 0.25, 0.0625 };
float offsets[5] = { -2, -1, 0, 1, 2 };
float2 texelSize = blurRadius / _ScreenParams.xy;
// Horizontal pass
for (int i = 0; i < 5; i++)
{
float2 offsetUV = uv + float2(offsets[i] * texelSize.x, 0);
result += SAMPLE_TEXTURE2D_X(_CameraOpaqueTexture, sampler_LinearClamp, offsetUV).rgb * weights[i];
}
return result;
}
void EnkiBillalFullscreen_float
(
float2 UV,
out float3 Output
)
{
float2 screenUV = UV;
// DEPTH
float rawDepth = SampleSceneDepth(screenUV);
float depthMeters = LinearEyeDepth(rawDepth, _ZBufferParams); // linear eye-space depth in metres
float depth01 = Linear01Depth(rawDepth, _ZBufferParams); // normalised linear depth [0..1]
// POSITION WORLD SPACE
// Remap depth for non-reversed-Z platforms before reconstruction
float depthForReconstruct = rawDepth;
#if !UNITY_REVERSED_Z
depthForReconstruct = lerp(UNITY_NEAR_CLIP_VALUE, 1.0, rawDepth);
#endif
// ComputeWorldSpacePosition handles perspective divide and platform differences
float3 positionWS = ComputeWorldSpacePosition(screenUV, depthForReconstruct, UNITY_MATRIX_I_VP);
// NORMAL WORLD SPACE
// Requires DepthNormals PrePass to be enabled in the URP Renderer
float3 normalWS = SampleSceneNormals(screenUV);
// SCENE COLOR
float3 originColor = SampleSceneColor(screenUV);
float greyscale = (originColor.x + originColor.y + originColor.z) / 3.0;
float3 offsetUV = PerlinColor3D(positionWS * float3(1, 5, 1), 1) * smoothstep(smoothstep(20, 3, depthMeters), 1, greyscale) * .1 / depthMeters;
float3 sceneColor = SampleSceneColor(screenUV + offsetUV);
//float3 sceneColor = SAMPLE_TEXTURE2D_X(_CameraOpaqueTexture, sampler_PointClamp, screenUV).rgb;
// OUTPUT
Output = SampleSceneColorBlurred(screenUV, 10);
}
#endif
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: d7e00f5980c540647a242d8e50cca93a
ShaderIncludeImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,432 @@
{
"m_SGVersion": 3,
"m_Type": "UnityEditor.ShaderGraph.GraphData",
"m_ObjectId": "5582b09252bc41cda9a92382e0bc37b6",
"m_Properties": [],
"m_Keywords": [],
"m_Dropdowns": [],
"m_CategoryData": [
{
"m_Id": "ee714d8b4e8e40cf9723c0f8c2f5bfea"
}
],
"m_Nodes": [
{
"m_Id": "2c912ecee26d4f84809bc483f9d048fc"
},
{
"m_Id": "81c31f27a1c04d16a82ab97e9602179e"
},
{
"m_Id": "a7bb6da6110b4bd2a09bff6b04958011"
},
{
"m_Id": "1d5c0b04e69841c9bade5e8e87181a13"
}
],
"m_GroupDatas": [],
"m_StickyNoteDatas": [],
"m_Edges": [
{
"m_OutputSlot": {
"m_Node": {
"m_Id": "1d5c0b04e69841c9bade5e8e87181a13"
},
"m_SlotId": 0
},
"m_InputSlot": {
"m_Node": {
"m_Id": "a7bb6da6110b4bd2a09bff6b04958011"
},
"m_SlotId": 0
}
},
{
"m_OutputSlot": {
"m_Node": {
"m_Id": "a7bb6da6110b4bd2a09bff6b04958011"
},
"m_SlotId": 1
},
"m_InputSlot": {
"m_Node": {
"m_Id": "2c912ecee26d4f84809bc483f9d048fc"
},
"m_SlotId": 0
}
}
],
"m_VertexContext": {
"m_Position": {
"x": 0.0,
"y": 0.0
},
"m_Blocks": []
},
"m_FragmentContext": {
"m_Position": {
"x": 0.0,
"y": 200.0
},
"m_Blocks": [
{
"m_Id": "2c912ecee26d4f84809bc483f9d048fc"
},
{
"m_Id": "81c31f27a1c04d16a82ab97e9602179e"
}
]
},
"m_PreviewData": {
"serializedMesh": {
"m_SerializedMesh": "{\"mesh\":{\"instanceID\":0}}",
"m_Guid": ""
},
"preventRotation": false
},
"m_Path": "Shader Graphs",
"m_GraphPrecision": 1,
"m_PreviewMode": 2,
"m_OutputNode": {
"m_Id": ""
},
"m_SubDatas": [],
"m_ActiveTargets": [
{
"m_Id": "d47ec47d894843e38d60739e5f111b92"
}
]
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector2MaterialSlot",
"m_ObjectId": "0b966ce7ec254b9f915ef10fd00be2c7",
"m_Id": 0,
"m_DisplayName": "UV",
"m_SlotType": 0,
"m_Hidden": false,
"m_ShaderOutputName": "UV",
"m_StageCapability": 3,
"m_Value": {
"x": 0.0,
"y": 0.0
},
"m_DefaultValue": {
"x": 0.0,
"y": 0.0
},
"m_Labels": []
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.ScreenPositionNode",
"m_ObjectId": "1d5c0b04e69841c9bade5e8e87181a13",
"m_Group": {
"m_Id": ""
},
"m_Name": "Screen Position",
"m_DrawState": {
"m_Expanded": true,
"m_Position": {
"serializedVersion": "2",
"x": -927.1663818359375,
"y": 116.83366394042969,
"width": 208.0,
"height": 312.0
}
},
"m_Slots": [
{
"m_Id": "e04f606d707446dbb9ad2e41446d0a58"
}
],
"synonyms": [],
"m_Precision": 0,
"m_PreviewExpanded": true,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
},
"m_ScreenSpaceType": 0
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot",
"m_ObjectId": "232fdc9aca704b0fba60a4247e0f7457",
"m_Id": 0,
"m_DisplayName": "Alpha",
"m_SlotType": 0,
"m_Hidden": false,
"m_ShaderOutputName": "Alpha",
"m_StageCapability": 2,
"m_Value": 1.0,
"m_DefaultValue": 1.0,
"m_Labels": [],
"m_LiteralMode": false
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.BlockNode",
"m_ObjectId": "2c912ecee26d4f84809bc483f9d048fc",
"m_Group": {
"m_Id": ""
},
"m_Name": "SurfaceDescription.BaseColor",
"m_DrawState": {
"m_Expanded": true,
"m_Position": {
"serializedVersion": "2",
"x": 0.0,
"y": 0.0,
"width": 0.0,
"height": 0.0
}
},
"m_Slots": [
{
"m_Id": "39cf28cae2de4e9cad4013ed5e4b0077"
}
],
"synonyms": [],
"m_Precision": 0,
"m_PreviewExpanded": true,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
},
"m_SerializedDescriptor": "SurfaceDescription.BaseColor"
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.Rendering.Fullscreen.ShaderGraph.FullscreenData",
"m_ObjectId": "3062c8feae4a446d90f024c17897d5f1",
"m_Version": 0,
"m_fullscreenMode": 0,
"m_BlendMode": 0,
"m_SrcColorBlendMode": 0,
"m_DstColorBlendMode": 1,
"m_ColorBlendOperation": 0,
"m_SrcAlphaBlendMode": 0,
"m_DstAlphaBlendMode": 1,
"m_AlphaBlendOperation": 0,
"m_EnableStencil": false,
"m_StencilReference": 0,
"m_StencilReadMask": 255,
"m_StencilWriteMask": 255,
"m_StencilCompareFunction": 8,
"m_StencilPassOperation": 0,
"m_StencilFailOperation": 0,
"m_StencilDepthFailOperation": 0,
"m_DepthWrite": false,
"m_depthWriteMode": 0,
"m_AllowMaterialOverride": false,
"m_DepthTestMode": 0
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.ColorRGBMaterialSlot",
"m_ObjectId": "39cf28cae2de4e9cad4013ed5e4b0077",
"m_Id": 0,
"m_DisplayName": "Base Color",
"m_SlotType": 0,
"m_Hidden": false,
"m_ShaderOutputName": "BaseColor",
"m_StageCapability": 2,
"m_Value": {
"x": 0.5,
"y": 0.5,
"z": 0.5
},
"m_DefaultValue": {
"x": 0.5,
"y": 0.5,
"z": 0.5
},
"m_Labels": [],
"m_ColorMode": 0,
"m_DefaultColor": {
"r": 0.5,
"g": 0.5,
"b": 0.5,
"a": 1.0
}
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.BlockNode",
"m_ObjectId": "81c31f27a1c04d16a82ab97e9602179e",
"m_Group": {
"m_Id": ""
},
"m_Name": "SurfaceDescription.Alpha",
"m_DrawState": {
"m_Expanded": true,
"m_Position": {
"serializedVersion": "2",
"x": 0.0,
"y": 0.0,
"width": 0.0,
"height": 0.0
}
},
"m_Slots": [
{
"m_Id": "232fdc9aca704b0fba60a4247e0f7457"
}
],
"synonyms": [],
"m_Precision": 0,
"m_PreviewExpanded": true,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
},
"m_SerializedDescriptor": "SurfaceDescription.Alpha"
}
{
"m_SGVersion": 1,
"m_Type": "UnityEditor.ShaderGraph.CustomFunctionNode",
"m_ObjectId": "a7bb6da6110b4bd2a09bff6b04958011",
"m_Group": {
"m_Id": ""
},
"m_Name": "EnkiBillalFullscreen (Custom Function)",
"m_DrawState": {
"m_Expanded": true,
"m_Position": {
"serializedVersion": "2",
"x": -511.9999694824219,
"y": 191.99998474121095,
"width": 262.0,
"height": 77.00001525878906
}
},
"m_Slots": [
{
"m_Id": "0b966ce7ec254b9f915ef10fd00be2c7"
},
{
"m_Id": "f840ccb65a474f4c999bc6357918f904"
}
],
"synonyms": [
"code",
"HLSL"
],
"m_Precision": 0,
"m_PreviewExpanded": false,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
},
"m_SourceType": 0,
"m_FunctionName": "EnkiBillalFullscreen",
"m_FunctionSource": "d7e00f5980c540647a242d8e50cca93a",
"m_FunctionSourceUsePragmas": true,
"m_FunctionBody": "Enter function body here..."
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.Rendering.Universal.ShaderGraph.UniversalFullscreenSubTarget",
"m_ObjectId": "cba6f25984a64bdcb4659d47165011b5"
}
{
"m_SGVersion": 1,
"m_Type": "UnityEditor.Rendering.Universal.ShaderGraph.UniversalTarget",
"m_ObjectId": "d47ec47d894843e38d60739e5f111b92",
"m_Datas": [
{
"m_Id": "3062c8feae4a446d90f024c17897d5f1"
}
],
"m_ActiveSubTarget": {
"m_Id": "cba6f25984a64bdcb4659d47165011b5"
},
"m_AllowMaterialOverride": false,
"m_SurfaceType": 0,
"m_ZTestMode": 4,
"m_ZWriteControl": 0,
"m_AlphaMode": 0,
"m_RenderFace": 2,
"m_AlphaClip": false,
"m_CastShadows": true,
"m_ReceiveShadows": true,
"m_DisableTint": false,
"m_Sort3DAs2DCompatible": false,
"m_AdditionalMotionVectorMode": 0,
"m_AlembicMotionVectors": false,
"m_SupportsLODCrossFade": false,
"m_CustomEditorGUI": "",
"m_SupportVFX": false
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector4MaterialSlot",
"m_ObjectId": "e04f606d707446dbb9ad2e41446d0a58",
"m_Id": 0,
"m_DisplayName": "Out",
"m_SlotType": 1,
"m_Hidden": false,
"m_ShaderOutputName": "Out",
"m_StageCapability": 3,
"m_Value": {
"x": 0.0,
"y": 0.0,
"z": 0.0,
"w": 0.0
},
"m_DefaultValue": {
"x": 0.0,
"y": 0.0,
"z": 0.0,
"w": 0.0
},
"m_Labels": []
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.CategoryData",
"m_ObjectId": "ee714d8b4e8e40cf9723c0f8c2f5bfea",
"m_Name": "",
"m_ChildObjectList": []
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot",
"m_ObjectId": "f840ccb65a474f4c999bc6357918f904",
"m_Id": 1,
"m_DisplayName": "Output",
"m_SlotType": 1,
"m_Hidden": false,
"m_ShaderOutputName": "Output",
"m_StageCapability": 3,
"m_Value": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"m_DefaultValue": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"m_Labels": []
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 9256acd168941544ea69594ff8763468
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3}
useAsTemplate: 0
exposeTemplateAsShader: 0
template:
name:
category:
description:
icon: {instanceID: 0}
thumbnail: {instanceID: 0}