mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-03 17:56:21 +03:00
0024855: Revision of parameters of standard materials
Improve consistency and visual appearance of predefined OCCT materials in various rendering modes, including ray-tracing: - Increase the specular exponents (shininesses) for metallic surfaces: Brass, Bronze, Copper, Gold, Pewter, Silver, Steel, Chrome, Aluminum. - Revise specular colors for metals: Copper, Gold, Aluminum, Silver (according to "Real-Time Rendering, 3rd Edition", AK Peters 2008). - Increase diffuse reflection of metals: Silver, Aluminum, Chrome (to make them brighter in OpenGL mode). - Extend Material definition by Refraction Index. Advanced rendering methods based on shaders or ray-tracing can utilize it to produce refraction effects. In addition: - Introduce three translucent materials: Water, Glass, and Diamond. - Add Charcoal for modeling dark diffuse surfaces. Add new TCL-based sample (materials.tcl) and test case (tests/v3d/materials/bug24855).
This commit is contained in:
parent
013a854956
commit
44c7c33eb0
87
samples/tcl/materials.tcl
Normal file
87
samples/tcl/materials.tcl
Normal file
@ -0,0 +1,87 @@
|
||||
# Script displays properties of different materials available in OCCT
|
||||
|
||||
set THE_MATERIALS {brass bronze copper gold jade neon_phc pewter obsidian plaster plastic satin silver steel stone chrome aluminium water glass diamond charcoal}
|
||||
set THE_COLORS {default red green blue1}
|
||||
set THE_ROW_DIST 35
|
||||
|
||||
proc drawLabels {} {
|
||||
set x 20
|
||||
set y 15
|
||||
set r 25
|
||||
set g 25
|
||||
set b 25
|
||||
foreach aMatIter $::THE_MATERIALS {
|
||||
vdrawtext "$aMatIter" $x $y 0 $r $g $b 2 1 000 0 14 1 Arial
|
||||
incr y 10
|
||||
}
|
||||
set x 40
|
||||
set y 5
|
||||
foreach aColIter $::THE_COLORS {
|
||||
if { $aColIter == "red" } {
|
||||
set r 255
|
||||
set g 0
|
||||
set b 0
|
||||
} elseif { $aColIter == "green" } {
|
||||
set r 0
|
||||
set g 255
|
||||
set b 0
|
||||
} elseif { $aColIter == "blue1" } {
|
||||
set r 0
|
||||
set g 0
|
||||
set b 255
|
||||
}
|
||||
vdrawtext "$aColIter" $x $y 0 $r $g $b 1 1 000 0 14 1 Arial
|
||||
incr x $::THE_ROW_DIST
|
||||
}
|
||||
}
|
||||
|
||||
proc drawObjects {theRow theColor} {
|
||||
set aSize 4
|
||||
set aCtr -2
|
||||
set aCounter 0
|
||||
set x [expr 30 + $theRow * $::THE_ROW_DIST]
|
||||
set y 15
|
||||
foreach aMatIter $::THE_MATERIALS {
|
||||
set aSph s${theRow}_${aCounter}
|
||||
set aBox b${theRow}_${aCounter}
|
||||
uplevel #0 psphere $aSph $aSize
|
||||
uplevel #0 box $aBox $aCtr $aCtr $aCtr $aSize $aSize $aSize
|
||||
uplevel #0 ttranslate $aSph $x $y 0
|
||||
uplevel #0 ttranslate $aBox [expr $x + 10] $y 0
|
||||
uplevel #0 vdisplay -noredraw $aSph $aBox
|
||||
uplevel #0 vsetmaterial -noredraw $aSph $aBox $aMatIter
|
||||
if {$theColor != ""} {
|
||||
uplevel #0 vsetcolor -noredraw $aSph $aBox $theColor
|
||||
}
|
||||
incr aCounter
|
||||
incr y 10
|
||||
}
|
||||
}
|
||||
|
||||
# setup 3D viewer content
|
||||
pload MODELING VISUALIZATION
|
||||
|
||||
catch { vclose View1 }
|
||||
vinit View1 w=768 h=768
|
||||
vclear
|
||||
vtop
|
||||
vglinfo
|
||||
vsetgradientbg 180 200 255 180 180 180 2
|
||||
vlight change 0 pos -1 1 1
|
||||
vsetdispmode 1
|
||||
|
||||
# adjust scene bounding box
|
||||
box bnd 0 0 0 180 210 1
|
||||
vdisplay -noredraw bnd
|
||||
vsetdispmode bnd 0
|
||||
vfit
|
||||
vremove -noredraw bnd
|
||||
|
||||
# draw spheres and boxes with different materials
|
||||
drawLabels
|
||||
drawObjects 0 ""
|
||||
drawObjects 1 red
|
||||
drawObjects 2 green
|
||||
drawObjects 3 blue1
|
||||
#vfit
|
||||
vzfit
|
@ -115,32 +115,39 @@ is
|
||||
|
||||
enumeration NameOfMaterial is
|
||||
NOM_BRASS, -- laiton (PHYSIC)
|
||||
NOM_BRONZE, -- bronze (PHYSIC)
|
||||
NOM_COPPER, -- cuivre (PHYSIC)
|
||||
NOM_GOLD, -- or (PHYSIC)
|
||||
NOM_BRONZE, -- bronze (PHYSIC)
|
||||
NOM_COPPER, -- cuivre (PHYSIC)
|
||||
NOM_GOLD, -- or (PHYSIC)
|
||||
|
||||
NOM_PEWTER, -- etain (PHYSIC)
|
||||
NOM_PEWTER, -- etain (PHYSIC)
|
||||
|
||||
NOM_PLASTER, -- platre (GENERIC)
|
||||
NOM_PLASTIC, -- plastic (GENERIC)
|
||||
NOM_PLASTER, -- platre (GENERIC)
|
||||
NOM_PLASTIC, -- plastic (GENERIC)
|
||||
|
||||
NOM_SILVER, -- argent (PHYSIC)
|
||||
NOM_SILVER, -- argent (PHYSIC)
|
||||
|
||||
NOM_STEEL, -- acier (PHYSIC)
|
||||
NOM_STEEL, -- acier (PHYSIC)
|
||||
|
||||
NOM_STONE, -- pierre (PHYSIC)
|
||||
NOM_STONE, -- pierre (PHYSIC)
|
||||
|
||||
NOM_SHINY_PLASTIC, -- plastique brillant (GENERIC)
|
||||
NOM_SATIN, -- satin (GENERIC)
|
||||
NOM_METALIZED, -- metallise New (GENERIC)
|
||||
NOM_NEON_GNC, -- neon New (GENERIC)
|
||||
NOM_CHROME, -- chrome New (PHYSIC)
|
||||
NOM_ALUMINIUM, -- aluminium New (PHYSIC)
|
||||
NOM_OBSIDIAN, -- obsidian New (PHYSIC)
|
||||
NOM_NEON_PHC, -- neon New (PHYSIC)
|
||||
NOM_JADE, -- jade New (PHYSIC)
|
||||
NOM_DEFAULT,
|
||||
NOM_UserDefined -- owner material
|
||||
NOM_SHINY_PLASTIC, -- plastique brillant (GENERIC)
|
||||
NOM_SATIN, -- satin (GENERIC)
|
||||
NOM_METALIZED, -- metallise New (GENERIC)
|
||||
NOM_NEON_GNC, -- neon New (GENERIC)
|
||||
NOM_CHROME, -- chrome New (PHYSIC)
|
||||
NOM_ALUMINIUM, -- aluminium New (PHYSIC)
|
||||
NOM_OBSIDIAN, -- obsidian New (PHYSIC)
|
||||
NOM_NEON_PHC, -- neon New (PHYSIC)
|
||||
NOM_JADE, -- jade New (PHYSIC)
|
||||
|
||||
NOM_CHARCOAL,
|
||||
|
||||
NOM_WATER,
|
||||
NOM_GLASS,
|
||||
NOM_DIAMOND,
|
||||
|
||||
NOM_DEFAULT,
|
||||
NOM_UserDefined -- owner material
|
||||
end NameOfMaterial;
|
||||
---Purpose: Types of aspect materials.
|
||||
---Category: Enumerations
|
||||
|
@ -143,6 +143,15 @@ is
|
||||
-- negative value or greater than 1.0.
|
||||
raises MaterialDefinitionError from Graphic3d is static;
|
||||
|
||||
SetRefractionIndex ( me : in out;
|
||||
theValue : Real from Standard )
|
||||
---Level: Public
|
||||
---Purpose: Modifies the refraction index of the material.
|
||||
-- Category: Methods to modify the class definition
|
||||
-- Warning: Raises MaterialDefinitionError if <theValue> is a
|
||||
-- lesser than 1.0.
|
||||
raises MaterialDefinitionError from Graphic3d is static;
|
||||
|
||||
SetColor ( me : in out;
|
||||
AColor : Color from Quantity )
|
||||
is static;
|
||||
@ -313,7 +322,14 @@ is
|
||||
---Purpose: Returns the transparency coefficient of the surface.
|
||||
---Category: Inquire methods
|
||||
|
||||
Emissive ( me )
|
||||
RefractionIndex ( me )
|
||||
returns Real from Standard
|
||||
is static;
|
||||
---Level: Public
|
||||
---Purpose: Returns the refraction index of the material
|
||||
---Category: Inquire methods
|
||||
|
||||
Emissive ( me )
|
||||
returns Real from Standard
|
||||
is static;
|
||||
---Level: Public
|
||||
@ -409,7 +425,7 @@ is
|
||||
|
||||
Init ( me : out; AName : NameOfMaterial from Graphic3d) is private;
|
||||
|
||||
--
|
||||
--
|
||||
|
||||
fields
|
||||
|
||||
@ -449,47 +465,44 @@ fields
|
||||
-- Iris Advanced Graphics, unit D
|
||||
--
|
||||
--
|
||||
-- the coefficient of diffuse reflection, the colour, and the activity
|
||||
MyDiffuseCoef : ShortReal from Standard;
|
||||
MyDiffuseColor : Color from Quantity;
|
||||
MyDiffuseActivity : Boolean from Standard;
|
||||
-- the coefficient of diffuse reflection, the colour, and the activity
|
||||
myDiffuseCoef : ShortReal from Standard;
|
||||
myDiffuseColor : Color from Quantity;
|
||||
myDiffuseActivity : Boolean from Standard;
|
||||
|
||||
-- the coefficient of ambient reflection, the colour
|
||||
-- and the activity
|
||||
MyAmbientCoef : ShortReal from Standard;
|
||||
MyAmbientColor : Color from Quantity;
|
||||
MyAmbientActivity : Boolean from Standard;
|
||||
-- the coefficient of ambient reflection, the colour and the activity
|
||||
myAmbientCoef : ShortReal from Standard;
|
||||
myAmbientColor : Color from Quantity;
|
||||
myAmbientActivity : Boolean from Standard;
|
||||
|
||||
-- the coefficient of specular reflection, the colour
|
||||
-- and the activity
|
||||
MySpecularCoef : ShortReal from Standard;
|
||||
MySpecularColor : Color from Quantity;
|
||||
MySpecularActivity : Boolean from Standard;
|
||||
|
||||
-- the coefficient of emissive reflection
|
||||
MyEmissiveCoef : ShortReal from Standard;
|
||||
MyEmissiveColor : Color from Quantity;
|
||||
MyEmissiveActivity : Boolean from Standard;
|
||||
-- the coefficient of specular reflection, the colour and the activity
|
||||
mySpecularCoef : ShortReal from Standard;
|
||||
mySpecularColor : Color from Quantity;
|
||||
mySpecularActivity : Boolean from Standard;
|
||||
|
||||
-- the coefficient of transparency
|
||||
MyTransparencyCoef : ShortReal from Standard;
|
||||
-- the coefficient of emissive reflection
|
||||
myEmissiveCoef : ShortReal from Standard;
|
||||
myEmissiveColor : Color from Quantity;
|
||||
myEmissiveActivity : Boolean from Standard;
|
||||
|
||||
-- the coefficient of luminosity
|
||||
MyShininess : ShortReal from Standard;
|
||||
-- the coefficient of transparency and refraction index
|
||||
myTransparencyCoef : ShortReal from Standard;
|
||||
myRefractionIndex : ShortReal from Standard;
|
||||
|
||||
-- the specular exponent
|
||||
myShininess : ShortReal from Standard;
|
||||
|
||||
-- the coeficient of reflexion for the environment texture
|
||||
MyEnvReflexion : ShortReal from Standard;
|
||||
|
||||
-- the type of material
|
||||
--MyMaterialType : Boolean from Standard;
|
||||
MyMaterialType : TypeOfMaterial from Graphic3d;
|
||||
-- the coeficient of reflexion for the environment texture
|
||||
myEnvReflexion : ShortReal from Standard;
|
||||
|
||||
-- the Name of material
|
||||
MyMaterialName : NameOfMaterial from Graphic3d;
|
||||
MyRequestedMaterialName : NameOfMaterial from Graphic3d;
|
||||
-- the type of material
|
||||
myMaterialType : TypeOfMaterial from Graphic3d;
|
||||
|
||||
-- the string name of the material
|
||||
MyStringName : AsciiString from TCollection;
|
||||
-- the Name of material
|
||||
myMaterialName : NameOfMaterial from Graphic3d;
|
||||
myRequestedMaterialName : NameOfMaterial from Graphic3d;
|
||||
|
||||
-- the string name of the material
|
||||
myStringName : AsciiString from TCollection;
|
||||
|
||||
end MaterialAspect;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1034,12 +1034,13 @@ void Graphic3d_Structure::SetPrimitivesAspect (const Handle(Graphic3d_AspectFill
|
||||
// Back Material
|
||||
const Graphic3d_MaterialAspect& aBack = theAspFill->BackMaterial();
|
||||
// Light specificity
|
||||
myCStructure->ContextFillArea.Back.Shininess = float (aBack.Shininess());
|
||||
myCStructure->ContextFillArea.Back.Ambient = float (aBack.Ambient());
|
||||
myCStructure->ContextFillArea.Back.Diffuse = float (aBack.Diffuse());
|
||||
myCStructure->ContextFillArea.Back.Specular = float (aBack.Specular());
|
||||
myCStructure->ContextFillArea.Back.Transparency = float (aBack.Transparency());
|
||||
myCStructure->ContextFillArea.Back.Emission = float (aBack.Emissive());
|
||||
myCStructure->ContextFillArea.Back.Shininess = float (aBack.Shininess());
|
||||
myCStructure->ContextFillArea.Back.Ambient = float (aBack.Ambient());
|
||||
myCStructure->ContextFillArea.Back.Diffuse = float (aBack.Diffuse());
|
||||
myCStructure->ContextFillArea.Back.Specular = float (aBack.Specular());
|
||||
myCStructure->ContextFillArea.Back.Transparency = float (aBack.Transparency());
|
||||
myCStructure->ContextFillArea.Back.RefractionIndex = float (aBack.RefractionIndex());
|
||||
myCStructure->ContextFillArea.Back.Emission = float (aBack.Emissive());
|
||||
|
||||
// Reflection mode
|
||||
myCStructure->ContextFillArea.Back.IsAmbient = (aBack.ReflectionMode (Graphic3d_TOR_AMBIENT) ? 1 : 0);
|
||||
@ -1077,12 +1078,13 @@ void Graphic3d_Structure::SetPrimitivesAspect (const Handle(Graphic3d_AspectFill
|
||||
// Front Material
|
||||
const Graphic3d_MaterialAspect& aFront = theAspFill->FrontMaterial();
|
||||
// Light specificity
|
||||
myCStructure->ContextFillArea.Front.Shininess = float (aFront.Shininess());
|
||||
myCStructure->ContextFillArea.Front.Ambient = float (aFront.Ambient());
|
||||
myCStructure->ContextFillArea.Front.Diffuse = float (aFront.Diffuse());
|
||||
myCStructure->ContextFillArea.Front.Specular = float (aFront.Specular());
|
||||
myCStructure->ContextFillArea.Front.Transparency = float (aFront.Transparency());
|
||||
myCStructure->ContextFillArea.Front.Emission = float (aFront.Emissive());
|
||||
myCStructure->ContextFillArea.Front.Shininess = float (aFront.Shininess());
|
||||
myCStructure->ContextFillArea.Front.Ambient = float (aFront.Ambient());
|
||||
myCStructure->ContextFillArea.Front.Diffuse = float (aFront.Diffuse());
|
||||
myCStructure->ContextFillArea.Front.Specular = float (aFront.Specular());
|
||||
myCStructure->ContextFillArea.Front.Transparency = float (aFront.Transparency());
|
||||
myCStructure->ContextFillArea.Front.RefractionIndex = float (aFront.RefractionIndex());
|
||||
myCStructure->ContextFillArea.Front.Emission = float (aFront.Emissive());
|
||||
|
||||
// Reflection mode
|
||||
myCStructure->ContextFillArea.Front.IsAmbient = (aFront.ReflectionMode (Graphic3d_TOR_AMBIENT) ? 1 : 0);
|
||||
|
@ -62,8 +62,9 @@ typedef struct {
|
||||
float Emission;
|
||||
int IsEmission;
|
||||
|
||||
float Transparency;
|
||||
float Shininess;
|
||||
float Transparency;
|
||||
float RefractionIndex;
|
||||
|
||||
float EnvReflexion;
|
||||
|
||||
|
@ -33,7 +33,7 @@ namespace
|
||||
static OPENGL_SURF_PROP THE_DEFAULT_MATERIAL =
|
||||
{
|
||||
0.2F, 0.8F, 0.1F, 0.0F, // amb, diff, spec, emsv
|
||||
1.0F, 10.0F, 0.0F, // trans, shine, env_reflexion
|
||||
1.0F, 10.0F, 1.0F, 0.0F, // trans, shine, index, env_reflexion
|
||||
0, // isphysic
|
||||
(OPENGL_AMBIENT_MASK | OPENGL_DIFFUSE_MASK | OPENGL_SPECULAR_MASK), // color_mask
|
||||
{{ 1.0F, 1.0F, 1.0F, 1.0F }}, // ambient color
|
||||
@ -110,6 +110,7 @@ void OpenGl_AspectFace::convertMaterial (const CALL_DEF_MATERIAL& theMat,
|
||||
// trans = 1. => transparent
|
||||
// in OpenGl it is opposite.
|
||||
theSurf.trans = 1.0f - theMat.Transparency;
|
||||
theSurf.index = theMat.RefractionIndex;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
|
@ -42,7 +42,7 @@ static const TEL_POFFSET_PARAM THE_DEFAULT_POFFSET = { Aspect_POM_Fill, 1.0F, 0.
|
||||
struct OPENGL_SURF_PROP
|
||||
{
|
||||
float amb, diff, spec, emsv;
|
||||
float trans, shine;
|
||||
float trans, shine, index;
|
||||
float env_reflexion;
|
||||
int isphysic;
|
||||
unsigned int color_mask;
|
||||
|
@ -16,7 +16,7 @@ vsetdispmode 1
|
||||
vfit
|
||||
vsetcolor result GREEN
|
||||
|
||||
checkcolor $x_coord $y_coord 0.45 0.95 0.05
|
||||
checkcolor $x_coord $y_coord 0.00 0.83 0.00
|
||||
|
||||
set 3dviewer 1
|
||||
|
||||
|
@ -22,14 +22,14 @@ vdisplay b
|
||||
vsetdispmode 1
|
||||
vsetcolor b ANTIQUEWHITE
|
||||
|
||||
checkcolor 24 55 0.75686198472976685 0 0
|
||||
checkcolor 16 76 0 0 0.50195999999999996
|
||||
checkcolor 26 107 0.18039199709892273 0.5686269998550415 0.180392
|
||||
checkcolor 34 114 0.29803898930549622 0.29803898930549622 0.298039
|
||||
checkcolor 24 131 0.61960697174072266 0 0
|
||||
checkcolor 18 139 0.21568599343299866 0 0.78431300000000004
|
||||
checkcolor 56 160 1 0 0
|
||||
checkcolor 30 160 0 1 0.90980300000000003
|
||||
checkcolor 24 55 0.753 0.000 0.000
|
||||
checkcolor 16 76 0.000 0.000 1.000
|
||||
checkcolor 25 107 0.000 1.000 0.000
|
||||
checkcolor 34 114 0.298 0.298 0.298
|
||||
checkcolor 24 131 0.922 0.000 0.000
|
||||
checkcolor 18 139 0.145 0.000 0.855
|
||||
checkcolor 56 160 1.000 0.000 0.000
|
||||
checkcolor 30 160 0.188 0.761 0.698
|
||||
|
||||
set only_screen 1
|
||||
|
||||
|
@ -23,8 +23,8 @@ vsetcolor p_2 green
|
||||
vsettransparency p_1 0.5
|
||||
vsettransparency p_1 0
|
||||
|
||||
checkcolor 120 150 1 0.3 0.06
|
||||
checkcolor 180 273 0.39 1 0.058
|
||||
checkcolor 120 150 0.831 0.000 0.000
|
||||
checkcolor 180 273 0.000 0.753 0.000
|
||||
|
||||
set only_screen 1
|
||||
|
||||
|
@ -43,6 +43,6 @@ if {"$aWireColor" != "HOTPINK"} {
|
||||
if {"$anEdgeColor" != "RED"} {
|
||||
puts "Error: wrong Edge color"
|
||||
}
|
||||
if {"$aFaceColor" != "LEMONCHIFFON1"} {
|
||||
if {"$aFaceColor" != "GRAY62"} {
|
||||
puts "Error: wrong Face color"
|
||||
}
|
||||
|
@ -15,13 +15,13 @@ set y2 269
|
||||
set x3 348
|
||||
set y3 238
|
||||
|
||||
set KUB_R 0.45098000764846802
|
||||
set KUB_G 0.32941100001335144
|
||||
set KUB_B 1
|
||||
set KUB_R 0.00
|
||||
set KUB_G 0.00
|
||||
set KUB_B 0.83
|
||||
|
||||
set LINE_R 0
|
||||
set LINE_G 0
|
||||
set LINE_B 1
|
||||
set LINE_R 0.00
|
||||
set LINE_G 0.00
|
||||
set LINE_B 1.00
|
||||
|
||||
|
||||
box b1 10 10 10
|
||||
|
@ -12,3 +12,4 @@
|
||||
012 voxel
|
||||
013 glsl
|
||||
014 raytrace
|
||||
015 materials
|
||||
|
43
tests/v3d/materials/bug24855
Normal file
43
tests/v3d/materials/bug24855
Normal file
@ -0,0 +1,43 @@
|
||||
puts "========"
|
||||
puts "OCC24855: Revision of parameters of standard materials"
|
||||
puts "========"
|
||||
|
||||
# custom shapes
|
||||
set aShape [locate_data_file occ/Top.brep]
|
||||
|
||||
# setup 3D viewer content
|
||||
vinit View1 w=768 h=768
|
||||
vglinfo
|
||||
|
||||
vsetgradientbg 180 200 255 180 180 180 2
|
||||
|
||||
# display shape
|
||||
vlight change 0 pos -1 1 1
|
||||
restore $aShape s
|
||||
vsetdispmode 1
|
||||
vdisplay s
|
||||
vfit
|
||||
|
||||
proc testmat {dirname filename} {
|
||||
foreach {aMatIter} {brass bronze copper gold jade neon_phc pewter obsidian plaster plastic satin silver steel stone chrome aluminium charcoal} {
|
||||
vsetmaterial -noredraw s $aMatIter
|
||||
vdump $dirname/${filename}_${aMatIter}.png
|
||||
}
|
||||
}
|
||||
|
||||
# make material screenshots
|
||||
testmat $imagedir $casename
|
||||
|
||||
vshaderprog s phong
|
||||
testmat $imagedir ${casename}_phong
|
||||
|
||||
vraytrace 1
|
||||
vtextureenv on 5
|
||||
vsetraytracemode aa=1 refl=1
|
||||
|
||||
testmat $imagedir ${casename}_rt
|
||||
|
||||
vclear
|
||||
vraytrace 0
|
||||
vtextureenv off
|
||||
source $env(CASROOT)/samples/tcl/materials.tcl
|
Loading…
x
Reference in New Issue
Block a user