Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (487)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (553)
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  
  Render to texture  (Read 3267 times)
0 Members and 1 Guest are viewing this topic.
Offline Niwak

Senior Member


Medals: 1
Projects: 1



« Posted 2005-04-01 13:15:44 »

I've just added render to texture feature to my build of Xith3D.

Here are a few screenshots ;

Radial Blur (Nehe lesson 36)



Cube rendered on the faces of a cube



This is my first post and my first participation to an open source projet. Therefore I don't know how to contribute so I post everything here ;

Here are the source for the examples and the cvs diff ;
http://vbousquet.free.fr/Xith3d/CubeInCube.java
http://vbousquet.free.fr/Xith3d/RadialBlur.java
http://vbousquet.free.fr/Xith3d/mychanges.diff

This is mainly a first post to get feedback on this work.
I think the code still needs a few improvements to be usable by other peoples.

Bye

              Vincent
Offline arne

Senior Member




money is the worst drug- we should not let it rule


« Reply #1 - Posted 2005-04-01 13:58:36 »

Heck !!! This looks nice dude Cheesy
How much rendering efford does it take?

:: JOODE :: Xith3d :: OdeJava ::
Offline Niwak

Senior Member


Medals: 1
Projects: 1



« Reply #2 - Posted 2005-04-01 14:04:22 »

The code is very simple.

I don't think it costs too much FPS since it uses JOGL PBuffer which are based on either WGL_ARB extension or NVidia extension which are known to be the most effective offscreen surface (compared to render to back buffer then copy, and similar techniques).

Anyway, my videocard is quite old (early Geforce 2) and everything runs at full speed.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ewills

Junior Member




Java skeletal animation systems rock!


« Reply #3 - Posted 2005-04-01 15:21:04 »

Sounds (and looks) great!  What does the API look like?  Could you submit a patch?
Offline Niwak

Senior Member


Medals: 1
Projects: 1



« Reply #4 - Posted 2005-04-01 15:32:47 »

Have to a look to the sample.

The easier to understand is the CubeInCube one.

The code is very easy to use ;

First, you create a texture canvas like this ;

ITextureCanvasPeer tcp = renderPeer.makeTextureCanvas(displayCanvas.get3DPeer(), 256, 256);

And then you can use it just as any canvas peer.

To use the rendered texture, you just have to use the getTexture method the created canvas. For example like this ;

appearance.setTexture(tcp.getTexture());

Now when you want to update your texture (i.e. you want to render to the texture), you just call view.renderOnce() on the view attached to the texture canvas.

Bye

            Vincent
Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #5 - Posted 2005-04-01 21:15:36 »

great stuff!

