Modern3D: low-level shader-centric 3D graphics library

Modern3D is low-level 3D graphics library (similar to OpenGL or Direct3D) written in Java. It’s entirely shader centric, this means you set the shader, its inputs, how it interacts with frame buffer, setup geometry and draw. No fixed functionality is present except things that are not covered by shaders (like blending). There are no matrices stacks, it’s entirely on you what inputs you feed into your shaders.

Features

  • easy to use low-level object oriented API, can be compared to OpenGL/Direct3D level
  • shaders are written in Cg language and precompiled (no Cg runtime required for your application)
  • currently supports Shader Model 2.0 and 2.0a/2.0b
  • uses OpenGL 1.4 with extensions for actual HW access (through LWJGL)
  • there is only one way to access HW features (like using VBOs exclusively)
  • geometry utilities for drawing primitives immediatelly (own implementation that uses VBOs) or for storing for later usage
  • provides Java2D API implementation that allows advanced 2D drawing (including text and non-trivial vector shapes)
  • utility classes for matrix stacks handling
  • support for conversion to and from half data type (16bit float)
  • batched geometry builder class for easy to use generation of optimized static geometry
  • open source, distributed under BSD license

Notes

  • currently only SM 2.0 and 2.0a/2.0b are supported, more profiles will be available in future
  • fixed function pipeline support (implemented as special “shader”) is also considered for some future version
  • GLSL is currently unsupported, but will be added in some future version (using both runtime compilation and pre-compilation using Cg compiler)
  • it’s currently using only OpenGL through LWJGL, but due to modular implementations it could use JOGL or even Direct3D when some binding for it will emerge
  • drawing of arbitrary shapes has antialiasing disabled currently, there is proof of concept implementation that can be enabled in sources
  • not all blend operators using Java2D API are correctly working
  • some less used features are currently missing (such as 3D textures)

You can download it on Modern3D homepage.

It seems interesting, I’m going to look at your library now. Thanks.

Edit.: I don’t know whether it would be difficult to use it with JOGL 2 and GLSL.

Sounds cool! It is definitely on my list to check it out.

Sounds very interesting, the Java-2D alike API is a good idea. It’d be cool to see some demos of what it can do.

Wow dude that is awesome. The only way to have good performance these days with modern GPU is to use Shaders. We definitively need library like this.

What performance boost did you measure using Modern3d for Java2D drawing ?
Do you plan to support Geometric shaders ?

I’ll rewrite sooner or later my 3d engine using shaders, I draw graphs, nothing complicated expect thousands of thousands lines and spheres, your library could be a great help !

Thanks again, great job !

While shaders can be used to some performance boost from fixed function pipeline (which is emulated using shaders on “modern” shader capable cards), it’s mainly about different way of rendering and having much more freedom.

[quote=“zeyous,post:5,topic:34421”]
The arbitrary shape rendering in Java2D is pretty much “incompatible” with how 3D accelerators works, the geometry needs to be tesselated into triangles, or use bruteforce approach using stencil buffer. Modern3D uses the latter as polygon triangulation is very hard to be working for every case and also the time spent on triangulation can be slower than using bruteforce approach. This means there is probably not much good performance improvement against optimized software rendering, but the advantage is that for rendering such shapes you don’t have to stall the GPU pipeline or even upload tons of data each frame from software renderer.

[quote=“zeyous,post:5,topic:34421”]
Yes, at some point in future. But as I don’t have HW to test on (have GF6600GT on AGP 4x) and it’s highly unlikely I will upgrade in year or two, the support would be needed to be done by someone else.

New version available on Modern3D homepage.

Changes in release 20100325:

  • Fixed issue with broken characters
  • Added clamping when drawing images
  • Fixed compilation under Java 5
  • Fixed setting of depth mask when clearing depth buffer
  • Added TextureRect and Texture3D
  • Fixed compiling of shaders when constant registers are explicit
  • Fixed issue when not all vertex arrays are used in shader
  • Added support for LUMINANCE8 and ALPHA8 textures for BufferedImages
  • Fixed drawing of transformed fonts
  • Added common API for external image flushing
  • Added auto generation of NameID constants
  • Added SHDC define so shaders can detect if they’re processed using shdc
  • Added support for 64bit on Windows for shdc
  • Other bug fixes