New Graphics Features and Improvements

James Lane
FrontEnd Graphics(3D) Developer

(RowDefault[, (Spacer1), , (Spacer1), ])  #WolframTechConf

Overview

New features and improvements in FrontEnd graphics

LabeledGraphicsBox >> better label placement around Graphics and Graphics3D with graphics style selection

Multisample anti-aliasing + Depth Peeling  >> improved anti-aliasing rendering transparency and layer rendering

AxisObject' s RangeBehavior option >> control whether AxisObjects influence the PlotRange or ImageRange

WFR Function: Visualize3DView >> gaining insight into camera setup and how Graphics3D view options influence the final rendered image

LabeledGraphicsBox

Improved label placement around Graphics(3D) with graphics-style selection

Plot[2 Sin[x],{x,0,10},PlotLabel->"This is my very impressive plot of 2 Sin[x] which should look very pretty and ... oh dear this really is a very long label but it would be nice to see the full label",LabelStyle->Directive[Bold,Orange]]

Labeled[Graphics3D[{Sphere[]}],{"This a labeled sphere","Left","Right","Bottom"},{Top,Left,Right,Bottom}]

LabeledGraphicsBox

Improved label placement around Graphics(3D) with graphics-style selection

LabeledGraphicsBox instead wraps long labels - based on width, i.e. horizontally constrained

RawBoxes[
LabeledGraphicsBox[ToBoxes[Plot[2 Sin[x],{x,0,10},LabelStyle->Directive[Bold,Orange]]],
"This is my very impressive plot of 2 Sin[x] which should look very pretty and ... oh dear this really is a very long label but it would be nice to see the full label",
Top,
LabelStyle->Directive[Bold,Orange]]]

compared to PlotLabel:

Labels not just at the top - simple placement control

LabeledGraphicsBox

Improved label placement around Graphics(3D) with graphics-style selection

Graphics-style selection with resize handles that can be used to resize the whole construct

RawBoxes[
LabeledGraphicsBox[ToBoxes[Graphics3D[{Sphere[]}]],{"This is a labeled sphere","Left","Right","Bottom"}, {Top,Left,Right,Bottom}]]

a low-level(Box level) grouping construct that represents a Graphics(3D) box with label(s) attached to it

LabeledGraphicsBox could be one possible low-level representation of Labeled

compared to Labeled:

Labeled[
Graphics3D[{Sphere[]}],
{"This a labeled sphere","Left","Right","Bottom"},{Top,Left,Right,Bottom}]

LabeledGraphicsBox

Improved label placement around Graphics(3D) with graphics-style selection

(Re)sizing Behavior

Keeps Labels tight around the Graphic

Resizing a LabeledGraphicsBox will automatically resize the GraphicsBox to use the full available space, minus the space required to draw labels.

RawBoxes[LabeledGraphicsBox[
ToBoxes[Graphics[{Disk[]},Background->LightYellow]],
ToBoxes[Graphics[{Line[{{0,0},{10,1}}]},Background->LightBlue]],Top]]

Avoids jumpiness when resizing

LabeledGraphicsBox

Improved label placement around Graphics(3D) with graphics-style selection

(Re)sizing Behavior

Setting the ImageSize of the LabeledGraphicsBox fills the space with the labels and fits the GraphicsChild to fill remaining space:

RawBoxes[
LabeledGraphicsBox[ToBoxes[Graphics[Circle[{0,0}],Background->LightBlue]],1234567890,
ImageSize->{100,200},Background->LightYellow]]

LabeledGraphicsBox ImageSize constrains the ImageSize of the Graphics:

RawBoxes[LabeledGraphicsBox[ToBoxes[Graphics[Circle[{0,0}],ImageSize->{1000,1000},Background->LightBlue]],1234567890,ImageSize->{100,200},Background->LightYellow]]

LabeledGraphicsBox

Control label placement around Graphics(3D) with graphics-style selection and (re)sizing behavior that keeps labels tight to the graphic

Options and usage analogous to Labeled[]

Use Graphics, Graphics3D, CheckBox...as labels

More exotic placements e.g. in the top and right, but these will be able to be over the Graphics one day

RawBoxes[
LabeledGraphicsBox[GraphicsBox[CircleBox[],ImageSize->200],
{Graphics3DBox[SphereBox[{0,0,0}],ImageSize->50],
CheckboxBox[True]},
{{Top,Right},Bottom}]]

