Horde3D

Next-Generation Graphics Engine
It is currently 28.03.2024, 11:03

All times are UTC + 1 hour




Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: 07.06.2009, 12:29 
Offline

Joined: 07.06.2009, 12:07
Posts: 5
Hi,

I am trying to use a
Code:
Horde3D::createTexture2D("mirrorTex", 0, 1024, 1024, true);

created renderable texture as a render target. How do I set this up in the pipeline definition? I tried:
Code:
<SwitchTarget target="mirrorTex"/>

which fails with:
Quote:
Pipeline resource 'pipelines/mirror.pipeline.xml': Error in stage 'Geometry': Reference to undefined render target in SwitchTarget

From the source code in egPipeline.cpp it seems clear that it does.

My question is: What is the right way to submit such a texture as a valid rendering target for a pipeline stage?

Any help will be greatly appreciated.

Henrik


Top
 Profile  
Reply with quote  
PostPosted: 07.06.2009, 23:50 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
You need to bind your renderable texture as output buffer to a camera (CameraNodeParams::OutputTex) and call Horde3D::render with that camera. Inside the pipeline you just bind no render target in order to write to that output buffer. From the docs:

Quote:
SwitchTarget
command for setting the currently active render target to which data is rendered; the command implicitely calls the UnbindBuffers command before the desired render target is activated; child of Stage element {*}
target
name of the render target which was defined in the Setup section or empty string to bind the output buffer assigned to the current camera {required}


Top
 Profile  
Reply with quote  
PostPosted: 09.06.2009, 08:58 
Offline

Joined: 07.06.2009, 12:07
Posts: 5
Thanks. That works great.

At least most of the time. Sometimes the textured polygon is just black, no rendered image appears. Restarting the application often helps. Can this be a timing problem? It looks non-deterministic?

Also, how can I enable the depth buffer for my render target? Normaly this seems to be done with the depthBuf attribute on the RenderTarget element.

Henrik


Top
 Profile  
Reply with quote  
PostPosted: 09.06.2009, 19:46 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
monophon wrote:
Also, how can I enable the depth buffer for my render target? Normaly this seems to be done with the depthBuf attribute on the RenderTarget element.

At the moment you can't have a depth buffer for renderable textures outside the pipeline. This should be enhanced in the future.


Top
 Profile  
Reply with quote  
PostPosted: 11.07.2009, 07:32 
Offline

Joined: 04.07.2009, 03:52
Posts: 8
I have tried to follow the steps you suggested (set OutputTex, render the camera, unbind targets), yet my supposedly-rendered-to-textures come out all black.

I create an empty texture with:
Code:
ResHandle texRes = Horde3D::createTexture2D("NewRenderTexture", 0, 256, 256, true);

This is bound to a camera (the camera uses the forward pipeline that comes with the demos) with:
Code:
Horde3D::setNodeParami(camNode, CameraNodeParams::OutputTex, texRes);

The render-to-texture camera is rendered before the main camera, and finalizeframe is called after the main camera render.

The texture (texRes with name "NewRenderTexture") is referenced in a material file:
Code:
<Material>
  <Shader source="shaders/model.shader" />
  <Sampler name="albedoMap" map="NewRenderTexture" />
</Material>

Yet the geometry drawn with this material comes out all black. If I render the render-to-texture camera after the main camera, Horde3d switches to the debug renderer.

Any ideas?


Top
 Profile  
Reply with quote  
PostPosted: 11.07.2009, 09:23 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
You should create the renderable texture before the material using it is loaded (otherwise the texture already has been added by the material and will be non-renderable). If Horde switches to debug view, it could mean that the pipeline used for rendering is not found or not valid. Are there any debug messages in the log?


Top
 Profile  
Reply with quote  
PostPosted: 12.07.2009, 02:59 
Offline

Joined: 04.07.2009, 03:52
Posts: 8
Hmm. It seems that I'm seeing the same non-deterministic behavior as monophon.

I created a special pipeline that does nothing but clear buf0 to red. On one computer it never works (the render-to-texture textured boxes which should be red are black). On another computer it works maybe 30% of the time, but using the forward pipeline in RTT never works. On a third computer both the red pipeline and the forward pipeline work in RTT about 80% of the time (although the lack of depth buffer makes the result look quite weird).

The computer on which it never works has the best graphics card of the three (an nvidia gtx260), so I doubt the problem stems from a lack of graphics card capability.

My program is running all the graphics from a single thread, and I'm sure that everything happens in exactly the same order every time.


Top
 Profile  
Reply with quote  
PostPosted: 12.07.2009, 09:53 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
Hmm, difficult to say what goes wrong here. If you could provide a minimal sample, I can test it on my machine. You could also try to step into the Horde code with your debugger to see if there are some obvious problems.


Top
 Profile  
Reply with quote  
PostPosted: 13.07.2009, 05:00 
Offline

Joined: 13.07.2009, 04:53
Posts: 2
I'm working with Wakka. I've created a minimal test by modifying the Chicago demo, and attached the added and changed files (just app.cpp and app.h and some additional resources). If you uncompress the zip into the horde3d folder of beta 3, it ought to work.

When it works there should be a blatantly obvious square with RTT working on it right in front of you when you start the chicago demo. To get around the no depth buffer on output textures, it uses a forward pipeline that renders everything to an intermediate buffer first and then copies that to the output target (a texture in this case).

On this computer, it works all the time provided you run outside of debugging mode. If you run in debugging mode, the RTT texture is just black. Additionally, I got an assertion failure once (complaining that there was an opengl error).


Attachments:
File comment: Zip of changes to the chicago demo. Unzip in the Horde3D folder of the beta 3 download.
rtt_test.zip [13.64 KiB]
Downloaded 967 times
Top
 Profile  
Reply with quote  
PostPosted: 13.07.2009, 05:14 
Offline

Joined: 04.07.2009, 03:52
Posts: 8
Ok, using Pyry's patch on this machine (Pentium D w/ GeForce 9800GT running Ubuntu Jaunty), I am getting about a 50% hit rate. That is, 50% of the time, when I start the modded Chicago, I get an RTT square, and 50% of the time I get a completely black square. I've restarted it about 40 times, and I can't see any pattern predicting when it will work.


Top
 Profile  
Reply with quote  
PostPosted: 19.07.2009, 10:58 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
Thanks for the repro case. I can see the problem but some quick debugging did not yet reveal what's going wrong.


Top
 Profile  
Reply with quote  
PostPosted: 26.07.2009, 13:52 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
The problem is hopefully fixed now in the latest svn version. Could you please confirm that using your application?


Top
 Profile  
Reply with quote  
PostPosted: 06.12.2016, 16:46 
Offline

Joined: 02.12.2016, 12:30
Posts: 23
Hay! Can any one tell me how to implement "Render To Texture" on H3D.................. or any working demo link would be fine.................. :| I mean rendering from a different camera( in this case i called it 2nd camera) into a texture, and i don't want to show that 2nd camera rendered buffer on the screen but into a texture so that i can use it as a texture for a CCTV model...............

_________________
~@AlmahmudRony@~


Top
 Profile  
Reply with quote  
PostPosted: 07.12.2016, 20:44 
Offline

Joined: 17.11.2009, 17:00
Posts: 205
Location: Russia, Moscow
You should probably use render to texture somewhat like this:
1) Load pipeline (a custom one or a standard) for the second camera
2) Create second camera with this pipeline
3) Create texture and mark it as renderable. h3dCreateTexture( "tex1", width, height, H3DFormats::BGRA8, H3DResFlags::TexRenderable)
4) Set output texture for the second camera. h3dSetNodeParamI( cam2Idx, H3DCamera::OutTexResI, textureIdx)
5) h3dRender with the second camera
6) Apply the texture id to the material of the desired object. h3dSetResParamI( matID, H3DMaterialRes::SamplerElem, 0, H3DMaterialRes::SampTexResI, textureIdx)

I have not tested it, so it may not be fully functional.


Top
 Profile  
Reply with quote  
PostPosted: 10.12.2016, 17:42 
Offline

Joined: 02.12.2016, 12:30
Posts: 23
Thank you Irdis............. its working but still having some problem.... if i use forward pipeline with 2nd camera its rendering the texture with alpha transparent :shock: ........... and if i use deferred pipeline with the 2nd camera its making something crazy, actually its rendering depth buffer only :roll: ....... You can take a look to those screen shot.............


Attachments:
File comment: with forward pipeline
forwordpipeline.jpg
forwordpipeline.jpg [ 142.68 KiB | Viewed 23434 times ]
File comment: with deferred pipeline
deferredpipeline.jpg
deferredpipeline.jpg [ 114.23 KiB | Viewed 23434 times ]

_________________
~@AlmahmudRony@~
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 60 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group