Page 1 of 1

OSL compile error with boolean widget

Posted: Mon Aug 14, 2023 8:43 pm
by ChrisH
Hi, I found a problem with OSL compilation.
I've tested this in both "Octane Blender" (27.16 / 3.5.1) and with the add-on (27.16.3 / 3.6.1)
(I've also tested the OSL script in the Octane Node Graph, and Cycles, where it works fine)

The problem is that you can't have an int as an boolean widget, you can't have it enabled by default.
Relevant line ("full" example bellow and attached):

Code: Select all

      int use_a = 1 [[string label = "Use A", string widget = "boolean"]], // This DOESN'T work!
//    int use_a = 0 [[string label = "Use A", string widget = "boolean"]], // This works

And it gives this error:

Code: Select all

Traceback (most recent call last):
  File "C:\Users\chris\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\octane\nodes\base_osl.py", line 439, in invoke
    node.compile_osl_node(self.report)
  File "C:\Users\chris\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\octane\nodes\base_osl.py", line 392, in compile_osl_node
    reply_data = str(ET.fromstring(response).get("content"))
  File "C:\Program Files\Blender Foundation\Blender 3.6\3.6\python\lib\xml\etree\ElementTree.py", line 1342, in XML
    parser.feed(text)
xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 3, column 127
Error: Python: Traceback (most recent call last):
  File "C:\Users\chris\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\octane\nodes\base_osl.py", line 439, in invoke
    node.compile_osl_node(self.report)
  File "C:\Users\chris\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\octane\nodes\base_osl.py", line 392, in compile_osl_node
    reply_data = str(ET.fromstring(response).get("content"))
  File "C:\Program Files\Blender Foundation\Blender 3.6\3.6\python\lib\xml\etree\ElementTree.py", line 1342, in XML
    parser.feed(text)
xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 3, column 127
Example:

Code: Select all

shader Switch(
//    int use_a = 0 [[string label = "Use A", string widget = "boolean"]], // This works
    int use_a = 1 [[string label = "Use A", string widget = "boolean"]], // This DOESN'T work!
    color col_a = 0 [[string label = "A"]],
    color col_b = 1 [[string label = "B"]],
    output color out = 0 [[string label = "Output"]]
)
{
    if (use_a)
        out = col_a;
    else
        out = col_b;
}