SlideShare ist ein Scribd-Unternehmen logo
1 von 67
Downloaden Sie, um offline zu lesen
AMD Developer Summit
Session: WT-4071
GPU Accelerated 3D Graphics for Java
Kevin Rushforth & Chien Yang
Oracle Corporation

1

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

Insert Information Protection Policy Classification from Slide 13
Program Agenda
!  JavaFX Graphics Overview
!  Transforms
!  Camera and Coordinate System
!  Z-buffer (depth test)
!  Movable Camera

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
2
Program Agenda
!  3D Geometry
!  3D Attributes
!  3D Picking
!  MSAA
!  SubScene
!  Wrap-up / Q&A

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
3
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

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
4
JavaFX Graphics Overview
" 

Capabilities
" 

Transformation (translate, rotate, scale and shear)

" 

Animation (timeline and transitions)

" 

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

" 

Rendering attributes

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
5
JavaFX Graphics Overview
" 

Primary graphical node types
" 

Shape (rectangle, circle, path, etc.)

" 

Text (a specialized form of Shape)

" 

ImageView

" 

MediaView

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
6
JavaFX SW Block Diagram
Application

JavaFX UI Controls
JavaFX Scene Graph API
Prism Renderer
SW

OpenGL

D3D
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
7
A Simple JavaFX Scene Graph
Stage

Scene

fill : SILVER

Root

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

effect : DropShadow
translateX : 100
translateY : 75
Simple Scenegraph Demo

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
9
JavaFX 3D Features in JDK 7 (FX 2)
" 

3D Transforms

" 

Depth Buffer (Z-Buffer)

" 

Perspective Camera

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
10
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

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
11
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

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
12
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

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
13
JavaFX on Linux
" 

Ubuntu 12.04 LTS or later, OEL 6 or later

" 

HW acceleration via OpenGL 2.0
" 

" 

Requires vendor-supplied driver

" 

" 

GPUs include: AMD, NVIDIA

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

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
14
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

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
15
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)

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
16
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)

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
17
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]
...
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
18
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

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
19
Depth Buffer (Z-buffer)
Group
A

Group
B
C

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

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

D
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

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
21
Depth Buffer (Z-buffer)
Group
A

Group

Z=0

B
Z=3

C
Z=1

D
Z=2

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

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
22
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

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
23
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)

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

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

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
26
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

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
27
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)

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
28
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]

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
29
Coordinate System
Coordinate System
Converter Group

Axis Group

Translate
Rotate
Scale

3D Group

X Axis
Z Axis
Y Axis
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
30

Box
Coordinate System Demo

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
31
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

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
32
Camera Class Hierarchy
" 

javafx.scene.Node
" 

javafx.scene.Camera
- 

javafx.scene.ParallelCamera

- 

javafx.scene.PerspectiveCamera

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
33
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

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
34
Specifying a Fixed Camera

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

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
35
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);
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
36
Movable Camera Demo

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
37
3D Shapes
" 

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

" 

FX 8 adds 3D shapes
" 

User-defined shapes

" 

Predefined shapes

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
38
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

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
39
Shape3D Class Hierarchy, continued
" 

java.lang.Object
" 

javafx.scene.shape.Mesh
- 

javafx.scene.shape.TriangleMesh

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

Geometry
" 

" 

A set of texture coordinates

" 

" 

A set of positions
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

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
41
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);
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
42
MeshView Demo

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
43
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)

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

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
45
3D Attributes
" 

Lights

" 

Materials
" 

Used to specify the appearance of a 3D shape

" 

Face culling

" 

Drawing mode (fill versus wireframe)

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
46
Light Class Hierarchy
" 

javafx.scene.Node
" 

javafx.scene.LightBase
- 

javafx.scene.AmbientLight

- 

javafx.scene.PointLight

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
47
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)

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
48
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);
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
49
Lighting Demo

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
50
Material Class Hierarchy
" 

java.lang.Object
" 

javafx.scene.paint.Material
- 

javafx.scene.paint.PhongMaterial

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
51
3D Attributes: PhongMaterial
" 

Contains the following properties:
" 
" 

Specular color, specular map

" 

Specular power

" 

Bump map

" 
" 

Diffuse color, diffuse map

Self-illumination map

Sharable among multiple Shape3D nodes

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
52
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);

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

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
54
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

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

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

javafx.scene.Node
" 

javafx.scene.SubScene

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
57
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

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

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
59
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

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
60
3D Picking Demo

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
61
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

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

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
63
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

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

