mirror of
https://github.com/UberGames/lilium-voyager.git
synced 2024-11-14 00:10:39 +00:00
OpenGL2: Set cubemap mip selection to match output from ggxcc.
This commit is contained in:
parent
e0b2256043
commit
a40588c8b9
2 changed files with 17 additions and 3 deletions
|
@ -370,11 +370,11 @@ void main()
|
||||||
// from http://seblagarde.wordpress.com/2012/09/29/image-based-lighting-approaches-and-parallax-corrected-cubemap/
|
// from http://seblagarde.wordpress.com/2012/09/29/image-based-lighting-approaches-and-parallax-corrected-cubemap/
|
||||||
vec3 parallax = u_CubeMapInfo.xyz + u_CubeMapInfo.w * viewDir;
|
vec3 parallax = u_CubeMapInfo.xyz + u_CubeMapInfo.w * viewDir;
|
||||||
|
|
||||||
vec3 cubeLightColor = textureCubeLod(u_CubeMap, R + parallax, 7.0 * roughness).rgb * u_EnableTextures.w;
|
vec3 cubeLightColor = textureCubeLod(u_CubeMap, R + parallax, ROUGHNESS_MIPS * roughness).rgb * u_EnableTextures.w;
|
||||||
|
|
||||||
// normalize cubemap based on lowest mip (~diffuse)
|
// normalize cubemap based on last roughness mip (~diffuse)
|
||||||
// multiplying cubemap values by lighting below depends on either this or the cubemap being normalized at generation
|
// multiplying cubemap values by lighting below depends on either this or the cubemap being normalized at generation
|
||||||
//vec3 cubeLightDiffuse = max(textureCubeLod(u_CubeMap, N, 6.0).rgb, 0.5 / 255.0);
|
//vec3 cubeLightDiffuse = max(textureCubeLod(u_CubeMap, N, ROUGHNESS_MIPS).rgb, 0.5 / 255.0);
|
||||||
//cubeLightColor /= dot(cubeLightDiffuse, vec3(0.2125, 0.7154, 0.0721));
|
//cubeLightColor /= dot(cubeLightDiffuse, vec3(0.2125, 0.7154, 0.0721));
|
||||||
|
|
||||||
#if defined(USE_PBR)
|
#if defined(USE_PBR)
|
||||||
|
|
|
@ -325,6 +325,20 @@ static void GLSL_GetShaderHeader( GLenum shaderType, const GLcharARB *extra, cha
|
||||||
if (r_pbr->integer)
|
if (r_pbr->integer)
|
||||||
Q_strcat(dest, size, "#define USE_PBR\n");
|
Q_strcat(dest, size, "#define USE_PBR\n");
|
||||||
|
|
||||||
|
if (r_cubeMapping->integer)
|
||||||
|
{
|
||||||
|
int cubeMipSize = r_cubemapSize->integer;
|
||||||
|
int numRoughnessMips = 0;
|
||||||
|
|
||||||
|
while (cubeMipSize)
|
||||||
|
{
|
||||||
|
cubeMipSize >>= 1;
|
||||||
|
numRoughnessMips++;
|
||||||
|
}
|
||||||
|
numRoughnessMips = MAX(1, numRoughnessMips - 2);
|
||||||
|
Q_strcat(dest, size, va("#define ROUGHNESS_MIPS float(%d)\n", numRoughnessMips));
|
||||||
|
}
|
||||||
|
|
||||||
if (extra)
|
if (extra)
|
||||||
{
|
{
|
||||||
Q_strcat(dest, size, extra);
|
Q_strcat(dest, size, extra);
|
||||||
|
|
Loading…
Reference in a new issue