Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1] 2
1  Game Development / Shared Code / Re: Atmospheric Scattering on: 2013-01-16 21:43:26
The HSV/HSB color space is not very well defined. Particualrly in the most common implementations color of the same volume/brightness are not appearing equally bright to a human eye.

But eventually unless you doa  scientific application (e.g. if you just do it to get a nice garphical effect for another project) you can always tweak the conversion till you get pleasant results.

Personally I prefer YUV to HSB becuase it has better "equal" luminance values, and you get something similar to hue by the combining the u and v vectors.

I've downloaded the code, but I was too distracted with other things yet to dig into it.
Now that the code is working, I might try some other colour space conversions to see if it simplifies the shader.

After posting the updated code last night, I figured out what was causing the grey band at the bottom of the screen.  In the BufferedImage version, I am faking the distance of the 'vertices' used to draw the sky, however, in the shader version it is using an orthographic projection where vertices are close to the camera.  Having the vertices this close causes an issue with lerp-ing the overcast sky factor into the sky colour.  Removing the lerp made the sky show with correct colours.

2  Game Development / Shared Code / Re: Atmospheric Scattering on: 2013-01-16 11:25:30
Found a different HSV to/from RGB conversion algorithm here which fixed the purple sunsets on the mobile.  All I can think is that the GLSL compiler on the mobile didn't like the branching or something in the old version.

The problem of the grey band at the bottom of the screen still persists, but it is a minor issue now.

The at the PAMD link in the first post contains the updated shader project.

3  Game Development / Shared Code / Re: Atmospheric Scattering on: 2013-01-15 09:51:16

I updated the links to point to a folder with zips of the code.

After a little investigation, I think I have narrowed down the Android sunset colour problem to the function converting HSV back to RGB.  If that step is taken out, the colours displayed on the desktop and the mobile are basically identical.  I don't know if its the float precision, or maybe something to do with casts since that is the only function with casts in the frag shader.

Another thing I am pondering, is why in the simple render to BufferedImage version, the bottom of the screen renders in light colours (as it should) while in both desktop and mobile shader versions a grey band is rendered.

Anyway, any pointers anyone might have for things that I missed in the conversion to shaders, slight mathematical differences or shader gotchas, would be appreciated.

4  Game Development / Shared Code / Re: Atmospheric Scattering on: 2013-01-13 13:39:43
After Roquen reminded me about the paper, I spent this weekend getting a basic version of "A Practical Analytic Model for Daylight" working.

The code is based on the Sky Dome class from JME2, with the bits I didn't need removed, and converted to work in screen space.  There are two versions, the first simply creates a BufferedImage and displays it in a JFrame.  The second version uses a shader created from the first version's code.

Simple (and slow) BufferedImage implementation of "Practical Analytic Model for Daylight"

Libgdx based shader implementation

One thing I do need a bit of help with, is that the Android version of the Libgdx shader code displays strange colours as the sun is setting.  It seems to not be including any green in the colour output from the fragment shader.  When the sun is high in the sky, everything looks normal, just as the sun nears the bottom of the screen it turns to purple and then dark blue.


Edited links to point to zips of code
5  Game Development / Shared Code / Re: Atmospheric Scattering on: 2013-01-10 12:42:18
Somewhere in the dim dark past I remember reading "A Practical Analytic Model for Daylight".
I will have to revisit it I think.  Thanks for the reminder Smiley
6  Game Development / Shared Code / Re: Atmospheric Scattering on: 2013-01-09 12:13:01
Looks like I'll have to re-read the papers and articles to figure some more of this out.
7  Game Development / Shared Code / Re: Atmospheric Scattering on: 2013-01-08 08:12:29
If you care, I can point you to where most of the numbers come from.

Yes please!

Some of the things are easy, its just ones like the Rayleigh scale depth, or trying to figure out why if I draw the sky sphere with size "atmosphere radius + 1" (i.e. just outside the atmosphere depth) it doesn't work properly, but if it is drawn at "atmosphere radius * 1.5" does.

8  Game Development / Shared Code / Atmospheric Scattering on: 2013-01-07 10:47:06
Howdy folks,

Over the weekend I found out just how hard it is for a not overly mathematical person to make heads or tails of the atmospheric scattering maths in research papers.  I also found out how hard it is to find working example code (Java or otherwise) that shows even the most basic scattering equations working.

