Felipe Lira
8 年前
当前提交
05e84b23
共有 239 个文件被更改,包括 1437 次插入 和 1024 次删除
-
1Assets/BasicRenderLoopTutorial/BasicRenderLoop.cs
-
3Assets/Editor/Tests/RenderloopTests/RenderloopTestFixture.cs
-
2Assets/Editor/Tests/ShaderGeneratorTests/ShaderGeneratorTests.cs
-
10Assets/ScriptableRenderLoop/AdditionalLightData.cs
-
5Assets/ScriptableRenderLoop/Editor/MaterialUpgrader.cs
-
6Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/DebugViewMaterial.cs
-
4Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/DebugViewMaterial.cs.hlsl
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/Resources/DebugViewMaterialGBuffer.shader
-
10Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/Resources/DebugViewTiles.shader
-
8Assets/ScriptableRenderLoop/HDRenderPipeline/Editor/UpgradeStandardShaderMaterials.cs
-
32Assets/ScriptableRenderLoop/HDRenderPipeline/Editor/HDRenderPipelineMenuItems.cs
-
10Assets/ScriptableRenderLoop/HDRenderPipeline/Editor/HDRenderPipelineInspector.cs
-
137Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.cs
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting.meta
-
6Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/LightDefinition.cs
-
32Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/LightDefinition.cs.hlsl
-
4Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/LightLoop.cs
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/Resources/Deferred.shader
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass.meta
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/Resources/lightlistbuild-bigtile.compute
-
31Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/TilePass.cs
-
14Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/TilePass.cs.hlsl
-
17Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/TilePass.hlsl
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/Material.meta
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Builtin/BuiltinData.cs
-
8Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Builtin/BuiltinData.cs.hlsl
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit.meta
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/Editor.meta
-
175Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/Editor/LayeredLitUI.cs
-
112Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/LayeredLit.shader
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit.meta
-
138Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Editor/BaseLitUI.cs
-
51Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Editor/LitUI.cs
-
7Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Editor/StandardSpecularToHDLitMaterialUpgrader.cs
-
10Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Editor/StandardToHDLitMaterialUpgrader.cs
-
5Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Lit.cs
-
12Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Lit.cs.hlsl
-
151Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Lit.hlsl
-
73Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Lit.shader
-
195Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitData.hlsl
-
31Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitProperties.hlsl
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LtcData.DisneyDiffuse.cs
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LtcData.GGX.cs
-
6Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Resources/PreIntegratedFGD.shader
-
92Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitDataInternal.hlsl
-
8Assets/ScriptableRenderLoop/HDRenderPipeline/Material/MaterialUtilities.hlsl
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Unlit/Editor/BaseUnlitUI.cs
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Unlit/Editor/UnlitUI.cs
-
4Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Unlit/Unlit.cs
-
8Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Unlit/Unlit.cs.hlsl
-
98Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Unlit/Unlit.shader
-
27Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Unlit/UnlitData.hlsl
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Unlit/UnlitSharePass.hlsl
-
207Assets/ScriptableRenderLoop/HDRenderPipeline/PostProcess/Resources/FinalPass.shader
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/SceneSettings/CommonSettings.cs
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/SceneSettings/Editor/CommonSettingsEditor.cs
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderConfig.cs
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderConfig.cs.hlsl
-
4Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPass.cs
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPass.cs.hlsl
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl
-
11Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassForward.hlsl
-
8Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassGBuffer.hlsl
-
6Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassLightTransport.hlsl
-
32Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderVariables.hlsl
-
4Assets/ScriptableRenderLoop/HDRenderPipeline/Shadow/FixedSizePCF/FixedSizePCF.cs
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/Sky.meta
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/HDRISky/Editor/HDRISkyEditor.cs
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/HDRISky/HDRISkyParameters.cs
-
4Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/HDRISky/HDRISkyRenderer.cs
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/HDRISky/Resources/SkyHDRI.shader
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/ProceduralSky/Editor/ProceduralSkyEditor.cs
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/ProceduralSky/ProceduralSkyParameters.cs
-
4Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/ProceduralSky/ProceduralSkyRenderer.cs
-
10Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/ProceduralSky/Resources/SkyProcedural.shader
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/Resources/GGXConvolve.shader
-
6Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/SkyManager.cs
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/SkyManager.cs.hlsl
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/SkyParameters.cs
-
4Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/SkyRenderer.cs
-
4Assets/ScriptableRenderLoop/HDRenderPipeline/Utilities.cs
-
2Assets/ScriptableRenderLoop/RenderPasses/ShadowRenderPass.cs
-
9Assets/ScriptableRenderLoop/ShaderLibrary/AreaLighting.hlsl
-
37Assets/ScriptableRenderLoop/ShaderLibrary/BSDF.hlsl
-
62Assets/ScriptableRenderLoop/ShaderLibrary/Common.hlsl
-
25Assets/ScriptableRenderLoop/ShaderLibrary/CommonLighting.hlsl
-
15Assets/ScriptableRenderLoop/ShaderLibrary/CommonMaterial.hlsl
-
62Assets/ScriptableRenderLoop/ShaderLibrary/EntityLighting.hlsl
-
4Assets/ScriptableRenderLoop/ShaderLibrary/Fibonacci.hlsl
-
260Assets/ScriptableRenderLoop/ShaderLibrary/ImageBasedLighting.hlsl
-
51Assets/ScriptableRenderLoop/ShaderLibrary/Packing.hlsl
-
2Assets/ScriptableRenderLoop/common/TextureCache.cs
-
2Assets/ScriptableRenderLoop/common/TextureSettings.cs
-
4Assets/ScriptableRenderLoop/core/RenderPipeline.cs
-
4Assets/ScriptableRenderLoop/fptl/FptlLighting.cs
-
2Assets/ScriptableRenderLoop/fptl/LightDefinitions.cs
-
5Assets/ShaderGenerator/Editor/CSharpToHLSL.cs
-
2Assets/ShaderGenerator/Editor/ShaderGeneratorMenu.cs
-
4Assets/ShaderGenerator/Editor/ShaderTypeGeneration.cs
-
2Assets/ShaderGenerator/ShaderGeneratorAttributes.cs
|
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
|
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
namespace UnityEngine.Experimental.ScriptableRenderLoop |
|||
namespace UnityEditor.Experimental.Rendering.HDPipeline |
|||
[UnityEditor.MenuItem("HDRenderPipeline/Create Scene Settings")] |
|||
[MenuItem("HDRenderPipeline/Create Scene Settings")] |
|||
CommonSettings[] settings = Object.FindObjectsOfType(typeof(CommonSettings)) as CommonSettings[]; |
|||
CommonSettings[] settings = Object.FindObjectsOfType<CommonSettings>(); |
|||
if(settings.Length == 0) |
|||
if (settings.Length == 0) |
|||
GameObject go = new GameObject(); |
|||
go.name = "SceneSettings"; |
|||
go.AddComponent(typeof(CommonSettings)); |
|||
GameObject go = new GameObject { name = "SceneSettings" }; |
|||
go.AddComponent<CommonSettings>(); |
|||
go.AddComponent<PostProcessing>(); |
|||
} |
|||
} |
|||
|
|||
[MenuItem("HDRenderPipeline/Synchronize all Layered materials")] |
|||
static void SynchronizeAllLayeredMaterial() |
|||
{ |
|||
Object[] materials = Resources.FindObjectsOfTypeAll<Material>(); |
|||
foreach (Object obj in materials) |
|||
{ |
|||
Material mat = obj as Material; |
|||
if(mat.shader.name == "HDRenderLoop/LayeredLit") |
|||
{ |
|||
LayeredLitGUI.SynchronizeAllLayers(mat); |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
// Final compositing pass, just does gamma correction for now. |
|||
|
|||
_ToneMapCoeffs1("Parameters for neutral tonemap", Vector) = (0.0, 0.0, 0.0, 0.0) |
|||
_ToneMapCoeffs2("Parameters for neutral tonemap", Vector) = (0.0, 0.0, 0.0, 0.0) |
|||
_Exposure("Exposure", Range(-32.0, 32.0)) = 0 |
|||
[ToggleOff] _EnableToneMap("Enable Tone Map", Float) = 0 |
|||
SubShader { |
|||
Pass { |
|||
ZTest Always Cull Off ZWrite Off |
|||
HLSLINCLUDE |
|||
HLSLPROGRAM |
|||
#pragma vertex Vert |
|||
#pragma fragment Frag |
|||
#pragma target 5.0 |
|||
#pragma target 5.0 |
|||
#include "Common.hlsl" |
|||
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderVariables.hlsl" |
|||
#include "ColorGrading.hlsl" |
|||
#include "Common.hlsl" |
|||
#include "Color.hlsl" |
|||
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderVariables.hlsl" |
|||
TEXTURE2D(_MainTex); |
|||
SAMPLER2D(sampler_MainTex); |
|||
TEXTURE2D(_MainTex); |
|||
SAMPLER2D(sampler_MainTex); |
|||
TEXTURE2D(_AutoExposure); |
|||
SAMPLER2D(sampler_AutoExposure); |
|||
float4 _ToneMapCoeffs1; |
|||
float4 _ToneMapCoeffs2; |
|||
TEXTURE2D(_LogLut); |
|||
SAMPLER2D(sampler_LogLut); |
|||
#define InBlack _ToneMapCoeffs1.x |
|||
#define OutBlack _ToneMapCoeffs1.y |
|||
#define InWhite _ToneMapCoeffs1.z |
|||
#define OutWhite _ToneMapCoeffs1.w |
|||
#define WhiteLevel _ToneMapCoeffs2.z |
|||
#define WhiteClip _ToneMapCoeffs2.w |
|||
float4 _LogLut_Params; |
|||
float _Exposure; |
|||
float _EnableToneMap; |
|||
float _Exposure; |
|||
struct Attributes |
|||
{ |
|||
float3 vertex : POSITION; |
|||
float2 texcoord : TEXCOORD0; |
|||
}; |
|||
float4 _NeutralTonemapperParams1; |
|||
float4 _NeutralTonemapperParams2; |
|||
struct Varyings |
|||
{ |
|||
float4 vertex : SV_POSITION; |
|||
float2 texcoord : TEXCOORD0; |
|||
}; |
|||
struct Attributes |
|||
{ |
|||
float3 vertex : POSITION; |
|||
float2 texcoord : TEXCOORD0; |
|||
}; |
|||
Varyings Vert(Attributes input) |
|||
{ |
|||
Varyings output; |
|||
output.vertex = TransformWorldToHClip(input.vertex); |
|||
output.texcoord = input.texcoord.xy; |
|||
return output; |
|||
} |
|||
struct Varyings |
|||
{ |
|||
float4 vertex : SV_POSITION; |
|||
float2 texcoord : TEXCOORD0; |
|||
}; |
|||
float3 evalCurve(float3 x, float A, float B, float C, float D, float E, float F) |
|||
{ |
|||
return ((x*(A*x + C*B) + D*E) / (x*(A*x + B) + D*F)) - E / F; |
|||
} |
|||
Varyings Vert(Attributes input) |
|||
{ |
|||
Varyings output; |
|||
output.vertex = TransformWorldToHClip(input.vertex); |
|||
output.texcoord = input.texcoord.xy; |
|||
return output; |
|||
} |
|||
float3 applyTonemapFilmicAD(float3 linearColor) |
|||
{ |
|||
float blackRatio = InBlack / OutBlack; |
|||
float whiteRatio = InWhite / OutWhite; |
|||
// Neutral tonemapping (Hable/Hejl/Frostbite) |
|||
// Input is linear RGB |
|||
float3 NeutralCurve(float3 x, float a, float b, float c, float d, float e, float f) |
|||
{ |
|||
return ((x * (a * x + c * b) + d * e) / (x * (a * x + b) + d * f)) - e / f; |
|||
} |
|||
|
|||
float3 NeutralTonemap(float3 x, float4 params1, float4 params2) |
|||
{ |
|||
// ACES supports negative color values and WILL output negative values when coming from ACES or ACEScg |
|||
// Make sure negative channels are clamped to 0.0 as this neutral tonemapper can't deal with them properly |
|||
x = max((0.0).xxx, x); |
|||
|
|||
// Tonemap |
|||
float a = params1.x; |
|||
float b = params1.y; |
|||
float c = params1.z; |
|||
float d = params1.w; |
|||
float e = params2.x; |
|||
float f = params2.y; |
|||
float whiteLevel = params2.z; |
|||
float whiteClip = params2.w; |
|||
// blend tunable coefficients |
|||
float B = lerp(0.57, 0.37, blackRatio); |
|||
float C = lerp(0.01, 0.24, whiteRatio); |
|||
float D = lerp(0.02, 0.20, blackRatio); |
|||
float3 whiteScale = (1.0).xxx / NeutralCurve(whiteLevel, a, b, c, d, e, f); |
|||
x = NeutralCurve(x * whiteScale, a, b, c, d, e, f); |
|||
x *= whiteScale; |
|||
// constants |
|||
float A = 0.2; |
|||
float E = 0.02; |
|||
float F = 0.30; |
|||
// Post-curve white point adjustment |
|||
x /= whiteClip.xxx; |
|||
// eval and correct for white point |
|||
float3 whiteScale = 1.0f / evalCurve(WhiteLevel, A, B, C, D, E, F); |
|||
float3 curr = evalCurve(linearColor * whiteScale, A, B, C, D, E, F); |
|||
return x; |
|||
} |
|||
return curr * whiteScale; |
|||
} |
|||
float4 Frag(Varyings input) : SV_Target |
|||
{ |
|||
float4 color = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, input.texcoord); |
|||
float3 remapWhite(float3 inPixel, float whitePt) |
|||
#if EYE_ADAPTATION |
|||
// var breakout for readability |
|||
const float inBlack = 0; |
|||
const float outBlack = 0; |
|||
float inWhite = whitePt; |
|||
const float outWhite = 1; |
|||
|
|||
// remap input range to output range |
|||
float3 outPixel = ((inPixel.rgb) - inBlack.xxx) / (inWhite.xxx - inBlack.xxx) * (outWhite.xxx - outBlack.xxx) + outBlack.xxx; |
|||
return (outPixel.rgb); |
|||
float autoExposure = SAMPLE_TEXTURE2D(_AutoExposure, sampler_AutoExposure, input.texcoord).r; |
|||
color *= autoExposure; |
|||
#endif |
|||
float3 NeutralTonemap(float3 x) |
|||
color.rgb *= _Exposure; // Exposure is in ev units (or 'stops'), precomputed CPU-side |
|||
|
|||
#if NEUTRAL_GRADING |
|||
float3 finalColor = applyTonemapFilmicAD(x); // curve (dynamic coeffs differ per level) |
|||
finalColor = remapWhite(finalColor, WhiteClip); // post-curve white point adjustment |
|||
finalColor = saturate(finalColor); |
|||
return finalColor; |
|||
color.rgb = NeutralTonemap(color.rgb, _NeutralTonemapperParams1, _NeutralTonemapperParams2); |
|||
#elif CUSTOM_GRADING |
|||
{ |
|||
float3 uvw = saturate(LinearToLogC(color)); |
|||
float3 ApplyToneMap(float3 color) |
|||
// Strip lut format where `height = sqrt(width)` |
|||
uvw.z *= _LogLut_Params.z; |
|||
half shift = floor(uvw.z); |
|||
uvw.xy = uvw.xy * _LogLut_Params.z * _LogLut_Params.xy + _LogLut_Params.xy * 0.5; |
|||
uvw.x += shift * _LogLut_Params.y; |
|||
uvw.xyz = lerp( |
|||
SAMPLE_TEXTURE2D(_LogLut, sampler_LogLut, uvw.xy).rgb, |
|||
SAMPLE_TEXTURE2D(_LogLut, sampler_LogLut, uvw.xy + half2(_LogLut_Params.y, 0)).rgb, |
|||
uvw.z - shift |
|||
); |
|||
|
|||
color.rgb = uvw; |
|||
} |
|||
#else |
|||
if (_EnableToneMap > 0.0) |
|||
{ |
|||
return NeutralTonemap(color); |
|||
} |
|||
else |
|||
{ |
|||
return saturate(color); |
|||
} |
|||
color = saturate(color); |
|||
#endif |
|||
float4 Frag(Varyings input) : SV_Target |
|||
{ |
|||
float4 c = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, input.texcoord); |
|||
// Gamma correction |
|||
return color; |
|||
} |
|||
// TODO: Currenlt in the editor there a an additional pass were the result is copyed in a render target RGBA8_sRGB. |
|||
// So we must not correct the sRGB here else it will be done two time. |
|||
// To fix! |
|||
ENDHLSL |
|||
c.rgb = ApplyToneMap(c.rgb * exp2(_Exposure)); |
|||
SubShader |
|||
{ |
|||
Cull Off ZWrite Off ZTest Always |
|||
// return LinearToSRGB(c); |
|||
return c; |
|||
Pass |
|||
{ |
|||
HLSLPROGRAM |
|||
#pragma vertex Vert |
|||
#pragma fragment Frag |
|||
#pragma multi_compile __ NEUTRAL_GRADING CUSTOM_GRADING |
|||
#pragma multi_compile __ EYE_ADAPTATION |
|||
} |
|||
|
|||
|
|||
Fallback Off |
|||
} |
部分文件因为文件数量过多而无法显示
撰写
预览
正在加载...
取消
保存
Reference in new issue