1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00
Files
occt/src/Shaders/PBRFresnel.glsl
iko 67312b7991 0030700: Visualization, TKOpenGl - support PBR Metallic-Roughness shading model
Metallic-Roughness shading model Graphic3d_TOSM_PBR has been implemented.
New materials descriptors Graphic3d_PBRMaterial have been added to Graphic3d_MaterialAspect.
PBR shading model requires OpenGL 3.0+ or OpenGL ES 3.0+ hardware.
Environment cubemap is expected to be provided for realistic look of metallic materials.

occLight_IsHeadlight() now returns bool instead of int.
Avoid using lowp for enumerations to workaround occLight_IsHeadlight()
ignorance on Adreno 308 caused by some GLSL optimizator bugs.

OpenGl_Texture::EstimatedDataSize() - fixed estimation for Cubemap textures.
OpenGl_Sampler::applySamplerParams() - fixed uninitialized GL_TEXTURE_WRAP_R in case of GL_TEXTURE_CUBE_MAP target.
2019-11-01 18:25:28 +03:00

37 lines
1.2 KiB
GLSL

//! Functions to calculate fresnel coefficient and approximate zero fresnel value.
vec3 occPBRFresnel (in vec3 theBaseColor,
in float theMetallic,
in float theIOR)
{
theIOR = (1.0 - theIOR) / (1.0 + theIOR);
theIOR *= theIOR;
vec3 f0 = vec3(theIOR);
f0 = mix (f0, theBaseColor.rgb, theMetallic);
return f0;
}
vec3 occPBRFresnel (in vec3 theBaseColor,
in float theMetallic,
in float theIOR,
in float theCosVH)
{
vec3 f0 = occPBRFresnel (theBaseColor, theMetallic, theIOR);
theCosVH = 1.0 - theCosVH;
theCosVH *= theCosVH;
theCosVH *= theCosVH * theCosVH * theCosVH * theCosVH;
return f0 + (vec3 (1.0) - f0) * theCosVH;
}
vec3 occPBRFresnel (in vec3 theBaseColor,
in float theMetallic,
in float theRoughness,
in float theIOR,
in float theCosV)
{
vec3 f0 = occPBRFresnel (theBaseColor, theMetallic, theIOR);
theCosV = 1.0 - theCosV;
theCosV *= theCosV;
theCosV *= theCosV * theCosV * theCosV * theCosV;
return f0 + (max(vec3(1.0 - theRoughness), f0) - f0) * theCosV;
}