WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas...

67
AMD Developer Summit Session: WT-4071 GPU Accelerated 3D Graphics for Java Kevin Rushforth & Chien Yang Oracle Corporation
  • date post

    18-Oct-2014
  • Category

    Technology

  • view

    748
  • download

    3

description

Presentation WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain at the AMD Developer Summit (APU13) Nov. 11-13, 2013.

Transcript of WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas...

Page 1: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13 1

AMD Developer Summit Session: WT-4071 GPU Accelerated 3D Graphics for Java

Kevin Rushforth & Chien Yang Oracle Corporation

Page 2: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 2

Program Agenda

! JavaFX Graphics Overview ! Transforms ! Camera and Coordinate System ! Z-buffer (depth test) ! Movable Camera

Page 3: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 3

Program Agenda

! 3D Geometry ! 3D Attributes ! 3D Picking ! MSAA ! SubScene ! Wrap-up / Q&A

Page 4: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 4

JavaFX Graphics Overview

"  Scene graph model "  Hierarchy of group and leaf (graphic primitive) nodes

"  Leaf nodes have individual graphical attributes

"  Group nodes can have collective attributes

"  Parent/child directed graph similar to component trees

Page 5: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 5

JavaFX Graphics Overview

"  Capabilities "  Transformation (translate, rotate, scale and shear)

"  Animation (timeline and transitions)

"  Effects (blurs, drop shadows, color filters, etc.)

"  Rendering attributes

Page 6: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 6

JavaFX Graphics Overview

"  Primary graphical node types "  Shape (rectangle, circle, path, etc.)

"  Text (a specialized form of Shape)

"  ImageView

"  MediaView

Page 7: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 7

JavaFX SW Block Diagram

Application

JavaFX Scene Graph API

Prism Renderer

D3D

OpenG

L

SW

JavaFX UI Controls

Page 8: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 8

A Simple JavaFX Scene Graph Stage

fill : SILVER

Root

ImageView

effect : DropShadowtranslateX : 100translateY : 75

Scene

Page 9: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 9

Simple Scenegraph Demo

Page 10: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 10

JavaFX 3D Features in JDK 7 (FX 2)

"  3D Transforms

"  Depth Buffer (Z-Buffer)

"  Perspective Camera

Page 11: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 11

How To Query 3D Support

"  3D is an optional feature "  Runs on AMD/ATI, Intel and NVIDIA with Pixel Shader 3 support

"  Certain cards and drivers “blacklisted”

"  Use ConditionalFeature.SCENE3D to check "  Indicates that 3D is available on the platform

"  Perspective camera, 3D transforms, depth test ignored on platform without 3D support

Page 12: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 12

JavaFX on Windows

"  Windows Vista / 7 / 8 (32-bit or 64-bit)

"  HW acceleration via DirectX 9.0c "  GPUs include: AMD, Intel HD, NVIDIA

"  May need newer driver (especially for Intel HD)

"  Run with -Dprism.verbose=true to check

Page 13: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 13

JavaFX on Mac OS X

"  Mac OS X 10.7 (Lion) and 10.8 (Mountain Lion)

"  HW acceleration via OpenGL 2.0 "  GPUs include: AMD, Intel HD, NVIDIA

"  Run with -Dprism.verbose=true to check

Page 14: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 14

JavaFX on Linux

"  Ubuntu 12.04 LTS or later, OEL 6 or later

"  HW acceleration via OpenGL 2.0 "  GPUs include: AMD, NVIDIA

"  Requires vendor-supplied driver

"  Run with -Dprism.verbose=true to check

"  Support for Intel HD, open source drivers in a later release

"  You can try it now: -Dprism.forceGPU=true

Page 15: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 15

JavaFX on Embedded

"  HW acceleration via OpenGL ES 2

"  3D is not supported for FX 8, but will be in future "  Requires chipset that supports non-power-of-two textures

