/****************************************************************************
**
** Copyright (C) 1993-2009 NVIDIA Corporation.
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt 3D Studio.
**
** $QT_BEGIN_LICENSE:FDL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\title The .shader Format
\page file-formats-shader.html
\ingroup qt3dstudio-file-formats
Qt 3D Studio supports custom
materials used to render elements. Materials are arbitrary single-pass
GLSL shaders, wrapped in a file format providing an artist-friendly
interface for tweaking material parameters in Studio.
\section1 Overview
The general structure of a \c{.shader} file is shown below. Note
that some of the attributes and elements shown here are optional (and
this example does not include all possible attributes):
\badcode
......
\endcode
The actual code for the shader is placed within the
\c{} elements.
\section1 Schemata
Legal \c{.shader} files are described by the following formal
schemata. The RelaxNG Compact schema is the reference from which the XML
Schema Definition schema was derived.
\section2 RelaxNG Compact (\c{.rnc)}
\badcode
grammar \{
start = MaterialElement # Everything is wrapped in a element
MaterialElement = element Material \{
attribute version \{"1.0"\, }# This file describes version 1.0 only
attribute formalName \{text\?, }# The formalName attribute is optional; default: filename (minus extension)
attribute description \{text\?, }# Optional long description of the material
MetaDataElement?, # is optional,
ShadersElement # but is required
\}
MetaDataElement = element MetaData\{
attribute author \{text\?, }# Various descriptive attributes (optional)
attribute created \{text\?,}
attribute modified \{text\?,}
PropertyElement* # Zero or more elements
\}
PropertyElement = element Property \{ # All attributes are optional except for name
attribute name \{xsd:ID\, }# The internal, script name of the property (must be a unique identifier)
attribute description \{text\?, }# Tooltip to display in Inspector palette
attribute formalName \{text\?, }# The name to display in Inspector palette; default: the property `name`
attribute type \{PropertyType\?, }# The type of the property (defined below); default: Float
attribute min \{xsd:float\?, }# UI min value for numeric types; default: none
attribute max \{xsd:float\?, }# UI max value for numeric types; default: none
attribute default \{text\?, }# Default value for the property; default: 0/""
attribute usage \{UsageType\?, }# Only for textures; default: diffuse
attribute filter \{FilterType\?, }# Only for textures; default: linear
attribute clamp \{ClampType\? }# Only for textures; default: wrap
\}
ShadersElement = element Shaders \{
attribute type \{"GLSL" | "HLSL"\?, }# Optional shader type; only GLSL supported. default: GLSL
attribute version \{text\?, }# Code version
element Shared \{text\?, }# Arbitrary definition code to run for all shaders (optional)
ShaderElement+ # There must be at least one in the .shader file
\}
ShaderElement = element Shader \{
attribute name \{xsd:NCName\?, }# An identifier-like name
((VSEl | FSEl) | (VSEl & FSEl)) # Either or both of and , in either order
\}
VSEl = element VertexShader \{ShaderContent\}
FSEl = element FragmentShader \{ShaderContent\}
ShaderContent = element Source \{ text \ }# Shaders currently require a single element
UsageType = "diffuse" | "specular" | "bump" | "environment"
FilterType = "nearest" | "linear"
ClampType = "clamp" | "wrap"
PropertyType = "Boolean" | "Color" | "Float" | "Float2" | "Font"
| "FontSize" | "Image" | "Import" | "Long" | "Mesh"
| "MultiLineString" | "Rotation" | "String" | "Vector"
| "Texture" | "Texture3D" | "TextureCube"
\}
\endcode
\section2 XML Schema Definition (\c{.xsd)}
\badcode
\endcode
*/