浏览代码
Merge pull request #159 from Unity-Technologies/bloom-removal
Merge pull request #159 from Unity-Technologies/bloom-removal
Removed broken temporary bloom implementation/Branch_Batching2
GitHub
8 年前
当前提交
4564bce6
共有 8 个文件被更改,包括 1 次插入 和 482 次删除
-
48Assets/ScriptableRenderPipeline/HDRenderPipeline/PostProcess/Editor/PostProcessingEditor.cs
-
17Assets/ScriptableRenderPipeline/HDRenderPipeline/PostProcess/PostProcessing.Settings.cs
-
151Assets/ScriptableRenderPipeline/HDRenderPipeline/PostProcess/PostProcessing.cs
-
26Assets/ScriptableRenderPipeline/HDRenderPipeline/PostProcess/Resources/FinalPass.shader
-
52Assets/ScriptableRenderPipeline/HDRenderPipeline/PostProcess/Resources/Bloom.hlsl
-
9Assets/ScriptableRenderPipeline/HDRenderPipeline/PostProcess/Resources/Bloom.hlsl.meta
-
9Assets/ScriptableRenderPipeline/HDRenderPipeline/PostProcess/Resources/Bloom.shader.meta
-
171Assets/ScriptableRenderPipeline/HDRenderPipeline/PostProcess/Resources/Bloom.shader
|
|||
#ifndef UNITY_BLOOM |
|||
#define UNITY_BLOOM |
|||
|
|||
// Downsample with a 4x4 box filter |
|||
float3 DownsampleFilter(TEXTURE2D_ARGS(tex, texSampler), float2 uv, float2 texelSize) |
|||
{ |
|||
float4 d = texelSize.xyxy * float4(-1.0, -1.0, 1.0, 1.0); |
|||
|
|||
float3 s; |
|||
s = SAMPLE_TEXTURE2D(tex, texSampler, uv + d.xy).rgb; |
|||
s += SAMPLE_TEXTURE2D(tex, texSampler, uv + d.zy).rgb; |
|||
s += SAMPLE_TEXTURE2D(tex, texSampler, uv + d.xw).rgb; |
|||
s += SAMPLE_TEXTURE2D(tex, texSampler, uv + d.zw).rgb; |
|||
|
|||
return s * (1.0 / 4.0); |
|||
} |
|||
|
|||
float3 UpsampleFilter(TEXTURE2D_ARGS(tex, texSampler), float2 uv, float2 texelSize, float sampleScale) |
|||
{ |
|||
#if 0 |
|||
// 4-tap bilinear upsampler |
|||
float4 d = texelSize.xyxy * float4(-1.0, -1.0, 1.0, 1.0) * (sampleScale * 0.5); |
|||
|
|||
float3 s; |
|||
s = SAMPLE_TEXTURE2D(tex, texSampler, uv + d.xy).rgb; |
|||
s += SAMPLE_TEXTURE2D(tex, texSampler, uv + d.zy).rgb; |
|||
s += SAMPLE_TEXTURE2D(tex, texSampler, uv + d.xw).rgb; |
|||
s += SAMPLE_TEXTURE2D(tex, texSampler, uv + d.zw).rgb; |
|||
|
|||
return s * (1.0 / 4.0); |
|||
#else |
|||
// 9-tap bilinear upsampler (tent filter) |
|||
float4 d = texelSize.xyxy * float4(1.0, 1.0, -1.0, 0.0) * sampleScale; |
|||
|
|||
float3 s; |
|||
s = SAMPLE_TEXTURE2D(tex, texSampler, uv - d.xy).rgb; |
|||
s += SAMPLE_TEXTURE2D(tex, texSampler, uv - d.wy).rgb * 2.0; |
|||
s += SAMPLE_TEXTURE2D(tex, texSampler, uv - d.zy).rgb; |
|||
|
|||
s += SAMPLE_TEXTURE2D(tex, texSampler, uv + d.zw).rgb * 2.0; |
|||
s += SAMPLE_TEXTURE2D(tex, texSampler, uv).rgb * 4.0; |
|||
s += SAMPLE_TEXTURE2D(tex, texSampler, uv + d.xw).rgb * 2.0; |
|||
|
|||
s += SAMPLE_TEXTURE2D(tex, texSampler, uv + d.zy).rgb; |
|||
s += SAMPLE_TEXTURE2D(tex, texSampler, uv + d.wy).rgb * 2.0; |
|||
s += SAMPLE_TEXTURE2D(tex, texSampler, uv + d.xy).rgb; |
|||
|
|||
return s * (1.0 / 16.0); |
|||
#endif |
|||
} |
|||
|
|||
#endif // UNITY_BLOOM |
|
|||
fileFormatVersion: 2 |
|||
guid: 41784642d71cc4a46acbaa1c81d71109 |
|||
timeCreated: 1486047545 |
|||
licenseType: Pro |
|||
ShaderImporter: |
|||
defaultTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 0e58ecfc4bcd918478485f7b80aae431 |
|||
timeCreated: 1486047504 |
|||
licenseType: Pro |
|||
ShaderImporter: |
|||
defaultTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
Shader "Hidden/HDRenderPipeline/Bloom" |
|||
{ |
|||
Properties |
|||
{ |
|||
_MainTex ("", 2D) = "" {} |
|||
_BaseTex ("", 2D) = "" {} |
|||
_AutoExposure ("", 2D) = "" {} |
|||
} |
|||
|
|||
HLSLINCLUDE |
|||
|
|||
#pragma target 4.5 |
|||
#include "ShaderLibrary/Common.hlsl" |
|||
#include "HDRenderPipeline/ShaderVariables.hlsl" |
|||
#include "Bloom.hlsl" |
|||
|
|||
TEXTURE2D(_MainTex); |
|||
SAMPLER2D(sampler_MainTex); |
|||
float4 _MainTex_TexelSize; |
|||
|
|||
TEXTURE2D(_BaseTex); |
|||
SAMPLER2D(sampler_BaseTex); |
|||
float4 _BaseTex_TexelSize; |
|||
|
|||
TEXTURE2D(_AutoExposure); |
|||
SAMPLER2D(sampler_AutoExposure); |
|||
|
|||
float _Threshold; |
|||
float3 _Curve; |
|||
float _SampleScale; |
|||
|
|||
struct Attributes |
|||
{ |
|||
float3 vertex : POSITION; |
|||
float2 texcoord : TEXCOORD0; |
|||
}; |
|||
|
|||
struct Varyings |
|||
{ |
|||
float4 vertex : SV_POSITION; |
|||
float2 texcoord : TEXCOORD0; |
|||
}; |
|||
|
|||
struct VaryingsMultitex |
|||
{ |
|||
float4 vertex : SV_POSITION; |
|||
float2 texcoordMain : TEXCOORD0; |
|||
float2 texcoordBase : TEXCOORD1; |
|||
}; |
|||
|
|||
Varyings Vert(Attributes input) |
|||
{ |
|||
Varyings output; |
|||
output.vertex = TransformWorldToHClip(input.vertex); |
|||
output.texcoord = input.texcoord.xy; |
|||
return output; |
|||
} |
|||
|
|||
VaryingsMultitex VertMultitex(Attributes input) |
|||
{ |
|||
VaryingsMultitex o; |
|||
o.vertex = TransformWorldToHClip(input.vertex); |
|||
o.texcoordMain = input.texcoord.xy; |
|||
o.texcoordBase = o.texcoordMain; |
|||
|
|||
#if UNITY_UV_STARTS_AT_TOP |
|||
if (_BaseTex_TexelSize.y < 0.0) |
|||
o.texcoordMain.y = 1.0 - o.texcoordMain.y; |
|||
#endif |
|||
|
|||
return o; |
|||
} |
|||
|
|||
float4 FetchAutoExposed(TEXTURE2D_ARGS(tex, texSampler), float2 uv) |
|||
{ |
|||
float autoExposure = 1.0; |
|||
|
|||
#if EYE_ADAPTATION |
|||
autoExposure = SAMPLE_TEXTURE2D(_AutoExposure, sampler_AutoExposure, uv).r; |
|||
#endif |
|||
|
|||
return SAMPLE_TEXTURE2D(tex, texSampler, uv) * autoExposure; |
|||
} |
|||
|
|||
float4 FragPrefilter(Varyings i) : SV_Target |
|||
{ |
|||
float2 uv = i.texcoord; |
|||
|
|||
float4 s0 = min(65504.0, FetchAutoExposed(TEXTURE2D_PARAM(_MainTex, sampler_MainTex), uv)); |
|||
float3 m = s0.rgb; |
|||
|
|||
// Pixel brightness |
|||
float br = max(m.r, max(m.g, m.r)); |
|||
|
|||
// Under-threshold part: quadratic curve |
|||
float rq = clamp(br - _Curve.x, 0.0, _Curve.y); |
|||
rq = _Curve.z * rq * rq; |
|||
|
|||
// Combine and apply the brightness response curve. |
|||
m *= max(rq, br - _Threshold) / max(br, 1e-5); |
|||
|
|||
return float4(m, 0.0); |
|||
} |
|||
|
|||
float4 FragDownsample1(Varyings i) : SV_Target |
|||
{ |
|||
return float4(DownsampleFilter(TEXTURE2D_PARAM(_MainTex, sampler_MainTex), i.texcoord, _MainTex_TexelSize.xy), 0.0); |
|||
} |
|||
|
|||
float4 FragDownsample2(Varyings i) : SV_Target |
|||
{ |
|||
return float4(DownsampleFilter(TEXTURE2D_PARAM(_MainTex, sampler_MainTex), i.texcoord, _MainTex_TexelSize.xy), 0.0); |
|||
} |
|||
|
|||
float4 FragUpsample(VaryingsMultitex i) : SV_Target |
|||
{ |
|||
float3 base = SAMPLE_TEXTURE2D(_BaseTex, sampler_BaseTex, i.texcoordBase).rgb; |
|||
float3 blur = UpsampleFilter(TEXTURE2D_PARAM(_MainTex, sampler_MainTex), i.texcoordMain, _MainTex_TexelSize.xy, _SampleScale); |
|||
return float4(base + blur, 0.0); |
|||
} |
|||
|
|||
ENDHLSL |
|||
|
|||
SubShader |
|||
{ |
|||
Cull Off ZWrite Off ZTest Always |
|||
|
|||
Pass |
|||
{ |
|||
HLSLPROGRAM |
|||
|
|||
#pragma multi_compile __ EYE_ADAPTATION |
|||
#pragma vertex Vert |
|||
#pragma fragment FragPrefilter |
|||
|
|||
ENDHLSL |
|||
} |
|||
|
|||
Pass |
|||
{ |
|||
HLSLPROGRAM |
|||
|
|||
#pragma vertex Vert |
|||
#pragma fragment FragDownsample1 |
|||
|
|||
ENDHLSL |
|||
} |
|||
|
|||
Pass |
|||
{ |
|||
HLSLPROGRAM |
|||
|
|||
#pragma vertex Vert |
|||
#pragma fragment FragDownsample2 |
|||
|
|||
ENDHLSL |
|||
} |
|||
|
|||
Pass |
|||
{ |
|||
HLSLPROGRAM |
|||
|
|||
#pragma vertex VertMultitex |
|||
#pragma fragment FragUpsample |
|||
|
|||
ENDHLSL |
|||
} |
|||
} |
|||
|
|||
Fallback Off |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue