Skip to content

Conversation

@silvialpz
Copy link

@silvialpz silvialpz commented Nov 28, 2025

Description

Fixes #2021

How it works:

  • Getting all of the output color variables from OSL Query in build_shader_group() in order to set the first one as the default renderer_outputs in OSLToyRenderer.
  • Creating Radio Buttons for output color param rows in the parameter layout panel.
  • Setting up a getter function so that the user selected output can be used in OSLToyRenderer
  • The selected output will be displayed when you hit recompile.
osltoy-auto-detect-output-variable.mov

Tests

I was working with a simple OSL file with two color output variables to test that the user could select the desired output with radio buttons.

surface test_noise (
    float scale = 10
        [[ string help = "Scaling factor for noise frequency" ]],
    output color rgb = 0
        [[ string help = "Perlin noise in color" ]],
    output color bw = 0
        [[ string help = "Perlin noise in black and white" ]]
    

)
{
    point uvw = point(u * scale, v * scale, 0);

    float n = noise("perlin", uvw);

    bw = color(n, n, n);
    rgb = color(noise("perlin", uvw),
             noise("perlin", uvw + 10),
             noise("perlin", uvw + 20));
}

Checklist:

  • I have read the contribution guidelines.
  • I have updated the documentation, if applicable.
  • I have ensured that the change is tested somewhere in the testsuite (adding new test cases if necessary).
  • My code follows the prevailing code style of this project. If I haven't
    already run clang-format v17 before submitting, I definitely will look at
    the CI test that runs clang-format and fix anything that it highlights as
    being nonconforming.

Signed-off-by: silvialpz <74107990+silvialpz@users.noreply.github.com>
@silvialpz silvialpz changed the title osltoy autodetect output color variable osltoy - Feature Request: autodetect output color variable Nov 28, 2025
@lgritz
Copy link
Collaborator

lgritz commented Nov 30, 2025

Great to see this land! I'm a little busy with releases for the next couple days, but will get to it right away after that.

Don't mind the failed CI for now, that is due to issues unrelated to your PR, and I'm fixing them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

osltoy: auto-detect output variable -- doesn't need to be Cout if there's only one

2 participants