浏览代码
Merge branch 'master' into LayeredLit
Merge branch 'master' into LayeredLit
# Conflicts: # Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/LayeredLit.shader/main
Julien Ignace
8 年前
当前提交
0f63e44e
共有 179 个文件被更改,包括 2763 次插入 和 974 次删除
-
101Assets/BasicRenderLoopTutorial/BasicRenderLoop.cs
-
4Assets/Editor/Tests/RenderloopTests/CullResultsTest.cs
-
37Assets/Editor/Tests/RenderloopTests/RenderloopTestFixture.cs
-
19Assets/ScriptableRenderLoop/ShaderLibrary/API/D3D11.hlsl
-
25Assets/ScriptableRenderLoop/ShaderLibrary/Common.hlsl
-
19Assets/ScriptableRenderLoop/ShaderLibrary/CommonLighting.hlsl
-
125Assets/ScriptableRenderLoop/ShaderLibrary/Fibonacci.hlsl
-
11Assets/ScriptableRenderLoop/ShaderLibrary/Hammersley.hlsl
-
368Assets/ScriptableRenderLoop/ShaderLibrary/ImageBasedLighting.hlsl
-
71Assets/ScriptableRenderLoop/core/RenderPipeline.cs
-
80Assets/ScriptableRenderLoop/fptl/FptlLighting.cs
-
2Assets/ShaderGenerator/Editor/ShaderGeneratorMenu.cs
-
10ProjectSettings/GraphicsSettings.asset
-
2ProjectSettings/ProjectVersion.txt
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting.meta
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/Material.meta
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderVariables.hlsl
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderConfig.cs.hlsl
-
4Assets/ScriptableRenderLoop/HDRenderPipeline/PostProcess/Resources/FinalPass.shader
-
8Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/Resources/DebugViewTiles.shader
-
10Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/Resources/DebugViewMaterialGBuffer.shader
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/DebugViewMaterial.cs.hlsl
-
10Assets/ScriptableRenderLoop/HDRenderPipeline/Editor/UpgradeStandardShaderMaterials.cs
-
4Assets/ScriptableRenderLoop/HDRenderPipeline/Editor/HDRenderLoopMenuItems.cs
-
46Assets/ScriptableRenderLoop/HDRenderPipeline/Editor/HDRenderLoopInspector.cs
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/Sky.meta
-
56Assets/ScriptableRenderLoop/HDRenderPipeline/Utilities.cs
-
26Assets/ScriptableRenderLoop/HDRenderPipeline/SceneSettings/CommonSettings.cs
-
281Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.cs
-
4Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/TilePass.hlsl
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/TilePass.cs.hlsl
-
22Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/TilePass.cs
-
120Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/Resources/shadeopaque.compute
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass.meta
-
8Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/Resources/Deferred.shader
-
12Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/Lighting.hlsl
-
4Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/LightLoop.cs
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/LightDefinition.cs.hlsl
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPass.cs.hlsl
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassLightTransport.hlsl
-
18Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/SkyParameters.cs
-
120Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/SkyManager.cs
-
56Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/Resources/GGXConvolve.shader
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/ProceduralSky/Resources/SkyProcedural.shader
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/ProceduralSky/Resources/AtmosphericScattering.hlsl
-
4Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/ProceduralSky/ProceduralSkyRenderer.cs
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/HDRISky/Resources/SkyHDRI.shader
-
4Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/HDRISky/HDRISkyRenderer.cs
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit.meta
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit.meta
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Attributes.hlsl
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Builtin/BuiltinData.cs.hlsl
-
10Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Unlit/Unlit.shader
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Unlit/Unlit.cs.hlsl
-
95Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/LayeredLit.shader
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/Editor.meta
-
7Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Lit.cs
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Lit.cs.hlsl
-
4Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Resources/PreIntegratedFGD.shader
-
6Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Editor/StandardToHDLitMaterialUpgrader.cs
-
6Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Editor/StandardSpecularToHDLitMaterialUpgrader.cs
-
84Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Lit.shader
-
9Assets/ScriptableRenderLoop/HDRenderPipeline.meta
-
9Assets/ScriptableRenderLoop/common/CubeToSpherical.shader.meta
-
24Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.asset
-
8Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.asset.meta
-
12Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.cs.meta
-
110Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Builtin/BuiltinData.hlsl
-
1001Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Lit.hlsl
-
152Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitProperties.hlsl
-
9Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitProperties.hlsl.meta
-
151Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Material.hlsl
-
9Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPass.cs.hlsl.meta
-
14Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/SkyManager.cs.hlsl
-
9Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/SkyManager.cs.hlsl.meta
-
160Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/Resources/BuildProbabilityTables.compute
-
9Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/Resources/BuildProbabilityTables.compute.meta
-
33Assets/ScriptableRenderLoop/core/DefaultCameraProvider.cs
-
12Assets/ScriptableRenderLoop/core/DefaultCameraProvider.cs.meta
-
40Assets/ScriptableRenderLoop/core/RenderingDataStore.cs
-
12Assets/ScriptableRenderLoop/core/RenderingDataStore.cs.meta
-
9Assets/ScriptableRenderLoop/HDRenderLoop.meta
-
0/Assets/ScriptableRenderLoop/HDRenderPipeline/Shadow
-
0/Assets/ScriptableRenderLoop/HDRenderPipeline/Debug.meta
-
0/Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting.meta
-
0/Assets/ScriptableRenderLoop/HDRenderPipeline/Material.meta
-
0/Assets/ScriptableRenderLoop/HDRenderPipeline/PostProcess.meta
-
0/Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderConfig.cs
-
0/Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderConfig.cs.hlsl.meta
-
0/Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderConfig.cs.meta
-
0/Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass.meta
-
0/Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderVariables.hlsl
-
0/Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderVariables.hlsl.meta
-
0/Assets/ScriptableRenderLoop/HDRenderPipeline/Shadow.meta
|
|||
m_EditorVersion: 5.6.0b1 |
|||
m_EditorVersion: 5.6.0b3 |
|
|||
#pragma kernel ShadeOpaque_Fptl SHADE_OPAQUE_ENTRY=ShadeOpaque_Fptl USE_FPTL_LIGHTLIST=1 |
|||
#pragma kernel ShadeOpaque_Clustered SHADE_OPAQUE_ENTRY=ShadeOpaque_Clustered USE_CLUSTERED_LIGHTLIST=1 |
|||
|
|||
|
|||
#define LIGHTLOOP_TILE_PASS 1 |
|||
#define LIGHTLOOP_TILE_DIRECT 1 |
|||
#define LIGHTLOOP_TILE_INDIRECT 1 |
|||
#define LIGHTLOOP_TILE_ALL 1 |
|||
#define USE_FPTL_LIGHTLIST 1 |
|||
|
|||
|
|||
//------------------------------------------------------------------------------------- |
|||
// Include |
|||
//------------------------------------------------------------------------------------- |
|||
|
|||
#include "Common.hlsl" |
|||
|
|||
// Note: We have fix as guidelines that we have only one deferred material (with control of GBuffer enabled). Mean a users that add a new |
|||
// deferred material must replace the old one here. If in the future we want to support multiple layout (cause a lot of consistency problem), |
|||
// the deferred shader will require to use multicompile. |
|||
#define UNITY_MATERIAL_LIT // Need to be define before including Material.hlsl |
|||
#include "Assets/ScriptableRenderLoop/HDRenderLoop/ShaderConfig.cs.hlsl" |
|||
#include "Assets/ScriptableRenderLoop/HDRenderLoop/ShaderVariables.hlsl" |
|||
#include "Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/Lighting.hlsl" // This include Material.hlsl |
|||
|
|||
//------------------------------------------------------------------------------------- |
|||
// variable declaration |
|||
//------------------------------------------------------------------------------------- |
|||
|
|||
DECLARE_GBUFFER_TEXTURE(_GBufferTexture); |
|||
|
|||
TEXTURE2D(_CameraDepthTexture); |
|||
SAMPLER2D(sampler_CameraDepthTexture); |
|||
|
|||
RWTexture2D<float4> uavOutput; |
|||
|
|||
[numthreads(TILE_SIZE, TILE_SIZE, 1)] |
|||
void SHADE_OPAQUE_ENTRY(uint2 dispatchThreadId : SV_DispatchThreadID, uint2 groupId : SV_GroupID) |
|||
{ |
|||
// input.positionCS is SV_Position |
|||
uint2 pixelCoord = dispatchThreadId; |
|||
PositionInputs posInput = GetPositionInput(pixelCoord.xy, _ScreenSize.zw); |
|||
float depth = LOAD_TEXTURE2D(_CameraDepthTexture, posInput.unPositionSS).x; |
|||
UpdatePositionInput(depth, _InvViewProjMatrix, _ViewProjMatrix, posInput); |
|||
float3 V = GetWorldSpaceNormalizeViewDir(posInput.positionWS); |
|||
|
|||
FETCH_GBUFFER(gbuffer, _GBufferTexture, posInput.unPositionSS); |
|||
BSDFData bsdfData; |
|||
float3 bakeDiffuseLighting; |
|||
DECODE_FROM_GBUFFER(gbuffer, bsdfData, bakeDiffuseLighting); |
|||
|
|||
PreLightData preLightData = GetPreLightData(V, posInput, bsdfData); |
|||
|
|||
float3 diffuseLighting; |
|||
float3 specularLighting; |
|||
LightLoop(V, posInput, preLightData, bsdfData, bakeDiffuseLighting, diffuseLighting, specularLighting); |
|||
|
|||
uavOutput[pixelCoord] = float4(diffuseLighting + specularLighting, 1.0); |
|||
} |
|||
|
|||
#pragma kernel ShadeOpaque_Fptl SHADE_OPAQUE_ENTRY=ShadeOpaque_Fptl USE_FPTL_LIGHTLIST=1 |
|||
#pragma kernel ShadeOpaque_Clustered SHADE_OPAQUE_ENTRY=ShadeOpaque_Clustered USE_CLUSTERED_LIGHTLIST=1 |
|||
|
|||
|
|||
#define LIGHTLOOP_TILE_PASS 1 |
|||
#define LIGHTLOOP_TILE_DIRECT 1 |
|||
#define LIGHTLOOP_TILE_INDIRECT 1 |
|||
#define LIGHTLOOP_TILE_ALL 1 |
|||
#define USE_FPTL_LIGHTLIST 1 |
|||
|
|||
|
|||
//------------------------------------------------------------------------------------- |
|||
// Include |
|||
//------------------------------------------------------------------------------------- |
|||
|
|||
#include "Common.hlsl" |
|||
|
|||
// Note: We have fix as guidelines that we have only one deferred material (with control of GBuffer enabled). Mean a users that add a new |
|||
// deferred material must replace the old one here. If in the future we want to support multiple layout (cause a lot of consistency problem), |
|||
// the deferred shader will require to use multicompile. |
|||
#define UNITY_MATERIAL_LIT // Need to be define before including Material.hlsl |
|||
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderConfig.cs.hlsl" |
|||
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderVariables.hlsl" |
|||
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/Lighting.hlsl" // This include Material.hlsl |
|||
|
|||
//------------------------------------------------------------------------------------- |
|||
// variable declaration |
|||
//------------------------------------------------------------------------------------- |
|||
|
|||
DECLARE_GBUFFER_TEXTURE(_GBufferTexture); |
|||
|
|||
TEXTURE2D(_CameraDepthTexture); |
|||
SAMPLER2D(sampler_CameraDepthTexture); |
|||
|
|||
RWTexture2D<float4> uavOutput; |
|||
|
|||
[numthreads(TILE_SIZE, TILE_SIZE, 1)] |
|||
void SHADE_OPAQUE_ENTRY(uint2 dispatchThreadId : SV_DispatchThreadID, uint2 groupId : SV_GroupID) |
|||
{ |
|||
// input.positionCS is SV_Position |
|||
uint2 pixelCoord = dispatchThreadId; |
|||
PositionInputs posInput = GetPositionInput(pixelCoord.xy, _ScreenSize.zw); |
|||
float depth = LOAD_TEXTURE2D(_CameraDepthTexture, posInput.unPositionSS).x; |
|||
UpdatePositionInput(depth, _InvViewProjMatrix, _ViewProjMatrix, posInput); |
|||
float3 V = GetWorldSpaceNormalizeViewDir(posInput.positionWS); |
|||
|
|||
FETCH_GBUFFER(gbuffer, _GBufferTexture, posInput.unPositionSS); |
|||
BSDFData bsdfData; |
|||
float3 bakeDiffuseLighting; |
|||
DECODE_FROM_GBUFFER(gbuffer, bsdfData, bakeDiffuseLighting); |
|||
|
|||
PreLightData preLightData = GetPreLightData(V, posInput, bsdfData); |
|||
|
|||
float3 diffuseLighting; |
|||
float3 specularLighting; |
|||
LightLoop(V, posInput, preLightData, bsdfData, bakeDiffuseLighting, diffuseLighting, specularLighting); |
|||
|
|||
uavOutput[pixelCoord] = float4(diffuseLighting + specularLighting, 1.0); |
|||
} |
|||
|
|
|||
fileFormatVersion: 2 |
|||
guid: 4c38eac64d0e8344d85c9f309419d619 |
|||
folderAsset: yes |
|||
timeCreated: 1483548930 |
|||
licenseType: Pro |
|||
DefaultImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 595434cc3b6405246b6cd3086d0b6f7d |
|||
timeCreated: 1482845902 |
|||
licenseType: Pro |
|||
ShaderImporter: |
|||
defaultTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!114 &11400000 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_PrefabParentObject: {fileID: 0} |
|||
m_PrefabInternal: {fileID: 0} |
|||
m_GameObject: {fileID: 0} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: d440c0deec24a2f478b3e9021cb66c29, type: 3} |
|||
m_Name: HDRenderPipeline |
|||
m_EditorClassIdentifier: |
|||
m_ShadowSettings: |
|||
enabled: 1 |
|||
shadowAtlasWidth: 4096 |
|||
shadowAtlasHeight: 4096 |
|||
maxShadowDistance: 1000 |
|||
directionalLightCascadeCount: 4 |
|||
directionalLightCascades: {x: 0.05, y: 0.2, z: 0.3} |
|||
m_TextureSettings: |
|||
spotCookieSize: 128 |
|||
pointCookieSize: 512 |
|||
reflectionCubemapSize: 128 |
|
|||
fileFormatVersion: 2 |
|||
guid: e185fecca3c73cd47a09f1092663ef32 |
|||
timeCreated: 1483606455 |
|||
licenseType: Pro |
|||
NativeFormatImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: d440c0deec24a2f478b3e9021cb66c29 |
|||
timeCreated: 1483605696 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
#ifndef UNITY_BUILTIN_DATA_INCLUDED |
|||
#define UNITY_BUILTIN_DATA_INCLUDED |
|||
|
|||
//----------------------------------------------------------------------------- |
|||
// BuiltinData |
|||
// This structure include common data that should be present in all material |
|||
// and are independent from the BSDF parametrization. |
|||
// Note: These parameters can be store in GBuffer if the writer wants |
|||
//----------------------------------------------------------------------------- |
|||
|
|||
#include "BuiltinData.cs.hlsl" |
|||
|
|||
//----------------------------------------------------------------------------- |
|||
// common Encode/Decode functions |
|||
//----------------------------------------------------------------------------- |
|||
|
|||
// Guideline for velocity buffer. |
|||
// We support various architecture for HDRenderPipeline |
|||
// - Forward only rendering |
|||
// - Hybrid forward/deferred opaque |
|||
// - Regular deferred |
|||
// The velocity buffer is potentially fill in several pass. |
|||
// - In gbuffer pass with extra RT |
|||
// - In forward opaque pass (Can happen even when deferred) with MRT |
|||
// - In dedicated velocity pass |
|||
// Also the velocity buffer is only fill in case of dynamic or deformable objects, static case can use camera reprojection to retrieve motion vector (<= TODO: this may be false with TAA due to jitter matrix) |
|||
// or just previous and current transform |
|||
|
|||
// So here we decide the following rules: |
|||
// - A deferred material can't override the velocity buffer format of builtinData, must use appropriate function |
|||
// - If velocity buffer is enable in deferred material it is the last one |
|||
// - Velocity buffer can be optionally enabled (either in forward or deferred) |
|||
// - Velocity data can't be pack with other properties |
|||
// - Same velocity buffer is use for all scenario, so if deferred define a velocity buffer, the same is reuse for forward case. |
|||
// For these reasons we chose to avoid to pack velocity buffer with anything else in case of PackgbufferInFP16 (and also in case the format change) |
|||
|
|||
// Encode/Decode velocity/distortion in a buffer (either forward of deferred) |
|||
// Design note: We assume that velocity/distortion fit into a single buffer (i.e not spread on several buffer) |
|||
void EncodeVelocity(float2 velocity, out float4 outBuffer) |
|||
{ |
|||
// RT - 16:16 float |
|||
outBuffer = float4(velocity.xy, 0.0, 0.0); |
|||
} |
|||
|
|||
void DecodeVelocity(float4 inBuffer, out float2 velocity) |
|||
{ |
|||
velocity = inBuffer.xy; |
|||
} |
|||
|
|||
void EncodeDistortion(float2 distortion, float distortionBlur, out float4 outBuffer) |
|||
{ |
|||
// RT - 16:16:16:16 float |
|||
// distortionBlur in alpha for a different blend mode |
|||
outBuffer = float4(distortion, 0.0, distortionBlur); |
|||
} |
|||
|
|||
void DecodeDistortion(float4 inBuffer, out float2 distortion, out float2 distortionBlur) |
|||
{ |
|||
distortion = inBuffer.xy; |
|||
distortionBlur = inBuffer.a; |
|||
} |
|||
|
|||
void GetBuiltinDataDebug(uint paramId, BuiltinData builtinData, inout float3 result, inout bool needLinearToSRGB) |
|||
{ |
|||
switch (paramId) |
|||
{ |
|||
case DEBUGVIEW_BUILTIN_BUILTINDATA_OPACITY: |
|||
result = builtinData.opacity.xxx; |
|||
break; |
|||
case DEBUGVIEW_BUILTIN_BUILTINDATA_BAKE_DIFFUSE_LIGHTING: |
|||
// TODO: require a remap |
|||
result = builtinData.bakeDiffuseLighting; |
|||
break; |
|||
case DEBUGVIEW_BUILTIN_BUILTINDATA_EMISSIVE_COLOR: |
|||
// emissiveColor is premultiply by emissive intensity |
|||
result = (builtinData.emissiveColor / builtinData.emissiveIntensity); needLinearToSRGB = true; |
|||
break; |
|||
case DEBUGVIEW_BUILTIN_BUILTINDATA_EMISSIVE_INTENSITY: |
|||
result = builtinData.emissiveIntensity.xxx; |
|||
break; |
|||
case DEBUGVIEW_BUILTIN_BUILTINDATA_VELOCITY: |
|||
result = float3(builtinData.velocity, 0.0); |
|||
break; |
|||
case DEBUGVIEW_BUILTIN_BUILTINDATA_DISTORTION: |
|||
result = float3(builtinData.distortion, 0.0); |
|||
break; |
|||
case DEBUGVIEW_BUILTIN_BUILTINDATA_DISTORTION_BLUR: |
|||
result = builtinData.distortionBlur.xxx; |
|||
break; |
|||
case DEBUGVIEW_BUILTIN_BUILTINDATA_DEPTH_OFFSET: |
|||
result = builtinData.depthOffset.xxx * 10.0; // * 10 assuming 1 unity unity is 1m |
|||
break; |
|||
} |
|||
} |
|||
|
|||
void GetLighTransportDataDebug(uint paramId, LighTransportData lightTransportData, inout float3 result, inout bool needLinearToSRGB) |
|||
{ |
|||
switch (paramId) |
|||
{ |
|||
case DEBUGVIEW_BUILTIN_LIGHTRANSPORTDATA_DIFFUSE_COLOR: |
|||
result = lightTransportData.diffuseColor; needLinearToSRGB = true; |
|||
break; |
|||
case DEBUGVIEW_BUILTIN_LIGHTRANSPORTDATA_EMISSIVE_COLOR: |
|||
// TODO: Need a tonemap ? |
|||
result = lightTransportData.emissiveColor; |
|||
break; |
|||
} |
|||
} |
|||
|
|||
#endif // UNITY_BUILTIN_DATA_INCLUDED |
1001
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Lit.hlsl
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
#ifndef LAYERED_LIT_SHADER |
|||
|
|||
// Set of users variables |
|||
float4 _BaseColor; |
|||
TEXTURE2D(_BaseColorMap); |
|||
SAMPLER2D(sampler_BaseColorMap); |
|||
float4 _BaseColorMap_ST; |
|||
|
|||
float _Metallic; |
|||
float _Smoothness; |
|||
TEXTURE2D(_MaskMap); |
|||
SAMPLER2D(sampler_MaskMap); |
|||
TEXTURE2D(_SpecularOcclusionMap); |
|||
SAMPLER2D(sampler_SpecularOcclusionMap); |
|||
|
|||
TEXTURE2D(_NormalMap); |
|||
SAMPLER2D(sampler_NormalMap); |
|||
|
|||
TEXTURE2D(_DetailMask); |
|||
SAMPLER2D(sampler_DetailMask); |
|||
TEXTURE2D(_DetailMap); |
|||
SAMPLER2D(sampler_DetailMap); |
|||
float4 _DetailMap_ST; |
|||
float _DetailAlbedoScale; |
|||
float _DetailNormalScale; |
|||
float _DetailSmoothnessScale; |
|||
float _DetailHeightScale; |
|||
float _DetailAOScale; |
|||
|
|||
TEXTURE2D(_HeightMap); |
|||
SAMPLER2D(sampler_HeightMap); |
|||
|
|||
float _HeightScale; |
|||
float _HeightBias; |
|||
|
|||
TEXTURE2D(_TangentMap); |
|||
SAMPLER2D(sampler_TangentMap); |
|||
|
|||
float _Anisotropy; |
|||
TEXTURE2D(_AnisotropyMap); |
|||
SAMPLER2D(sampler_AnisotropyMap); |
|||
|
|||
//float _SubSurfaceRadius; |
|||
//TEXTURE2D(_SubSurfaceRadiusMap); |
|||
//SAMPLER2D(sampler_SubSurfaceRadiusMap); |
|||
|
|||
// float _Thickness; |
|||
//TEXTURE2D(_ThicknessMap); |
|||
//SAMPLER2D(sampler_ThicknessMap); |
|||
|
|||
// float _CoatCoverage; |
|||
//TEXTURE2D(_CoatCoverageMap); |
|||
//SAMPLER2D(sampler_CoatCoverageMap); |
|||
|
|||
// float _CoatRoughness; |
|||
//TEXTURE2D(_CoatRoughnessMap); |
|||
//SAMPLER2D(sampler_CoatRoughnessMap); |
|||
|
|||
TEXTURE2D(_DiffuseLightingMap); |
|||
SAMPLER2D(sampler_DiffuseLightingMap); |
|||
|
|||
TEXTURE2D(_DistortionVectorMap); |
|||
SAMPLER2D(sampler_DistortionVectorMap); |
|||
|
|||
float3 _EmissiveColor; |
|||
TEXTURE2D(_EmissiveColorMap); |
|||
SAMPLER2D(sampler_EmissiveColorMap); |
|||
float _EmissiveIntensity; |
|||
|
|||
float _AlphaCutoff; |
|||
|
|||
float _TexWorldScale; |
|||
float _UVMappingPlanar; |
|||
float4 _UVMappingMask; |
|||
float4 _UVDetailsMappingMask; |
|||
|
|||
#else // LAYERED_LIT_SHADER |
|||
|
|||
// Set of users variables |
|||
#define PROP_DECL(type, name) type name, name##0, name##1, name##2, name##3; |
|||
#define PROP_DECL_TEX2D(name)\ |
|||
TEXTURE2D(name##0); \ |
|||
SAMPLER2D(sampler##name##0); \ |
|||
TEXTURE2D(name##1); \ |
|||
TEXTURE2D(name##2); \ |
|||
TEXTURE2D(name##3); |
|||
|
|||
// Set of users variables |
|||
PROP_DECL(float4, _BaseColor); |
|||
PROP_DECL_TEX2D(_BaseColorMap); |
|||
float4 _BaseColorMap0_ST; |
|||
float4 _BaseColorMap1_ST; |
|||
float4 _BaseColorMap2_ST; |
|||
float4 _BaseColorMap3_ST; |
|||
|
|||
PROP_DECL(float, _Metallic); |
|||
PROP_DECL(float, _Smoothness); |
|||
PROP_DECL_TEX2D(_MaskMap); |
|||
PROP_DECL_TEX2D(_SpecularOcclusionMap); |
|||
|
|||
PROP_DECL_TEX2D(_NormalMap); |
|||
PROP_DECL_TEX2D(_HeightMap); |
|||
|
|||
PROP_DECL_TEX2D(_DetailMask); |
|||
PROP_DECL_TEX2D(_DetailMap); |
|||
float4 _DetailMap0_ST; |
|||
float4 _DetailMap1_ST; |
|||
float4 _DetailMap2_ST; |
|||
float4 _DetailMap3_ST; |
|||
PROP_DECL(float, _UVDetail); |
|||
PROP_DECL(float, _DetailAlbedoScale); |
|||
PROP_DECL(float, _DetailNormalScale); |
|||
PROP_DECL(float, _DetailSmoothnessScale); |
|||
PROP_DECL(float, _DetailHeightScale); |
|||
PROP_DECL(float, _DetailAOScale); |
|||
|
|||
PROP_DECL(float, _HeightScale); |
|||
PROP_DECL(float, _HeightBias); |
|||
|
|||
TEXTURE2D(_DiffuseLightingMap); |
|||
SAMPLER2D(sampler_DiffuseLightingMap); |
|||
|
|||
TEXTURE2D(_DistortionVectorMap); |
|||
SAMPLER2D(sampler_DistortionVectorMap); |
|||
|
|||
TEXTURE2D(_LayerMaskMap); |
|||
SAMPLER2D(sampler_LayerMaskMap); |
|||
|
|||
float _HeightOffset1; |
|||
float _HeightOffset2; |
|||
float _HeightOffset3; |
|||
float _HeightFactor1; |
|||
float _HeightFactor2; |
|||
float _HeightFactor3; |
|||
float _BlendSize1; |
|||
float _BlendSize2; |
|||
float _BlendSize3; |
|||
float _VertexColorHeightFactor; |
|||
|
|||
float3 _EmissiveColor; |
|||
TEXTURE2D(_EmissiveColorMap); |
|||
SAMPLER2D(sampler_EmissiveColorMap); |
|||
float _EmissiveIntensity; |
|||
|
|||
PROP_DECL(float, _TexWorldScale); |
|||
PROP_DECL(float, _UVMappingPlanar); |
|||
PROP_DECL(float4, _UVMappingMask); |
|||
PROP_DECL(float4, _UVDetailsMappingMask); |
|||
|
|||
float _AlphaCutoff; |
|||
|
|||
#endif // LAYERED_LIT_SHADER |
|
|||
fileFormatVersion: 2 |
|||
guid: edd4a01243e14f04687542aee1f03b8a |
|||
timeCreated: 1483551695 |
|||
licenseType: Pro |
|||
ShaderImporter: |
|||
defaultTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
#ifndef UNITY_MATERIAL_INCLUDED |
|||
#define UNITY_MATERIAL_INCLUDED |
|||
|
|||
#include "Color.hlsl" |
|||
#include "Packing.hlsl" |
|||
#include "BSDF.hlsl" |
|||
#include "Debug.hlsl" |
|||
#include "GeometricTools.hlsl" |
|||
#include "CommonMaterial.hlsl" |
|||
#include "EntityLighting.hlsl" |
|||
#include "ImageBasedLighting.hlsl" |
|||
|
|||
//----------------------------------------------------------------------------- |
|||
// BuiltinData |
|||
//----------------------------------------------------------------------------- |
|||
|
|||
#include "Builtin/BuiltinData.hlsl" |
|||
|
|||
//----------------------------------------------------------------------------- |
|||
// Material definition |
|||
//----------------------------------------------------------------------------- |
|||
|
|||
// Here we include all the different lighting model supported by the renderloop based on define done in .shader |
|||
// Only one deferred layout is allowed for a HDRenderPipeline, this will be detect by the redefinition of GBUFFERMATERIAL_COUNT |
|||
// If GBUFFERMATERIAL_COUNT is define two time, the shaders will not compile |
|||
#ifdef UNITY_MATERIAL_LIT |
|||
#include "Lit/Lit.hlsl" |
|||
#elif defined(UNITY_MATERIAL_UNLIT) |
|||
#include "Unlit/Unlit.hlsl" |
|||
#endif |
|||
|
|||
//----------------------------------------------------------------------------- |
|||
// Define for GBuffer management |
|||
//----------------------------------------------------------------------------- |
|||
|
|||
#ifdef GBUFFERMATERIAL_COUNT |
|||
|
|||
#if GBUFFERMATERIAL_COUNT == 2 |
|||
|
|||
#define OUTPUT_GBUFFER(NAME) \ |
|||
out GBufferType0 MERGE_NAME(NAME, 0) : SV_Target0, \ |
|||
out GBufferType1 MERGE_NAME(NAME, 1) : SV_Target1 |
|||
|
|||
#define DECLARE_GBUFFER_TEXTURE(NAME) \ |
|||
TEXTURE2D(MERGE_NAME(NAME, 0)); \ |
|||
TEXTURE2D(MERGE_NAME(NAME, 1)); |
|||
|
|||
#define FETCH_GBUFFER(NAME, TEX, unCoord2) \ |
|||
GBufferType0 MERGE_NAME(NAME, 0) = LOAD_TEXTURE2D(MERGE_NAME(TEX, 0), unCoord2); \ |
|||
GBufferType1 MERGE_NAME(NAME, 1) = LOAD_TEXTURE2D(MERGE_NAME(TEX, 1), unCoord2); |
|||
|
|||
#define ENCODE_INTO_GBUFFER(SURFACE_DATA, BAKE_DIFFUSE_LIGHTING, NAME) EncodeIntoGBuffer(SURFACE_DATA, BAKE_DIFFUSE_LIGHTING, MERGE_NAME(NAME,0), MERGE_NAME(NAME,1)) |
|||
#define DECODE_FROM_GBUFFER(NAME, BSDF_DATA, BAKE_DIFFUSE_LIGHTING) DecodeFromGBuffer(MERGE_NAME(NAME,0), MERGE_NAME(NAME,1), BSDF_DATA, BAKE_DIFFUSE_LIGHTING) |
|||
|
|||
#if SHADEROPTIONS_VELOCITY_IN_GBUFFER |
|||
#define OUTPUT_GBUFFER_VELOCITY(NAME) ,out float4 NAME : SV_Target2 |
|||
#endif |
|||
|
|||
#elif GBUFFERMATERIAL_COUNT == 3 |
|||
|
|||
#define OUTPUT_GBUFFER(NAME) \ |
|||
out GBufferType0 MERGE_NAME(NAME, 0) : SV_Target0, \ |
|||
out GBufferType1 MERGE_NAME(NAME, 1) : SV_Target1, \ |
|||
out GBufferType2 MERGE_NAME(NAME, 2) : SV_Target2 |
|||
|
|||
#define DECLARE_GBUFFER_TEXTURE(NAME) \ |
|||
TEXTURE2D(MERGE_NAME(NAME, 0)); \ |
|||
TEXTURE2D(MERGE_NAME(NAME, 1)); \ |
|||
TEXTURE2D(MERGE_NAME(NAME, 2)); |
|||
|
|||
#define FETCH_GBUFFER(NAME, TEX, unCoord2) \ |
|||
GBufferType0 MERGE_NAME(NAME, 0) = LOAD_TEXTURE2D(MERGE_NAME(TEX, 0), unCoord2); \ |
|||
GBufferType1 MERGE_NAME(NAME, 1) = LOAD_TEXTURE2D(MERGE_NAME(TEX, 1), unCoord2); \ |
|||
GBufferType2 MERGE_NAME(NAME, 2) = LOAD_TEXTURE2D(MERGE_NAME(TEX, 2), unCoord2); |
|||
|
|||
#define ENCODE_INTO_GBUFFER(SURFACE_DATA, BAKE_DIFFUSE_LIGHTING, NAME) EncodeIntoGBuffer(SURFACE_DATA, BAKE_DIFFUSE_LIGHTING, MERGE_NAME(NAME,0), MERGE_NAME(NAME,1), MERGE_NAME(NAME,2)) |
|||
#define DECODE_FROM_GBUFFER(NAME, BSDF_DATA, BAKE_DIFFUSE_LIGHTING) DecodeFromGBuffer(MERGE_NAME(NAME,0), MERGE_NAME(NAME,1), MERGE_NAME(NAME,2), BSDF_DATA, BAKE_DIFFUSE_LIGHTING) |
|||
|
|||
#if SHADEROPTIONS_VELOCITY_IN_GBUFFER |
|||
#define OUTPUT_GBUFFER_VELOCITY(NAME) ,out float4 NAME : SV_Target3 |
|||
#endif |
|||
|
|||
#elif GBUFFERMATERIAL_COUNT == 4 |
|||
|
|||
#define OUTPUT_GBUFFER(NAME) \ |
|||
out GBufferType0 MERGE_NAME(NAME, 0) : SV_Target0, \ |
|||
out GBufferType1 MERGE_NAME(NAME, 1) : SV_Target1, \ |
|||
out GBufferType2 MERGE_NAME(NAME, 2) : SV_Target2, \ |
|||
out GBufferType3 MERGE_NAME(NAME, 3) : SV_Target3 |
|||
|
|||
#define DECLARE_GBUFFER_TEXTURE(NAME) \ |
|||
TEXTURE2D(MERGE_NAME(NAME, 0)); \ |
|||
TEXTURE2D(MERGE_NAME(NAME, 1)); \ |
|||
TEXTURE2D(MERGE_NAME(NAME, 2)); \ |
|||
TEXTURE2D(MERGE_NAME(NAME, 3)); |
|||
|
|||
#define FETCH_GBUFFER(NAME, TEX, unCoord2) \ |
|||
GBufferType0 MERGE_NAME(NAME, 0) = LOAD_TEXTURE2D(MERGE_NAME(TEX, 0), unCoord2); \ |
|||
GBufferType1 MERGE_NAME(NAME, 1) = LOAD_TEXTURE2D(MERGE_NAME(TEX, 1), unCoord2); \ |
|||
GBufferType2 MERGE_NAME(NAME, 2) = LOAD_TEXTURE2D(MERGE_NAME(TEX, 2), unCoord2); \ |
|||
GBufferType3 MERGE_NAME(NAME, 3) = LOAD_TEXTURE2D(MERGE_NAME(TEX, 3), unCoord2); |
|||
|
|||
#define ENCODE_INTO_GBUFFER(SURFACE_DATA, BAKE_DIFFUSE_LIGHTING, NAME) EncodeIntoGBuffer(SURFACE_DATA, BAKE_DIFFUSE_LIGHTING, MERGE_NAME(NAME, 0), MERGE_NAME(NAME, 1), MERGE_NAME(NAME, 2), MERGE_NAME(NAME, 3)) |
|||
#define DECODE_FROM_GBUFFER(NAME, BSDF_DATA, BAKE_DIFFUSE_LIGHTING) DecodeFromGBuffer(MERGE_NAME(NAME, 0), MERGE_NAME(NAME, 1), MERGE_NAME(NAME, 2), MERGE_NAME(NAME, 3), BSDF_DATA, BAKE_DIFFUSE_LIGHTING) |
|||
|
|||
#if SHADEROPTIONS_VELOCITY_IN_GBUFFER |
|||
#define OUTPUT_GBUFFER_VELOCITY(NAME) ,out float4 NAME : SV_Target4 |
|||
#endif |
|||
|
|||
#elif GBUFFERMATERIAL_COUNT == 5 |
|||
|
|||
#define OUTPUT_GBUFFER(NAME) \ |
|||
out GBufferType0 MERGE_NAME(NAME, 0) : SV_Target0, \ |
|||
out GBufferType1 MERGE_NAME(NAME, 1) : SV_Target1, \ |
|||
out GBufferType2 MERGE_NAME(NAME, 2) : SV_Target2, \ |
|||
out GBufferType3 MERGE_NAME(NAME, 3) : SV_Target3, \ |
|||
out GBufferType4 MERGE_NAME(NAME, 4) : SV_Target4 |
|||
|
|||
#define DECLARE_GBUFFER_TEXTURE(NAME) \ |
|||
TEXTURE2D(MERGE_NAME(NAME, 0)); \ |
|||
TEXTURE2D(MERGE_NAME(NAME, 1)); \ |
|||
TEXTURE2D(MERGE_NAME(NAME, 2)); \ |
|||
TEXTURE2D(MERGE_NAME(NAME, 3)); \ |
|||
TEXTURE2D(MERGE_NAME(NAME, 4)); |
|||
|
|||
#define FETCH_GBUFFER(NAME, TEX, unCoord2) \ |
|||
GBufferType0 MERGE_NAME(NAME, 0) = LOAD_TEXTURE2D(MERGE_NAME(TEX, 0), unCoord2); \ |
|||
GBufferType1 MERGE_NAME(NAME, 1) = LOAD_TEXTURE2D(MERGE_NAME(TEX, 1), unCoord2); \ |
|||
GBufferType2 MERGE_NAME(NAME, 2) = LOAD_TEXTURE2D(MERGE_NAME(TEX, 2), unCoord2); \ |
|||
GBufferType3 MERGE_NAME(NAME, 3) = LOAD_TEXTURE2D(MERGE_NAME(TEX, 3), unCoord2); \ |
|||
GBufferType4 MERGE_NAME(NAME, 4) = LOAD_TEXTURE2D(MERGE_NAME(TEX, 4), unCoord2); |
|||
|
|||
#define ENCODE_INTO_GBUFFER(SURFACE_DATA, BAKE_DIFFUSE_LIGHTING, NAME) EncodeIntoGBuffer(SURFACE_DATA, BAKE_DIFFUSE_LIGHTING, MERGE_NAME(NAME, 0), MERGE_NAME(NAME, 1), MERGE_NAME(NAME, 2), MERGE_NAME(NAME, 3), MERGE_NAME(NAME, 4)) |
|||
#define DECODE_FROM_GBUFFER(NAME, BSDF_DATA, BAKE_DIFFUSE_LIGHTING) DecodeFromGBuffer(MERGE_NAME(NAME, 0), MERGE_NAME(NAME, 1), MERGE_NAME(NAME, 2), MERGE_NAME(NAME, 3), MERGE_NAME(NAME, 4), BSDF_DATA, BAKE_DIFFUSE_LIGHTING) |
|||
|
|||
#if SHADEROPTIONS_VELOCITY_IN_GBUFFER |
|||
#define OUTPUT_GBUFFER_VELOCITY(NAME) ,out float4 NAME : SV_Target5 |
|||
#endif |
|||
|
|||
#endif |
|||
|
|||
#if SHADEROPTIONS_VELOCITY_IN_GBUFFER |
|||
#define ENCODE_VELOCITY_INTO_GBUFFER(VELOCITY, NAME) EncodeVelocity(VELOCITY, NAME) |
|||
#else |
|||
#define OUTPUT_GBUFFER_VELOCITY(NAME) |
|||
#define ENCODE_VELOCITY_INTO_GBUFFER(VELOCITY, NAME) |
|||
#endif |
|||
|
|||
#endif // #ifdef GBUFFERMATERIAL_COUNT |
|||
|
|||
#endif // UNITY_MATERIAL_INCLUDED |
|
|||
fileFormatVersion: 2 |
|||
guid: 2c2d7b256f4650943b60cc4ef1c7aeaa |
|||
timeCreated: 1483548875 |
|||
licenseType: Pro |
|||
ShaderImporter: |
|||
defaultTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
// |
|||
// This file was automatically generated from Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/SkyManager.cs. Please don't edit by hand. |
|||
// |
|||
|
|||
#ifndef SKYMANAGER_CS_HLSL |
|||
#define SKYMANAGER_CS_HLSL |
|||
// |
|||
// UnityEngine.Experimental.ScriptableRenderLoop.LightSamplingParameters: static fields |
|||
// |
|||
#define LIGHTSAMPLINGPARAMETERS_TEXTURE_HEIGHT (256) |
|||
#define LIGHTSAMPLINGPARAMETERS_TEXTURE_WIDTH (512) |
|||
|
|||
|
|||
#endif |
|
|||
fileFormatVersion: 2 |
|||
guid: 839dd86bae5fa4d46bf4facd02608862 |
|||
timeCreated: 1483546512 |
|||
licenseType: Pro |
|||
ShaderImporter: |
|||
defaultTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
// Given a cube map (passed as a 2D array), builds CDFs of two distributions: |
|||
// 1. 1D texture with marginal densities, telling us the likelihood of selecting a particular row, |
|||
// 2. 2D texture with conditional densities, which correspond to the PDF of the texel given its row. |
|||
// Ref: PBRT v3, 13.6.7 "Piecewise-Constant 2D Distributions". |
|||
// Note that we use the equiareal sphere-to-square mapping instead of the latitude-longitude one. |
|||
|
|||
#include "Common.hlsl" |
|||
#include "ImageBasedLighting.hlsl" |
|||
|
|||
/* --- Input --- */ |
|||
|
|||
#define TEXTURE_HEIGHT 256 // Equiareal texture map: cos(theta) = 1.0 - 2.0 * v |
|||
#define TEXTURE_WIDTH 2 * TEXTURE_HEIGHT // Equiareal texture map: phi = TWO_PI * (1.0 - u) |
|||
|
|||
TEXTURECUBE(envMap); // Input cubemap |
|||
SAMPLERCUBE(sampler_envMap); |
|||
|
|||
/* --- Output --- */ |
|||
|
|||
RWTexture2D<float> marginalRowDensities; // [(TEXTURE_HEIGHT + 1) x 1] (+ 1 for the image integral) |
|||
RWTexture2D<float> conditionalDensities; // [TEXTURE_WIDTH x TEXTURE_HEIGHT] |
|||
|
|||
/* --- Implementation --- */ |
|||
|
|||
// Creates an access pattern which avoids shared memory bank conflicts. |
|||
#define NUM_BANKS 32 |
|||
#define SHARED_MEM(x) ((x) + (x) / NUM_BANKS) |
|||
|
|||
// Performs a block-level parallel scan. |
|||
// Ref: GPU Gems 3, Chapter 39: "Parallel Prefix Sum (Scan) with CUDA". |
|||
#define PARALLEL_SCAN(i, n, temp, sum) \ |
|||
{ \ |
|||
uint offset; \ |
|||
\ |
|||
/* Execute the up-sweep phase. */ \ |
|||
for (offset = 1; offset <= n / 2; offset *= 2) \ |
|||
{ \ |
|||
GroupMemoryBarrierWithGroupSync(); \ |
|||
\ |
|||
/*** a1 = (2 * i + 1) * offset - 1 */ \ |
|||
uint a1 = Mad24(Mad24(2, i, 1), offset, -1); \ |
|||
uint a2 = a1 + offset; \ |
|||
\ |
|||
if (a2 < n) \ |
|||
{ \ |
|||
temp[SHARED_MEM(a2)] += temp[SHARED_MEM(a1)]; \ |
|||
} \ |
|||
} \ |
|||
\ |
|||
GroupMemoryBarrierWithGroupSync(); \ |
|||
\ |
|||
/* Prevent NaNs arising from the division of 0 by 0. */ \ |
|||
sum = max(temp[SHARED_MEM(n - 1)], FLT_MIN); \ |
|||
\ |
|||
GroupMemoryBarrierWithGroupSync(); \ |
|||
\ |
|||
/* The exclusive scan requires the last element to be 0. */ \ |
|||
if (i == 0) \ |
|||
{ \ |
|||
temp[SHARED_MEM(n - 1)] = 0.0; \ |
|||
} \ |
|||
\ |
|||
/* Execute the down-sweep phase. */ \ |
|||
for (offset = n / 2; offset > 0; offset /= 2) \ |
|||
{ \ |
|||
GroupMemoryBarrierWithGroupSync(); \ |
|||
\ |
|||
/*** a1 = (2 * i + 1) * offset - 1 */ \ |
|||
uint a1 = Mad24(Mad24(2, i, 1), offset, -1); \ |
|||
uint a2 = a1 + offset; \ |
|||
\ |
|||
if (a2 < n) \ |
|||
{ \ |
|||
float t1 = temp[SHARED_MEM(a1)]; \ |
|||
temp[SHARED_MEM(a1)] = temp[SHARED_MEM(a2)]; \ |
|||
temp[SHARED_MEM(a2)] += t1; \ |
|||
} \ |
|||
} \ |
|||
\ |
|||
GroupMemoryBarrierWithGroupSync(); \ |
|||
} |
|||
|
|||
#pragma kernel ComputeConditionalDensities |
|||
|
|||
groupshared float rowVals[SHARED_MEM(TEXTURE_WIDTH)]; |
|||
|
|||
[numthreads(TEXTURE_WIDTH / 2, 1, 1)] |
|||
void ComputeConditionalDensities(uint3 groupId : SV_GroupID, |
|||
uint3 groupThreadId : SV_GroupThreadID) |
|||
{ |
|||
// There are TEXTURE_HEIGHT thread groups processing 2 texels per thread. |
|||
const uint n = TEXTURE_WIDTH; |
|||
const uint i = groupThreadId.x; |
|||
const uint j = groupId.x; |
|||
const uint i1 = i; |
|||
const uint i2 = i + n / 2; |
|||
|
|||
float w = TEXTURE_WIDTH; |
|||
float h = TEXTURE_HEIGHT; |
|||
float u1 = i1 / w + 0.5 / w; |
|||
float u2 = i2 / w + 0.5 / w; |
|||
float v = j / h + 0.5 / h; |
|||
|
|||
float3 L1 = ConvertEquiarealToCubemap(u1, v); |
|||
float3 L2 = ConvertEquiarealToCubemap(u2, v); |
|||
float3 c1 = SAMPLE_TEXTURECUBE_LOD(envMap, sampler_envMap, L1, 0).rgb; |
|||
float3 c2 = SAMPLE_TEXTURECUBE_LOD(envMap, sampler_envMap, L2, 0).rgb; |
|||
|
|||
// Compute the integral of the step function (row values). |
|||
// TODO: process 4 texels per thread, and manually unroll. |
|||
rowVals[SHARED_MEM(i1)] = c1.r + c1.g + c1.b; |
|||
rowVals[SHARED_MEM(i2)] = c2.r + c2.g + c2.b; |
|||
|
|||
float rowValSum; |
|||
|
|||
PARALLEL_SCAN(i, n, rowVals, rowValSum) |
|||
|
|||
// Compute the CDF. Note: the value at (i = n) is implicitly 1. |
|||
conditionalDensities[uint2(i1, j)] = rowVals[SHARED_MEM(i1)] / rowValSum; |
|||
conditionalDensities[uint2(i2, j)] = rowVals[SHARED_MEM(i2)] / rowValSum; |
|||
|
|||
if (i == 0) |
|||
{ |
|||
float rowIntegralValue = rowValSum / n; |
|||
marginalRowDensities[uint2(j, 0)] = rowIntegralValue; |
|||
} |
|||
} |
|||
|
|||
#pragma kernel ComputeMarginalRowDensities |
|||
|
|||
groupshared float rowInts[SHARED_MEM(TEXTURE_HEIGHT)]; |
|||
|
|||
[numthreads(TEXTURE_HEIGHT / 2, 1, 1)] |
|||
void ComputeMarginalRowDensities(uint3 groupThreadId : SV_GroupThreadID) |
|||
{ |
|||
// There is only one thread group processing 2 texels per thread. |
|||
const uint n = TEXTURE_HEIGHT; |
|||
const uint i = groupThreadId.x; |
|||
const uint i1 = i; |
|||
const uint i2 = i + n / 2; |
|||
|
|||
// Compute the integral of the step function (row integrals). |
|||
// TODO: process 4 texels per thread, and manually unroll. |
|||
rowInts[SHARED_MEM(i1)] = marginalRowDensities[uint2(i1, 0)]; |
|||
rowInts[SHARED_MEM(i2)] = marginalRowDensities[uint2(i2, 0)]; |
|||
|
|||
float rowIntSum; |
|||
|
|||
PARALLEL_SCAN(i, n, rowInts, rowIntSum) |
|||
|
|||
// Compute the CDF. Note: the value at (i = n) is implicitly 1. |
|||
marginalRowDensities[uint2(i1, 0)] = rowInts[SHARED_MEM(i1)] / rowIntSum; |
|||
marginalRowDensities[uint2(i2, 0)] = rowInts[SHARED_MEM(i2)] / rowIntSum; |
|||
|
|||
if (i == 0) |
|||
{ |
|||
float imgIntegralValue = rowIntSum / n; |
|||
marginalRowDensities[uint2(n, 0)] = imgIntegralValue; |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: b9f26cf340afe9145a699753531b2a4c |
|||
timeCreated: 1482419936 |
|||
licenseType: Pro |
|||
ComputeShaderImporter: |
|||
currentAPIMask: 4 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections.Generic; |
|||
using UnityEngine.Experimental.Rendering; |
|||
|
|||
namespace UnityEngine.ScriptableRenderPipeline |
|||
{ |
|||
public class DefaultCameraProvider : ICameraProvider |
|||
{ |
|||
public Camera overrideCamera { get; set; } |
|||
|
|||
public static void GetCamerasToRenderDefault(List<Camera> cameras) |
|||
{ |
|||
cameras.Clear(); |
|||
foreach (var c in Camera.allCameras) |
|||
{ |
|||
if (c.enabled) |
|||
cameras.Add(c); |
|||
} |
|||
} |
|||
|
|||
public void GetCamerasToRender(List<Camera> cameras) |
|||
{ |
|||
if (overrideCamera != null) |
|||
{ |
|||
cameras.Clear(); |
|||
cameras.Add(overrideCamera); |
|||
} |
|||
else |
|||
{ |
|||
GetCamerasToRenderDefault(cameras); |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 3ac0b0f83d74a194f8578dc2907cacf6 |
|||
timeCreated: 1483007679 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine.Experimental.Rendering; |
|||
|
|||
namespace UnityEngine.ScriptableRenderPipeline |
|||
{ |
|||
public class RenderingDataStore : IScriptableRenderDataStore |
|||
{ |
|||
private bool m_NeedsBuild = true; |
|||
|
|||
public RenderingDataStore(IRenderPipeline owner) |
|||
{ |
|||
this.owner = owner; |
|||
} |
|||
|
|||
public void Build() |
|||
{ |
|||
if (m_NeedsBuild) |
|||
{ |
|||
InternalBuild(); |
|||
m_NeedsBuild = false; |
|||
} |
|||
} |
|||
|
|||
protected virtual void InternalBuild() |
|||
{} |
|||
|
|||
public void Cleanup() |
|||
{ |
|||
if (!m_NeedsBuild) |
|||
{ |
|||
InternalCleanup(); |
|||
m_NeedsBuild = true; |
|||
} |
|||
} |
|||
|
|||
protected virtual void InternalCleanup() |
|||
{} |
|||
|
|||
public IRenderPipeline owner { get; private set; } |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: bd20f7d7bf8c34548b33677973016a96 |
|||
timeCreated: 1483005411 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: efe43be6d4923e441a2d4b20b3783b7f |
|||
folderAsset: yes |
|||
timeCreated: 1474540060 |
|||
licenseType: Pro |
|||
DefaultImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
部分文件因为文件数量过多而无法显示
撰写
预览
正在加载...
取消
保存
Reference in new issue