Remy
7 年前
当前提交
9db2a137
共有 80 个文件被更改,包括 1162 次插入 和 1202 次删除
-
61com.unity.render-pipelines.core/CoreRP/ShaderLibrary/BSDF.hlsl
-
11com.unity.render-pipelines.core/CoreRP/ShaderLibrary/CommonLighting.hlsl
-
68com.unity.render-pipelines.core/CoreRP/ShaderLibrary/ImageBasedLighting.hlsl
-
25com.unity.render-pipelines.high-definition/CHANGELOG.md
-
40com.unity.render-pipelines.high-definition/HDRP/Debug/DebugColorPicker.shader
-
5com.unity.render-pipelines.high-definition/HDRP/Debug/DebugDisplay.cs
-
5com.unity.render-pipelines.high-definition/HDRP/Debug/DebugDisplay.hlsl
-
3com.unity.render-pipelines.high-definition/HDRP/Editor/RenderPipeline/HDAssetFactory.cs
-
2com.unity.render-pipelines.high-definition/HDRP/Editor/RenderPipeline/Settings/LightLoopSettingsUI.cs
-
46com.unity.render-pipelines.high-definition/HDRP/Editor/ShaderGraph/HDPBRPass.template
-
288com.unity.render-pipelines.high-definition/HDRP/Editor/ShaderGraph/HDPBRSubShader.cs
-
242com.unity.render-pipelines.high-definition/HDRP/Editor/ShaderGraph/HDSubShaderUtilities.cs
-
58com.unity.render-pipelines.high-definition/HDRP/Editor/ShaderGraph/HDUnlitPassForward.template
-
294com.unity.render-pipelines.high-definition/HDRP/Editor/ShaderGraph/HDUnlitSubShader.cs
-
57com.unity.render-pipelines.high-definition/HDRP/Lighting/LightEvaluation.hlsl
-
2com.unity.render-pipelines.high-definition/HDRP/Material/Builtin/BuiltinData.cs
-
4com.unity.render-pipelines.high-definition/HDRP/Material/Builtin/BuiltinData.cs.hlsl
-
2com.unity.render-pipelines.high-definition/HDRP/Material/Decal/Decal.cs
-
14com.unity.render-pipelines.high-definition/HDRP/Material/Decal/Decal.cs.hlsl
-
2com.unity.render-pipelines.high-definition/HDRP/Material/Decal/ShaderPass/DecalSharePass.hlsl
-
10com.unity.render-pipelines.high-definition/HDRP/Material/Lit/Lit.cs
-
48com.unity.render-pipelines.high-definition/HDRP/Material/Lit/Lit.cs.hlsl
-
111com.unity.render-pipelines.high-definition/HDRP/Material/Lit/Lit.hlsl
-
2com.unity.render-pipelines.high-definition/HDRP/Material/Lit/ShaderPass/LitDepthPass.hlsl
-
2com.unity.render-pipelines.high-definition/HDRP/Material/Lit/ShaderPass/LitDistortionPass.hlsl
-
2com.unity.render-pipelines.high-definition/HDRP/Material/Lit/ShaderPass/LitSharePass.hlsl
-
2com.unity.render-pipelines.high-definition/HDRP/Material/Lit/ShaderPass/LitVelocityPass.hlsl
-
106com.unity.render-pipelines.high-definition/HDRP/Material/PreIntegratedFGD/PreIntegratedFGD.cs
-
17com.unity.render-pipelines.high-definition/HDRP/Material/PreIntegratedFGD/PreIntegratedFGD.hlsl
-
4com.unity.render-pipelines.high-definition/HDRP/Material/PreIntegratedFGD/preIntegratedFGD_CharlieClothLambert.shader
-
2com.unity.render-pipelines.high-definition/HDRP/Material/StackLit/ShaderPass/StackLitDepthPass.hlsl
-
2com.unity.render-pipelines.high-definition/HDRP/Material/StackLit/ShaderPass/StackLitDistortionPass.hlsl
-
2com.unity.render-pipelines.high-definition/HDRP/Material/StackLit/ShaderPass/StackLitSharePass.hlsl
-
12com.unity.render-pipelines.high-definition/HDRP/Material/StackLit/StackLit.cs
-
114com.unity.render-pipelines.high-definition/HDRP/Material/StackLit/StackLit.cs.hlsl
-
110com.unity.render-pipelines.high-definition/HDRP/Material/StackLit/StackLit.hlsl
-
2com.unity.render-pipelines.high-definition/HDRP/Material/Unlit/ShaderPass/UnlitDepthPass.hlsl
-
2com.unity.render-pipelines.high-definition/HDRP/Material/Unlit/ShaderPass/UnlitDistortionPass.hlsl
-
2com.unity.render-pipelines.high-definition/HDRP/Material/Unlit/ShaderPass/UnlitSharePass.hlsl
-
4com.unity.render-pipelines.high-definition/HDRP/Material/Unlit/Unlit.cs
-
4com.unity.render-pipelines.high-definition/HDRP/Material/Unlit/Unlit.cs.hlsl
-
76com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDRenderPipeline.cs
-
5com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDStringConstants.cs
-
1com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/SceneViewDrawMode.cs
-
10com.unity.render-pipelines.high-definition/HDRP/RenderPipelineResources/CameraMotionVectors.shader
-
5com.unity.render-pipelines.high-definition/HDRP/RenderPipelineResources/HDRenderPipelineResources.asset
-
3com.unity.render-pipelines.high-definition/HDRP/RenderPipelineResources/RenderPipelineResources.cs
-
8com.unity.render-pipelines.lightweight/CHANGELOG.md
-
2com.unity.render-pipelines.lightweight/LWRP/Data/LightweightPipelineAsset.cs
-
5com.unity.render-pipelines.lightweight/LWRP/Editor/ShaderGraph/lightweightPBRForwardPass.template
-
10com.unity.render-pipelines.lightweight/LWRP/Editor/ShaderPreprocessor.cs
-
6com.unity.render-pipelines.lightweight/LWRP/LightweightForwardRenderer.cs
-
25com.unity.render-pipelines.lightweight/LWRP/LightweightPipeline.cs
-
10com.unity.render-pipelines.lightweight/LWRP/Passes/DirectionalShadowsPass.cs
-
1com.unity.render-pipelines.lightweight/LWRP/Passes/ForwardLitPass.cs
-
4com.unity.render-pipelines.lightweight/LWRP/ShaderLibrary/Input.hlsl
-
5com.unity.render-pipelines.lightweight/LWRP/ShaderLibrary/InputSurfacePBR.hlsl
-
6com.unity.render-pipelines.lightweight/LWRP/ShaderLibrary/Lighting.hlsl
-
7com.unity.render-pipelines.lightweight/LWRP/ShaderLibrary/Shadows.hlsl
-
7com.unity.render-pipelines.lightweight/LWRP/Shaders/LightweightScreenSpaceShadows.shader
-
1com.unity.render-pipelines.lightweight/LWRP/Shaders/LightweightStandard.shader
-
1com.unity.render-pipelines.lightweight/LWRP/Shaders/LightweightStandardSimpleLighting.shader
-
1com.unity.render-pipelines.lightweight/LWRP/Shaders/Terrain/LightweightStandardTerrain.shader
-
1com.unity.render-pipelines.lightweight/LWRP/Shaders/Terrain/LightweightStandardTerrainAddPass.shader
-
1com.unity.render-pipelines.lightweight/LWRP/Shaders/Terrain/LightweightStandardTerrainBase.shader
-
1com.unity.render-pipelines.lightweight/LWRP/Shaders/Terrain/LightweightWavingGrass.shader
-
1com.unity.render-pipelines.lightweight/LWRP/Shaders/Terrain/LightweightWavingGrassBillboard.shader
-
68com.unity.shadergraph/Editor/Data/Util/GraphUtil.cs
-
18com.unity.shadergraph/Editor/Drawing/Blackboard/BlackboardFieldPropertyView.cs
-
8com.unity.shadergraph/Editor/Drawing/Controls/ToggleControl.cs
-
8com.unity.shadergraph/Editor/Drawing/Views/PBRSettingsView.cs
-
8com.unity.shadergraph/Editor/Drawing/Views/Slots/BooleanSlotControlView.cs
-
8com.unity.shadergraph/Editor/Drawing/Views/UnlitSettingsView.cs
-
9com.unity.shadergraph/Editor/Util/CompatibilityExtensions.cs
-
168com.unity.render-pipelines.high-definition/HDRP/Material/MaterialEvaluation.hlsl
-
9com.unity.render-pipelines.high-definition/HDRP/Material/MaterialEvaluation.hlsl.meta
-
9com.unity.render-pipelines.high-definition/HDRP/Material/PreIntegratedFGD/preIntegratedFGD_CharlieClothLambert.shader.meta
-
59com.unity.render-pipelines.high-definition/HDRP/Material/PreIntegratedFGD/preIntegratedFGD_GGXDisneyDiffuse.shader
-
0/com.unity.render-pipelines.high-definition/HDRP/Material/PreIntegratedFGD/preIntegratedFGD_GGXDisneyDiffuse.shader.meta
-
0/com.unity.render-pipelines.high-definition/HDRP/Material/PreIntegratedFGD/preIntegratedFGD_CharlieClothLambert.shader
|
|||
// This files include various function uses to evaluate material |
|||
|
|||
//----------------------------------------------------------------------------- |
|||
// Lighting structure for light accumulation |
|||
//----------------------------------------------------------------------------- |
|||
|
|||
// These structure allow to accumulate lighting accross the Lit material |
|||
// AggregateLighting is init to zero and transfer to EvaluateBSDF, but the LightLoop can't access its content. |
|||
struct DirectLighting |
|||
{ |
|||
float3 diffuse; |
|||
float3 specular; |
|||
}; |
|||
|
|||
struct IndirectLighting |
|||
{ |
|||
float3 specularReflected; |
|||
float3 specularTransmitted; |
|||
}; |
|||
|
|||
struct AggregateLighting |
|||
{ |
|||
DirectLighting direct; |
|||
IndirectLighting indirect; |
|||
}; |
|||
|
|||
void AccumulateDirectLighting(DirectLighting src, inout AggregateLighting dst) |
|||
{ |
|||
dst.direct.diffuse += src.diffuse; |
|||
dst.direct.specular += src.specular; |
|||
} |
|||
|
|||
void AccumulateIndirectLighting(IndirectLighting src, inout AggregateLighting dst) |
|||
{ |
|||
dst.indirect.specularReflected += src.specularReflected; |
|||
dst.indirect.specularTransmitted += src.specularTransmitted; |
|||
} |
|||
|
|||
//----------------------------------------------------------------------------- |
|||
// Ambient occlusion helper |
|||
//----------------------------------------------------------------------------- |
|||
|
|||
// Ambient occlusion |
|||
struct AmbientOcclusionFactor |
|||
{ |
|||
float3 indirectAmbientOcclusion; |
|||
float3 directAmbientOcclusion; |
|||
float3 indirectSpecularOcclusion; |
|||
}; |
|||
|
|||
void GetScreenSpaceAmbientOcclusion(float2 positionSS, float NdotV, float perceptualRoughness, float ambientOcclusionFromData, float specularOcclusionFromData, out AmbientOcclusionFactor aoFactor) |
|||
{ |
|||
// Note: When we ImageLoad outside of texture size, the value returned by Load is 0 (Note: On Metal maybe it clamp to value of texture which is also fine) |
|||
// We use this property to have a neutral value for AO that doesn't consume a sampler and work also with compute shader (i.e use ImageLoad) |
|||
// We store inverse AO so neutral is black. So either we sample inside or outside the texture it return 0 in case of neutral |
|||
|
|||
// Ambient occlusion use for indirect lighting (reflection probe, baked diffuse lighting) |
|||
#ifndef _SURFACE_TYPE_TRANSPARENT |
|||
float indirectAmbientOcclusion = 1.0 - LOAD_TEXTURE2D(_AmbientOcclusionTexture, positionSS).x; |
|||
// Ambient occlusion use for direct lighting (directional, punctual, area) |
|||
float directAmbientOcclusion = lerp(1.0, indirectAmbientOcclusion, _AmbientOcclusionParam.w); |
|||
#else |
|||
float indirectAmbientOcclusion = 1.0; |
|||
float directAmbientOcclusion = 1.0; |
|||
#endif |
|||
|
|||
float roughness = PerceptualRoughnessToRoughness(perceptualRoughness); |
|||
float specularOcclusion = GetSpecularOcclusionFromAmbientOcclusion(ClampNdotV(NdotV), indirectAmbientOcclusion, roughness); |
|||
|
|||
aoFactor.indirectSpecularOcclusion = lerp(_AmbientOcclusionParam.rgb, float3(1.0, 1.0, 1.0), min(specularOcclusionFromData, specularOcclusion)); |
|||
aoFactor.indirectAmbientOcclusion = lerp(_AmbientOcclusionParam.rgb, float3(1.0, 1.0, 1.0), min(ambientOcclusionFromData, indirectAmbientOcclusion)); |
|||
aoFactor.directAmbientOcclusion = lerp(_AmbientOcclusionParam.rgb, float3(1.0, 1.0, 1.0), directAmbientOcclusion); |
|||
} |
|||
|
|||
void GetScreenSpaceAmbientOcclusionMultibounce(float2 positionSS, float NdotV, float perceptualRoughness, float ambientOcclusionFromData, float specularOcclusionFromData, float3 diffuseColor, float3 fresnel0, out AmbientOcclusionFactor aoFactor) |
|||
{ |
|||
// Use GTAOMultiBounce approximation for ambient occlusion (allow to get a tint from the diffuseColor) |
|||
// Note: When we ImageLoad outside of texture size, the value returned by Load is 0 (Note: On Metal maybe it clamp to value of texture which is also fine) |
|||
// We use this property to have a neutral value for AO that doesn't consume a sampler and work also with compute shader (i.e use ImageLoad) |
|||
// We store inverse AO so neutral is black. So either we sample inside or outside the texture it return 0 in case of neutral |
|||
|
|||
// Ambient occlusion use for indirect lighting (reflection probe, baked diffuse lighting) |
|||
#ifndef _SURFACE_TYPE_TRANSPARENT |
|||
float indirectAmbientOcclusion = 1.0 - LOAD_TEXTURE2D(_AmbientOcclusionTexture, positionSS).x; |
|||
// Ambient occlusion use for direct lighting (directional, punctual, area) |
|||
float directAmbientOcclusion = lerp(1.0, indirectAmbientOcclusion, _AmbientOcclusionParam.w); |
|||
#else |
|||
float indirectAmbientOcclusion = 1.0; |
|||
float directAmbientOcclusion = 1.0; |
|||
#endif |
|||
|
|||
float roughness = PerceptualRoughnessToRoughness(perceptualRoughness); |
|||
float specularOcclusion = GetSpecularOcclusionFromAmbientOcclusion(ClampNdotV(NdotV), indirectAmbientOcclusion, roughness); |
|||
|
|||
aoFactor.indirectSpecularOcclusion = GTAOMultiBounce(min(specularOcclusionFromData, specularOcclusion), fresnel0); |
|||
aoFactor.indirectAmbientOcclusion = GTAOMultiBounce(min(ambientOcclusionFromData, indirectAmbientOcclusion), diffuseColor); |
|||
aoFactor.directAmbientOcclusion = GTAOMultiBounce(directAmbientOcclusion, diffuseColor); |
|||
} |
|||
|
|||
void ApplyAmbientOcclusionFactor(AmbientOcclusionFactor aoFactor, inout BakeLightingData bakeLightingData, inout AggregateLighting lighting) |
|||
{ |
|||
// Note: in case of Lit, bakeLightingData.bakeDiffuseLighting contain indirect diffuse + emissive, |
|||
// so Ambient occlusion is multiply by emissive which is wrong but not a big deal |
|||
bakeLightingData.bakeDiffuseLighting *= aoFactor.indirectAmbientOcclusion; |
|||
lighting.indirect.specularReflected *= aoFactor.indirectSpecularOcclusion; |
|||
lighting.direct.diffuse *= aoFactor.directAmbientOcclusion; |
|||
} |
|||
|
|||
#ifdef DEBUG_DISPLAY |
|||
// mipmapColor is color use to store texture streaming information in XXXData.hlsl (look for DEBUGMIPMAPMODE_NONE) |
|||
void PostEvaluateBSDFDebugDisplay( AmbientOcclusionFactor aoFactor, BakeLightingData bakeLightingData, AggregateLighting lighting, float3 mipmapColor, |
|||
inout float3 diffuseLighting, inout float3 specularLighting) |
|||
{ |
|||
if (_DebugLightingMode != 0) |
|||
{ |
|||
// Caution: _DebugLightingMode is used in other part of the code, don't do anything outside of |
|||
// current cases |
|||
switch (_DebugLightingMode) |
|||
{ |
|||
case DEBUGLIGHTINGMODE_LUX_METER: |
|||
diffuseLighting = lighting.direct.diffuse + bakeLightingData.bakeDiffuseLighting; |
|||
|
|||
//Compress lighting values for color picker if enabled |
|||
if (_ColorPickerMode != COLORPICKERDEBUGMODE_NONE) |
|||
diffuseLighting = diffuseLighting / LUXMETER_COMPRESSION_RATIO; |
|||
|
|||
specularLighting = float3(0.0, 0.0, 0.0); // Disable specular lighting |
|||
break; |
|||
|
|||
case DEBUGLIGHTINGMODE_INDIRECT_DIFFUSE_OCCLUSION: |
|||
diffuseLighting = aoFactor.indirectAmbientOcclusion; |
|||
specularLighting = float3(0.0, 0.0, 0.0); // Disable specular lighting |
|||
break; |
|||
|
|||
case DEBUGLIGHTINGMODE_INDIRECT_SPECULAR_OCCLUSION: |
|||
diffuseLighting = aoFactor.indirectSpecularOcclusion; |
|||
specularLighting = float3(0.0, 0.0, 0.0); // Disable specular lighting |
|||
break; |
|||
|
|||
case DEBUGLIGHTINGMODE_SCREEN_SPACE_TRACING_REFRACTION: |
|||
if (_DebugLightingSubMode != DEBUGSCREENSPACETRACING_COLOR) |
|||
diffuseLighting = lighting.indirect.specularTransmitted; |
|||
break; |
|||
|
|||
case DEBUGLIGHTINGMODE_SCREEN_SPACE_TRACING_REFLECTION: |
|||
if (_DebugLightingSubMode != DEBUGSCREENSPACETRACING_COLOR) |
|||
diffuseLighting = lighting.indirect.specularReflected; |
|||
break; |
|||
|
|||
case DEBUGLIGHTINGMODE_VISUALIZE_SHADOW_MASKS: |
|||
#ifdef SHADOWS_SHADOWMASK |
|||
diffuseLighting = float3( |
|||
bakeLightingData.bakeShadowMask.r / 2 + bakeLightingData.bakeShadowMask.g / 2, |
|||
bakeLightingData.bakeShadowMask.g / 2 + bakeLightingData.bakeShadowMask.b / 2, |
|||
bakeLightingData.bakeShadowMask.b / 2 + bakeLightingData.bakeShadowMask.a / 2 |
|||
); |
|||
specularLighting = float3(0, 0, 0); |
|||
#endif |
|||
break ; |
|||
} |
|||
} |
|||
else if (_DebugMipMapMode != DEBUGMIPMAPMODE_NONE) |
|||
{ |
|||
diffuseLighting = mipmapColor; |
|||
specularLighting = float3(0.0, 0.0, 0.0); // Disable specular lighting |
|||
} |
|||
} |
|||
#endif |
|
|||
fileFormatVersion: 2 |
|||
guid: 3c80046db57367445b2a7c154c18879e |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 3b3bf235775cf8b4baae7f3306787ab0 |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
Shader "Hidden/HDRenderPipeline/preIntegratedFGD_GGXDisneyDiffuse" |
|||
{ |
|||
SubShader |
|||
{ |
|||
Tags{ "RenderPipeline" = "HDRenderPipeline" } |
|||
Pass |
|||
{ |
|||
ZTest Always Cull Off ZWrite Off |
|||
|
|||
HLSLPROGRAM |
|||
#pragma vertex Vert |
|||
#pragma fragment Frag |
|||
#pragma target 4.5 |
|||
#pragma only_renderers d3d11 ps4 xboxone vulkan metal switch |
|||
|
|||
#include "CoreRP/ShaderLibrary/Common.hlsl" |
|||
#include "CoreRP/ShaderLibrary/ImageBasedLighting.hlsl" |
|||
#include "../../ShaderVariables.hlsl" |
|||
|
|||
struct Attributes |
|||
{ |
|||
uint vertexID : SV_VertexID; |
|||
}; |
|||
|
|||
struct Varyings |
|||
{ |
|||
float4 positionCS : SV_POSITION; |
|||
float2 texCoord : TEXCOORD0; |
|||
}; |
|||
|
|||
Varyings Vert(Attributes input) |
|||
{ |
|||
Varyings output; |
|||
|
|||
output.positionCS = GetFullScreenTriangleVertexPosition(input.vertexID); |
|||
output.texCoord = GetFullScreenTriangleTexCoord(input.vertexID); |
|||
|
|||
return output; |
|||
} |
|||
|
|||
float4 Frag(Varyings input) : SV_Target |
|||
{ |
|||
// These coordinate sampling must match the decoding in GetPreIntegratedDFG in lit.hlsl, i.e here we use perceptualRoughness, must be the same in shader |
|||
float NdotV = input.texCoord.x; |
|||
float perceptualRoughness = input.texCoord.y; |
|||
float3 V = float3(sqrt(1 - NdotV * NdotV), 0, NdotV); |
|||
float3 N = float3(0.0, 0.0, 1.0); |
|||
|
|||
// Pre integrate GGX with smithJoint visibility as well as DisneyDiffuse |
|||
float4 preFGD = IntegrateGGXAndDisneyDiffuseFGD(V, N, PerceptualRoughnessToRoughness(perceptualRoughness)); |
|||
|
|||
return float4(preFGD.xyz, 1.0); |
|||
} |
|||
|
|||
ENDHLSL |
|||
} |
|||
} |
|||
Fallback Off |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue