Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (483)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (550)
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]
1  Game Development / Shared Code / Re: ( almost :) ) Realtime Java Raytracing on: 2013-07-14 16:14:35
Thank's.

I'm using barycentric coordinates algo for ray-triangles intersections from :

http://www.flipcode.com/archives/Raytracing_Topics_Techniques-Part_7_Kd-Trees_and_More_Speed.shtml
2  Game Development / Shared Code / ( almost :) ) Realtime Java Raytracing on: 2013-07-12 16:44:35
Hy everyone.

First, please sorry for my poor english but i’m french.

Here is my first raytracer in java. With low parameters, i’m close to realtime. On my computer - core
i5 2500K 4 cores at 4.2ghz - the demo’s scene - 17762 triangles - is about 3 fps with a screen at 600x400.
With higher parameters (anti-alliasing, smooth shadows, higher recursion), it can be very, very slow.

You can configure the raytracer with the « Param.txt » configuration file in "_Param" directory. All the
parameters are explained and easy to understand.

Some coding tips :

KDTREE:
I’m using 2 kdtree for this demo.
- 1 for static objects that use SAH optimisation.
- 1 for dynamic objects, that must be rebuilt on each frame, with middle splitting axe. With « symetric »
objects, it’s not very much slower than SAH.

The KDTree build is multithreaded. At level 2, 4 threads are created. After, for the SAH version only,
if there are enough faces, 3 threads are created, one for each plane to check.

I use another optimization : as the triangles coordinate are sorted on the current axe, we don’t just use
left and right child, but i introduce a middle child, that was copied to the right child.

ANTI-ALIASING:
When turn on, the rendering is made twice :
- The standart one
- One the second pass, each pixel is compared to the 4 around. A delta is computed. If this delta
is higher the a value (AA_DELTA_COLOR in parameter’s file) then AA_LEVEL rays are fired.

SMOOTH SHADOW:
For smooth shadow, i’m using a poisson distribution on light area (each light have is own rectangular
area) to avoid banding.


I’m a developper, not a graphist, so sorry for the demo’s scene that I know to be awful. All the
algorithms used come from the web. I’m just tried to use the best. I'm not a great programmer, as
i can see in this forum, so, please, be gentle with me and thank’s for reading my code and give
me you’re feedback and what can be improved. In particular, the normal mapping part, that i'm pretty
sure to be false. The most important classes are RT_SCENE.java and RT_KDTREE.java

Java 7 is required (i think)

Thank'you.
Fred

The executable jar
The eclipse jar (kepler)


3  Java Game APIs & Engines / OpenGL Development / Re: LWJGL - OpenGL 4.2 Planets simulator on: 2012-10-02 15:12:52
Please, could you send me the error page ?
(have you an OGL 4.2 driver or JRE 1.7 ?)


4  Java Game APIs & Engines / OpenGL Development / Re: LWJGL - OpenGL 4.2 Planets simulator on: 2012-10-02 05:28:28
Thanks


5  Java Game APIs & Engines / OpenGL Development / Re: LWJGL - OpenGL 4.2 Planets simulator on: 2012-09-29 18:07:32
so...



yuck !!!

More beautiful when animated !!!

6  Java Game APIs & Engines / OpenGL Development / Re: LWJGL - OpenGL 4.2 Planets simulator on: 2012-09-29 17:23:16
too ugly   Wink

It's not the goal of it !!!
7  Java Game APIs & Engines / OpenGL Development / LWJGL - OpenGL 4.2 Planets simulator on: 2012-09-29 13:39:34
Hi everyone.

First, sorry for my poor english but I'm french.