Accelerated mesh animation

" 

Loaders

" 

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

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

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

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

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

HSA HSAIL Introduction Hot Chips 2013
HSA HSAIL Introduction  Hot Chips 2013 HSA HSAIL Introduction  Hot Chips 2013
HSA HSAIL Introduction Hot Chips 2013
 
PL-4047, Big Data Workload Analysis Using SWAT and Ipython Notebooks, by Moni...
PL-4047, Big Data Workload Analysis Using SWAT and Ipython Notebooks, by Moni...PL-4047, Big Data Workload Analysis Using SWAT and Ipython Notebooks, by Moni...
PL-4047, Big Data Workload Analysis Using SWAT and Ipython Notebooks, by Moni...
 
GS-4108, Direct Compute in Gaming, by Bill Bilodeau
GS-4108, Direct Compute in Gaming, by Bill BilodeauGS-4108, Direct Compute in Gaming, by Bill Bilodeau
GS-4108, Direct Compute in Gaming, by Bill Bilodeau
 
PL-4043, Accelerating OpenVL for Heterogeneous Platforms, by Gregor Miller
PL-4043, Accelerating OpenVL for Heterogeneous Platforms, by Gregor MillerPL-4043, Accelerating OpenVL for Heterogeneous Platforms, by Gregor Miller
PL-4043, Accelerating OpenVL for Heterogeneous Platforms, by Gregor Miller
 
HSA-4123, HSA Memory Model, by Ben Gaster
HSA-4123, HSA Memory Model, by Ben GasterHSA-4123, HSA Memory Model, by Ben Gaster
HSA-4123, HSA Memory Model, by Ben Gaster
 
HC-4018, How to make the most of GPU accessible memory, by Paul Blinzer
HC-4018, How to make the most of GPU accessible memory, by Paul BlinzerHC-4018, How to make the most of GPU accessible memory, by Paul Blinzer
HC-4018, How to make the most of GPU accessible memory, by Paul Blinzer
 
The Small Batch (and other) solutions in Mantle API, by Guennadi Riguer, Mant...
The Small Batch (and other) solutions in Mantle API, by Guennadi Riguer, Mant...The Small Batch (and other) solutions in Mantle API, by Guennadi Riguer, Mant...
The Small Batch (and other) solutions in Mantle API, by Guennadi Riguer, Mant...
 
GS-4147, TressFX 2.0, by Bill-Bilodeau
GS-4147, TressFX 2.0, by Bill-BilodeauGS-4147, TressFX 2.0, by Bill-Bilodeau
GS-4147, TressFX 2.0, by Bill-Bilodeau
 
PT-4057, Automated CUDA-to-OpenCL™ Translation with CU2CL: What's Next?, by W...
PT-4057, Automated CUDA-to-OpenCL™ Translation with CU2CL: What's Next?, by W...PT-4057, Automated CUDA-to-OpenCL™ Translation with CU2CL: What's Next?, by W...
PT-4057, Automated CUDA-to-OpenCL™ Translation with CU2CL: What's Next?, by W...
 
PT-4054, "OpenCL™ Accelerated Compute Libraries" by John Melonakos
PT-4054, "OpenCL™ Accelerated Compute Libraries" by John MelonakosPT-4054, "OpenCL™ Accelerated Compute Libraries" by John Melonakos
PT-4054, "OpenCL™ Accelerated Compute Libraries" by John Melonakos
 
PL-4048, Adapting languages for parallel processing on GPUs, by Neil Henning
PL-4048, Adapting languages for parallel processing on GPUs, by Neil HenningPL-4048, Adapting languages for parallel processing on GPUs, by Neil Henning
PL-4048, Adapting languages for parallel processing on GPUs, by Neil Henning
 
TressFX The Fast and The Furry by Nicolas Thibieroz
TressFX The Fast and The Furry by Nicolas ThibierozTressFX The Fast and The Furry by Nicolas Thibieroz
TressFX The Fast and The Furry by Nicolas Thibieroz
 
Computer Vision Powered by Heterogeneous System Architecture (HSA) by Dr. Ha...
Computer Vision Powered by Heterogeneous System Architecture (HSA) by  Dr. Ha...Computer Vision Powered by Heterogeneous System Architecture (HSA) by  Dr. Ha...
Computer Vision Powered by Heterogeneous System Architecture (HSA) by Dr. Ha...
 
