Hi there!
I’m working on integrating the Cycles renderer with my own application, which is built using Qt and OpenGL.
I’ve got some reasonable progress on it, but I’m having crashes when I try to add materials/shaders to my geometry. The scene renders correctly with just geometry, but when I create a shader with a shader graph, I now have random crashes. The crashes seem to happen in the OpenGL part of my application, so I’m guessing that the OpenGL state is being disturbed by Cycles in some way, but since I’m using a CPU device, I don’t know if that is actually the cause…
Has anybody had any issues with this and/or can shed some light into this issue?
The shader I’m using is pretty simple:
void CyclesRender::set_shader_pbr(ccl::Mesh* mesh, const std::string& albedo_name)
{
// Create shader graph
ShaderGraph* shader_graph = new ShaderGraph();
auto output_node = shader_graph->output();
auto bsdf_node = new PrincipledBsdfNode();
shader_graph->add(bsdf_node);
if (albedo_name != "")
{
ImageTextureNode* itn = new ImageTextureNode();
itn->set_filename(ustring(albedo_name));
shader_graph->connect(itn->output("Color"), bsdf_node->input("Base Color"));
shader_graph->add(itn);
}
// Create connections
shader_graph->connect(bsdf_node->output("BSDF"), output_node->input("Surface"));
// Create shader
Shader* shader = new Shader();
shader->set_graph(shader_graph);
_scene->shaders.push_back(shader);
// Set shader to material
array<Node*> used_shaders = mesh->get_used_shaders();
used_shaders.push_back_slow(shader);
mesh->set_used_shaders(used_shaders);
}
Thanks in advance!
Diogo