So, I present to you, an implementation of the GPU version of Sean Oneill's atmospheric scattering.

I don't promise that the code is pretty, or very well written, but it works (and there are sunsets).

  • It uses LWJGL
  • There are magic numbers I haven't quite figured out yet


Edit (Added PAMD code links from this post):

Simple (and slow) BufferedImage implementation of "Practical Analytic Model for Daylight"

Libgdx based shader implementation of "Practical Analytic Model for Daylight"
9  Games Center / Archived Projects / Re: Crabs! on: 2011-10-09 03:34:09
At what point do you reach a pretty consistent 15fps?

Samsung Galaxy S
15 fps @ ~1200
10  Game Development / Newbie & Debugging Questions / Re: SlickDesktop JPanel on: 2011-02-20 01:35:52
Using a dragable JPanel is probably not the best way to do this.  Either use a JFrame with setUndecorate(true), or a

As far as dragging the thing around, you will have to listen for mouse pressed/released events on the window.  Don't know if it will still receive mousemoved events for the dragging though.
11  Discussions / General Discussions / Oracle not about to sue anybody over Javascript on: 2010-08-18 09:34:20

*accompanied by the sounds of a camel's back breaking*
12  Java Game APIs & Engines / Tools Discussion / Re: Java - using XML with XSD? on: 2010-07-11 02:11:54
If you already have the XSD, then will generate a set of objects to parse and create new XML documents
13  Java Game APIs & Engines / JavaFX / Re: What does this all mean for us? on: 2009-03-05 01:14:50
Since it can run on mobile phones running Java ME, I doubt it can improve performance that much.  I mean, does it even allow floating point?  I seem to recall the Java ME doesn't, which suggests that Java FX can't either.

It's not that Java ME can't use floating point numbers, the problem used to be that the phone hardware didn't support floating point operations.  In fact, from what I have read, anything that offers CLDC 1.1 supports floating point.

14  Java Game APIs & Engines / Java 2D / Re: 2D and OpenGL? on: 2009-01-09 02:02:30
Another vote here for Slick.  Kev did (does) a great job with it.  Plenty of 2D graphics related stuff already built in, and access to OpenGL when you need it.

15  Discussions / General Discussions / Re: Community Call to Action re: JVM on PS3 on: 2008-09-29 07:06:16
I think the idea of a JVM on PS3 is a good one.  However, I don't think it is going to get anywhere as a community driven effort.  We as Java developers and game programming hobbyists don't have the weight or finances to get something like this off the ground.

I think for this to have any chance of happening,  there needs to be official backing from Sun.  Also Sony has to be shown an overwhelming business case as to why bothering with Java on their console is going to make them any money, or give a competitive advantage over Nintendo and Microsoft.

I think our only chance is for the PS3 JVM to ride in on the coat-tails of something like Project Darkstar, with a passionate spokesperson taking the lead and making the case *cough*ChrisM*cough*.

16  Java Game APIs & Engines / JOGL Development / Re: why these two method generate different results? on: 2008-08-31 01:21:43
My best guess would be that the method can't handle multi-dimensional arrays.

17  Game Development / Newbie & Debugging Questions / Re: Frameshape on Desktop on: 2008-07-25 15:03:35
This should do the trick:

18  Java Game APIs & Engines / JOGL Development / Re: Tilemap to texture? on: 2008-07-03 12:30:33
Just wondering why you "have to avoid rendering one quad per tile"?

If drawing a few hundred quads on screen is causing major slowdowns for your tile engine then you have much bigger problems.

The batches you should be creating are making sure you draw all tiles with the same texture before switching textures and drawing the next batch of tiles.  You could even get fancy and have multiple tile textures in a larger texture to avoid even more texture switching.
19  Discussions / Miscellaneous Topics / Diablo 3 on: 2008-06-28 12:47:01

Can I get a WOO! from anyone? Cheesy
20  Java Game APIs & Engines / JOGL Development / Re: GLSL atmosphere on: 2008-06-12 13:23:56
Files are now hosted properly, see first post for link
21  Java Game APIs & Engines / JOGL Development / Re: GLSL atmosphere on: 2008-06-06 02:39:03
If its the shaders going wrong then I'm not really sure I can help.  They're just pulled straight from the demo code zip.  It could just be that it need some specific gfx card feature that both machines I've run it on just happen to have by chance (laptop 9500M, desktop 8800GTS).