"  You can try it now on Raspberry Pi: -Dcom.sun.javafx.experimental.embedded.3d=true

Page 16: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 16

3D Transforms: Node "  Transform Properties

"  layoutX, layoutY – X and Y translation used for layout

"  translateX, translateY, translateZ – X, Y and Z translation

"  rotate – angle of rotation in degrees (about Node center)

"  rotationAxis – axis about which rotation is done (default Z-axis)

"  scaleX, scaleY, scaleZ – X, Y and Z scale (about Node center)

"  transforms – A list of Transform objects (applied in order)

Page 17: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 17

Transforms

"  Transform objects

"  Translate(x, y, z, pivotX, pivotY, pivotZ)

"  Scale(x, y, z, pivotX, pivotY, pivotZ)

"  Rotate(angle, pivotX, pivotY, pivotZ, axis)

"  Affine(mxx, mxy, mxz, tx, myx, myy, myz, ty, mzx, mzy, mzz, tz)

Page 18: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 18

Order of Transform Operations Translate(layoutX+translateX, layoutY+translateY, translateZ)

Translate(pivotX, pivotY, pivotZ) // computed center of node

Rotate(rotate, rotationAxis)

Scale(scaleX, scaleY, scaleZ)

Translate(-pivotX, -pivotY, -pivotZ) // computed center of node

transform[0]

transform[1]

...

Page 19: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 19

Depth Buffer (Z-buffer)

"  Objects rendered in scene graph order

"  Render order defines z order for 2D scene

"  Render order != z value of objects in 3D scene (unless you reorder the scene graph)

"  Depth buffer will sort objects based on their z value

"  Sort is done per pixel by GPU

Page 20: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 20

Depth Buffer (Z-buffer)

Group

A

CB

Group

D

2D Rendering Order: A, B, C, D“D” is on top

Page 21: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 21

Depth Buffer (Z-buffer)

"  Objects rendered in scene graph order

"  Render order defines z order for 2D scene

"  Render order != z value of objects in 3D scene (unless you reorder the scene graph)

"  Depth buffer will sort objects based on their z value

"  Sort is done per pixel by GPU

Page 22: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 22

Depth Buffer (Z-buffer)

Group

A

CB

Group

D

Rendering Order: A, B, C, D

Z = 0

Z = 3Z = 1 Z = 2

Actual Z Order: B, D, C, A “A” should be on top, but “D” will be

Page 23: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 23

Depth Buffer (Z-buffer)

"  Objects rendered in scene graph order

"  Render order defines z order for 2D scene

"  Render order != z value of objects in 3D scene (unless you reorder the scene graph)

"  Depth buffer will sort objects based on their z value

"  Sort is done per pixel by GPU

Page 24: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 24

Depth Buffer (Z-buffer)

"  Construct scene with depth buffer attribute

"  Node has depthTest property "  DISABLE, ENABLE and INHERIT

"  depthTest is only used on Scene with a depth buffer

"  Its default value is INHERIT

"  If depthTest = INHERIT, depth testing is enabled if it is enabled for its parent node (or its parent node is null)

Page 25: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 25

Depth Test Demo

Page 26: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 26

VideoCube Demo

Page 27: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 27

Cameras and Coordinate System

"  ParallelCamera Class

"  A viewing volume for a parallel (ortho) projection; a rectangular box

"  Located at center of the scene; looks along the positive Z-axis

"  Origin in the upper left corner of the scene with the Y-axis pointing down and the Z-axis pointing away from the viewer (into the screen)

"  The units are in pixel coordinates

"  This is the default if no camera is specified

Page 28: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 28

Cameras and Coordinate System

"  PerspectiveCamera Class

"  A viewing volume for a perspective projection; a truncated right pyramid

-  Field of view property (default = 30 degrees)

"  It is always located at center of the scene and looks along the positive Z-axis

"  Origin in the upper left corner of the scene with the Y-axis pointing down and the Z-axis pointing away from the viewer (into the screen)

