mormurekkep
Just dropped in
Offline
Posts: 6
|
 |
« on: 17. August 2009, 05:34:13 pm » |
|
is it possible to get/set pixel's RGB values in xith3d? i mean, how can i obtain the functionality of glReadPixels/glDrawPixels using xith3d? thanks...
|
|
|
|
|
Logged
|
|
|
|
Marvin Fröhlich
Xith Lord
Administrator
Guru
   
Online
Posts: 4381
May the 4th, be with you...
|
 |
« Reply #1 on: 17. August 2009, 06:17:52 pm » |
|
You can simply extend an ImageWidget and draw on it. Have a look at the HUDRadarTest. Is that what you need?
Marvin
|
|
|
|
|
Logged
|
|
|
|
mormurekkep
Just dropped in
Offline
Posts: 6
|
 |
« Reply #2 on: 18. August 2009, 07:51:26 am » |
|
In fact, my purpose is to perform stereo rendering by interzigging the pixels of left and right eye views according to the display I use. So, I want to 1. render the whole scene for 2 cameras (left & right) 2. get the left&right view's images 3. generate the stereo image (by interzigging the pixels of 2 views) 4. draw the interzigged image to the render buffer
I can easily do this using directly JOGL or OpenGL & c++ by rendering 2 views to offscreen buffers, read these images (glReadPixels), interzig 2 images, and write the resulting image to the framebuffer (glDrawPixels).
I want to learn the simplest way to do this process. Is there any example that does offscreen rendering using xith3d? Or is it possible?
|
|
|
|
|
Logged
|
|
|
|
Marvin Fröhlich
Xith Lord
Administrator
Guru
   
Online
Posts: 4381
May the 4th, be with you...
|
 |
« Reply #3 on: 18. August 2009, 05:29:41 pm » |
|
Maybe you don't need to do this. There is a StereoViewportTest in xith-tk. Please have a look at it.
If it doesn't do, what you need we could add a method to the Texture2D class, to read back the pixel data from graphics memory.
Marvin
|
|
|
|
|
Logged
|
|
|
|
mormurekkep
Just dropped in
Offline
Posts: 6
|
 |
« Reply #4 on: 19. August 2009, 07:29:56 am » |
|
Thank you. I have looked at StereoViewportTest. It helped but it is not sufficient for me. I use a special display for stereo viewing and the display requires an image in which the pixels are mixed according to the interzigging principle of the display.
So, first I have to render the left and right views to different render targets, then read these targets, mix them, and write the resulting image to the screen.
A method for reading pixel data will be very helpful.
|
|
|
|
|
Logged
|
|
|
|
|
Mathias 'cylab' Henze
|
 |
« Reply #5 on: 24. August 2009, 12:06:41 am » |
|
Hmm, this might be an expensive operation using glReadPixels/glDrawPixels. It might be better to render to textures and use a shader to do the inzigging. What hardware (GPU-wise) are you targetting?
|
|
|
|
|
Logged
|
|
|
|
abc
Just dropped in
Offline
Posts: 9
|
 |
« Reply #6 on: 11. October 2009, 06:36:42 am » |
|
Hi.
I also need such kind of operation. I render the scene to 2 different texture render targets, from 2 different viewpoints. Then I want to mix these 2 targets in pixel shader. But how can I read these textures in shader?
Thanks...
|
|
|
|
|
Logged
|
|
|
|
Marvin Fröhlich
Xith Lord
Administrator
Guru
   
Online
Posts: 4381
May the 4th, be with you...
|
 |
« Reply #7 on: 11. October 2009, 01:49:35 pm » |
|
I also need such kind of operation. I render the scene to 2 different texture render targets, from 2 different viewpoints. Then I want to mix these 2 targets in pixel shader. But how can I read these textures in shader?
This is already possible. Just apply these two textures to the first and second texture unit and read them from within the shader. Marvin
|
|
|
|
|
Logged
|
|
|
|
abc
Just dropped in
Offline
Posts: 9
|
 |
« Reply #8 on: 04. November 2009, 07:09:52 am » |
|
I now this is a very basic stuff but I am new to this field. I created 2 textures for left and right views using 2 render targets. But I couldn't bind these textures to texture units. Texture unit 1 is always empty and I am not sure about texture unit 0 contains the right texture.
Normally, I use TextureLoader class to texture the objects. So, I cannot see the code which handles the binding issue. By the way, I use my own vertex and pixel shaders, not the default ones. Could this be a problem? Any suggestion, sample code will be very helpful.
Thanks...
|
|
|
|
|
Logged
|
|
|
|
|
hawkwind
|
 |
« Reply #9 on: 05. November 2009, 02:20:15 am » |
|
Away from my pc, tomorrow I will post something
|
|
|
|
|
Logged
|
|
|
|
|
hawkwind
|
 |
« Reply #10 on: 05. November 2009, 01:37:54 pm » |
|
in your shader class set both texture units as follows, where the value 0/1 is the same as the texture nits in the apperance.
shaderProgram.getUniformParameters().setUniformVar("tex0", 0); shaderProgram.getUniformParameters().setUniformVar("tex1", 1);
In the appearance of the target shape
app.setTexture(0, Tex1); app.setTexture(1, Tex1);
|
|
|
|
|
Logged
|
|
|
|
abc
Just dropped in
Offline
Posts: 9
|
 |
« Reply #11 on: 10. November 2009, 09:56:47 am » |
|
Thanks. I also want to ask another question.
I couldn't find documentation about the getPixel() and similar methods of TextureImage2D class. What does this method return exactly? What should be the length of parameter data?
|
|
|
|
|
Logged
|
|
|
|
Marvin Fröhlich
Xith Lord
Administrator
Guru
   
Online
Posts: 4381
May the 4th, be with you...
|
 |
« Reply #12 on: 10. November 2009, 06:50:32 pm » |
|
I couldn't find documentation about the getPixel() and similar methods of TextureImage2D class. What does this method return exactly? What should be the length of parameter data?
If your texture has an alpha channel (RGBA), you need (at least) four bytes, if it doesn't have an alpha channel (RGB), you need (at least) three bytes. But don't expect this method to read the pixels from VRAM. These methods are only meant to be used for drawing textures. Hence, if you draw something onto it using the provided methods of TextureImage2D, you can read that pixel data back. But you cannot read data this way from a texture generated by setting it as a RenderTarget. Marvin
|
|
|
|
|
Logged
|
|
|
|
abc
Just dropped in
Offline
Posts: 9
|
 |
« Reply #13 on: 16. November 2009, 07:25:06 pm » |
|
Hi again, I have a critical problem. I think I really need a method in Texture class to read/write pixel data. Isn't it possible to add such a method?
|
|
|
|
|
Logged
|
|
|
|
|
hawkwind
|
 |
« Reply #14 on: 17. November 2009, 02:44:47 am » |
|
Is the radartest example adequate ??
|
|
|
|
|
Logged
|
|
|
|
|