Using GPUs to handle Big Data with Java by Adam Roberts.
Using GPUs to handle Big Data with Java by Adam Roberts.Using GPUs to handle Big Data with Java by Adam Roberts.
Using GPUs to handle Big Data with Java by Adam Roberts.
 
GS-4150, Bullet 3 OpenCL Rigid Body Simulation, by Erwin Coumans
GS-4150, Bullet 3 OpenCL Rigid Body Simulation, by Erwin CoumansGS-4150, Bullet 3 OpenCL Rigid Body Simulation, by Erwin Coumans
GS-4150, Bullet 3 OpenCL Rigid Body Simulation, by Erwin Coumans
 
Keynote (Mike Muller) - Is There Anything New in Heterogeneous Computing - by...
Keynote (Mike Muller) - Is There Anything New in Heterogeneous Computing - by...Keynote (Mike Muller) - Is There Anything New in Heterogeneous Computing - by...
Keynote (Mike Muller) - Is There Anything New in Heterogeneous Computing - by...
 
An Introduction to OpenCL™ Programming with AMD GPUs - AMD & Acceleware Webinar
An Introduction to OpenCL™ Programming with AMD GPUs - AMD & Acceleware WebinarAn Introduction to OpenCL™ Programming with AMD GPUs - AMD & Acceleware Webinar
An Introduction to OpenCL™ Programming with AMD GPUs - AMD & Acceleware Webinar
 
Gpu with cuda architecture
Gpu with cuda architectureGpu with cuda architecture
Gpu with cuda architecture
 
ISCA 2014 | Heterogeneous System Architecture (HSA): Architecture and Algorit...
ISCA 2014 | Heterogeneous System Architecture (HSA): Architecture and Algorit...ISCA 2014 | Heterogeneous System Architecture (HSA): Architecture and Algorit...
ISCA 2014 | Heterogeneous System Architecture (HSA): Architecture and Algorit...
 
MM-4092, Optimizing FFMPEG and Handbrake Using OpenCL and Other AMD HW Capabi...
MM-4092, Optimizing FFMPEG and Handbrake Using OpenCL and Other AMD HW Capabi...MM-4092, Optimizing FFMPEG and Handbrake Using OpenCL and Other AMD HW Capabi...
MM-4092, Optimizing FFMPEG and Handbrake Using OpenCL and Other AMD HW Capabi...
 

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

Game Engine Overview
Game Engine OverviewGame Engine Overview
Game Engine Overview
Sharad Mitra
 
Multi-faceted Microarchitecture Level Reliability Characterization for NVIDIA...
Multi-faceted Microarchitecture Level Reliability Characterization for NVIDIA...Multi-faceted Microarchitecture Level Reliability Characterization for NVIDIA...
Multi-faceted Microarchitecture Level Reliability Characterization for NVIDIA...
Stefano Di Carlo
 
Leaving Flatland: Getting Started with WebGL- SXSW 2012
Leaving Flatland: Getting Started with WebGL- SXSW 2012Leaving Flatland: Getting Started with WebGL- SXSW 2012
Leaving Flatland: Getting Started with WebGL- SXSW 2012
philogb
 

Ähnlich wie WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang, John Yoon and Nicolas Lorain (20)

Graal and Truffle: One VM to Rule Them All
Graal and Truffle: One VM to Rule Them AllGraal and Truffle: One VM to Rule Them All
Graal and Truffle: One VM to Rule Them All
 
World wind java sdk in progess
World wind java sdk in progessWorld wind java sdk in progess
World wind java sdk in progess
 
Visibility Optimization for Games
Visibility Optimization for GamesVisibility Optimization for Games
Visibility Optimization for Games
 
Visibility Optimization for Games
Visibility Optimization for GamesVisibility Optimization for Games
Visibility Optimization for Games
 
Your Game Needs Direct3D 11, So Get Started Now!
Your Game Needs Direct3D 11, So Get Started Now!Your Game Needs Direct3D 11, So Get Started Now!
Your Game Needs Direct3D 11, So Get Started Now!
 
GTC Taiwan 2017 深度學習於表面瑕疵檢測之應用
GTC Taiwan 2017 深度學習於表面瑕疵檢測之應用GTC Taiwan 2017 深度學習於表面瑕疵檢測之應用
GTC Taiwan 2017 深度學習於表面瑕疵檢測之應用
 
Advanced Graphics Workshop - GFX2011
Advanced Graphics Workshop - GFX2011Advanced Graphics Workshop - GFX2011
Advanced Graphics Workshop - GFX2011
 
