1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
GL2ES2PipelineThe main change if Java3D 1.7 is the addition of a pipeline that is compatible with the ES2 and ES3 OpenGL drivers. These drivers are generally found less powerful OS and hardware, for example iOS, Android and Raspbian. Note that this release of Java3D is still tightly bound to the awt package and so cannot run on any thing that does not support that package e.g. Android In addition this release does not yet fully support compressed textures, which are mandatory on all apps that are of significant size due to memory constraints. You can however extend it to support them, contact the forum to find out how. ##How to use the GL2ES2 pipeline Put this property in either the command line -Dj3d.rend=jogl2es2 or at the beginning of your main public static main(String[] args){System.setProperty("j3d.rend", "jogl2es2"); … You will probably also want these 2 other properties at least: sun.awt.noerasebackground=true j3d.displaylist=false ##Where to get examples of its use, including shader code Please look in the java3d-examples project particularly under the org.jdesktop.j3d.examples.gl2es2pipeline package The examples include:
A good place to start is with:
There is a nice comparison in the org.jdesktop.j3d.examples.sphere_motion package of FFP, glsl with #version 100 built-in variables and the gl2es2pipeline equivalent. This shows that the output is nearly identical and shows how easy it is to go from a built-in using shader to the gl2es2pipeline. ##What variables can be used in the shaders In creating the GL2ES2Pipeline, the mechanism was setup such that the some new variables would be available that will work like the earlier built-in variables from glsl #version 100 and that they would flow through from the scenegraph/pipeline into the shader, in a manner that should allow simple conversion and a clear understanding. The built-in gl_* type variables have been replicated by having a gl* equivalent. To access these new variables they need to be defined in the shader, this is unlike the built-in equivalents. This occurs for attributes and uniforms e.g. gl_Vertex can be accessed via glVertex, so long as glVertex is defined in the shader like so: attribute vec4 glVertex; It will supply exactly the same value as gl_Vertex did. Note that Light, Material and Fog data require a struct to be defined before they can be used, see examples for more information. These example shaders attempt to explain the new usable built-in equivalent variables and some information on how to calculate other built-in variables that may be required. /j3dexamples/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/fixed_function_shader.frag /j3dexamples/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/fixed_function_shader.vert Or A note of caution: If you are using a shader with a low #version number it will not complain if you accidentally mis-type one of the new GL2ES2Pipline variables as it’s equivalent fixed function built-in e.g. glVertex as gl_Vertex The shader will compile and run fine, but you will get no data in that variable. The solution is to set a higher version number e.g. #version 150 or to be very careful. ##GL2ES2Pipeline limitations
|