LabeledGraphicsBox

Control label placement around Graphics(3D) with graphics-style selection and (re)sizing behavior that keeps labels tight to the graphic

Spacings

RawBoxes[LabeledGraphicsBox[GraphicsBox[{CircleBox[{0,0},1]},Background->RGBColor[1,1,0.85]],{"Bottom","Top","Left","RightTop"},{Bottom,Top,Left,{Right,Top}},Background->LightBlue,Spacings->{60,30}]]

LabeledGraphicsBox

Control label placement around Graphics(3D) with graphics-style selection and (re)sizing behavior that keeps labels tight to the graphic

Nested LabeledGraphicsBox

RawBoxes[
LabeledGraphicsBox[
LabeledGraphicsBox[Graphics3DBox[CuboidBox[{0,0,0}]],{"Nested Left","Nested Top","Nested Right","Nested Bottom"},{Left,Top,Right,Bottom}],{GraphicsBox[DiskBox[{0,0}], ImageSize->Tiny], GraphicsBox[{RGBColor[1,0,0],CircleBox[{0,0}]},ImageSize->Tiny]},{Top,Left}]]

LabeledGraphicsBox as label

RawBoxes[LabeledGraphicsBox[LabeledGraphicsBox[Graphics3DBox[CuboidBox[{0,0,0}]],{Left,Top,Right,Bottom},{Left,Top,Right,Bottom}],{LabeledGraphicsBox[GraphicsBox[DiskBox[{0,0}], ImageSize->Tiny],{Left,Right,Top,Bottom},{Left,Right,Top,Bottom}], GraphicsBox[{RGBColor[1,0,0],CircleBox[{0,0}]},ImageSize->Tiny]},{Top,Left}]]

Inset LabeledGraphicsBox

RawBoxes[GraphicsBox[{InsetBox[
LabeledGraphicsBox[Graphics3DBox[SphereBox[{0,0,0}]],"Top",Top]
]}]]

Use multiple levels of nested LabeledGraphicsBox using nested LabeledGraphicsBox as labels :

