mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-04 18:06:22 +03:00
0031682: Visualization - Prs3d_ShadingAspect::SetTransparency() has no effect with Graphic3d_TOSM_UNLIT shading model
Prs3d_ShadingAspect::SetTransparency() now sets transparency also to interior color. AIS_RubberBand now uses Graphic3d_TOSM_UNLIT.
This commit is contained in:
parent
6d8f9f4a49
commit
9f013fee98
@ -44,6 +44,7 @@ AIS_RubberBand::AIS_RubberBand()
|
||||
myDrawer->SetLineAspect (new Prs3d_LineAspect (Quantity_NOC_WHITE, Aspect_TOL_SOLID, 1.0));
|
||||
myDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
|
||||
myDrawer->ShadingAspect()->SetMaterial (Graphic3d_NOM_PLASTIC);
|
||||
myDrawer->ShadingAspect()->Aspect()->SetShadingModel (Graphic3d_TOSM_UNLIT);
|
||||
myDrawer->ShadingAspect()->Aspect()->SetInteriorStyle (Aspect_IS_EMPTY);
|
||||
myDrawer->ShadingAspect()->Aspect()->SetAlphaMode (Graphic3d_AlphaMode_Blend);
|
||||
myDrawer->ShadingAspect()->SetTransparency (1.0);
|
||||
@ -66,6 +67,7 @@ AIS_RubberBand::AIS_RubberBand (const Quantity_Color& theLineColor,
|
||||
myDrawer->SetLineAspect (new Prs3d_LineAspect (theLineColor, theLineType, theWidth));
|
||||
myDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
|
||||
myDrawer->ShadingAspect()->SetMaterial (Graphic3d_NOM_PLASTIC);
|
||||
myDrawer->ShadingAspect()->Aspect()->SetShadingModel (Graphic3d_TOSM_UNLIT);
|
||||
myDrawer->ShadingAspect()->Aspect()->SetInteriorStyle (Aspect_IS_EMPTY);
|
||||
myDrawer->ShadingAspect()->Aspect()->SetAlphaMode (Graphic3d_AlphaMode_Blend);
|
||||
myDrawer->ShadingAspect()->SetTransparency (1.0);
|
||||
@ -91,6 +93,7 @@ AIS_RubberBand::AIS_RubberBand (const Quantity_Color& theLineColor,
|
||||
myDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
|
||||
myDrawer->ShadingAspect()->SetMaterial (Graphic3d_NOM_PLASTIC);
|
||||
myDrawer->ShadingAspect()->SetColor (theFillColor);
|
||||
myDrawer->ShadingAspect()->Aspect()->SetShadingModel (Graphic3d_TOSM_UNLIT);
|
||||
myDrawer->ShadingAspect()->Aspect()->SetInteriorStyle (Aspect_IS_SOLID);
|
||||
myDrawer->ShadingAspect()->Aspect()->SetAlphaMode (Graphic3d_AlphaMode_Blend);
|
||||
myDrawer->ShadingAspect()->SetTransparency (theTransparency);
|
||||
|
@ -119,7 +119,7 @@ AIS_ViewController::AIS_ViewController()
|
||||
myAnchorPointPrs2->SetZLayer (Graphic3d_ZLayerId_Topmost);
|
||||
myAnchorPointPrs2->SetMutable (true);
|
||||
|
||||
myRubberBand = new AIS_RubberBand (Quantity_NOC_LIGHTBLUE, Aspect_TOL_SOLID, Quantity_NOC_LIGHTBLUE, 0.4, 1.0);
|
||||
myRubberBand = new AIS_RubberBand (Quantity_NOC_LIGHTBLUE, Aspect_TOL_SOLID, Quantity_NOC_LIGHTBLUE4, 0.5, 1.0);
|
||||
myRubberBand->SetZLayer (Graphic3d_ZLayerId_TopOSD);
|
||||
myRubberBand->SetTransformPersistence (new Graphic3d_TransformPers (Graphic3d_TMF_2d, Aspect_TOTP_LEFT_UPPER));
|
||||
myRubberBand->SetDisplayMode (0);
|
||||
|
@ -144,12 +144,14 @@ void Prs3d_ShadingAspect::SetTransparency (const Standard_Real theValue,
|
||||
|| theModel == Aspect_TOFM_BOTH_SIDE)
|
||||
{
|
||||
myAspect->ChangeFrontMaterial().SetTransparency (Standard_ShortReal(theValue));
|
||||
myAspect->SetInteriorColor (Quantity_ColorRGBA (myAspect->InteriorColor(), 1.0f - Standard_ShortReal(theValue)));
|
||||
}
|
||||
|
||||
if (theModel == Aspect_TOFM_BACK_SIDE
|
||||
|| theModel == Aspect_TOFM_BOTH_SIDE)
|
||||
{
|
||||
myAspect->ChangeBackMaterial().SetTransparency (Standard_ShortReal(theValue));
|
||||
myAspect->SetBackInteriorColor (Quantity_ColorRGBA (myAspect->BackInteriorColor(), 1.0f - Standard_ShortReal(theValue)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,19 +8,21 @@ vclose ALL
|
||||
vinit View1 -width 912 -height 912
|
||||
|
||||
# define spheres with a rough triangulation to easily distinguish Shading Models
|
||||
psphere p1 10
|
||||
copytranslate p2 p1 40 0 0
|
||||
copytranslate p3 p1 20 20 0
|
||||
copytranslate p4 p1 0 40 0
|
||||
copytranslate p5 p1 40 40 0
|
||||
compound p1 p2 p3 p4 p5 ss
|
||||
psphere p0 10
|
||||
copytranslate p11 p0 0 0 0
|
||||
copytranslate p12 p0 40 0 0
|
||||
copytranslate p21 p0 0 20 0
|
||||
copytranslate p22 p0 40 20 0
|
||||
copytranslate p31 p0 0 40 0
|
||||
copytranslate p32 p0 40 40 0
|
||||
compound p11 p12 p21 p22 p31 p32 ss
|
||||
incmesh ss 1
|
||||
vdefaults -autoTriang 0
|
||||
|
||||
# display objects
|
||||
vdisplay -dispMode 1 p1 p2 p3 p4 p5
|
||||
vdrawparray p6 triangles v 0 55 0 v 0 75 0 v 20 55 0 v 0 55 0 v 0 75 0 v 0 55 20 v 0 55 0 v 0 55 20 v 20 55 0 v 0 75 0 v 0 55 20 v 20 55 0
|
||||
vdrawparray p7 triangles v 40 55 0 v 40 75 0 v 60 55 0 v 40 55 0 v 40 75 0 v 40 55 20 v 40 55 0 v 40 55 20 v 60 55 0 v 40 75 0 v 40 55 20 v 60 55 0
|
||||
vdisplay -dispMode 1 p11 p12 p21 p22 p31 p32
|
||||
vdrawparray p41 triangles v 0 55 0 v 0 75 0 v 20 55 0 v 0 55 0 v 0 75 0 v 0 55 20 v 0 55 0 v 0 55 20 v 20 55 0 v 0 75 0 v 0 55 20 v 20 55 0
|
||||
vdrawparray p42 triangles v 40 55 0 v 40 75 0 v 60 55 0 v 40 55 0 v 40 75 0 v 40 55 20 v 40 55 0 v 40 55 20 v 60 55 0 v 40 75 0 v 40 55 20 v 60 55 0
|
||||
vtop
|
||||
vrotate -0.9 0.1 0
|
||||
vfit
|
||||
@ -32,24 +34,30 @@ vcaps -ffp 0
|
||||
vdump $::imagedir/${::casename}_defaults.png
|
||||
|
||||
# customize shading models
|
||||
vaspects p1 -setShadingModel VERTEX
|
||||
vdrawtext t1 Graphic3d_TOSM_VERTEX -pos 10 5 10 -color RED -aspect BOLD
|
||||
vaspects p2 -setShadingModel FRAGMENT
|
||||
vdrawtext t2 Graphic3d_TOSM_FRAGMENT -pos 50 5 10 -color RED -aspect BOLD
|
||||
vaspects p3 -setShadingModel DEFAULT
|
||||
vdrawtext t3 Graphic3d_TOSM_DEFAULT -pos 30 25 10 -color RED -aspect BOLD
|
||||
vaspects p4 -setShadingModel UNLIT
|
||||
vdrawtext t4 Graphic3d_TOSM_UNLIT -pos 10 45 10 -color RED -aspect BOLD
|
||||
vaspects p5 -setShadingModel FACET
|
||||
vdrawtext t5 Graphic3d_TOSM_FACET -pos 50 45 10 -color RED -aspect BOLD
|
||||
vaspects p6 -setShadingModel DEFAULT
|
||||
vdrawtext t6 Graphic3d_TOSM_DEFAULT -pos 10 65 10 -color RED -aspect BOLD
|
||||
vaspects p7 -setShadingModel FACET
|
||||
vdrawtext t7 Graphic3d_TOSM_FACET -pos 50 65 10 -color RED -aspect BOLD
|
||||
vdisplay -topmost t1 t2 t3 t4 t5 t6 t7
|
||||
vaspects p11 -setShadingModel VERTEX
|
||||
vdrawtext t11 Graphic3d_TOSM_VERTEX -pos 10 5 10 -color RED -aspect BOLD
|
||||
vaspects p12 -setShadingModel FRAGMENT
|
||||
vdrawtext t12 Graphic3d_TOSM_FRAGMENT -pos 50 5 10 -color RED -aspect BOLD
|
||||
|
||||
vaspects p21 -setShadingModel PBR
|
||||
vdrawtext t21 Graphic3d_TOSM_PBR -pos 10 25 10 -color RED -aspect BOLD
|
||||
vaspects p22 -setShadingModel PBR_FACET
|
||||
vdrawtext t22 Graphic3d_TOSM_PBR_FACET -pos 50 25 10 -color RED -aspect BOLD
|
||||
|
||||
vaspects p31 -setShadingModel UNLIT
|
||||
vdrawtext t31 Graphic3d_TOSM_UNLIT -pos 10 45 10 -color RED -aspect BOLD
|
||||
vaspects p32 -setShadingModel FACET
|
||||
vdrawtext t32 Graphic3d_TOSM_FACET -pos 50 45 10 -color RED -aspect BOLD
|
||||
vaspects p41 -setShadingModel VERTEX
|
||||
vdrawtext t41 Graphic3d_TOSM_VERTEX -pos 10 65 10 -color RED -aspect BOLD
|
||||
vaspects p42 -setShadingModel FACET
|
||||
vdrawtext t42 Graphic3d_TOSM_FACET -pos 50 65 10 -color RED -aspect BOLD
|
||||
vdisplay -topmost t11 t12 t21 t22 t31 t32 t41 t42
|
||||
|
||||
vcaps -ffp 1
|
||||
vdump $::imagedir/${::casename}_ffp.png
|
||||
|
||||
vcaps -ffp 0
|
||||
vlight -change 1 -intensity 0.1
|
||||
vrenderparams -shadingModel pbr
|
||||
vdump $::imagedir/${::casename}.png
|
||||
|
65
tests/v3d/glsl/transp1
Normal file
65
tests/v3d/glsl/transp1
Normal file
@ -0,0 +1,65 @@
|
||||
puts "========"
|
||||
puts "Test various Shading Models assigned per-object with transparency"
|
||||
puts "========"
|
||||
|
||||
# setup viewer
|
||||
vclear
|
||||
vclose ALL
|
||||
vinit View1 -width 912 -height 912
|
||||
|
||||
# define spheres with a rough triangulation to easily distinguish Shading Models
|
||||
psphere p0 10
|
||||
box b0 4 4 4
|
||||
copytranslate p11 p0 0 0 0
|
||||
copytranslate b11 b0 0 0 0
|
||||
copytranslate p12 p0 40 0 0
|
||||
copytranslate b12 b0 40 0 0
|
||||
copytranslate p21 p0 0 20 0
|
||||
copytranslate b21 b0 0 20 0
|
||||
copytranslate p22 p0 40 20 0
|
||||
copytranslate b22 b0 40 20 0
|
||||
copytranslate p31 p0 0 40 0
|
||||
copytranslate b31 b0 0 40 0
|
||||
copytranslate p32 p0 40 40 0
|
||||
copytranslate b32 b0 40 40 0
|
||||
compound p11 p12 p21 p22 p31 p32 b11 b12 b21 b22 b31 b32 ss
|
||||
incmesh ss 1
|
||||
vdefaults -autoTriang 0
|
||||
|
||||
# display objects
|
||||
vdisplay -dispMode 1 p11 p12 p21 p22 p31 p32 b11 b12 b21 b22 b31 b32
|
||||
vdrawparray p41 triangles v 0 55 0 v 0 75 0 v 20 55 0 v 0 55 0 v 0 75 0 v 0 55 20 v 0 55 0 v 0 55 20 v 20 55 0 v 0 75 0 v 0 55 20 v 20 55 0
|
||||
vdrawparray p42 triangles v 40 55 0 v 40 75 0 v 60 55 0 v 40 55 0 v 40 75 0 v 40 55 20 v 40 55 0 v 40 55 20 v 60 55 0 v 40 75 0 v 40 55 20 v 60 55 0
|
||||
vtop
|
||||
vrotate -0.9 0.1 0
|
||||
vfit
|
||||
|
||||
set aMatProps "-setMaterial DIAMOND -setColor GRAY70 -setTransparency 0.8"
|
||||
|
||||
# customize shading models
|
||||
vaspects b11 b12 b21 b22 b31 b32 -setShadingModel FRAGMENT -setColor RED
|
||||
|
||||
vaspects p11 -setShadingModel VERTEX {*}$aMatProps
|
||||
vdrawtext t11 Graphic3d_TOSM_VERTEX -pos 10 5 10 -color RED -aspect BOLD
|
||||
vaspects p12 -setShadingModel FRAGMENT {*}$aMatProps
|
||||
vdrawtext t12 Graphic3d_TOSM_FRAGMENT -pos 50 5 10 -color RED -aspect BOLD
|
||||
|
||||
vaspects p21 -setShadingModel PBR {*}$aMatProps
|
||||
vdrawtext t21 Graphic3d_TOSM_PBR -pos 10 25 10 -color RED -aspect BOLD
|
||||
vaspects p22 -setShadingModel PBR_FACET {*}$aMatProps
|
||||
vdrawtext t22 Graphic3d_TOSM_PBR_FACET -pos 50 25 10 -color RED -aspect BOLD
|
||||
|
||||
vaspects p31 -setShadingModel UNLIT {*}$aMatProps
|
||||
vdrawtext t31 Graphic3d_TOSM_UNLIT -pos 10 45 10 -color RED -aspect BOLD
|
||||
vaspects p32 -setShadingModel FACET {*}$aMatProps
|
||||
vdrawtext t32 Graphic3d_TOSM_FACET -pos 50 45 10 -color RED -aspect BOLD
|
||||
vaspects p41 -setShadingModel VERTEX {*}$aMatProps
|
||||
vdrawtext t41 Graphic3d_TOSM_VERTEX -pos 10 65 10 -color RED -aspect BOLD
|
||||
vaspects p42 -setShadingModel FACET {*}$aMatProps
|
||||
vdrawtext t42 Graphic3d_TOSM_FACET -pos 50 65 10 -color RED -aspect BOLD
|
||||
vdisplay -topmost t11 t12 t21 t22 t31 t32 t41 t42
|
||||
|
||||
vlight -change 0 -intensity 1.0
|
||||
vlight -change 1 -intensity 0.5
|
||||
vrenderparams -shadingModel pbr
|
||||
vdump $::imagedir/${::casename}.png
|
Loading…
x
Reference in New Issue
Block a user