Although from my experience running it on the laptop, and you using a mobile gfx card too, and both of us getting problems, I'm leaning towards it being a mobile gfx card/driver problem.

If you're desperate to see what it looks like I also got the C version compiled (for Windows).  I could bundle it up with all the DLLs and send it to you.  It does look slightly better too since the TIFF of the earth in the demo has a proper reflectance value while the JPG from the Java version just has uniform reflectance on land and sea.

22  Java Game APIs & Engines / JOGL Development / GLSL atmosphere on: 2008-06-05 07:07:25

Files are now hosted properly.  Go to

The first (and only) article on the front page has both the Java and Win32 versions attached.  Hopefully it will work this time.

Hi all,

I saw a post over at
about computing atmosphere lookup tables.

I decided it would be much improved if the C code that he released was running in Java  Tongue.

So, here it is.  Nearly everything is done in shaders so and it uses 8 texture units.  There is also a slight problem I found when running this on my laptop.  In inscatterS.glsl I have commented out a line that causes a very nasty crash where the laptop's display driver stops responding.  The same thing happened with the C version so its probably a driver problem.  The same shader code worked fine on my desktop.  So... you can pop that line back in if you think your gfx card driver is bug free.

If the link/download is broken, send me a PM and i'll email you the zip, its only ~90k.

left-mouse to move the sun
shift + left-mouse to rotate the earth
ctrl + left-mouse to rotate the scene
up and down arrows to change altitude

23  Discussions / General Discussions / Re: Project Darkstar - OPEN SOURCE AVAILABLE! on: 2007-08-30 19:17:43
Woo!  Congratulations  Cheesy
24  Java Game APIs & Engines / JOGL Development / Re: FPS camera implementation on: 2007-06-10 16:46:35
Here is a FPS camera implementation for gleem which I adapted from gleem's FreeViewer.  It limits pitch angle and rotates around the camera position rather than rotating around a given point.

25  Discussions / General Discussions / Re: Post your video game setup here! on: 2007-03-22 05:26:21
Here are a few pics of my setup.  Not quite as console packed as Chris' but I'm still at Uni so...

First pic (On the couch):
This is a picture of my meagre home entertainment setup.  The only piece of game related goodness is the PS2, sadly the only console I own.  Also to be seen are my "coffee table", a small portion of my DVD collection, HL2 hat, and if you look closely a tyre pressure guage.  Hard to see are all the cables snaking away from the VCR/DVD which connect to things in the next pic.

Second pic (Messy desk):
As you can see here, my desk is a little messy.  Two 20" widescreen monitors and down the bottom, my pride and joy, an HD widescreen video projector for 250cm of gaming/tv/movie goodness  Cool.  Other things to note in this shot are my home-made plush headcrab relaxing with a bit of Java coding, and a Terminator head coffee mug (Universal Studios).  The MGM Grand lion can be seen in its natural habitat stalking its prey, the ever elusive Wizard Hat of Excalibur (souvenirs from a trip to Las Vegas).  If you look closely just behind the two stacks of CDs near my keyboard, you can see the closest thing I have to an XBox... a little toy XBox branded motorbike game that was in a packet of cereal.

BTW, if you need to ask why I have two monitors and a video projector and no furniture... I pity you  Tongue

26  Java Game APIs & Engines / JOGL Development / Re: openGL pipeline on: 2007-03-01 12:51:50
With the following flags set for both of my small test programs, things worked perfectly with the OpenGL pipeline enabled:

-Dsun.java2d.opengl.fbobject=false -Dsun.java2d.noddraw=True -Dsun.java2d.opengl=True

(Edit - System specs)
AMD Athlon 64 3200+
XP Pro SP2
GeForce 6800 GT (AGP 8X) 128MB
Video BIOS:
ForceWare version: 93.71

The larger of my test apps places swing components on top of a GLJPanel.  It repaints/responds properly with the fboobject flag set even when using the Substance L&F.

Here is my smaller test app which doesn't include any JOGL but still has problems when not using the fboobject flag:

