Author Topic: Beta of 1.15 released!  (Read 18653 times)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Beta of 1.15 released!
« on: July 16, 2007, 10:15:10 pm »
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):


Code: [Select]
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
« Last Edit: July 16, 2007, 11:07:29 pm by EgonOlsen »

Offline cyberkilla

  • float
  • ****
  • Posts: 413
    • View Profile
    • http://futurerp.net
Re: Beta of 1.15 released!
« Reply #1 on: July 17, 2007, 01:02:26 am »
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

Offline raft

  • quad
  • ******
  • Posts: 1974
    • View Profile
    • http://www.aptalkarga.com
Re: Beta of 1.15 released!
« Reply #2 on: July 17, 2007, 03:58:12 am »
great work Egon, congratulations ;)

Offline hytparadisee

  • int
  • **
  • Posts: 86
    • View Profile
    • http://peterhi.com
Re: Beta of 1.15 released!
« Reply #3 on: July 19, 2007, 05:10:41 am »
Thanks in advance, though I can't help much. (My damn shitty intel chip :'()
Today I finally found a problem to my soluuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuution

Offline rolz

  • float
  • ****
  • Posts: 280
  • Technocrat
    • View Profile
Re: Beta of 1.15 released!
« Reply #4 on: July 24, 2007, 12:39:12 am »
Egon,
Great work. I'll give it a try.

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

Offline Melssj5

  • double
  • *****
  • Posts: 715
    • View Profile
Re: Beta of 1.15 released!
« Reply #5 on: July 24, 2007, 02:04:30 am »
Long time Rolz! hOW IS TECHNOPOLIS?
Nada por ahora

Offline manumoi

  • long
  • ***
  • Posts: 121
    • View Profile
    • http://www.iro.umontreal.ca/~blanchae
Re: Beta of 1.15 released!
« Reply #6 on: July 24, 2007, 06:55:22 am »
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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Beta of 1.15 released!
« Reply #7 on: July 24, 2007, 04:45:11 pm »
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.

Offline Melssj5

  • double
  • *****
  • Posts: 715
    • View Profile
Re: Beta of 1.15 released!
« Reply #8 on: July 24, 2007, 05:30:14 pm »
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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Beta of 1.15 released!
« Reply #9 on: July 24, 2007, 05:38:52 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.... :-[

Offline raft

  • quad
  • ******
  • Posts: 1974
    • View Profile
    • http://www.aptalkarga.com
Re: Beta of 1.15 released!
« Reply #10 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

Offline hytparadisee

  • int
  • **
  • Posts: 86
    • View Profile
    • http://peterhi.com
Re: Beta of 1.15 released!
« Reply #11 on: July 24, 2007, 05:56:52 pm »
Awwww, no wonder mine can't work ----> Intel 852 :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'(
Today I finally found a problem to my soluuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuution

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Beta of 1.15 released!
« Reply #12 on: July 24, 2007, 06:05:41 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?

Offline raft

  • quad
  • ******
  • Posts: 1974
    • View Profile
    • http://www.aptalkarga.com
Re: Beta of 1.15 released!
« Reply #13 on: July 24, 2007, 06:23:15 pm »
default glShadowZBias


glShadowZBias = 2

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Beta of 1.15 released!
« Reply #14 on: July 24, 2007, 06:35:34 pm »
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?