Dev:Source/Render/Cycles/Standalone/XML API

提供: wiki
移動先: 案内検索

Cycles XML API

Introduction

Once cycles standalone is successfully compiled, this page helps create xml files to be rendered using cycles engine for testing purposes or which allows an integration into other 3D programs and pipelines.

Cycles needs to be started from the terminal/cmd. It can be run by executing the executable from cmd followed by options and path to XML scene file

e.g. >cycles --samples 1000 F:\Examples\Test.xml

Following option are avaialble :

  • --devices : This options allows you to set device to use for rendering (e.g. opencl, cuda, cpu etc)
  • --samples : This options allows you to set number of samples to render
  • --list-devices : this option will list the detected devices in the system
  • --shadingsys : Shading system to be used for rendering (e.g. svm, osl)
  • --background : It will render in background without showing any UI . This option doesn't require any value
  • --quiet : It will stop cycles from printing progress messages. This option doesn't require any balue
  • --output : Path to output image file.
  • --threads : Number of CPU threads to use while rendering
  • --width : Set the width of rendered image
  • --height: Set the height of rendered image

The XML Format

The example files provided along with the source is a great reference for creating xml files. XML file consists of XML tags/nodes defining camera, integration, lights, background, shaders and meshes .

Camera

<camera width="800" height="500" />

<transform translate="0 0 -4" scale="1 1 1"> <camera type="perspective" /> </transform>


Background

 
<background>
	<background name="bg" strength="2.0" color="0.2, 0.2, 0.2" ao_factor="1.0" ao_distance="10.0"/>
	<connect from="bg background" to="output surface" />
</background>

Specify background color and strength with ambient occlusion factor and distance in background node.

Mesh

Mesh can be defined in two ways. 1. Embeded mesh data 2. Including seperate XML object file with mesh data. Transform node wrapped around state node defines transform for mesh. State node wrapped around mesh node defines which shader to apply and the interpolation.

<transform rotate="180 0 1 1" translate="0 0 0" scale="1 1 1">
	<state interpolation="smooth" shader="sphere">
		<include src="./objects/sphere.xml" />
                <!-- or embedding mesh data like this-->
                <!--  <mesh P="-0.977935 0.096318 0.097399  -0.980005 0.072289 0.097399  -0.981485 0.048217 0.097399 ..... " /> -->                   
        </state>
</transform>

Shaders Nodes

All basic shader/material nodes that are available in blender integrated cycles are implemented in the standalone version as well except these 1.RGBCurvesNode, 2.VectorCurvesNode, 3.RGBRampNode and 4.ConvertNode (RGB -> BW) and maybe some more but hope the missing to be integrated soon.

 
<shader name="cube">
        
      <!-- PARAMETERS -->
	<texture_coordinate name="texcod" />
	<mapping name="map" type="POINT" translation="0.0, 0.0, 0.0" rotation="0, 0, 0" scale="1, 1, 1"  />
	<image_texture name="imgtex" src="Textures\acp_Metal.jpg" />
	<bump name="bump" Strength="1" Distance="0.001" />
	<glossy_bsdf name="glossy" distribution="Beckmann" Roughness="0.210" Color="1, 1, 1" />
	<mix_closure name="mix" Fac="0.300" />
	<mix_closure name="mix2" Fac="0.100" />
	<velvet_bsdf name="velvet" Color="1, 1, 1" Sigma="0.600" />
	<diffuse_bsdf name="Diffuse" />
      
      <!-- I/O Connections -->
	<connect from="texcod Generated" to="map Vector" />
	<connect from="map Vector" to="imgtex Vector"/>
	<connect from="imgtex color" to="Diffuse Color" />
	<connect from="imgtex color" to="bump Height" />
	<connect from="velvet BSDF" to="mix Closure2" />
	<connect from="bump Normal" to="Diffuse Normal" />
	<connect from="Diffuse BSDF" to="mix Closure1" />
	<connect from="glossy BSDF" to="mix2 Closure2" />
	<connect from="mix Closure" to="mix2 Closure1" />
	<connect from="mix2 Closure" to="output surface"/>
</shader>

Shaders can be defined in the file as the above where all the parameters for the nodes are defined first followed by the i/o connections.

While defining parameters the node name implemented in cycles_xml.cpp needs to be given first followed by a userdefined name in name parameter & all the parameters & their values of that node like type,roughness,strength,fac.. etc.

While defining connections in the connect tag the userdefined name followed by the outputnode should be connected to the userdefined name & the input node.