COLLADA & WebGL
COLLADA & WebGLCOLLADA & WebGL
COLLADA & WebGL
 
Game Engine Overview
Game Engine OverviewGame Engine Overview
Game Engine Overview
 
Advanced Game Development with the Mobile 3D Graphics API
Advanced Game Development with the Mobile 3D Graphics APIAdvanced Game Development with the Mobile 3D Graphics API
Advanced Game Development with the Mobile 3D Graphics API
 
LightWave™ 3D 11 Add-a-Seat
LightWave™ 3D 11 Add-a-SeatLightWave™ 3D 11 Add-a-Seat
LightWave™ 3D 11 Add-a-Seat
 
JavaFX 2.1 - следующее поколение клиентской Java
JavaFX 2.1 - следующее поколение клиентской JavaJavaFX 2.1 - следующее поколение клиентской Java
JavaFX 2.1 - следующее поколение клиентской Java
 
Infrastructure-as-code: bridging the gap between Devs and Ops
Infrastructure-as-code: bridging the gap between Devs and OpsInfrastructure-as-code: bridging the gap between Devs and Ops
Infrastructure-as-code: bridging the gap between Devs and Ops
 
OW2con'14 - XLcoud, 3D rendering in the cloud, Marius Preda, Institut Mines T...
OW2con'14 - XLcoud, 3D rendering in the cloud, Marius Preda, Institut Mines T...OW2con'14 - XLcoud, 3D rendering in the cloud, Marius Preda, Institut Mines T...
OW2con'14 - XLcoud, 3D rendering in the cloud, Marius Preda, Institut Mines T...
 
RenderMan*: The Role of Open Shading Language (OSL) with Intel® Advanced Vect...
RenderMan*: The Role of Open Shading Language (OSL) with Intel® Advanced Vect...RenderMan*: The Role of Open Shading Language (OSL) with Intel® Advanced Vect...
RenderMan*: The Role of Open Shading Language (OSL) with Intel® Advanced Vect...
 
Shaders in Unity
Shaders in UnityShaders in Unity
Shaders in Unity
 
Multi-faceted Microarchitecture Level Reliability Characterization for NVIDIA...
Multi-faceted Microarchitecture Level Reliability Characterization for NVIDIA...Multi-faceted Microarchitecture Level Reliability Characterization for NVIDIA...
Multi-faceted Microarchitecture Level Reliability Characterization for NVIDIA...
 
UE4 Landscape
UE4 LandscapeUE4 Landscape
UE4 Landscape
 
Leaving Flatland: Getting Started with WebGL- SXSW 2012
Leaving Flatland: Getting Started with WebGL- SXSW 2012Leaving Flatland: Getting Started with WebGL- SXSW 2012
Leaving Flatland: Getting Started with WebGL- SXSW 2012
 
20200402 oracle cloud infrastructure data science
20200402 oracle cloud infrastructure data science20200402 oracle cloud infrastructure data science
20200402 oracle cloud infrastructure data science
 

Mehr von AMD Developer Central

Rendering Battlefield 4 with Mantle by Yuriy ODonnell
Rendering Battlefield 4 with Mantle by Yuriy ODonnellRendering Battlefield 4 with Mantle by Yuriy ODonnell
Rendering Battlefield 4 with Mantle by Yuriy ODonnell
AMD Developer Central
 

Mehr von AMD Developer Central (20)

DX12 & Vulkan: Dawn of a New Generation of Graphics APIs
DX12 & Vulkan: Dawn of a New Generation of Graphics APIsDX12 & Vulkan: Dawn of a New Generation of Graphics APIs
DX12 & Vulkan: Dawn of a New Generation of Graphics APIs
 
Leverage the Speed of OpenCL™ with AMD Math Libraries
Leverage the Speed of OpenCL™ with AMD Math LibrariesLeverage the Speed of OpenCL™ with AMD Math Libraries
Leverage the Speed of OpenCL™ with AMD Math Libraries
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Media SDK Webinar 2014
Media SDK Webinar 2014Media SDK Webinar 2014
Media SDK Webinar 2014
 
DirectGMA on AMD’S FirePro™ GPUS
DirectGMA on AMD’S  FirePro™ GPUSDirectGMA on AMD’S  FirePro™ GPUS
DirectGMA on AMD’S FirePro™ GPUS
 
Webinar: Whats New in Java 8 with Develop Intelligence
Webinar: Whats New in Java 8 with Develop IntelligenceWebinar: Whats New in Java 8 with Develop Intelligence
Webinar: Whats New in Java 8 with Develop Intelligence
 
