Main Menu

Beta of 1.15 released!

Started by EgonOlsen, July 16, 2007, 10:15:10 PM

Previous topic - Next topic

EgonOlsen

Due to the significant changes that come with this version, i decided to add a beta-phase before actually releasing it. Grab it here: http://www.jpct.net/download/beta/jpctapi.zip.

Changes:

Added a possibility to the TextureManager to get the name for an ID. Fixed a bug when using environment mapping on multi-pass objects. Fixed a flaw in the discrete polygon and triangle strip rendering. Fixed a bug in Object3D.clone() that prevented a transparency setting from being cloned. Simplified the visibility list management.
Modified the behaviour of FrameBuffer.update() to make applications work that omit the call to one of the display()-methods. Fixed a bug in the getPosition()-methods for light sources. Fixed a bug in projective texturing that caused a wrong fov-value to be set. Added the possibility to Camera to explicitly set the y-fov.
Added shadow mapping using a fixed function pipeline approach with depth textures. A new class in util called ShadowHelper eases shadow mapping. Added some helper methods here and there to ease shadow mapping. Added a method to Texture to add another texture's content to one. Added a new constructor to texture to create a blank x*y texture.


And an example of how to use shadow mapping (showing a simple scene with a cube casting a shadow):



import java.awt.*;
import com.threed.jpct.*;
import com.threed.jpct.util.*;

public class SimpleShadows {

private FrameBuffer fb = null;
private World world = null;
private Object3D plane = null;
private Object3D cube = null;
private Object3D sphere = null;
private Projector projector=null;
private ShadowHelper sh = null;
private Light sun=null;

public SimpleShadows() {
Config.glColorDepth = 24;
Config.glFullscreen = false;
Config.farPlane = 1000;
Config.glShadowZBias = 0.8f;
Config.glTrilinear=true;
}

private void initStuff() throws Exception {
fb = new FrameBuffer(800, 600, FrameBuffer.SAMPLINGMODE_NORMAL);
world = new World();
fb.enableRenderer(IRenderer.RENDERER_OPENGL, IRenderer.MODE_OPENGL);
fb.disableRenderer(IRenderer.RENDERER_SOFTWARE);

plane = Primitives.getPlane(20, 30);
plane.rotateX((float) Math.PI / 2f);

cube=Primitives.getCube(15);
cube.setAdditionalColor(Color.RED);
cube.translate(0, -30, -10);

sphere=Primitives.getSphere(12);
sphere.translate(0, 0, -50);
sphere.setAdditionalColor(new Color(0,0,50));

world.addObject(sphere);
world.addObject(plane);
world.addObject(cube);

TextureManager tm = TextureManager.getInstance();

projector = new Projector();
sh = new ShadowHelper(world, fb, projector, 512);
sh.addCaster(cube);
sh.addReceiver(plane);
sh.addReceiver(sphere);
sh.setAmbientLight(new Color(30,30,30));
sh.setFiltering(true);

world.setAmbientLight(90,90,90);
world.buildAllObjects();

sun=new Light(world);
sun.setIntensity(50, 50, 50);
}

private void doIt() throws Exception {
Camera cam = world.getCamera();
cam.moveCamera(Camera.CAMERA_MOVEOUT, 150);
cam.moveCamera(Camera.CAMERA_MOVEUP, 100);
cam.lookAt(plane.getTransformedCenter());

projector.setFOV(0.5f);
projector.setYFOV(0.5f);

SimpleVector pos=cube.getTransformedCenter();

projector.setPosition(pos);
projector.moveCamera(Camera.CAMERA_MOVEUP, 200);
projector.lookAt(pos);
SimpleVector offset=new SimpleVector(1,0,-1).normalize();
projector.moveCamera(offset, 215);

while (!org.lwjgl.opengl.Display.isCloseRequested()) {

projector.lookAt(cube.getTransformedCenter());
offset.rotateY(0.007f);
projector.setPosition(pos);
projector.moveCamera(new SimpleVector(0,-1,0), 200);
projector.moveCamera(offset, 215);
sun.setPosition(projector.getPosition());

sh.updateShadowMap();

fb.clear();
sh.drawScene();

fb.update();
fb.displayGLOnly();

Thread.sleep(10);
}
fb.disableRenderer(IRenderer.RENDERER_OPENGL);
fb.dispose();
System.exit(0);
}

public static void main(String[] args) throws Exception {
SimpleShadows cd = new SimpleShadows();
cd.initStuff();
cd.doIt();
}
}


Edit: Here's a little PDF from NVidia dealing with the theory behind shadow mapping for you to get a feeling for possibilities and limitations. The implementation in jPCT may not be exactly like the one described in the PDF, but the theory applies: http://developer.nvidia.com/attach/8456

cyberkilla

Wow! I really can't believe how much work you've done on this.
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

raft

great work Egon, congratulations ;)

hytparadisee

Thanks in advance, though I can't help much. (My damn shitty intel chip :'()
Today I finally found a problem to my soluuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuution

rolz

Egon,
Great work. I'll give it a try.

2 Hytparadisee: man, works perfectly on my work laptop's shitty Intel 945GM
Regards,
Andrei

Melssj5

Long time Rolz! hOW IS TECHNOPOLIS?
Nada por ahora

manumoi

Congratulation for the shadow texturing Egon... that s definetely a huge improvement (and huge work i suspect).

Also happy to see that Rolz is still in the field.

EgonOlsen

Quote from: rolz on July 24, 2007, 12:39:12 AM
2 Hytparadisee: man, works perfectly on my work laptop's shitty Intel 945GM
It does? Amazing! I've never expected it to work on Intel.

Melssj5

Quote from: EgonOlsen on July 24, 2007, 04:45:11 PM
Quote from: rolz on July 24, 2007, 12:39:12 AM
2 Hytparadisee: man, works perfectly on my work laptop's shitty Intel 945GM
It does? Amazing! I've never expected it to work on Intel.

why not? I have had very good results on intel based chipsets!
Nada por ahora

EgonOlsen

Quote from: Melssj5 on July 24, 2007, 05:30:14 PM
why not? I have had very good results on intel based chipsets!
Because my machine@work has on onboard intel chipset not almost nothing works on it. But this may be related to the drivers...they are very old and i'm not allowed to update them.... :-[

raft

it does work on my Intel 915GM too. but the shadows at borders arent that sharp as the image above . i've played with Config.glShadowZBias but didnt help much

hytparadisee

Awwww, no wonder mine can't work ----> Intel 852 :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'(
Today I finally found a problem to my soluuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuution

EgonOlsen

Quote from: raft on July 24, 2007, 05:43:27 PM
it does work on my Intel 915GM too. but the shadows at borders arent that sharp as the image above . i've played with Config.glShadowZBias but didnt help much
Do you have a screenshot of this?

raft

default glShadowZBias


glShadowZBias = 2

EgonOlsen

Looks like an issue with filtering. You can disable it by removing the call to <ShadowHelper>.setFiltering();...or set it to false explicitly just to be sure. Does that change anything?