RawBoxes[NestList[LabeledGraphicsBox[#,{#,#},{Top,Left}]&,GraphicsBox[DiskBox[{0,0}],ImageSize->30],2]]

Multisample Anti-aliasing + Depth Peeling

Improved anti-aliasing(smoother edges) for transparency rendering

({{ SSAA x 4, MSAA x 8, MSAA x 32}, {, , }})

Multisample Anti-aliasing + Depth Peeling

Improved anti-aliasing; smoother edges in transparent and peeled layer rendering

Better Quality Anti-aliasing

More samples depending on hardware

Better sample distribution

({{ ,  SSAA , MSAA}, {Max # Samples, 4, 4,8,16,32}, {Sampling, center sampling, Poisson sample distribution
good pixel area coverage
}})

({{ SSAA x 4, MSAA x 8, MSAA x 32}, {, , }})

Multisample Anti-aliasing + Depth Peeling

Improved anti-aliasing; smoother edges in transparent and peeled layer rendering

Less noticeable on high resolution monitors for low MSAA sample counts

Multisample Anti-aliasing + Depth Peeling

Improved anti-aliasing; smoother edges in transparent and peeled layer rendering

Faster

e . g . ImageSize -> {1100.`, 1106.7150360399025`} x 60 trials using MSAA with 4 Samples

Depends on ImageSize and MSAA Sample Count

Implemented in our OpenGL(14.1), Metal (14.2) and DirectX (next release) Renderers

AxisObject’s RangeBehavior Option

Control whether AxisObjects pushes out the PlotRange or ImageRange and how it is clipped

AxisObjects push out the PlotRange by default:

Graphics[{Disk[{0.5,0.5},0.1],
AxisObject[{"Vertical",0.0, {0.5, 1.5}},BaseStyle->Orange, TickLabelPositioning->"Tip", RangeBehavior->Automatic]
},Frame->True]

RangeBehavior->Automatic | RangeBehavior->"PlotRange"

Let AxisObjects influence the image range:

Graphics[{Disk[{0.5,0.5},0.1],
AxisObject[{"Vertical",0.0, {0.5, 1.5}},BaseStyle->Orange, TickLabelPositioning->"Tip", RangeBehavior->"ImageRange"]
},Frame->True]

Clip AxisObjects outside of the PlotRange:

Graphics[{Disk[{0.5,0.5},0.1],
AxisObject[{"Vertical",0.0, {0.5, 1.5}},BaseStyle->Orange, TickLabelPositioning->"Tip", RangeBehavior->None]
},Frame->True]

WFR Visualize3DView Function

Gain insight into camera setup and how Graphics3D view options influence the final rendered image

an example

thePlot=ParametricPlot3D[{Sin[u],Cos[u],u/10},{u,0,20},Axes->None,Method->{"LookAroundControl"->"Orbit"}]

Aim: view the following scene from inside the box

insideThePlot=Show[thePlot,ViewVector->{{0,0,1},{1,0,-1}}]

Problem: rotating causes spiral to distort. What’s going on ? ? ?

Visualize3DView@insideThePlot

AbsoluteOptions[insideThePlot,ViewAngle]

Visualize3DView@Show[insideThePlot,ViewAngle->60Degree]

Notes

xyzTP[{θ_,ϕ_}]:={Cos[θ]*Sin[ϕ],Sin[θ]*Sin[ϕ],Cos[ϕ]};
UswapVandK[{x_,y_,z_}]:=(1/(1+z))*{{-y^2-z*(1+z),x*y,x*(1+z)},{x*y,-x^2-z*(1+z),y*(1+z)},{x*(1+z),y*(1+z),z*(1+z)}};

Clear[cpPrelim];
cpPrelim[legends_]:=cpPrelim[contours,legends]=ContourPlot[Cos[ϕ]-((Sin[ϕ] Cos[θ])^2-(Sin[ϕ] Sin[θ])^2),{θ,0,2 π},{ϕ,0,π},Contours->41,ColorFunction->"TemperatureMap",PlotLegends->legends,AspectRatio->Automatic,PlotPoints->30,ContourLabels->None];

cpPrelim[Automatic];

If[$VersionNumber<12,cp:=Graphics3D[GraphicsComplex[xyzTP[#]&/@cpPrelim[None][[1,1]],cpPrelim[None][[1,2]]]],cp:=Graphics3D[GraphicsComplex[xyzTP[#]&/@cpPrelim[None][[1,1,1]],cpPrelim[None][[1,1,2]]]]];

eye=100 xyzTP[{20 Degree,65 Degree}];

60 Trials of 61 excluding 1st trial which is an outlier

MSAA={0.10138`,0.102146`,0.104589`,0.104664`,0.103564`,0.100327`,0.099803`,0.100057`,0.099701`,0.102637`,0.107051`,0.103673`,0.104686`,0.102479`,0.102535`,0.104156`,0.102097`,0.101769`,0.104232`,0.11269`,0.104275`,0.103533`,0.136422`,0.099501`,0.100261`,0.103609`,0.106387`,0.102307`,0.100783`,0.102971`,0.101037`,0.103745`,0.101064`,0.100309`,0.098717`,0.102061`,0.100786`,0.09913`,0.102931`,0.10228`,0.101174`,0.101868`,0.099559`,0.119575`,0.098584`,0.100518`,0.103347`,0.10024`,0.103219`,0.102976`,0.102564`,0.113305`,0.101218`,0.099185`,0.103167`,0.119544`,0.103377`,0.105745`,0.101908`,0.103568`};
SSAA={0.174538`,0.172988`,0.173413`,0.168842`,0.172173`,0.16955`,0.174782`,0.170208`,0.169354`,0.168118`,0.16918`,0.169627`,0.173647`,0.174698`,0.168675`,0.167552`,0.170993`,0.168424`,0.168777`,0.167077`,0.17301`,0.173873`,0.170916`,0.168172`,0.171117`,0.167667`,0.172849`,0.172901`,0.168171`,0.170035`,0.169383`,0.168246`,0.167461`,0.170046`,0.167579`,0.167819`,0.169362`,0.168252`,0.167251`,0.176955`,0.168698`,0.168361`,0.170585`,0.166926`,0.168093`,0.169636`,0.167886`,0.170395`,0.172494`,0.168734`,0.170639`,0.169003`,0.169017`,0.174435`,0.170688`,0.170402`,0.172945`,0.17177`,0.168603`,0.166563`};

BoxWhiskerChart[{MSAA,SSAA},ChartLabels->Placed[{"MSAA","SSAA"},Below]]

MS=;
SS=;