MantisBT - Open CASCADE
View Issue Details
0029902Open CASCADE[OCCT] OCCT:Data Exchangepublic2018-06-28 11:582019-10-09 19:17
kgv 
bugmaster 
normalfeature 
reviewedopen 
 
[OCCT] 7.5.0* 
0029902: Data Exchange, XCAF - provide extended Material definition for visualization purposes
XCAF defines a structure XCAFPrs_Style accumulating visual properties:
- Surface color and transparency, RGBA;
- Curve color, RGB;
- Hidden flag, Boolean.

This structure is filled in by XCAFDoc_ColorTool from Color attributes on the Label (XCAFDoc_ColorGen, XCAFDoc_ColorSurf and XCAFDoc_ColorCurv).
The following sources in XCAF document are actually considered by XCAFPrs::CollectStyleSettings for a given Label
(in ascending order of priority, so that each next item in the list overrides previous one, when both defined):
- Reference Label (Product Label for a given Instance Label);
- Components (for a given Label to an Assembly);
- Layer, where the Label is defined on, if any (using XCAFDoc_LayerTool);
- SHUO structures;
- Label itself;
- Sub-shape Labels.

XCAF structure also considers that sub-entity (Component) inherits a Style of a parent object (Assembly) in the Tree (if Style is not defined for sub-shape).
So that XCAFPrs::CollectStyleSettings() will return an incomplete map when called for a Component without own Style (considering parent Assembly object defines a Style).

In practice, this obscure behavior of XCAFPrs::CollectStyleSettings() may happen only for application-based XCAF document, because within STEP and IGES translators such definition is not possible (and therefore, it is preferred that application would not define such XCAF document to avoid problems with Data Exchange and make Style deduction straight-forward).

There are, however, a context, where existing Style definition is not enough for defining visual properties.
The following attributes are missing for preserving visual properties in 3D Viewer and for Data Exchange capabilities with formats like glTF and OBJ:
1) Common Material definition
   Obsolete material definition used for T&L (Transform and lighting) shading model coming from FFP (Fixed-Function Pipeline); but also implemented via GLSL programs.
2) Metallic-Roughness definition
   Commonly used by real-time Physically-Based Rendering (PBR) engines.
3) BSDF (bidirectional scattering distribution function)
   A PBR material definition for Path-Tracing engines (as used by OCCT itself).

As a shared task across all Material definitions is introduction of Textures - references to external Image files or embedded into XCAF document.

Although only one Material definition can be used at once by Rendering engine for specific object, and Common Material definition is already obsolete, it is still desired supporting several definitions for compatibility reasons (for rendering using faster Shading Model or for Data Exchange with formats supporting one or another Material definition).

Note that extending Rendering capabilities of OCCT 3D Viewer is a dedicated task.
It might be reasonable keeping Graphic3d_MaterialAspect definition independent from XCAF types, since they are following different tasks (Data Exchange and Visualization), though this would imply some code duplication.
Relationship with XCAFPrs_Style, an auxiliary structure transferring visual properties from XCAF layer to OCCT 3D Viewer layer (XCAFPrs_AISObject) should be also examined during implementation; probably, XCAFPrs_Style should store a Handle pointing to Material definition, and existing Color attributes should behave like Graphic3d_MaterialAspect + Graphic3d_AspectFillArea3d::InteriorColor().

Materials are expected to be shared across components in the Assembly Tree, so that it makes sense splitting Materials definition and assignment in 2 parts:
- Dedicated section in the document listing all Materials (probably with a map for a fast lookup, detection of unique materials and a tool to clean up duplicates / unused Materials).
- Refer to a Material (not duplicate) at Component/Layer/Shape Label.

0) Extension to Material definition
 - enum: alphaMode
 - float: alphaCutoff
 - bool: closed primitive group of triangles (solid)
 - bool: backCulling, back face culling flag
 - texture: normalMap, RGB tangent space normal map.