"  The units are in pixel coordinates at the projection plane (Z=0)

Page 29: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 29

JavaFX Coordinate System

"  Differences from typical 3D coordinate systems

"  Origin: top-left vs. center

"  Direction: Y down vs. Y up

"  Unit: pixel vs. normalized [-1, 1]

Page 30: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 30

Coordinate System

Axis Group

X Axis

Y Axis

Z Axis

Y Axis

3D Group

Box

TranslateRotateScale

Coordinate SystemConverter Group

Page 31: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 31

Coordinate System Demo

Page 32: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 32

New JavaFX 3D Features in JDK 8 "  Movable cameras

"  3D primitives (e.g., meshes, predefined solids)

"  3D attributes (e.g., lights, materials)

"  3D picking

"  Scene Antialiasing

"  SubScene

Page 33: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 33

Camera Class Hierarchy

"  javafx.scene.Node

"  javafx.scene.Camera

-  javafx.scene.ParallelCamera -  javafx.scene.PerspectiveCamera

Page 34: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 34

Movable Camera

"  Camera is now a Node

"  Add to scene graph to move the camera -  Position and aim camera using transforms -  New “fixed eye” mode for 3D scenes

"  Non-moving camera need not be added to scene graph

"  New properties for near & far clipping plane

Page 35: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 35

Specifying a Fixed Camera

// Create a camera and set it on the Scene Camera camera = new PerspectiveCamera(); scene.setCamera(camera);

Page 36: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 36

Specifying a Movable Camera // Create a movable camera and set it on the Scene Camera camera = new PerspectiveCamera(true); scene.setCamera(camera); // Add camera to scene graph (so it can move) Group cameraGroup = new Group(); cameraGroup.getChildren().add(camera); root.getChildren().add(cameraGroup);

// Rotate the camera camera.rotate(45);

// Move the cameraGroup (camera moves with it) cameraGroup.setTranslateZ(-75);

Page 37: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 37

Movable Camera Demo

Page 38: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 38

3D Shapes

"  FX 2 only has 2D shapes (with 3D transforms)

"  FX 8 adds 3D shapes

"  User-defined shapes "  Predefined shapes

Page 39: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 39

Shape3D Class Hierarchy

"  javafx.scene.Node

"  javafx.scene.shape.Shape3D

-  javafx.scene.shape.MeshView -  javafx.scene.shape.Box -  javafx.scene.shape.Cylinder -  javafx.scene.shape.Sphere

Page 40: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 40

Shape3D Class Hierarchy, continued

"  java.lang.Object

"  javafx.scene.shape.Mesh

-  javafx.scene.shape.TriangleMesh

Page 41: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 41

TriangleMesh "  Geometry

"  A set of positions "  A set of texture coordinates

"  A set of faces (triangles) that describe the topology

"  Smoothing group "  Used to group triangles that are part of same curved surface "  Hard edges between triangles in different smoothing groups

"  Sharable among multiple MeshView nodes

Page 42: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 42

Defining a MeshView // Create the arrays of positions, texCoords float[] positions = createPositions(); float[] texCoords = createUVs(); // Create faces (indices into the positions, texCoord arrays) int[] faces = createFaces(); // Create a mesh TriangleMesh mesh = new TriangleMesh(); mesh.getPositions.setAll(positions); mesh.getTexCoords.setAll(texCoords); mesh.getFaces.setAll(faces); // Create meshView MeshView mv = new MeshView(mesh);

Page 43: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 43

MeshView Demo

Page 44: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 44

Using Predefined Shapes // Create a sphere with the given radius Sphere sphere = new Sphere(0.3); // Create a sphere with the given radius, number of divisions Sphere sphere = new Sphere(0.3, 40); // Create a cylinder with the given radius, and height Sphere sphere = new Cylinder(0.2, 0.8); // Create a box with the given width, height, and depth Box box = new Box(0.5, 0.5, 0.5); // NOTE: All 3D shapes are centered at (0,0,0)

