Help for Multiple Rendering Passes with 3Delight

I’m working on a script for 3Delight scripted, but I’m failing to get multiple passes, I try to do it with a for loop, but I don’t get any results. This  supposed that I should get several images, one on each pass, but I only get the first one.

My intension is to have multiple render passes with the same Render Script and changing some surface parameters on each pass, but the number of passes depends on the number of objects in the scene so it’s not as easy as placing multiple RiWorldBegin-RiEndWorld blocks in the script as the amount of objects-surfaces in a scene can be large and vary, so first I thought that a for loop would be the answer. but if I try a structure as

 

Renderer.riDeclare( "estado1", "color" );

Renderer.riQuantize( "estado1", 255, 0, 255, 0.5 );

Renderer.riDisplay(some nice display parameters);

var n = 0;

for ( n = 0 ; n <Scene.getNumNodes() ; n++ ) {

       Renderer.riWorldBegin();

           // Some lines changing materials propiertes based in index n

           // adding nodes to be rendered using Renderer.renderNode

        Renderer.riEndWorld( "Here start  each rendering..." );  

}

only the first Renderer.riEndWorld takes action, so only the first block RiWorldBegin-RiEndWorld takes effect and the rest is ignored.

When I use the number of frame animation instead of the for loop (eliminating the for loop and changing Scene.getNumNodes() to Scene.getFrame())  this place each different pass in a different frame and this works wonders, I get all the output images I wanted and how I wanted them, but I don’t know if this is an "elegant" way to solve the problem.

In other hand, I thought I could make a script with a loop that calls material.length times to render script, but I don’t know how to do this.

In short:
1. Is it possible to implement a loop for the RiWorldBegin-RiEndWorld block and does not work for me because I am doing it wrong at some point?
2. Is it not possible to implement a loop for the RiWorldBegin-RiEndWorld block and it can only be done using animation frames?
3. Is there any way to call render script several times from another script?

I would be grateful if anyone could answer any or all of my questions. Only for 3Delight, I need the kind of render that is produced by riDisplay and this is not available for Iray.

Post edited by [email protected] on

Comments

  • OmnifluxOmniflux Posts: 359

    I don't know anything about the DzScriptedRenderer, but

    StandardExampleRenderScript.js says:

    // Passes start with Renderer.riBegin() and end with Renderer.EndWorld();

    So perhaps you need to call riBegin() before riWorldBegin()

  • martinez.zora77@gmail.com[email protected] Posts: 1,343
    edited January 2022

    Omniflux said:

    I don't know anything about the DzScriptedRenderer, but

    StandardExampleRenderScript.js says:

    // Passes start with Renderer.riBegin() and end with Renderer.EndWorld();

    So perhaps you need to call riBegin() before riWorldBegin()

    Yes, I have a riBegin() before riWorldBegin(). I’m just showing the main scheme. The script works like a charm in one pass. 

    The problem is that the DS doesn't want to make several passes with a loop and this is probably because it is not possible to make loops that are not frames, or in case it is possible, I am not placing the loop properly.

    A different solution would be to make a loop in which it is possible to do the same as pressing the button "Render" on the "Render Settings" tab for each iteration.

    If anyone knows which method is equivalent to pressing the Render button I would be very grateful.

    Post edited by [email protected] on
  • OmnifluxOmniflux Posts: 359
    edited January 2022

    I'm not sure you understand what I am saying. (The forum is having issues displaying code blocks)

    var oScriptedRenderer = App.getRenderMgr().findRenderer ("DzScriptedRenderer");

    for (var i=0; i < Scene.getNumNodes(); i++) {
      print ("Beginning loop - i=%1".arg (i));
      oScriptedRenderer.riWorldBegin();
      oScriptedRenderer.riEndWorld ("Rendering...");
      print ("Ending loop - i=%1".arg (i)); }

     This works when i=0, but when i=1, riWorldBegin throws an error (QScriptEngine::popContext() doesn't match with pushContext()) and the loop fails

    var oScriptedRenderer = App.getRenderMgr().findRenderer ("DzScriptedRenderer");

    for (var i=0; i < Scene.getNumNodes(); i++) {
      print ("Beginning loop - i=%1".arg (i));
      oScriptedRenderer.riBegin();
      oScriptedRenderer.riWorldBegin();
      oScriptedRenderer.riEndWorld ("Rendering...");
      print ("Ending loop - i=%1".arg (i)); }

    This works when i=0...n. There is no error and the loop repeats for however many nodes I place in the scene.

    I don't know that this is the correct way to do what you are trying to do, only that it resolves the issue of an error being thrown and halting the loop.

     

    Post edited by Omniflux on
  • Omniflux said:

    I'm not sure you understand what I am saying. (The forum is having issues displaying code blocks)

    var oScriptedRenderer = App.getRenderMgr().findRenderer ("DzScriptedRenderer");

    for (var i=0; i < Scene.getNumNodes(); i++) {
      print ("Beginning loop - i=%1".arg (i));
      oScriptedRenderer.riWorldBegin();
      oScriptedRenderer.riEndWorld ("Rendering...");
      print ("Ending loop - i=%1".arg (i)); }

     This works when i=0, but when i=1, riWorldBegin throws an error (QScriptEngine::popContext() doesn't match with pushContext()) and the loop fails

    var oScriptedRenderer = App.getRenderMgr().findRenderer ("DzScriptedRenderer");

    for (var i=0; i < Scene.getNumNodes(); i++) {
      print ("Beginning loop - i=%1".arg (i));
      oScriptedRenderer.riBegin();
      oScriptedRenderer.riWorldBegin();
      oScriptedRenderer.riEndWorld ("Rendering...");
      print ("Ending loop - i=%1".arg (i)); }

    This works when i=0...n. There is no error and the loop repeats for however many nodes I place in the scene.

    I don't know that this is the correct way to do what you are trying to do, only that it resolves the issue of an error being thrown and halting the loop.

     

     I wasn’t really understanding. My RiBegin is out of the loop when it should be in. Great, I’ll try it. Thank you so much for testing it.

  • Thanks omniflux!!!

    My script works just now, I'm very happy.

Sign In or Register to comment.