Inside XBox- One, by Martin Fuller
Inside XBox- One, by Martin FullerInside XBox- One, by Martin Fuller
Inside XBox- One, by Martin Fuller
 
Rendering Battlefield 4 with Mantle by Yuriy ODonnell
Rendering Battlefield 4 with Mantle by Yuriy ODonnellRendering Battlefield 4 with Mantle by Yuriy ODonnell
Rendering Battlefield 4 with Mantle by Yuriy ODonnell
 
Low-level Shader Optimization for Next-Gen and DX11 by Emil Persson
Low-level Shader Optimization for Next-Gen and DX11 by Emil PerssonLow-level Shader Optimization for Next-Gen and DX11 by Emil Persson
Low-level Shader Optimization for Next-Gen and DX11 by Emil Persson
 
Gcn performance ftw by stephan hodes
Gcn performance ftw by stephan hodesGcn performance ftw by stephan hodes
Gcn performance ftw by stephan hodes
 
Inside XBOX ONE by Martin Fuller
Inside XBOX ONE by Martin FullerInside XBOX ONE by Martin Fuller
Inside XBOX ONE by Martin Fuller
 
Direct3D12 and the Future of Graphics APIs by Dave Oldcorn
Direct3D12 and the Future of Graphics APIs by Dave OldcornDirect3D12 and the Future of Graphics APIs by Dave Oldcorn
Direct3D12 and the Future of Graphics APIs by Dave Oldcorn
 
Introduction to Direct 3D 12 by Ivan Nevraev
Introduction to Direct 3D 12 by Ivan NevraevIntroduction to Direct 3D 12 by Ivan Nevraev
Introduction to Direct 3D 12 by Ivan Nevraev
 
Holy smoke! Faster Particle Rendering using Direct Compute by Gareth Thomas
Holy smoke! Faster Particle Rendering using Direct Compute by Gareth ThomasHoly smoke! Faster Particle Rendering using Direct Compute by Gareth Thomas
Holy smoke! Faster Particle Rendering using Direct Compute by Gareth Thomas
 
Productive OpenCL Programming An Introduction to OpenCL Libraries with Array...
Productive OpenCL Programming An Introduction to OpenCL Libraries  with Array...Productive OpenCL Programming An Introduction to OpenCL Libraries  with Array...
Productive OpenCL Programming An Introduction to OpenCL Libraries with Array...
 
Rendering Battlefield 4 with Mantle by Johan Andersson - AMD at GDC14
Rendering Battlefield 4 with Mantle by Johan Andersson - AMD at GDC14Rendering Battlefield 4 with Mantle by Johan Andersson - AMD at GDC14
Rendering Battlefield 4 with Mantle by Johan Andersson - AMD at GDC14
 
RapidFire - the Easy Route to low Latency Cloud Gaming Solutions - AMD at GDC14
RapidFire - the Easy Route to low Latency Cloud Gaming Solutions - AMD at GDC14RapidFire - the Easy Route to low Latency Cloud Gaming Solutions - AMD at GDC14
RapidFire - the Easy Route to low Latency Cloud Gaming Solutions - AMD at GDC14
 
Mantle and Nitrous - Combining Efficient Engine Design with a modern API - AM...
Mantle and Nitrous - Combining Efficient Engine Design with a modern API - AM...Mantle and Nitrous - Combining Efficient Engine Design with a modern API - AM...
Mantle and Nitrous - Combining Efficient Engine Design with a modern API - AM...
 
Mantle - Introducing a new API for Graphics - AMD at GDC14
Mantle - Introducing a new API for Graphics - AMD at GDC14Mantle - Introducing a new API for Graphics - AMD at GDC14
Mantle - Introducing a new API for Graphics - AMD at GDC14
 
Direct3D and the Future of Graphics APIs - AMD at GDC14
Direct3D and the Future of Graphics APIs - AMD at GDC14Direct3D and the Future of Graphics APIs - AMD at GDC14
Direct3D and the Future of Graphics APIs - AMD at GDC14
 

