Skip to content

Commit 5036cc5

Browse files
committed
Fixed a path renaming bug.
Enclosed examples in a namespace. Gave example shaders nested names.
1 parent 5aab081 commit 5036cc5

20 files changed

Lines changed: 782 additions & 743 deletions

Editor/CustomPostProcessSettingsEditor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ private struct DrawerState {
3535
/// <param name="type"></param>
3636
/// <returns></returns>
3737
private string GetName(Type type){
38-
return CustomPostProcessAttribute.GetAttribute(type)?.Name ?? type.Name;
38+
return CustomPostProcessAttribute.GetAttribute(type)?.Name ?? type?.Name;
3939
}
4040

4141
// This code is mostly copied from Unity's HDRP repository

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ Other custom effects in samples but not used in screenshots:
3232

3333
## How To Install
3434

35-
**TODO**
35+
Follow the instructions from the Unity manual on [Installing from a Git URL](https://docs.unity3d.com/Manual/upm-ui-giturl.html) and insert the url: https://github.com/yahiaetman/urp-custom-pps.git then wait for the package to be downloaded and installed.
36+
37+
The package contains 8 example effect which are included as a sample. Samples can be imported from the package page in the package manager.
3638

3739
## Tutorial
3840

Runtime/RenderFeatures/CustomPostProcessRenderer.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ public CustomPostProcessAttribute(string name, CustomPostProcessInjectPoint inje
108108
}
109109

110110
public static CustomPostProcessAttribute GetAttribute(Type type){
111+
if(type == null) return null;
111112
var atttributes = type.GetCustomAttributes(typeof(CustomPostProcessAttribute), false);
112113
return (atttributes.Length != 0) ? (atttributes[0] as CustomPostProcessAttribute) : null;
113114
}

Samples~/Examples/Resources/Shaders/PostProcessing/Blend.shader

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
Shader "Hidden/Blend"
1+
Shader "Hidden/Yetman/PostProcess/Blend"
22
{
33
HLSLINCLUDE
4-
#include "Packages/com.yetman.render-pipelines.universal.postprocessing/ShaderLibrary/Core.hlsl"
4+
#include "Packages/com.yetman.render-pipelines.universal.postprocess/ShaderLibrary/Core.hlsl"
55

66
TEXTURE2D_X(_MainTex);
77
TEXTURE2D_X(_SecondaryTex);
88

9-
float3 _blend;
9+
float3 _Blend;
1010

1111
float4 BlendFragmentProgram(PostProcessVaryings input) : SV_Target
1212
{
@@ -16,7 +16,7 @@
1616
float3 mainColor = LOAD_TEXTURE2D_X(_MainTex, positionSS).rgb;
1717
float3 secondaryColor = LOAD_TEXTURE2D_X(_SecondaryTex, positionSS).rgb;
1818
// blend the main and secondary color
19-
float3 color = lerp(mainColor, secondaryColor, _blend);
19+
float3 color = lerp(mainColor, secondaryColor, _Blend);
2020
return float4(color, 1);
2121
}
2222
ENDHLSL

Samples~/Examples/Resources/Shaders/PostProcessing/ChromaSplit.shader

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
Shader "Hidden/ChromaSplit"
1+
Shader "Hidden/Yetman/PostProcess/ChromaSplit"
22
{
33
HLSLINCLUDE
4-
#include "Packages/com.yetman.render-pipelines.universal.postprocessing/ShaderLibrary/Core.hlsl"
4+
#include "Packages/com.yetman.render-pipelines.universal.postprocess/ShaderLibrary/Core.hlsl"
55

66
TEXTURE2D_X(_MainTex);
77

88
// The split amount
9-
uint2 _split;
9+
uint2 _Split;
1010

1111
float4 ChromaSplitFragmentProgram(PostProcessVaryings input) : SV_Target
1212
{
@@ -17,8 +17,8 @@
1717
float4 color = LOAD_TEXTURE2D_X(_MainTex, positionSS);
1818

1919
// Read read and blue from the neighbouring pixels at the given split offset
20-
color.r = LOAD_TEXTURE2D_X(_MainTex, positionSS - _split).r;
21-
color.b = LOAD_TEXTURE2D_X(_MainTex, positionSS + _split).b;
20+
color.r = LOAD_TEXTURE2D_X(_MainTex, positionSS - _Split).r;
21+
color.b = LOAD_TEXTURE2D_X(_MainTex, positionSS + _Split).b;
2222

2323
return color;
2424
}

Samples~/Examples/Resources/Shaders/PostProcessing/EdgeDetection.shader

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
Shader "Hidden/EdgeDetection"
1+
Shader "Hidden/Yetman/PostProcess/EdgeDetection"
22
{
33
HLSLINCLUDE
4-
#include "Packages/com.yetman.render-pipelines.universal.postprocessing/ShaderLibrary/Core.hlsl"
4+
#include "Packages/com.yetman.render-pipelines.universal.postprocess/ShaderLibrary/Core.hlsl"
55
// In URP 10, this should be replaced by the same file from URP's ShaderLibrary
6-
#include "Packages/com.yetman.render-pipelines.universal.postprocessing/ShaderLibrary/DeclareNormalsTexture.hlsl"
6+
#include "Packages/com.yetman.render-pipelines.universal.postprocess/ShaderLibrary/DeclareNormalsTexture.hlsl"
77
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareDepthTexture.hlsl"
88

99
TEXTURE2D_X(_MainTex);
1010
float4 _MainTex_TexelSize;
1111

1212
// The blending factor for the edges with the original color
13-
float _intensity;
13+
float _Intensity;
1414
// The threshold ranges for edge detection (xy used for normals, zw used for depth)
15-
float4 _threshold;
15+
float4 _Threshold;
1616
// The thickness of the edge (determines how far the neighbour samples spread around the center sample)
17-
float _thickness;
17+
float _Thickness;
1818
// The color of the edge
19-
float3 _color;
19+
float3 _Color;
2020

2121
// Curtom Scene normal and depth sampling function to read from a custom texture and sampler
2222
float3 SampleSceneNormals(float2 uv, TEXTURE2D_X_FLOAT(_Texture), SAMPLER(sampler_Texture))
@@ -79,15 +79,15 @@
7979
float4 color = LOAD_TEXTURE2D_X(_MainTex, uv * _ScreenParams.xy);
8080

8181
float4 center = SampleSceneDepthNormal(uv);
82-
float4 neighborhood = SampleNeighborhood(uv, _thickness);
82+
float4 neighborhood = SampleNeighborhood(uv, _Thickness);
8383
// Normal similarity is calculated using a dot product
84-
float normalSame = smoothstep(_threshold.x, _threshold.y, dot(center.xyz, neighborhood.xyz));
84+
float normalSame = smoothstep(_Threshold.x, _Threshold.y, dot(center.xyz, neighborhood.xyz));
8585
// Depth similarity is calculated using absolute difference
86-
float depthSame = smoothstep(_threshold.w, _threshold.z, abs(center.w - neighborhood.w));
86+
float depthSame = smoothstep(_Threshold.w, _Threshold.z, abs(center.w - neighborhood.w));
8787
// Combine normal and depth sameness to get edge factor
8888
float edge = 1 - normalSame * depthSame;
8989

90-
color.rgb = lerp(color.rgb, _color, edge * _intensity);
90+
color.rgb = lerp(color.rgb, _Color, edge * _Intensity);
9191
return color;
9292
}
9393
ENDHLSL

Samples~/Examples/Resources/Shaders/PostProcessing/GradientFog.shader

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
Shader "Hidden/GradientFog"
1+
Shader "Hidden/Yetman/PostProcess/GradientFog"
22
{
33
HLSLINCLUDE
4-
#include "Packages/com.yetman.render-pipelines.universal.postprocessing/ShaderLibrary/Core.hlsl"
4+
#include "Packages/com.yetman.render-pipelines.universal.postprocess/ShaderLibrary/Core.hlsl"
55
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareDepthTexture.hlsl"
66

77
TEXTURE2D_X(_MainTex);
88

9-
float _intensity;
10-
float _exponent;
9+
float _Intensity;
10+
float _Exponent;
1111

1212
// The near and far color distance
13-
float2 _colorRange;
14-
float3 _nearFogColor;
15-
float3 _farFogColor;
13+
float2 _ColorRange;
14+
float3 _NearFogColor;
15+
float3 _FarFogColor;
1616

1717
// The value from the depth buffer must be remapped from [0,1]
1818
// to [-1,1] before computing view space position
@@ -36,12 +36,12 @@
3636
float3 viewPos = ComputeViewSpacePosition(uv, deviceDepth, unity_CameraInvProjection);
3737
float distance = length(viewPos);
3838

39-
float fogFactor = 1.0 - exp(- _exponent * distance); // exponential fog
40-
float3 fogColor = lerp(_nearFogColor, _farFogColor, smoothstep(_colorRange.x, _colorRange.y, distance));
39+
float fogFactor = 1.0 - exp(- _Exponent * distance); // exponential fog
40+
float3 fogColor = lerp(_NearFogColor, _FarFogColor, smoothstep(_ColorRange.x, _ColorRange.y, distance));
4141

4242
float4 color = LOAD_TEXTURE2D_X(_MainTex, positionSS);
4343

44-
color.rgb = lerp(color.rgb, fogColor, _intensity * fogFactor);
44+
color.rgb = lerp(color.rgb, fogColor, _Intensity * fogFactor);
4545
return color;
4646
}
4747
ENDHLSL

Samples~/Examples/Resources/Shaders/PostProcessing/GrayAndInvert.shader

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
Shader "Hidden/GrayAndInvert"
1+
Shader "Hidden/Yetman/PostProcess/GrayAndInvert"
22
{
33
HLSLINCLUDE
4-
#include "Packages/com.yetman.render-pipelines.universal.postprocessing/ShaderLibrary/Core.hlsl"
4+
#include "Packages/com.yetman.render-pipelines.universal.postprocess/ShaderLibrary/Core.hlsl"
55
// This file contains the "Luminance" which we use to get the grayscale value
66
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
77

88
TEXTURE2D_X(_MainTex);
99

10-
float _grayBlend;
11-
float _invertBlend;
10+
float _GrayBlend;
11+
float _InvertBlend;
1212

1313
float4 GrayAndInverFragmentProgram(PostProcessVaryings input) : SV_Target
1414
{
@@ -19,12 +19,12 @@
1919

2020
#if GRAYSCALE_ON
2121
// Blend between the original and the grayscale color
22-
color.rgb = lerp(color.rgb, Luminance(color.rgb).xxx, _grayBlend);
22+
color.rgb = lerp(color.rgb, Luminance(color.rgb).xxx, _GrayBlend);
2323
#endif
2424

2525
#if INVERT_ON
2626
// just invert the colors and blend with the original color
27-
color.rgb = lerp(color.rgb, 1.0 - color.rgb, _invertBlend);
27+
color.rgb = lerp(color.rgb, 1.0 - color.rgb, _InvertBlend);
2828
#endif
2929

3030
return color;

Samples~/Examples/Resources/Shaders/PostProcessing/Grayscale.shader

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
Shader "Hidden/Grayscale"
1+
Shader "Hidden/Yetman/PostProcess/Grayscale"
22
{
33
HLSLINCLUDE
4-
#include "Packages/com.yetman.render-pipelines.universal.postprocessing/ShaderLibrary/Core.hlsl"
4+
#include "Packages/com.yetman.render-pipelines.universal.postprocess/ShaderLibrary/Core.hlsl"
55
// This file contains the "Luminance" which we use to get the grayscale value
66
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
77

88
TEXTURE2D_X(_MainTex);
99

10-
float _blend;
10+
float _Blend;
1111

1212
float4 GrayscaleFragmentProgram (PostProcessVaryings input) : SV_Target
1313
{
@@ -17,7 +17,7 @@
1717
float4 color = LOAD_TEXTURE2D_X(_MainTex, uv * _ScreenParams.xy);
1818

1919
// Blend between the original and the grayscale color
20-
color.rgb = lerp(color.rgb, Luminance(color.rgb).xxx, _blend);
20+
color.rgb = lerp(color.rgb, Luminance(color.rgb).xxx, _Blend);
2121

2222
return color;
2323
}

Samples~/Examples/Resources/Shaders/PostProcessing/Invert.shader

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
Shader "Hidden/Invert"
1+
Shader "Hidden/Yetman/PostProcess/Invert"
22
{
33
HLSLINCLUDE
4-
#include "Packages/com.yetman.render-pipelines.universal.postprocessing/ShaderLibrary/Core.hlsl"
4+
#include "Packages/com.yetman.render-pipelines.universal.postprocess/ShaderLibrary/Core.hlsl"
55

66
TEXTURE2D_X(_MainTex);
77

8-
float _blend;
8+
float _Blend;
99

1010
float4 InvertFragmentProgram(PostProcessVaryings input) : SV_Target
1111
{
1212
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
1313
float2 uv = UnityStereoTransformScreenSpaceTex(input.texcoord);
1414
float4 color = LOAD_TEXTURE2D_X(_MainTex, uv * _ScreenParams.xy);
1515
// just invert the colors and blend with the original color
16-
color.rgb = lerp(color.rgb, 1.0 - color.rgb, _blend);
16+
color.rgb = lerp(color.rgb, 1.0 - color.rgb, _Blend);
1717
return color;
1818
}
1919
ENDHLSL

0 commit comments

Comments
 (0)