Page 45: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 45

Predefined Shapes Demo

Page 46: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 46

3D Attributes

"  Lights

"  Materials

"  Used to specify the appearance of a 3D shape "  Face culling

"  Drawing mode (fill versus wireframe)

Page 47: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 47

Light Class Hierarchy

"  javafx.scene.Node

"  javafx.scene.LightBase

-  javafx.scene.AmbientLight -  javafx.scene.PointLight

Page 48: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 48

3D Attributes: Lights

"  Defined as nodes in the scene graph

"  Scene contains a set of active lights

"  Default light provided when the set is empty "  Each light contains a set of affected nodes (scope)

"  If a Parent is in the set, all children are affected "  Default is root node of Scene

"  Each Shape3D affected by up to 3 lights (in FX 8)

Page 49: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 49

Defining Lights // Create point light and add it to the Scene PointLight light = new PointLight(); light.setColor(Color.RED); scene.getLights().add(light);

// Add light to scene graph (so it can move) Group lightGroup = new Group(); lightGroup.getChildren().add(light); root.getChildren().add(lightGroup); // Rotate the light light.rotate(45);

// Move the lightGroup (light moves with it) lightGroup.setTranslateZ(-75);

Page 50: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 50

Lighting Demo

Page 51: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 51

Material Class Hierarchy

"  java.lang.Object

"  javafx.scene.paint.Material

-  javafx.scene.paint.PhongMaterial

Page 52: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 52

3D Attributes: PhongMaterial

"  Contains the following properties:

"  Diffuse color, diffuse map "  Specular color, specular map "  Specular power "  Bump map "  Self-illumination map

"  Sharable among multiple Shape3D nodes

Page 53: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 53

Defining Materials // Create material Material mat = new PhongMaterial(); Image diffuseMap = new Image("diffuseMap.png"); Image bumpMap = new Image("normalMap.png"); // Set material properties mat.setDiffuseMap(diffuseMap); mat.setBumpMap(normalMap); mat.setSpecularColor(Color.WHITE); // Use the material for a shape shape3d.setMaterial(mat);

Page 54: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 54

Materials Demo

Page 55: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 55

Scene Antialiasing

"  In 2D, we use pixel shaders for alpha-blended AA

"  This doesn’t work for 3D

"  Alpha blending doesn’t play nice with depth test

"  Solution: Scene antialiasing (e.g., MSAA)

"  Render multiple samples per pixel

"  Filter the result when drawing to the screen

"  Requires hardware support

Page 56: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 56

Scene AA Demo

Page 57: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 57

SubScene Hierarchy

"  javafx.scene.Node

"  javafx.scene.SubScene

Page 58: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 58

SubScene

"  Use SubScene node to render part of scene with different camera or attributes (depth test, AA)

"  Used to separate 2D and 3D content

"  Overlay or “heads-up” display for UI controls in a scene with a moving camera

Page 59: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 59

SubScene Demo

Page 60: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 60

3D Picking

"  3D ray picking already used for 2D primitive with PerspectiveCamera

"  This is extended to support picking 3D geometry

"  Additional API provides intersected point

Page 61: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 61

3D Picking Demo

Page 62: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 62

Loading Models

"  Many 3D file formats exist, such as:

"  Obj, Maya, 3D Studio Max, Collada "  We will make sample code available for some of these

"  Members of the community can also write loaders

Page 63: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 63

Loader Demo

Page 64: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 64

Futures

"  More vertex data formats (e.g., normals)

"  More geometry (e.g, cone, 3D text, triangle strips, subdivision surfaces)

"  Advanced lighting and shading

"  Picking API

"  Mixing native (OpenGL, D3D?) rendering with JavaFX

Page 65: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 65

Futures

"  Accelerated mesh animation

"  Loaders

"  Geometry utilities (e.g., vecmath, camera controller)

Page 66: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 66

3D Demo

Page 67: WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 67

Q & A