import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
//import org.jvnet.substance.SubstanceLookAndFeel;
//import org.jvnet.substance.painter.SpecularGradientPainter;
//import org.jvnet.substance.theme.SubstanceBottleGreenTheme;

public class TestApp
    JFrame frame = null;
    public TestApp()
//        try
//        {
//            UIManager.setLookAndFeel(new SubstanceLookAndFeel());
//            SubstanceLookAndFeel.setCurrentGradientPainter( new SpecularGradientPainter() );
//            SubstanceLookAndFeel.setCurrentTheme(
//                    new SubstanceBottleGreenTheme()
//            );
//            JFrame.setDefaultLookAndFeelDecorated( true );
//        }
//        catch( UnsupportedLookAndFeelException ex )
//        {
//            ex.printStackTrace();
//        }

        frame = new JFrame( "Test" );
        frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
        frame.setSize( 500, 500 );
        frame.add( createButtonPanel( 8, 8 ) );
        frame.setVisible( true );
    private JPanel createButtonPanel( int rows, int cols )
        JPanel btnCanvas = new JPanel( new GridLayout( rows, cols ) );
        btnCanvas.setOpaque( false );
        JButton b = null;
        for( int i = 0; i < (rows*cols); i++ )
            b = new JButton( "test" + i );
            btnCanvas.add( b );
        return btnCanvas;

    public static void main(String[] args)
        new TestApp();
27  Java Game APIs & Engines / JOGL Development / Re: openGL pipeline on: 2007-03-01 00:41:46
I am having kind of the same problem except ANY application stops repainting when I enable the OpenGL pipeline.  When using a GLJPanel, the JOGL rendering stops as well. 

I have noticed that things are fine until the window has been fully initialised, i.e. the taskbar button has been created, etc.  Buttons repaint fine, the JOGL panel repaints, then everything just stops. 

If I'm using the default L&F, the frame repaints properly on resizes, but none of the contents do.  If I use a custom L&F, such as substance, the entire frame and contents stop repainting.

Everything works fine if I don't use "-Dsun.java2d.noddraw=true".

I only noticed this after I updated to the latest version of 1.6 (1.6 b105 I think, I'm not at my dev machine).  At the same time I also updated my video card drivers so like Pandaemonium I don't think it's a driver issue.

I also have the same problem with the Photo Cube demo from Chris Campbell's blog.  Pipeline disabled works perfectly, pipeline enabled just stops repainting.

28  Java Game APIs & Engines / JOGL Development / Re: Help with GLSL & FBO shadowing on: 2006-11-07 00:38:29
Ok, here is the new code rewritten from scratch.  As I said above there is an issue with the offset when objects are shadowing themselves but overall it is working.  There is room for optimisation of setting rendering states, etc. but the basics are there.

The two major issues with the first code were the setup of the texture matrix, and the shader code I was using to do the shadowing.

29  Java Game APIs & Engines / JOGL Development / Re: Help with GLSL & FBO shadowing on: 2006-11-06 13:45:15

*bjgil2 now knows the sound of one hand clapping and has achieved a state of zen-like transendence and oneness with the universe

also, I have figured it out (except for a slight offset issue).
30  Java Game APIs & Engines / JOGL Development / Help with GLSL & FBO shadowing on: 2006-11-03 08:16:30
Hi all,

I cobbled the attached code together from various tutes around the web.  The torus, plane, and spinning spheres display with something that looks like shadowing, but the shadows do not seem to match the rotation/orientation of the objects.  I think the problem lies with how I am setting up the texture matrix but I can't figure out where I've gone wrong.

Would some kind soul familiar with GLSL shadow mapping please take a look and point me in the right direction?

Pages: [1] 2
EgonOlsen (77 views)
2018-06-10 19:43:48

EgonOlsen (57 views)
2018-06-10 19:43:44

EgonOlsen (77 views)
2018-06-10 19:43:20

DesertCoockie (259 views)
2018-05-13 18:23:11

nelsongames (157 views)
2018-04-24 18:15:36

nelsongames (156 views)
2018-04-24 18:14:32

ivj94 (897 views)
2018-03-24 14:47:39

ivj94 (161 views)
2018-03-24 14:46:31

ivj94 (810 views)
2018-03-24 14:43:53

Solater (174 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!