1) Common Material definition
 - vec3: Ambient [Graphic3d_TOR_AMBIENT]
 - vec3: Diffuse (or vec4 considering Alpha) [Graphic3d_TOR_DIFFUSE]
 - vec3: Specular [Graphic3d_TOR_SPECULAR]
 - vec3: Emission [Graphic3d_TOR_EMISSION]
 - float: Shininess
 - float: Transparency/Alpha

2) Metallic-Roughness material
 - vec4: baseColor, base color of the material (or scale factor to the texture)
 - float: metallic, metalness of the material (or scale factor to the texture)
 - float: roughness, roughness of the material (or scale factor to the texture)
 - texture: baseColorTexture, sRGB texture for the base color
 - texture: metallicRoughnessTexture, RG texture packing the metallic and roughness properties together
 - vec3: emissiveFactor
 - texture: emissive, RGB emissive map controls the color and intensity of the light being emitted by the material.
 - texture: occlusion, R occlusion map indicating areas of indirect lighting.

3) BSDF definition [Graphic3d_BSDF]
 - vec4: Kc (Weight of coat specular/glossy BRDF)
 - vec3: Kd (Weight of base diffuse BRDF)
 - vec3: Ks (Weight of base specular/glossy BRDF)
 - vec3: Kt (Weight of base specular/glossy BTDF)
 - vec3: Le (Radiance emitted by the surface)
 - vec4: Absorption (Volume scattering color/density)
 - vec4: FresnelCoat (Parameters of Fresnel reflectance of coat layer)
 - vec4: FresnelBase (Parameters of Fresnel reflectance of base layer)
 - float RefractionIndex
No tags attached.
related to 0023037assigned gka Community Data Exchange - support different materials and transparency in XDE 
related to 0030691verified bugmaster Open CASCADE Data Exchange - implement import of mesh data from files in glTF format 
related to 0030700assigned iko Open CASCADE Visualization, TKOpenGl - support PBR Metallic-Roughness shading model 
Issue History
2018-06-28 11:58kgvNew Issue
2018-06-28 11:58kgvAssigned To => gka
2018-06-28 11:59kgvAssigned Togka => kgv
2018-06-28 11:59kgvStatusnew => assigned
2018-06-28 11:59kgvRelationship addedrelated to 0029296
2018-09-28 14:19kgvRelationship addedrelated to 0030171
2019-02-06 12:51abvRelationship addedrelated to 0023037
2019-05-05 13:15kgvRelationship addedrelated to 0030691
2019-05-07 14:18kgvRelationship addedrelated to 0030699
2019-05-07 14:22kgvRelationship addedrelated to 0030700
2019-07-03 11:30gitNote Added: 0085392
2019-08-13 15:28gitNote Added: 0086227
2019-08-21 16:20gitNote Added: 0086386
2019-08-21 16:56gitNote Added: 0086387
2019-08-22 16:46gitNote Added: 0086417
2019-08-22 17:27gitNote Added: 0086418
2019-08-22 17:49gitNote Added: 0086419
2019-08-22 17:55gitNote Added: 0086420
2019-08-26 15:34gitNote Added: 0086450
2019-09-04 15:54abvTarget Version7.4.0 => 7.5.0*
2019-10-08 20:23gitNote Added: 0087955
2019-10-08 23:07gitNote Added: 0087957
2019-10-09 01:10gitNote Added: 0087958
2019-10-09 01:14gitNote Added: 0087959
2019-10-09 01:35gitNote Added: 0087960
2019-10-09 11:07gitNote Added: 0087965
2019-10-09 11:56gitNote Added: 0087968
2019-10-09 12:29gitNote Added: 0087972
2019-10-09 13:51gitNote Added: 0087974
2019-10-09 14:56kgvNote Added: 0087978
2019-10-09 14:56kgvAssigned Tokgv => gka
2019-10-09 14:56kgvStatusassigned => resolved
2019-10-09 15:54gitNote Added: 0087981
2019-10-09 15:57gitNote Added: 0087982
2019-10-09 16:09gitNote Added: 0087983
2019-10-09 16:14gitNote Added: 0087984
2019-10-09 16:20gitNote Added: 0087985
2019-10-09 16:45gitNote Added: 0087986
2019-10-09 19:17gkaNote Added: 0087990
2019-10-09 19:17gkaAssigned Togka => bugmaster
2019-10-09 19:17gkaStatusresolved => reviewed

