浏览代码

HDRP: Update comment of integrate HDRI and clean a little code

/main
Sebastien Lagarde 6 年前
当前提交
458155fb
共有 2 个文件被更改,包括 8 次插入6 次删除
  1. 3
      com.unity.render-pipelines.high-definition/HDRP/Editor/Sky/HDRISky/HDRISkyEditor.cs
  2. 11
      com.unity.render-pipelines.high-definition/HDRP/Sky/HDRISky/IntegrateHDRISky.shader

3
com.unity.render-pipelines.high-definition/HDRP/Editor/Sky/HDRISky/HDRISkyEditor.cs


float omegaP = (Mathf.PI * 4) / (6.0f * hdri.width * hdri.width);
m_IntegrateHDRISkyMaterial.SetTexture(HDShaderIDs._Cubemap, hdri);
m_IntegrateHDRISkyMaterial.SetFloat(HDShaderIDs._InvOmegaP, 1.0f / omegaP);
Graphics.Blit(Texture2D.whiteTexture, m_IntensityTexture.rt, m_IntegrateHDRISkyMaterial);

base.CommonSkySettingsGUI();
}
}
}
}

11
com.unity.render-pipelines.high-definition/HDRP/Sky/HDRISky/IntegrateHDRISky.shader


{
[HideInInspector]
_Cubemap ("", CUBE) = "white" {}
_InvOmegaP ("", Float) = 0
}
SubShader

};
TextureCube<float4> _Cubemap;
float _InvOmegaP;
Varyings Vert(Attributes input)
{

}
// Spherical integration of the upper hemisphere
// With HDRI that have a large range (including the sun) it can be challenging to
// compute the lux value without multiple importance sampling.
// We instead use a brute force Uniforme Spherical integration of the upper hemisphere
// with a large number of sample. This is fine as this happen in the editor.
real GetUpperHemisphereLuxValue(TEXTURECUBE_ARGS(skybox, sampler_skybox), real3 N)
{
float sum = 0.0;

{
for (float theta = 0; theta < PI / 2.0; theta += dtheta)
{
// SphericalToCartesian function is for Z up, lets move to Y up with TransformGLtoDX
float3 L = TransformGLtoDX(SphericalToCartesian(phi, cos(theta)));
real val = Luminance(SAMPLE_TEXTURECUBE_LOD(skybox, sampler_skybox, L, 0).rgb);
sum += cos(theta) * sin(theta) * val;

float4 Frag(Varyings input) : SV_Target
{
// Integrate upper hemisphere (Y up)
float3 N = float3(0.0, 1.0, 0.0);
float intensity = GetUpperHemisphereLuxValue(TEXTURECUBE_PARAM(_Cubemap, s_trilinear_clamp_sampler), N);

}
}
Fallback Off
}
}
正在加载...
取消
保存