Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (581)
games submitted by our members
Games in WIP (500)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  shadow mapping  (Read 647 times)
0 Members and 1 Guest are viewing this topic.
Offline jsz

Junior Newbie




Java games rock!


« Posted 2005-01-10 13:04:22 »

I'm trying to add shadow mapping to my Xith3D-poject. The JOGL version of NVIDIA's HWShadowmapsSimple is my starting point.

After playing with HWShadowmapsSimple and many looks in the Xith3d source code, I think I have to implement the following parts:

1. Create an empty texture (should be a depth texture later; GL_ARB_depth_texture) as shadow map (if possible without big changes to Texture2D and TextureShaderPeer):

By now:
1  
2  
3  
4  
5  
6  
7  
8  
9  
int texSize = 512;
byte buffer[] = new byte[texSize*texSize*3];

texture = new Texture2D(Texture.BASE_LEVEL, Texture.RGB, texSize, texSize);
ImageComponent2D im = new ImageComponent2D(ImageComponent.FORMAT_RGB, texSize, texSize, false, false);
BufferedImage bi = DirectBufferedImage.getDirectImageRGB(texSize, texSize, buffer);

im.set(bi);
texture.setImage(0, im);

Is there a better way to do this?

2. Create a pbuffer in the same GL-Context as the instance of  CanvasPeerImpl of the camera's view:

I override CanvasPeerImpl and create the pbuffer during the initialization.
1  
2  
3  
4  
5  
6  
7  
8  
public class CanvasPeerMyImpl extends CanvasPeerImpl {
 PBuffer pbuffer;

  public void init(GLDrawable drawable) {
   super.init(drawable);
   pbuffer = drawable.createOffscreenDrawable(caps, width, height)
  }
}

3. Use an instance of View.java to render the scene from the light's point of view to the pbuffer (flat shading, depth texture ...):

I don't want to change the View class. Maybe I could implement something like PbufferPeerImpl (implements CanvasPeer)
and add it instead of CanvasPeerImpl to the Canvas3D attached to the view at the light's point of view?
Something like:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
View lightView = new View();

PbufferPeerImpl pbufferPeer = PbufferPeerImpl(...);
Canvas3D shadowCanvas = new Canvas3D();
canvas.set3DPeer(pbufferPeer);

lightView.addCanvas3D(shadowCanvas);

...

lightView.renderOnce();
cameraView.renderOnce();


The PbufferPeerImpl's Pbuffer should be created as described under 2.

4. Copy the pbuffer to the texture:

By now, I'm able to copy the Back Buffer to a texture with these lines:
1  
2  
3  
4  
5  
6  
7  
8  
public class CanvasPeerMyImpl extends CanvasPeerImpl {
 public void display(GLDrawable drawable) {
  super.display(drawable);
  gl.glBindTexture(GL.GL_TEXTURE_2D, 1);
  gl.glCopyTexSubImage2D(GL.GL_TEXTURE_2D, 0,   100, 100,   0, 0,  400, 300);
  gl.glFlush();
 }
}


First the PBuffer should be rendered and copied to the texture, second the camera's view should  be rendered (using the depth texture).

---

Please be honest, if this approach is completely stupid or won't work for any reason. This is my plan after studying the overview of the xith3d rendering pipeline and the jogl-example.

I'm grateful for any hint.
Offline jsz

Junior Newbie




Java games rock!


« Reply #1 - Posted 2005-01-14 13:37:23 »

I think it won't work  Sad

I would have to change many lines at least in the following classes:

    View.java
    CanvasPeerImpl.java
    maybe all ShaderPeers (because of cast from CanvasPeer to CanvasPeerImpl)

plus extending CanvasPeerImpl to an own Impl and so on.

Another possibility would be rendering the shadow map completely
new without using the xith3d rendering pipeline (not very nice).

Ok, my project doesn't have many objects so i'll implement everything
directly in JOGL.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

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

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (58 views)
2014-04-15 18:08:23

BurntPizza (56 views)
2014-04-15 03:46:01

UprightPath (69 views)
2014-04-14 17:39:50

UprightPath (52 views)
2014-04-14 17:35:47

Porlus (69 views)
2014-04-14 15:48:38

tom_mai78101 (95 views)
2014-04-10 04:04:31

BurntPizza (155 views)
2014-04-08 23:06:04

tom_mai78101 (250 views)
2014-04-05 13:34:39

trollwarrior1 (206 views)
2014-04-04 12:06:45

CJLetsGame (213 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!