Notes
(0085392)
git   
2019-07-03 11:30   
Branch CR29902_0 has been created by kgv.

SHA-1: 7eb29b2a1917995a4138872f595c7e88ec332329


Detailed log of new commits:

Author: kgv
Date: Wed Jul 3 11:28:26 2019 +0300

    0029902: Data Exchange, XCAF - provide extended Material definition for visualization purposes
(0086227)
git   
2019-08-13 15:28   
Branch CR29902_0 has been updated forcibly by kgv.

SHA-1: 51bc6e3113c9745be338ad83e11a7d6af6c9ddc0
(0086386)
git   
2019-08-21 16:20   
Branch CR29902_0 has been updated by kgv.

SHA-1: 5cdae2f875de2cdba6b2322ac21902cd9d26a851


Detailed log of new commits:

Author: kgv
Date: Wed Aug 21 16:17:29 2019 +0300

    Introduced new attribute XCAFDoc_VisMaterial storing visualization material definition.

Author: nds
Date: Thu Aug 15 13:17:18 2019 +0300

    0030901: Visualization - OSD_MemInfo moving memory computation out of the constructor

(0086387)
git   
2019-08-21 16:56   
Branch CR29902_0 has been updated forcibly by kgv.

SHA-1: f4dac03e43701abc838a62be6b1151bfbd4ba391
(0086417)
git   
2019-08-22 16:46   
Branch CR29902_0 has been updated forcibly by kgv.

SHA-1: 6f332a357293db422ad770e4c709b4506c513b0d
(0086418)
git   
2019-08-22 17:27   
Branch CR29902_0 has been updated forcibly by kgv.

SHA-1: 163f6a67bf1a4c627001d7d69e0d2c6bcf95b50b
(0086419)
git   
2019-08-22 17:49   
Branch CR29902_0 has been updated forcibly by kgv.

SHA-1: a553e176efb12fd2153b60975f08aef65bc4513d
(0086420)
git   
2019-08-22 17:55   
Branch CR29902_0 has been updated forcibly by kgv.

SHA-1: 058092bf77dfc2a37150bc66415b111b36425c67
(0086450)
git   
2019-08-26 15:34   
Branch CR29902_0 has been updated forcibly by kgv.

SHA-1: 3ed3d300128e0a74bcf575dd05df109605377b8f
(0087955)
git   
2019-10-08 20:23   
Branch CR29902_1 has been created by kgv.

SHA-1: 2454e934ae6b5898103ab579f4623f985fd23721


Detailed log of new commits:

Author: kgv
Date: Wed Jul 3 11:28:26 2019 +0300

    0029902: Data Exchange, XCAF - provide extended Material definition for visualization purposes
    
    Introduced new attribute XCAFDoc_VisMaterial storing visualization material definition.
    
    XCAFPrs_Style has been exteneded Material() property.
    XCAFPrs_AISObject::DispatchStyles() maps new XCAFPrs_Style::Material() property onto graphics aspects.
    
    RWGltf_GltfJsonParser and RWObj_CafReader now put Material definition into XCAF document instead of a color label.
    RWGltf_MaterialMetallicRoughness - added missing properties AlphaMode, AlphaCutOff and IsDoubleSided;
    fixed default values in constructor for Metallic and Roughness.
    
    Added commands XGetAllVisMaterials, XGetVisMaterial, XAddVisMaterial,
    XRemoveVisMaterial, XSetVisMaterial, XUnsetVisMaterial for working with
    new visualization materials table in the document.
(0087957)
git   
2019-10-08 23:07   
Branch CR29902_1 has been updated forcibly by kgv.

