Added the importer code fir RGBCurvesNode in xml_read_shader_graph() function
Changed the way to read shader, support reading from different places
Details
- Reviewers
- None
- Group Reviewers
Cycles
Diff Detail
Event Timeline
The rgbcurvesnode is a subnode under the <shader></shader> tag and cannot be loaded like the mesh data. It's not elegant to add a line in the xml_read_scene() specially for rgbcurvesnode. I feel it would be better to change the import code of xml_read_shader(): Check if the name already existed in the state.scene->shaders. So the nodes in a shader can be imported from different places.
For example
File 1
<cycles>
<shader name="name_1">
<certain_node />
</shader>
<include src="//File 2.xml" />
</cycles>
File 2
<cycles>
<shader name="name_1">
<certain_node />
</shader>
</cycles>
| E:\LinM\blender\cycles\src\app\cycles_xml.cpp | ||
|---|---|---|
| 1305 ↗ | (On Diff #6262) | I am assuming this is a debug print? Also we do have a proper logging infrastructure in cycles, so please use that |
To allow import the <shader></shader> with same name need to cache the node map. This may require new variable in the XMLReadState.
So currently the importer code of rgb curves node open a new XML document and process the data within the function xml_read_shader_graph()
Hi Martijn
I'm sorry this is my first time try to submit a patch so I might make some mistakes. And I also updated the code for the reason I wrote in my last comment.
In the xml file the rgb curves node now would be like
<rgb_curves name="test_rgb_curves" src="./objects/curves_data.xml"/>
and in the curves_data.xml, the curves data will be like
<cycles>
<curves_data name="curves_data" size="256" rcurve="... " gcurve="... " bcurve="... "/>
</cycles>
| src/app/cycles_xml.cpp | ||
|---|---|---|
| 403 | We should avoid having such a direct linkage, this is something <include> is intended to do. Benefits:
Surely some changes will need to be done in xml_read_include() or something like that. Perhaps easiest way to go would be to:
| |
| 412 | Code style: should be no space between keyword and brace. | |
| 413 | You're reporting error here, but still keep reading the node. Straight way to either write pass the array boundaries or to have uninitialized values. | |
| 415 | Why's that int and why not to use array of vectors instead? | |
| 420 | Please always use parenthesis. | |
| 421 | Code style. | |
| 423 | Why is that? | |
That is not a problem. You cannot learn without that, we just try to give the best possible feedback :)
Hi Sergey,
To support inline node, the xml file would be like
scene.xml
<cycles>
<shader name="shader_1">
<include src="node.xml">
</shader>
</cycles>
node.xml
<cycles>
<noise_texture name="tex" scale="2.0"/>
</cycles>
- I think an extra variable map<string, ShaderNode*> currentnodemap is needed in XMLReadState.
- There are different kinds of shader nodes, to make the xml_read_scene() aware of shader node
- change the shader node definition to <shader_node type="type_shader_node(e.g. rgbcurvesnode)" name="rgb_curves(for connect)">
Do you think this is the proper way? Thanks
Load shader node from different places.
scene.xml
<cycles>
<background>
<shader_node type="sky_texture" name="tex" />
<include src="./shader_node.xml" />
<shader_node type="connect" from="tex color" to="bg color" />
<shader_node type="connect" from="bg background" to="output surface" />
</background>
</cycles>
shader_node.xml
<cycles>
<shader_node type="background" name="bg" strength="8.0" />
</cycles>
No longer necessary now that there is generic code for importing all shader nodes and sockets.