GPU acceleration using GLSL

Hi all,

I was wondering if it is possible to retrieve values from the fragment or vertex shaders? ( An accessor GET method opposite but similar to the Material.setFloat( String name, float value ) methods )

I was considering moving a few heavy operations onto the GPU ( Terrain generation algorithm and physics ). I am quite new to shaders, so I was wondering if it is possible with the currently supported shaders.

Also are there plans to add support for GLSL 1.3 and 1.4 in the near future? I read in a 7 month old forum post that no-one has taken it on yet.



1 Like

Yes, OpenCL is what you’d want then. In addition to the links above, LWJGL supports OpenCL as of a few versions ago so you wouldn’t need to add any extra libraries besides what jME uses in order to get it working. You need to really evaluate your algorithms for generation, however.

The problem can be thought of in nearly the same way as if you were using MapReduce. Break the problem up into subroutines and see the performance when distributed. There seems to be two extremes to the myth of GPU computing, “Sending work to my graphics card will fix all my problems” and “If you’re asking questions about it you probably don’t need it”.

Both are absurd but do have measured truths to them. If your workload is indeed something that you’re certain can be distributed then you’re looking in the right place.

1 Like

Well, if its really like “I do all this stuff for the visuals in my shader anyway and so I also compute this other thing that depends on a lot of the made computations” then simply using some shader variable might make sense… @Momoko_Fan: Is this an architectural limitation?

Else I agree… If you plan to move a high-level concept like “physics” to the GPU, then actually reading and writing variables should be your smallest issue, dividing up the work so that you know what actually should be computed on the GPU is the biggest part then.

1 Like

Thank you guys. I will have a look at the OpenCL functionality in LWJGL next time I have some spare time.


I started with this little example a while back… works perfectly and should get you on your way

1 Like