SHA-1: f2ab47fe568276fa8cd59eb261ff99a1f2a5e12a
(0087958)
git   
2019-10-09 01:10   
Branch CR29902_1 has been updated forcibly by kgv.

SHA-1: 9e91d7b0b23244f45699c2c6c5f69bb69a1dee90
(0087959)
git   
2019-10-09 01:14   
Branch CR29902_2 has been created by kgv.

SHA-1: 972728a09bf18f4b93c1fec288e4b514bf4596c0


Detailed log of new commits:

Author: kgv
Date: Wed Jul 3 11:28:26 2019 +0300

    0029902: Data Exchange, XCAF - provide extended Material definition for visualization purposes
    
    Introduced new attribute XCAFDoc_VisMaterial storing visualization material definition.
    
    XCAFPrs_Style has been exteneded Material() property.
    XCAFPrs_AISObject::DispatchStyles() maps new XCAFPrs_Style::Material() property onto graphics aspects.
    
    RWGltf_GltfJsonParser and RWObj_CafReader now put Material definition into XCAF document instead of a color label.
    RWGltf_MaterialMetallicRoughness - added missing properties AlphaMode, AlphaCutOff and IsDoubleSided;
    fixed default values in constructor for Metallic and Roughness.
    
    Added commands XGetAllVisMaterials, XGetVisMaterial, XAddVisMaterial,
    XRemoveVisMaterial, XSetVisMaterial, XUnsetVisMaterial for working with
    new visualization materials table in the document.
(0087960)
git   
2019-10-09 01:35   
Branch CR29902_2 has been updated forcibly by kgv.

SHA-1: 9e5ddc9edb1751362a84ec07678e1aa2e0501d96
(0087965)
git   
2019-10-09 11:07   
Branch CR29902_2 has been updated forcibly by kgv.

SHA-1: 988b2b6e1742044f9c3cf99f3f69c6126b0e87a8
(0087968)
git   
2019-10-09 11:56   
Branch CR29902_2 has been updated forcibly by kgv.

SHA-1: 7678f3a555442c6527513dcedb2c08731278afc0
(0087972)
git   
2019-10-09 12:29   
Branch CR29902_2 has been updated forcibly by kgv.

SHA-1: 8ca1c1c9933f99f7d7838d27f4afac9682cb432a
(0087974)
git   
2019-10-09 13:51   
Branch CR29902_2 has been updated forcibly by kgv.

SHA-1: d88f2bfc404c036172df07d285d04444d230c1d3
(0087978)
kgv   
2019-10-09 14:56   
Patch is ready for review.
(0087981)
git   
2019-10-09 15:54   
Branch CR29902_2 has been updated forcibly by kgv.

SHA-1: b6e4388b62d5732d2fba663517fdb54ac8e33de9
(0087982)
git   
2019-10-09 15:57   
Branch CR29902_2 has been updated forcibly by kgv.

SHA-1: 5c253b40171404e86c5ff56394a59535a4b5f7bd
(0087983)
git   
2019-10-09 16:09   
Branch CR29902_2 has been updated forcibly by kgv.

SHA-1: ad2e9ee57fe9a8e3a74647f1f2642fb5dd8fbccf
(0087984)
git   
2019-10-09 16:14   
Branch CR29902_2 has been updated forcibly by kgv.

SHA-1: b942c6471a70de3a1ae8fca43708c71291aaef8f
(0087985)
git   
2019-10-09 16:20   
Branch CR29902_2 has been updated forcibly by kgv.

SHA-1: 62d78b9c48e65296d826823b7cda5820b417e0fa
(0087986)
git   
2019-10-09 16:45   
Branch CR29902_2 has been updated forcibly by kgv.

SHA-1: 5336d2b7a38e310c964e95f0ffe38ed9fbb4cc6e
(0087990)
gka   
2019-10-09 19:17   
Branches CR29902_2 OCCT Internal repository and CR29902_2 in the OCCT Products Internal repository were reviewed.