Sign up to the Xith3D project (https://xith3d.dev.java.net/) for the role BetaTester.  I will approve it ASAP.

Once approved, you can submit Issues with patches, etc.  Announcing it on the forums is good oto, but though IssueZilla a perminent record is kept which is good.  One of the Xith3D dev's (probably me) will then go though your patch, and then commit it in.

The only thing I would ask is that you port your changes to the LWJGL renderer as well.  As this renderer is officially supported by Xith3D, we can't accept patches that improve one renderer without the other (unless it is currently not possible, which is rare).

I'd love to see this feature in Xith3D.   Nice going Grin

Cheers,

Will.

Offline Yuri Vl. Gushchin

Senior Member




Speak Java!


« Reply #6 - Posted 2005-04-03 11:38:59 »

Hi,

This is very good and critical change.

I would like to coordinate addition of Render-to-texture with other changes of Xith3D.

Vincent, I would suggest you to search this forum for my previous posts (maybe half a year or even more ago) discussing multipass rendering, because of RTT is exactly subject for this change.

I have clear concept of how to add multipass rendering to Xith3D (covering stereo rendering, multi-projection rendering, render-to-texture, rendering reflections, etc.), but still not so much time to implement this.

In the meantime, how I already noted in other post, there is a new work coming, and there I will need multipass rendering in Xith3D anyway.

I planned to implement several different techniques for RTT, including true RTT as well as screen buffer re-use technique (involving copying part of screen buffer to texture).

You can contact me via PIM for more details, but of course we can also discuss this on the forum.

Yuri

Yuri Vl. Gushchin
JProof Group
Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #7 - Posted 2005-04-04 11:44:28 »

It will be nice to have this feature.

Are we placing issue 93 on hold  (https://xith3d.dev.java.net/issues/show_bug.cgi?id=93) for the time being then?

Yuri, do you have a draft timeline for the addition of these features?  They will be very valuable additions to Xith3D.

Will.

Offline DonCrudelis

Junior Member





« Reply #8 - Posted 2005-04-04 15:40:56 »

Sorry, I'm not so good at this Smiley
How do I install this great update?
Help is appreciated Smiley

Alonzo
Offline Niwak

Senior Member


Medals: 1
Projects: 1



« Reply #9 - Posted 2005-04-04 18:33:35 »

The update is just a proposal. It has not yet made it to be 'official'. It is not finished and is mainly for testing purpose.

If you want to try it, you should use th one posted ont he issue manager (issue 93 i think) which fix a few bugs and support LWJGL as well as JOGL.

This is the result of a cvs diff command against a fresh cvs checkout.

I don't know how to apply a diff. I suggest you look to cvs manual.

Sorry

  Vincent
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #10 - Posted 2005-04-04 23:00:48 »

Vincent,

We can post an experimental build with your changes if you like to xith.org.  This is a good way for people to try it out.

If you email me a zip or tar.gz of your xith3d directory, with a compiled xith3d.jar with your changes, I shall upload it.

Will.

Offline DonCrudelis

Junior Member





« Reply #11 - Posted 2005-04-22 13:17:00 »

Something new in this topic?
Offline ewills

Junior Member




Java skeletal animation systems rock!


« Reply #12 - Posted 2005-04-22 22:15:49 »

+1!  I would really like to use this feature soon!  Is it close to being added to CVS?
Offline Niwak

Senior Member


Medals: 1
Projects: 1



« Reply #13 - Posted 2005-04-26 17:40:30 »

I've placed the compiled jar and source tree of my changes under the following links ;

http://vbousquet.free.fr/Xith3d/xith3d.jar
http://vbousquet.free.fr/Xith3d/src.zip

If you want to try/use them, remember that this is just a proposal and that it is likely that render to texture will be implemented an other way in the core.

The jar is compiled with the examples (CubeInCube and RadialBlur) using lwjgl.

Bye

                Vincent
Offline ewills

Junior Member




Java skeletal animation systems rock!


« Reply #14 - Posted 2005-04-29 15:08:56 »

I get the following exception when I create a Window containing a Canvas3D attached to a View that also has a TextureCanvas attached to it:

Exception in thread "AWT-EventQueue-0" net.java.games.jogl.GLException: pbuffer
creation error: wglCreatePbufferARB() failed: tried 8 pixel formats, last error
was: (Unknown error code 0)
       at net.java.games.jogl.impl.windows.WindowsPbufferGLContext.createPbuffe
r(WindowsPbufferGLContext.java:304)
       at net.java.games.jogl.impl.windows.WindowsOnscreenGLContext.makeCurrent
(WindowsOnscreenGLContext.java:135)
       at net.java.games.jogl.impl.GLContext.invokeGL(GLContext.java:246)
       at net.java.games.jogl.impl.windows.WindowsOnscreenGLContext.invokeGL(Wi
ndowsOnscreenGLContext.java:76)
       at net.java.games.jogl.GLCanvas.maybeDoSingleThreadedWorkaround(GLCanvas
.java:228)
       at net.java.games.jogl.GLCanvas.reshape(GLCanvas.java:125)
       at java.awt.Component.setBounds(Unknown Source)
       at java.awt.BorderLayout.layoutContainer(Unknown Source)
       at java.awt.Container.layout(Unknown Source)
       at java.awt.Container.doLayout(Unknown Source)
       at java.awt.Container.validateTree(Unknown Source)
       at java.awt.Container.validateTree(Unknown Source)
       at java.awt.Container.validateTree(Unknown Source)
       at java.awt.Container.validateTree(Unknown Source)
       at java.awt.Container.validate(Unknown Source)
       at java.awt.Window.pack(Unknown Source)
       at jdm.viewer.DinoMorphViewer.<init>(DinoMorphViewer.java:67)
       at jdm.DinoMorph.startNewViewer(DinoMorph.java:192)
       at jdm.gui.DinoMenuBar$8.actionPerformed(DinoMenuBar.java:369)
       at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
       at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
       at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
       at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
       at javax.swing.AbstractButton.doClick(Unknown Source)
       at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
       at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown
Source)
       at java.awt.Component.processMouseEvent(Unknown Source)
       at javax.swing.JComponent.processMouseEvent(Unknown Source)
       at java.awt.Component.processEvent(Unknown Source)
       at java.awt.Container.processEvent(Unknown Source)
       at java.awt.Component.dispatchEventImpl(Unknown Source)
       at java.awt.Container.dispatchEventImpl(Unknown Source)
       at java.awt.Component.dispatchEvent(Unknown Source)
       at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
       at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
       at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
       at java.awt.Container.dispatchEventImpl(Unknown Source)
       at java.awt.Window.dispatchEventImpl(Unknown Source)
       at java.awt.Component.dispatchEvent(Unknown Source)
       at java.awt.EventQueue.dispatchEvent(Unknown Source)
       at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)

       at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
       at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
       at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
       at java.awt.EventDispatchThread.run(Unknown Source)

