Community
Arnold General Rendering Forum
abbrechen
Suchergebnisse werden angezeigt für 
Anzeigen  nur  | Stattdessen suchen nach 
Meintest du: 

Can I use the Arnold renderer SDK with SFML?

6 ANTWORTEN 6
GELÖST
Antworten
Nachricht 1 von 7
Anonymous
543 Aufrufe, 6 Antworten

Can I use the Arnold renderer SDK with SFML?

I would like to use the Arnold renderer SDK with SFML 2.5.1. Is this possible?

Tags (1)
Beschriftungen (1)
  • SDK
6 ANTWORTEN 6
Nachricht 2 von 7
Stephen.Blair
als Antwort auf: Anonymous

Why not? We use the Arnold SDK with the Maya sdk, the 3ds Max sdk, the Houdini sdk, the Katana sdk. And others use it with Blender and Gaffer and Softiamge



// Stephen Blair
// Arnold Renderer Support
Nachricht 3 von 7
Anonymous
als Antwort auf: Anonymous

Thank you. My question is really how can I use it.

I want to render on an SFML window instead to a JPEG. Here is my code:
I want to render the Arnold output on an SFML window I defined below:

(Please excuse me, I am new to C++)

#include <ai.h>
#include <SFML/Graphics.hpp>

class SFMLWindow {
public:
    int show(AtArray *arrayOutput) {
        // create the window
        sf::RenderWindow window(sf::VideoMode(800, 600), "My window");

        // run the program as long as the window is open
        while (window.isOpen())
        {
            // check all the window's events that were triggered since the last iteration of the loop
            sf::Event event;
            while (window.pollEvent(event))
            {
                // "close requested" event: we close the window
                if (event.type == sf::Event::Closed)
                    window.close();
            }

            // clear the window with black color
            window.clear(sf::Color::Black);


            // draw everything here...
            // window.draw(arrayOutput);

            // end the current frame
            window.display();
        }

        return EXIT_SUCCESS;
    }
};

int main()
{
   // start an Arnold session, log to both a file and the console
   AiBegin();
   AiMsgSetLogFileName("scene1.log");
   AiMsgSetConsoleFlags(AI_LOG_ALL);
  
   // create a sphere geometric primitive
   AtNode *sph = AiNode("sphere");
   AiNodeSetStr(sph, "name", "mysphere");
   AiNodeSetVec(sph, "center", 0.0f, 4.0f, 0.0f);
   AiNodeSetFlt(sph, "radius", 4.0f);
  
   // create a polymesh, with UV coordinates
   AtNode *mesh = AiNode("polymesh");
   AiNodeSetStr(mesh, "name", "mymesh");
   AtArray* nsides_array = AiArray(1, 1, AI_TYPE_UINT, 4);
   AiNodeSetArray(mesh, "nsides", nsides_array);
   AtArray* vlist_array = AiArray(12, 1, AI_TYPE_FLOAT, -10.f, 0.f, 10.f, 10.f, 0.f, 10.f, -10.f, 0.f, -10.f, 10.f, 0.f, -10.f);
   AiNodeSetArray(mesh, "vlist", vlist_array);
   AtArray* vidxs_array = AiArray(4, 1, AI_TYPE_UINT, 0, 1, 3, 2);
   AiNodeSetArray(mesh, "vidxs", vidxs_array);
   AtArray* uvlist_array = AiArray(8, 1, AI_TYPE_FLOAT, 0.f, 0.f, 1.f, 0.f, 1.f, 1.f, 0.f, 1.f);
   AiNodeSetArray(mesh, "uvlist", uvlist_array);
   AtArray* uvidxs_array = AiArray(4, 1, AI_TYPE_UINT, 0, 1, 2, 3);
   AiNodeSetArray(mesh, "uvidxs", uvidxs_array);
  
   // create a red standard surface shader
   AtNode *shader1 = AiNode("standard_surface");
   AiNodeSetStr(shader1, "name", "myshader1");
   AiNodeSetRGB(shader1, "base_color", 1.0f, 0.02f, 0.02f);
   AiNodeSetFlt(shader1, "specular", 0.05f);
  
   // create a textured standard surface shader
   AtNode *shader2 = AiNode("standard_surface");
   AiNodeSetStr(shader2, "name", "myshader2");
   AiNodeSetRGB(shader2, "base_color", 1.0f, 0.0f, 0.0f);
  
   // create an image shader for texture mapping
   AtNode *image = AiNode("image");
   AiNodeSetStr(image, "name", "myimage");
   AiNodeSetStr(image, "filename", "./dad_son.jpg");
   AiNodeSetFlt(image, "sscale", 4.f);
   AiNodeSetFlt(image, "tscale", 4.f);
   // link the output of the image shader to the color input of the surface shader
   AiNodeLink(image, "base_color", shader2);
  
   // assign the shaders to the geometric objects
   AiNodeSetPtr(sph, "shader", shader1);
   AiNodeSetPtr(mesh, "shader", shader2);
  
   // create a perspective camera
   AtNode *camera = AiNode("persp_camera");
   AiNodeSetStr(camera, "name", "mycamera");
   // position the camera (alternatively you can set 'matrix')
   AiNodeSetVec(camera, "position", 0.f, 10.f, 35.f);
   AiNodeSetVec(camera, "look_at", 0.f, 3.f, 0.f);
   AiNodeSetFlt(camera, "fov", 45.f);
  
   // create a point light source
   AtNode *light = AiNode("point_light");
   AiNodeSetStr(light, "name", "mylight");
   // position the light (alternatively use 'matrix')
   AiNodeSetVec(light, "position", 15.f, 30.f, 15.f);
   AiNodeSetFlt(light, "intensity", 4500.f); // alternatively, use 'exposure'
   AiNodeSetFlt(light, "radius", 4.f); // for soft shadows
  
   // get the global options node and set some options
   AtNode *options = AiUniverseGetOptions();
   AiNodeSetInt(options, "AA_samples", 8);
   AiNodeSetInt(options, "xres", 1480);
   AiNodeSetInt(options, "yres", 1360);
   AiNodeSetInt(options, "GI_diffuse_depth", 4);
   // set the active camera (optional, since there is only one camera)
   AiNodeSetPtr(options, "camera", camera);
  
   // create an output driver node
   AtNode *driver = AiNode("driver_jpeg");
   AiNodeSetStr(driver, "name", "mydriver");
   AiNodeSetStr(driver, "filename", "./scene1.jpg");
  
   // create a gaussian filter node
   AtNode *filter = AiNode("gaussian_filter");
   AiNodeSetStr(filter, "name", "myfilter");
  
   // assign the driver and filter to the main (beauty) AOV,
   // which is called "RGBA" and is of type RGBA
   AtArray *outputs_array = AiArrayAllocate(1, 1, AI_TYPE_STRING);
   AiArraySetStr(outputs_array, 0, "RGBA RGBA myfilter mydriver");
   AiNodeSetArray(options, "outputs", outputs_array);
  
   // finally, render the image!
   AiRender(AI_RENDER_MODE_CAMERA);

   SFMLWindow arnoldWindow = SFMLWindow();
   arnoldWindow.show(outputs_array);

   // ... or you can write out an .ass file instead
   //AiASSWrite("scene1.ass", AI_NODE_ALL, FALSE);
  
   // Arnold session shutdown
   AiEnd();
  
   return 0;
};
Nachricht 4 von 7
Stephen.Blair
als Antwort auf: Anonymous

The Arnold plugins (like MtoA) have a custom Arnold driver that writes the the display window.

Here's the SItoA driver:
https://github.com/Autodesk/sitoa/blob/master/plugins/sitoa/renderer/DisplayDriver.cpp



// Stephen Blair
// Arnold Renderer Support
Nachricht 5 von 7
Anonymous
als Antwort auf: Anonymous

Thank you. I am new to C++, and my question really is how to use it with SFML. I come from a Python and Java background.

Nachricht 6 von 7
Stephen.Blair
als Antwort auf: Anonymous

If you want to render to a window (eg an IPR window), you'll need a custom Arnold driver. For that you'll need to use C/C++

Then you can use the Arnold Python API to build the scene and render.

If you want to show the final rendered image, you just load the rendered file from disk.



// Stephen Blair
// Arnold Renderer Support
Nachricht 7 von 7
Anonymous
als Antwort auf: Anonymous

Ok, thanks!

Sie finden nicht, was Sie suchen? Fragen Sie die Community oder teilen Sie Ihr Wissen mit anderen.

In Foren veröffentlichen  

Autodesk Design & Make Report