mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0031096: Visualization, TKOpenGl - support metallic-roughness texture mapping
OpenGl_ShaderManager - metallic-roughness, emissive, occlusion and normal texture maps are now supported by PBR. Emissive, occlusion and normal texture maps are now supported by Phong shading model. Path-Tracing now handles metallic-roughness and emissive texture maps. Graphic3d_TextureUnit enumeration has been extended by new values corresponding to supported texture maps. OpenGl_TextureSet and OpenGl_ShaderProgram have been extended with bitmask Graphic3d_TextureSetBits identifying texture slots read from GLSL Program and slots defined within Texture Set to avoid undefined behavior by binding mock textures. OpenGl_TextureSet now duplicates texture unit information to handle textures shared across multiple slots (like Occlusion [R] + Metallic-Roughness [GB]). OpenGl_Context::BindTextures() has been extended with active GLSL program paramter to set mock textures to texture units used by program but undefined by texture set. OpenGl_Workspace::ApplyAspects() has been extended with parameter to avoid bining texture set.
This commit is contained in:
@@ -164,6 +164,7 @@ Graphic3d_TextureRoot.hxx
|
||||
Graphic3d_TextureUnit.hxx
|
||||
Graphic3d_TextureSet.cxx
|
||||
Graphic3d_TextureSet.hxx
|
||||
Graphic3d_TextureSetBits.hxx
|
||||
Graphic3d_ToneMappingMethod.hxx
|
||||
Graphic3d_TransformError.hxx
|
||||
Graphic3d_TransformPers.hxx
|
||||
|
@@ -208,5 +208,6 @@ Graphic3d_BSDF Graphic3d_BSDF::CreateMetallicRoughness (const Graphic3d_PBRMater
|
||||
aBsdf.Ks.SetValues (Graphic3d_Vec3 (thePbr.Alpha()), aRougness2);
|
||||
aBsdf.Kt = Graphic3d_Vec3 (1.0f - thePbr.Alpha());
|
||||
aBsdf.Kd = aDiff * (1.0f - thePbr.Metallic());
|
||||
aBsdf.Le = thePbr.Emission();
|
||||
return aBsdf;
|
||||
}
|
||||
|
@@ -80,6 +80,7 @@ Graphic3d_ShaderProgram::Graphic3d_ShaderProgram()
|
||||
: myNbLightsMax (THE_MAX_LIGHTS_DEFAULT),
|
||||
myNbClipPlanesMax (THE_MAX_CLIP_PLANES_DEFAULT),
|
||||
myNbFragOutputs (THE_NB_FRAG_OUTPUTS),
|
||||
myTextureSetBits (Graphic3d_TextureSetBits_NONE),
|
||||
myHasDefSampler (true),
|
||||
myHasAlphaTest (false),
|
||||
myHasWeightOitOutput (false),
|
||||
|
@@ -20,6 +20,7 @@
|
||||
#include <Graphic3d_ShaderObject.hxx>
|
||||
#include <Graphic3d_ShaderVariable.hxx>
|
||||
#include <Graphic3d_TextureParams.hxx>
|
||||
#include <Graphic3d_TextureSetBits.hxx>
|
||||
#include <NCollection_Sequence.hxx>
|
||||
|
||||
//! List of shader objects.
|
||||
@@ -152,12 +153,18 @@ public:
|
||||
void SetWeightOitOutput (Standard_Boolean theOutput) { myHasWeightOitOutput = theOutput; }
|
||||
|
||||
//! Return TRUE if standard program header should define functions and variables used in PBR pipeline.
|
||||
//! FALSE by default
|
||||
//! FALSE by default.
|
||||
Standard_Boolean IsPBR() const { return myIsPBR; }
|
||||
|
||||
//! Sets whether standard program header should define functions and variables used in PBR pipeline.
|
||||
void SetPBR (Standard_Boolean theIsPBR) { myIsPBR = theIsPBR; }
|
||||
|
||||
//! Return texture units declared within the program, @sa Graphic3d_TextureSetBits.
|
||||
Standard_Integer TextureSetBits() const { return myTextureSetBits; }
|
||||
|
||||
//! Set texture units declared within the program.
|
||||
void SetTextureSetBits (Standard_Integer theBits) { myTextureSetBits = theBits; }
|
||||
|
||||
//! Pushes custom uniform variable to the program.
|
||||
//! The list of pushed variables is automatically cleared after applying to GLSL program.
|
||||
//! Thus after program recreation even unchanged uniforms should be pushed anew.
|
||||
@@ -208,6 +215,7 @@ private:
|
||||
Standard_Integer myNbLightsMax; //!< length of array of light sources (THE_MAX_LIGHTS)
|
||||
Standard_Integer myNbClipPlanesMax; //!< length of array of clipping planes (THE_MAX_CLIP_PLANES)
|
||||
Standard_Integer myNbFragOutputs; //!< length of array of Fragment Shader outputs (THE_NB_FRAG_OUTPUTS)
|
||||
Standard_Integer myTextureSetBits;//!< texture units declared within the program, @sa Graphic3d_TextureSetBits
|
||||
Standard_Boolean myHasDefSampler; //!< flag indicating that program defines default texture sampler occSampler0
|
||||
Standard_Boolean myHasAlphaTest; //!< flag indicating that Fragment Shader performs alpha test
|
||||
Standard_Boolean myHasWeightOitOutput; //!< flag indicating that Fragment Shader includes weighted OIT coverage
|
||||
|
30
src/Graphic3d/Graphic3d_TextureSetBits.hxx
Normal file
30
src/Graphic3d/Graphic3d_TextureSetBits.hxx
Normal file
@@ -0,0 +1,30 @@
|
||||
// Copyright (c) 2019 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _Graphic3d_TextureSetBits_HeaderFile
|
||||
#define _Graphic3d_TextureSetBits_HeaderFile
|
||||
|
||||
#include <Graphic3d_TextureUnit.hxx>
|
||||
|
||||
//! Standard texture units combination bits.
|
||||
enum Graphic3d_TextureSetBits
|
||||
{
|
||||
Graphic3d_TextureSetBits_NONE = 0,
|
||||
Graphic3d_TextureSetBits_BaseColor = (unsigned int )(1 << int(Graphic3d_TextureUnit_BaseColor)),
|
||||
Graphic3d_TextureSetBits_Emissive = (unsigned int )(1 << int(Graphic3d_TextureUnit_Emissive)),
|
||||
Graphic3d_TextureSetBits_Occlusion = (unsigned int )(1 << int(Graphic3d_TextureUnit_Occlusion)),
|
||||
Graphic3d_TextureSetBits_Normal = (unsigned int )(1 << int(Graphic3d_TextureUnit_Normal)),
|
||||
Graphic3d_TextureSetBits_MetallicRoughness = (unsigned int )(1 << int(Graphic3d_TextureUnit_MetallicRoughness)),
|
||||
};
|
||||
|
||||
#endif // _Graphic3d_TextureSetBits_HeaderFile
|
@@ -35,17 +35,54 @@ enum Graphic3d_TextureUnit
|
||||
Graphic3d_TextureUnit_14,
|
||||
Graphic3d_TextureUnit_15,
|
||||
|
||||
Graphic3d_TextureUnit_BaseColor = Graphic3d_TextureUnit_0, //!< base color of the material
|
||||
//Graphic3d_TextureUnit_Normal = Graphic3d_TextureUnit_1, //!< tangent space normal map
|
||||
//Graphic3d_TextureUnit_MetallicRoughness = Graphic3d_TextureUnit_2, //!< metalness+roughness of the material
|
||||
//Graphic3d_TextureUnit_Emissive = Graphic3d_TextureUnit_3, //!< emissive map controls the color and intensity of the light being emitted by the material
|
||||
//Graphic3d_TextureUnit_Occlusion = Graphic3d_TextureUnit_4, //!< occlusion map indicating areas of indirect lighting
|
||||
// aliases
|
||||
|
||||
Graphic3d_TextureUnit_EnvMap = Graphic3d_TextureUnit_0 //!< environment cubemap for background
|
||||
//! sampler2D occSamplerBaseColor.
|
||||
//! RGB(A) base color of the material and alpha mask/opacity.
|
||||
Graphic3d_TextureUnit_BaseColor = Graphic3d_TextureUnit_0,
|
||||
//! sampler2D occSamplerEmissive.
|
||||
//! RGB emissive map controls the color and intensity of the light being emitted by the material.
|
||||
Graphic3d_TextureUnit_Emissive = Graphic3d_TextureUnit_1,
|
||||
//! sampler2D occSamplerOcclusion.
|
||||
//! Occlusion map indicating areas of indirect lighting.
|
||||
//! Encoded into RED channel, with 1.0 meaning no occlusion (full color intensity) and 0.0 complete occlusion (black).
|
||||
Graphic3d_TextureUnit_Occlusion = Graphic3d_TextureUnit_2,
|
||||
//! sampler2D occSamplerNormal.
|
||||
//! XYZ tangent space normal map.
|
||||
Graphic3d_TextureUnit_Normal = Graphic3d_TextureUnit_3,
|
||||
//! sampler2D occSamplerMetallicRoughness.
|
||||
//! Metalness + roughness of the material.
|
||||
//! Encoded into GREEN (roughness) + BLUE (metallic) channels,
|
||||
//! so that it can be optionally combined with occlusion texture (RED channel).
|
||||
Graphic3d_TextureUnit_MetallicRoughness = Graphic3d_TextureUnit_4,
|
||||
|
||||
//! samplerCube occSampler0.
|
||||
//! Environment cubemap for background. Rendered by dedicated program and normally occupies first texture unit.
|
||||
Graphic3d_TextureUnit_EnvMap = Graphic3d_TextureUnit_0,
|
||||
|
||||
//! sampler2D occSamplerPointSprite.
|
||||
//! Sprite alpha-mask or RGBA image mapped using point UV, additional to BaseColor (mapping using vertex UV).
|
||||
//! This texture unit is set Graphic3d_TextureUnit_1, so that it can be combined with Graphic3d_TextureUnit_BaseColor,
|
||||
//! while other texture maps (normal map and others) are unexpected and unsupported for points.
|
||||
//! Note that it can be overridden to Graphic3d_TextureUnit_0 for FFP fallback on hardware without multi-texturing.
|
||||
Graphic3d_TextureUnit_PointSprite = Graphic3d_TextureUnit_1,
|
||||
|
||||
//! sampler2D occEnvLUT.
|
||||
//! Lookup table for approximated PBR environment lighting.
|
||||
//! Configured as index at the end of available texture units - 3.
|
||||
Graphic3d_TextureUnit_PbrEnvironmentLUT = -3,
|
||||
//! sampler2D occDiffIBLMapSHCoeffs.
|
||||
//! Diffuse (irradiance) IBL map's spherical harmonics coefficients baked for PBR from environment cubemap image.
|
||||
//! Configured as index at the end of available texture units - 2.
|
||||
Graphic3d_TextureUnit_PbrIblDiffuseSH = -2,
|
||||
//! samplerCube occSpecIBLMap.
|
||||
//! Specular IBL (Image-Based Lighting) environment map baked for PBR from environment cubemap image.
|
||||
//! Configured as index at the end of available texture units - 1.
|
||||
Graphic3d_TextureUnit_PbrIblSpecular = -1,
|
||||
};
|
||||
enum
|
||||
{
|
||||
Graphic3d_TextureUnit_NB = Graphic3d_TextureUnit_15 + 1
|
||||
Graphic3d_TextureUnit_NB = Graphic3d_TextureUnit_15 + 1,
|
||||
};
|
||||
|
||||
#endif // _Graphic3d_TextureUnit_HeaderFile
|
||||
|
Reference in New Issue
Block a user