The XML shader resource class. More...

#include "murl_resource_xml_shader.h"

Inheritance diagram for Murl::Resource::XmlShader:

Additional Inherited Members

- Public Types inherited from Murl::IFactoryObject< IObject >
using ClassInfoArray = Array< const ClassInfo * >
 Definition of an array of ClassInfo objects.
 
- Public Member Functions inherited from Murl::Resource::IObject
virtual Bool GetFileDependencies (Array< String > &fileNames) const =0
 Fill a given string array with names of files the resource depends on. More...
 
- Public Member Functions inherited from Murl::IFactoryObject< IObject >
 ~IFactoryObject () override
 The destructor.
 
virtual const ClassInfo * GetObjectClassInfo () const=0
 Get the object instance's class info, if present. More...
 
virtual void ResetObjectProperties ()=0
 Reset the object instance's properties to their default values.
 
- Static Public Member Functions inherited from Murl::IFactoryObject< IObject >
static const PropertyInfoGetPropertyInfo ()
 Get the class' property info struct. More...
 
static const AttributeInfoGetAttributeInfo ()
 Get the class' attribute info struct. More...
 
static void ResetProperties (IFactoryObject< IObject > *object)
 Reset an object instance's properties to their default values. More...
 

Detailed Description

The XML shader resource class.

An XML shader file is recognized by its <Shader> root element. The root element accepts the following attributes:

  • ignoreErrors: default false tbd
  • forceOptimization: default false tbd

The following child elements are allowed for the root element:

  • <Constants>
  • <Attributes>
  • <ConstantBuffers>
  • <Varyings>
  • <Textures>
  • <VertexPrefix>
  • <FragmentPrefix>
  • <VertexSource>
  • <FragmentSource>

The <Constants> element allows the following child elements:

  • <Constant>

The following attributes are accepted in an <Constant> tag:

  • name: A string value specifying the name.
  • value: A string value specifying the value.
  • type: A string value from the IEnums::ConstantType enumeration specifying the type.
  • precision: A string value from the IEnums::ShaderVariablePrecision enumeration specifying the precision.

The <Attributes> element allows the following child elements:

  • <Attribute>

The following attributes are accepted in an <Attribute> tag:

The <ConstantBuffers> element allows the following child elements:

  • <ConstantBuffer>

The following attributes are accepted in an <ConstantBuffer> tag:

  • item: A string value from the IEnums::ConstantBufferItem enumeration specifying the item.
  • name: A string value defining the name.

The <ConstantBuffer> element allows the following child elements:

  • <Uniform>

The following attributes are accepted in an <Uniform> tag:

  • name: A string value defining the name.
  • item: A string value from the IEnums::UniformItem enumeration specifying the type.
  • arraySize: tbd
  • value: A string value defining the value.
  • type: A string value from the IEnums::UniformType enumeration specifying the type.
  • precision: A string value from the IEnums::ShaderVariablePrecision enumeration specifying the precision.

The <Varyings> element allows the following child elements:

  • <Varying>

The following attributes are accepted in an <Varying> tag:

The <Textures> element allows the following child elements:

  • <Texture>

The following attributes are accepted in an <Texture> tag:

The <VertexPrefix> element is used to specify an optional prefix part of the vertex shader. The actual code should be put inside a CDATA section (<![CDATA[ ... ]]>). The <VertexPrefix> element accepts the following attributes:

The <FragmentPrefix> element is used to specify an optional prefix part of the fragment shader. The actual code should be put inside a CDATA section (<![CDATA[ ... ]]>). The <FragmentPrefix> element accepts the following attributes:

The <VertexSource> element is used to specify the vertex shader source code. The actual code should be put inside a CDATA section (<![CDATA[ ... ]]>). The <VertexSource> element accepts the following attributes:

  • language: A string value from the IEnums::ShaderLanguage enumeration specifying the shader language.
  • inputLanguage: A string value from the IEnums::ShaderLanguage enumeration specifying the input shader language.
  • outputLanguage: A string value from the IEnums::ShaderLanguage enumeration specifying the output shader language.
  • enableOptimization: A boolean key to enable/disable optimization. The default value is ???.

The <FragmentSource> element is used to specify the fragment shader source code. The actual code should be put inside a CDATA section (<![CDATA[ ... ]]>). The <FragmentSource> element accepts the following attributes:

  • language: A string value from the IEnums::ShaderLanguage enumeration specifying the shader language.
  • inputLanguage: A string value from the IEnums::ShaderLanguage enumeration specifying the input shader language.
  • outputLanguage: A string value from the IEnums::ShaderLanguage enumeration specifying the output shader language.
  • enableOptimization: A boolean key to enable/disable optimization. The default value is ???.

Example of an XML shader file:

<?xml version="1.0"?>
<Shader xmlns="http://murlengine.com">
<Attributes>
<Attribute item="COORD" type="FLOAT_VECTOR_4"/>
<Attribute item="TEXCOORD_0" type="FLOAT_VECTOR_2"/>
</Attributes>
<ConstantBuffers>
<ConstantBuffer item="MODEL"/>
<ConstantBuffer item="CAMERA"/>
<ConstantBuffer name="pg0">
<Uniform name="uWeight" type="FLOAT" precision="MEDIUM"/>
</ConstantBuffer>
</ConstantBuffers>
<Varyings>
<Varying name="vTexCoord0" type="FLOAT_VECTOR_2" precision="MEDIUM"/>
</Varyings>
<Textures>
<Texture unit="0" type="FLAT" precision="LOW"/>
<Texture unit="1" type="FLAT" precision="LOW"/>
</Textures>
<VertexSource language="GLSL_ES_120">
<![CDATA[
void main()
{
gl_Position = uCameraViewProjectionMatrix * (uModelMatrix * aPosition);
vTexCoord0 = aTexCoord0;
}
]]>
</VertexSource>
<FragmentSource language="GLSL_ES_120">
<![CDATA[
void main()
{
vec4 color0 = texture2D(uTexture0, vTexCoord0);
vec4 color1 = texture2D(uTexture1, vTexCoord0);
gl_FragColor = (color1 * uWeight + color0 * (1.0 - uWeight)) * (1.0 - uWeight * 0.5);
}
]]>
</FragmentSource>
</Shader>

Use the <Resource> tag in a .murlres package's resource.xml file to specify an XML shader resource. See Resource::Object.


The documentation for this class was generated from the following file:
  • murl_resource_xml_shader.h


Copyright © 2011-2024 Spraylight GmbH.