Any ideas?
Offline Niwak

Senior Member


Medals: 1
Projects: 1



« Reply #15 - Posted 2005-04-30 06:28:45 »

Could you post a bit more info or send a bit of the code.

The strange thing in your code is that it seems that you are creating the rendered texture in the reshape JOGL event.

This may cause the problem since the actual code does not implement freeing of the created PBuffers. Therefore you may create a lot of them in a sequence of reshape events whithout freeing anything. I will have a look to add releasing of PBuffers since it's needed even if it's not the cause of your problem.

Another question is does the examples work on your system or not ?

And knowing a bit of your hardware/driver could help as well.

        Vincent
Offline ewills

Junior Member




Java skeletal animation systems rock!


« Reply #16 - Posted 2005-04-30 22:19:15 »

Ok... got it working on a different computer.  I'm not sure what the problem was, or why it was crashing when I resized the viewer Smiley   I am noticing another weirdness though.  I want to attach the texture canvas to the same View that the standard canvas is attached to so that I can do high-res captures.  When I attach both canvases to the same View, my machine grinds to a halt (memory leak?).  This does not seem to be an issue if I use two separate Views.
Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #17 - Posted 2005-04-30 23:17:14 »

Quote
+1!  I would really like to use this feature soon!  Is it close to being added to CVS?


I'm investigating this matter.  Hopefully we will have the Render to Texture feature in the core soon, I am looking forward to using it too.


BTW - if anyone want's to check out Niwak's source pretty printed, use these links Smiley
http://showsrc.com/$http://vbousquet.free.fr/Xith3d/CubeInCube.java
http://showsrc.com/$http://vbousquet.free.fr/Xith3d/RadialBlur.java

Cheers,

Will.

Offline ewills

Junior Member




Java skeletal animation systems rock!


« Reply #18 - Posted 2005-05-01 19:17:03 »

So using your code, how would one get a BufferedImage from the TextureCanvasPeer or RenderTexture?  I have been unsuccessful in doing this Sad
Offline Niwak

Senior Member


Medals: 1
Projects: 1



« Reply #19 - Posted 2005-05-02 05:10:33 »

It's not really designed for offscreen rendering so there is no straight forward solution.

I think the easiest solution is to render your scene to a big texture. Then render your texture to a classic canvas (using a simple quad) and take snapshots.

If the texture is bigger than the display canvas, just render it by making 4 passes (one for each corner) and take 4 snapshots. You will have to combine the 4 BufferedImage to get the complete high res snapshot.

        Vincent
Offline ewills

Junior Member




Java skeletal animation systems rock!


« Reply #20 - Posted 2005-05-02 14:50:07 »

That's basically the approach I'm using now... the only problem is that I have to render using an orthographic projection to avoid perspective distortions between camera locations.  Is there a way to do this without moving the camera?
Offline mmmike

Senior Newbie




Java games rock!


« Reply #21 - Posted 2005-12-22 11:24:47 »

Hi, guys, again!

Are there some news about adding 'Render To Texture' feature to Xith core? What is the case status?
Offline Niwak

Senior Member


Medals: 1
Projects: 1



« Reply #22 - Posted 2005-12-22 14:13:04 »

I've worked a simple hack to test render to texture with Xith. This hack has a few problems which are linked to the way the Xith3D core is designed.
I've started to work on this (and adding multi-pass rendering in the same time, since it is linked to the same problems).
It appeared that adding these features to the core would need a lot of refactoring. I finally decided that writing my own engine would be easier than refactoring Xith and I have stopped development on this Xith feature (my engine is now running and fullfill most of my needs).

Yuri seemed to have the same needs and was thinking in adding these functionnality to the core as well. Perhaps he has done some work on this.

           Vincent
Offline mmmike

Senior Newbie




Java games rock!


« Reply #23 - Posted 2005-12-24 20:30:58 »

Thanks for the detailed comment, Vincent.
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.

TehJavaDev (17 views)
2014-08-28 18:26:30

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

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

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

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

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

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

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

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

BurntPizza (36 views)
2014-08-08 02:01:56
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!