Kürzlich hochgeladen

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Kürzlich hochgeladen (20)

ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 

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

  • 1. AMD Developer Summit Session: WT-4071 GPU Accelerated 3D Graphics for Java Kevin Rushforth & Chien Yang Oracle Corporation 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13
  • 2. Program Agenda !  JavaFX Graphics Overview !  Transforms !  Camera and Coordinate System !  Z-buffer (depth test) !  Movable Camera Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 2
  • 3. Program Agenda !  3D Geometry !  3D Attributes !  3D Picking !  MSAA !  SubScene !  Wrap-up / Q&A Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 3
  • 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 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 4
  • 5. JavaFX Graphics Overview "  Capabilities "  Transformation (translate, rotate, scale and shear) "  Animation (timeline and transitions) "  Effects (blurs, drop shadows, color filters, etc.) "  Rendering attributes Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 5
  • 6. JavaFX Graphics Overview "  Primary graphical node types "  Shape (rectangle, circle, path, etc.) "  Text (a specialized form of Shape) "  ImageView "  MediaView Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 6
  • 7. JavaFX SW Block Diagram Application JavaFX UI Controls JavaFX Scene Graph API Prism Renderer SW OpenGL D3D Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 7
  • 8. A Simple JavaFX Scene Graph Stage Scene fill : SILVER Root Image View Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 8 effect : DropShadow translateX : 100 translateY : 75
  • 9. Simple Scenegraph Demo Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 9
  • 10. JavaFX 3D Features in JDK 7 (FX 2) "  3D Transforms "  Depth Buffer (Z-Buffer) "  Perspective Camera Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 10
  • 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 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 11
  • 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 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 12
  • 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 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 13
  • 14. JavaFX on Linux "  Ubuntu 12.04 LTS or later, OEL 6 or later "  HW acceleration via OpenGL 2.0 "  "  Requires vendor-supplied driver "  "  GPUs include: AMD, NVIDIA 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 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 14
  • 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 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 15
  • 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) Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 16
  • 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) Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 17
  • 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] ... Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 18
  • 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 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 19
  • 20. Depth Buffer (Z-buffer) Group A Group B C 2D Rendering Order: A, B, C, D “D” is on top Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 20 D
  • 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 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 21
  • 22. Depth Buffer (Z-buffer) Group A Group Z=0 B Z=3 C Z=1 D Z=2 Rendering Order: A, B, C, D Actual Z Order: B, D, C, A “A” should be on top, but “D” will be Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 22
  • 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 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 23
  • 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) Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 24
  • 25. Depth Test Demo Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 25
  • 26. VideoCube Demo Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 26
  • 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 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 27
  • 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) Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 28
  • 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] Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 29
  • 30. Coordinate System Coordinate System Converter Group Axis Group Translate Rotate Scale 3D Group X Axis Z Axis Y Axis Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 30 Box
  • 31. Coordinate System Demo Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 31
  • 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 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 32
  • 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 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 34
  • 35. Specifying a Fixed Camera // Create a camera and set it on the Scene Camera camera = new PerspectiveCamera(); scene.setCamera(camera); Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 35
  • 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); Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 36
  • 37. Movable Camera Demo Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 37
  • 38. 3D Shapes "  FX 2 only has 2D shapes (with 3D transforms) "  FX 8 adds 3D shapes "  User-defined shapes "  Predefined shapes Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 38
  • 40. Shape3D Class Hierarchy, continued "  java.lang.Object "  javafx.scene.shape.Mesh -  javafx.scene.shape.TriangleMesh Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 40
  • 41. TriangleMesh "  Geometry "  "  A set of texture coordinates "  "  A set of positions 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 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 41
  • 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); Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 42
  • 43. MeshView Demo Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 43
  • 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) Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 44
  • 45. Predefined Shapes Demo Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 45
  • 46. 3D Attributes "  Lights "  Materials "  Used to specify the appearance of a 3D shape "  Face culling "  Drawing mode (fill versus wireframe) Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 46
  • 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) Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 48
  • 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); Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 49
  • 50. Lighting Demo Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 50
  • 52. 3D Attributes: PhongMaterial "  Contains the following properties: "  "  Specular color, specular map "  Specular power "  Bump map "  "  Diffuse color, diffuse map Self-illumination map Sharable among multiple Shape3D nodes Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 52
  • 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); Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 53
  • 54. Materials Demo Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 54
  • 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 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 55
  • 56. Scene AA Demo Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 56
  • 57. SubScene Hierarchy "  javafx.scene.Node "  javafx.scene.SubScene Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 57
  • 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 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 58
  • 59. SubScene Demo Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 59
  • 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 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 60
  • 61. 3D Picking Demo Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 61
  • 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 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 62
  • 63. Loader Demo Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 63
  • 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 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 64
  • 65. Futures "  Accelerated mesh animation "  Loaders "  Geometry utilities (e.g., vecmath, camera controller) Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 65
  • 66. 3D Demo Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 66
  • 67. Q&A Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 67