This is my full OpenGL4.2 compliant planet simulator. It does :
- Full openGL 4.2 (core, no compatibility function is used) with LWJGL 2.8.4
- MultiThreaded Planet simulator (Newton's equations)
- Texturing
- OBJ loader
- Texture loader
- Instancing is used for planet drawing
- Text drawing with texture atlas
- GLSL 4.2
- VAO + VBO
- Java 7
- Correctly documented (in french: easy to understand)
- Code easily understandable by beginners
- few class, few code, no inused function ...

The executable jar https://mega.co.nz/#!PkR3CRaQ!GpUGCEx6oOZpatM7eEe3dTo_eHViIxgaVNVk8wILxUE
The eclipse project : https://mega.co.nz/#!q8AUlRSQ!d45i3xGyTfivfP3ENH8utQneDPg6Zi3GrIHJbSIUs5k

Please, give me your feedback : bugs, no oriended object or Opengl compliant aspects...



Thanks for all.
8  Java Game APIs & Engines / JOGL Development / [JOGL/JSR-231] Specular problem on: 2009-01-11 19:44:41
Hi everybody.

First, I'm french, so I'm sorry for my poor english.

I'm a JOGL (JSR-231) newbie and I have 2 difficulties with the specular component of my lighting.

1 / when my camera is pointing to z -, all seems to be working. The good code portion:

1  
2  
3  
4  
final float[] CAMERA_POSITION = new float[]{0F, 5F, 15F};
final float[] CAMERA_DIRECTION = new float[]{0F, 0F, 0F};
final float[] SPOT_POSITION = new float[]{0F, 5F, 15F, 1F};
final float[] SPOT_DIRECTION = new float[]{0F, 0F, -1F, 1F};


but if I'm pointing to the z-, I lose the specular component. The bad code portion:

1  
2  
3  
4  
final float[] CAMERA_POSITION = new float[]{0F, 5F, -15F};
final float[] CAMERA_DIRECTION = new float[]{0F, 0F, 0F};
final float[] SPOT_POSITION = new float[]{0F, 5F, -15F, 1F};
final float[] SPOT_DIRECTION = new float[]{0F, 0F, 1F, 1F};


2 / If i activate this :

1  
gl.glLightModeli(GL.GL_LIGHT_MODEL_LOCAL_VIEWER, GL.GL_TRUE)


I'm losing also the specular composant

The entire code :

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  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
package Test1;

import com.sun.opengl.util.Animator;
import com.sun.opengl.util.GLUT;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Insets;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.media.opengl.*;
import javax.media.opengl.glu.*;
import javax.swing.SwingUtilities;

public class TestAPoster extends Frame implements GLEventListener {

    private final GLU GLU = new GLU();
    private final GLUT GLUT = new GLUT();
    private final Dimension CLIENT_MINIMUM_DIMENSION = new Dimension(640, 480);

    final float[] CAMERA_POSITION = new float[]{0F, 5F, 15F};
    final float[] CAMERA_DIRECTION = new float[]{0F, 0F, 0F};
    final float[] SPOT_POSITION = new float[]{0F, 5F, 15F, 1F};
    final float[] SPOT_DIRECTION = new float[]{0F, 0F, -1F, 1F};

    public TestAPoster() {

        // Hardware OpenGl
       GLCapabilities glCapabilities = new GLCapabilities();
        glCapabilities.setDoubleBuffered(true);
        glCapabilities.setHardwareAccelerated(true);

        // Canvas JOGL
       GLCanvas canvas = new GLCanvas();
        canvas.addGLEventListener(this);
        canvas.setPreferredSize(CLIENT_MINIMUM_DIMENSION);
        add(canvas);

        // Fenêtre
       setTitle(getClass().getSimpleName());
        setLocation(20, 20);
        setVisible(true);
        final Insets insets = getInsets();
        setMinimumSize(new Dimension(CLIENT_MINIMUM_DIMENSION.width + insets.left + insets.right, CLIENT_MINIMUM_DIMENSION.height + insets.top + insets.bottom));
        pack();

        // Boucle d'affichage
       final Animator animator = new Animator(canvas);
        addWindowListener(new WindowAdapter() {

            @Override
            public void windowClosing(WindowEvent e) {
                new Thread(new Runnable() {

                    @Override
                    public void run() {
                        animator.stop();
                        System.exit(0);
                    }
                }).start();
            }
        });
        // Et c'est parti ...
       animator.start();
    }

    @Override
    public void init(GLAutoDrawable _glDrawable) {
    }

    @Override
    public void display(GLAutoDrawable _glDrawable) {
        final GL gl = _glDrawable.getGL();
        gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
        GLUT.glutSolidTeapot(3);
    }

    @Override
    public void reshape(GLAutoDrawable _glDrawable, int _x, int _y, int _width, int _height) {
        final GL gl = _glDrawable.getGL();

        // Couleur de fond et du zbuffer
       gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
        gl.glClearDepth(1.0f);

        // Caméra et projection
       gl.glMatrixMode(GL.GL_PROJECTION);
        gl.glLoadIdentity();
        GLU.gluPerspective(45, (double) ((double) _width / (double) _height), 0.1D, 100D);
        GLU.gluLookAt(CAMERA_POSITION[0], CAMERA_POSITION[1], CAMERA_POSITION[2], CAMERA_DIRECTION[0], CAMERA_DIRECTION[1], CAMERA_DIRECTION[2], 0D, 1D, 0D);

        // Matrix de vue
       gl.glMatrixMode(GL.GL_MODELVIEW);
        gl.glLoadIdentity();

        // Modèle d'éclairage
       gl.glShadeModel(GL.GL_SMOOTH);
        //gl.glLightModeli(GL.GL_LIGHT_MODEL_LOCAL_VIEWER, GL.GL_TRUE);

        // Lumière ponctiuelle
       gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, SPOT_POSITION, 0);
        gl.glLightfv(GL.GL_LIGHT0, GL.GL_SPOT_DIRECTION, SPOT_DIRECTION, 0);
        gl.glLightf(GL.GL_LIGHT0, gl.GL_SPOT_CUTOFF, 60F);
        gl.glLightf(GL.GL_LIGHT0, GL.GL_SPOT_EXPONENT, 3.0F);

        gl.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, new float[]{0.2F, 0.2F, 0.2F, 1F}, 0);
        gl.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, new float[]{1F, 0F, 0F, 1F}, 0);
        gl.glLightfv(GL.GL_LIGHT0, GL.GL_SPECULAR, new float[]{1F, 1F, 1F, 1F}, 0);

        // Matériau de l'objet
       gl.glMaterialfv(GL.GL_FRONT, GL.GL_AMBIENT, new float[]{0.2F, 0.2F, 0.2F, 1F}, 0);
        gl.glMaterialfv(GL.GL_FRONT, GL.GL_DIFFUSE, new float[]{1F, 0F, 0F, 1F}, 0);
        gl.glMaterialfv(GL.GL_FRONT, GL.GL_SPECULAR, new float[]{1F, 1F, 1F, 1F}, 0);
        gl.glMaterialfv(GL.GL_FRONT, GL.GL_SHININESS, new float[]{30F}, 0);

        // Etats
       gl.glEnable(GL.GL_DEPTH_TEST);
        gl.glEnable(GL.GL_LIGHTING);
        gl.glEnable(GL.GL_LIGHT0);
    }

    @Override
    public void displayChanged(GLAutoDrawable _glDrawable, boolean _modeChanged, boolean _deviceChanged) {
    }

    public static void main(String[] _args) {
        final TestAPoster test = new TestAPoster();
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                test.setVisible(true);
            }
        });
    }
}


In attachment the pictures.

Thank you very much for your answers.


Pages: [1]
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

CopyableCougar4 (15 views)
2014-08-22 19:31:30

atombrot (28 views)
2014-08-19 09:29:53

Tekkerue (25 views)
2014-08-16 06:45:27

Tekkerue (23 views)
2014-08-16 06:22:17

Tekkerue (15 views)
2014-08-16 06:20:21

Tekkerue (22 views)
2014-08-16 06:12:11

Rayexar (61 views)
2014-08-11 02:49:23

BurntPizza (39 views)
2014-08-09 21:09:32

BurntPizza (31 views)
2014-08-08 02:01:56

Norakomi (37 views)
2014-08-06 19:49:38
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org 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‑gaming.org
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!