Evgenii Golubev
7 年前
当前提交
d610a7cf
共有 6 个文件被更改,包括 137 次插入 和 6 次删除
-
12ScriptableRenderPipeline/Core/ShaderLibrary/Fibonacci.hlsl
-
26ScriptableRenderPipeline/Core/ShaderLibrary/ImageBasedLighting.hlsl
-
17ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.cs
-
9ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl
-
69ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Resources/ComputeGgxEnergyCompensationFactors.shader
-
10ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Resources/ComputeGgxEnergyCompensationFactors.shader.meta
|
|||
Shader "Hidden/HDRenderPipeline/ComputeGgxEnergyCompensationFactors" |
|||
{ |
|||
SubShader { |
|||
Pass { |
|||
ZTest Always Cull Off ZWrite Off |
|||
|
|||
HLSLPROGRAM |
|||
#pragma vertex Vert |
|||
#pragma fragment Frag |
|||
#pragma target 4.5 |
|||
#pragma only_renderers d3d11 ps4 metal // TEMP: until we go further in dev |
|||
|
|||
#include "../../../../Core/ShaderLibrary/Common.hlsl" |
|||
#include "../../../../Core/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 roughness = PerceptualRoughnessToRoughness(input.texCoord.y); |
|||
float3 N = float3(0, 0, 1); |
|||
float3 V = float3(sqrt(1 - NdotV * NdotV), 0, NdotV); |
|||
|
|||
float fDir = ComputeGgxEnergyCompensationFactor(V, N, roughness); |
|||
float fAvg = 0; |
|||
|
|||
const uint numSamples = 128; |
|||
|
|||
for (uint i = 0; i < numSamples; i++) |
|||
{ |
|||
NdotV = (i + 0.5) * rcp(numSamples); |
|||
V = float3(sqrt(1 - NdotV * NdotV), 0, NdotV); |
|||
|
|||
fAvg += ComputeGgxEnergyCompensationFactor(V, N, roughness) * NdotV * (2 * rcp(numSamples)); |
|||
} |
|||
|
|||
float f = (1 - fDir) * rsqrt(PI * (1 - fAvg)); |
|||
|
|||
// f_ms = f[NdotV, perceptualRoughness] * f[NdotL, perceptualRoughness]. |
|||
return f.xxxx; |
|||
} |
|||
|
|||
ENDHLSL |
|||
} |
|||
} |
|||
Fallback Off |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: c7c7d11c211eb5746b7fe3d016ae62e8 |
|||
timeCreated: 1508422200 |
|||
licenseType: Pro |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue