Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions src/osltoy/osltoyrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,34 @@ OSLToyRenderer::render_image()
m_framebuffer.reset(
OIIO::ImageSpec(m_xres, m_yres, 3, TypeDesc::FLOAT));

static ustring outputs[] = { ustring("Cout") };
std::vector<ustring> output_vars;

// Get the list of output variables from the shader group
shadingsys()->getattribute(shadergroup(), "renderer_outputs", output_vars);

// If no output variables are found, default to Cout
if (output_vars.empty()) {
output_vars.push_back(ustring("Cout"));
}

// If there's only one output variable, automatically use it
const ustring* outputs = &output_vars[0];
if (output_vars.size() == 1) {
outputs = &output_vars[0]; // auto-detect and use the single output
} else {
// If there are multiple outputs, you could implement additional logic here
// to choose between them or provide the user with a choice.
outputs = &output_vars[0]; // default to the first output
}
Comment on lines +143 to +150
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what's going on here. You set outputs to point to the first element of output_vars. OK. Then if that's the only item in output_vars, you... do it again? But if there are multiple items in output_vars, you... also do the same thing?


OIIO::paropt popt(0, OIIO::paropt::SplitDir::Tile, 4096);
shade_image(*shadingsys(), *shadergroup(), &m_shaderglobals_template,
m_framebuffer, outputs, ShadePixelCenters, OIIO::ROI(), popt);
// std::cout << timer() << "\n";
}




int
OSLToyRenderer::supports(string_view /*feature*/) const
{
Expand Down