Antoine Lelievre
6 年前
当前提交
7ba755b2
共有 14 个文件被更改,包括 226 次插入 和 22 次删除
-
1com.unity.render-pipelines.high-definition/HDRP/Editor/RenderPipeline/HDAssetFactory.cs
-
19com.unity.render-pipelines.high-definition/HDRP/Editor/Sky/HDRISky/HDRISkyEditor.cs
-
4com.unity.render-pipelines.high-definition/HDRP/Editor/Sky/ProceduralSky/ProceduralSkyEditor.cs
-
29com.unity.render-pipelines.high-definition/HDRP/Editor/Sky/SkySettingsEditor.cs
-
1com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDStringConstants.cs
-
1com.unity.render-pipelines.high-definition/HDRP/RenderPipelineResources/HDRenderPipelineResources.asset
-
1com.unity.render-pipelines.high-definition/HDRP/RenderPipelineResources/RenderPipelineResources.cs
-
8com.unity.render-pipelines.high-definition/HDRP/Sky/HDRISky/HDRISky.shader
-
44com.unity.render-pipelines.high-definition/HDRP/Sky/HDRISky/HDRISkyRenderer.cs
-
2com.unity.render-pipelines.high-definition/HDRP/Sky/SkyRenderer.cs
-
8com.unity.render-pipelines.high-definition/HDRP/Sky/SkyRenderingContext.cs
-
32com.unity.render-pipelines.high-definition/HDRP/Sky/SkySettings.cs
-
89com.unity.render-pipelines.high-definition/HDRP/Sky/HDRISky/IntegrateHDRISky.shader
-
9com.unity.render-pipelines.high-definition/HDRP/Sky/HDRISky/IntegrateHDRISky.shader.meta
|
|||
Shader "Hidden/HDRenderPipeline/IntegrateHDRI" |
|||
{ |
|||
Properties |
|||
{ |
|||
[HideInInspector] |
|||
_Cubemap ("", CUBE) = "white" {} |
|||
} |
|||
|
|||
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/Color.hlsl" |
|||
#include "CoreRP/ShaderLibrary/ImageBasedLighting.hlsl" |
|||
#include "../../ShaderVariables.hlsl" |
|||
|
|||
struct Attributes |
|||
{ |
|||
uint vertexID : SV_VertexID; |
|||
}; |
|||
|
|||
struct Varyings |
|||
{ |
|||
float4 positionCS : SV_POSITION; |
|||
float2 texCoord : TEXCOORD0; |
|||
}; |
|||
|
|||
TextureCube<float4> _Cubemap; |
|||
|
|||
Varyings Vert(Attributes input) |
|||
{ |
|||
Varyings output; |
|||
|
|||
output.positionCS = GetFullScreenTriangleVertexPosition(input.vertexID); |
|||
output.texCoord = GetFullScreenTriangleTexCoord(input.vertexID); |
|||
|
|||
return output; |
|||
} |
|||
|
|||
|
|||
real IntegrateHDRISky(TEXTURECUBE_ARGS(skybox, sampler_skybox), real3 N, uint sampleCount = 8192) |
|||
{ |
|||
real acc = 0.0; |
|||
|
|||
// Add some jittering on Hammersley2d |
|||
real2 randNum = InitRandom(0.5); |
|||
|
|||
real3x3 localToWorld = GetLocalFrame(N); |
|||
|
|||
for (uint i = 0; i < sampleCount; ++i) |
|||
{ |
|||
real2 u = frac(randNum + Hammersley2d(i, sampleCount)); |
|||
|
|||
real NdotL; |
|||
real weightOverPdf; |
|||
real3 L; |
|||
|
|||
ImportanceSampleLambert(u, localToWorld, L, NdotL, weightOverPdf); |
|||
real val = Luminance(SAMPLE_TEXTURECUBE_LOD(skybox, sampler_skybox, L, 0).rgb); |
|||
acc += NdotL * val; |
|||
} |
|||
|
|||
return acc / sampleCount; |
|||
} |
|||
|
|||
float4 Frag(Varyings input) : SV_Target |
|||
{ |
|||
float3 N = float3(0.0, 0.0, 1.0); |
|||
|
|||
float intensity = IntegrateHDRISky(TEXTURECUBE_PARAM(_Cubemap, s_trilinear_clamp_sampler), N); |
|||
|
|||
return float4(intensity, 1.0, 1.0, 1.0); |
|||
} |
|||
|
|||
ENDHLSL |
|||
} |
|||
} |
|||
Fallback Off |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 48db2705cf2856d4e893eb30a6892d1b |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue