Shader Builder API Guide

Transcription

Shader Builder API Guide
FAMILY 2017
Flame Flare Flame Assist
Shader Builder API Guide
2016-05-24
Autodesk Legal Notice
© 2016 Autodesk, Inc. All Rights Reserved. Except where otherwise noted, this work is licensed under a Creative
Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License that can be viewed online at
http://creativecommons.org/licenses/by-nc-sa/3.0/. This license content, applicable as of 16 December 2014 to this software
product, is reproduced here for offline users:
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE LEGAL SERVICES. DISTRIBUTION
OF THIS LICENSE DOES NOT CREATE AN ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES REGARDING THE INFORMATION
PROVIDED, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM ITS USE.
License
THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE
("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF
THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS
OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS
YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.
1. Definitions
a. "Adaptation" means a work based upon the Work, or upon the Work and other pre-existing works, such as a translation,
adaptation, derivative work, arrangement of music or other alterations of a literary or artistic work, or phonogram or
performance and includes cinematographic adaptations or any other form in which the Work may be recast, transformed,
or adapted including in any form recognizably derived from the original, except that a work that constitutes a Collection
will not be considered an Adaptation for the purpose of this License. For the avoidance of doubt, where the Work is a
musical work, performance or phonogram, the synchronization of the Work in timed-relation with a moving image
("synching") will be considered an Adaptation for the purpose of this License.
b. "Collection" means a collection of literary or artistic works, such as encyclopedias and anthologies, or performances,
phonograms or broadcasts, or other works or subject matter other than works listed in Section 1(g) below, which, by
reason of the selection and arrangement of their contents, constitute intellectual creations, in which the Work is included
in its entirety in unmodified form along with one or more other contributions, each constituting separate and independent
works in themselves, which together are assembled into a collective whole. A work that constitutes a Collection will not
be considered an Adaptation (as defined above) for the purposes of this License.
c. "Distribute" means to make available to the public the original and copies of the Work or Adaptation, as appropriate,
through sale or other transfer of ownership.
d. "License Elements" means the following high-level license attributes as selected by Licensor and indicated in the title
of this License: Attribution, Noncommercial, ShareAlike.
e. "Licensor" means the individual, individuals, entity or entities that offer(s) the Work under the terms of this License.
i
f. "Original Author" means, in the case of a literary or artistic work, the individual, individuals, entity or entities who
created the Work or if no individual or entity can be identified, the publisher; and in addition (i) in the case of a performance
the actors, singers, musicians, dancers, and other persons who act, sing, deliver, declaim, play in, interpret or otherwise
perform literary or artistic works or expressions of folklore; (ii) in the case of a phonogram the producer being the person
or legal entity who first fixes the sounds of a performance or other sounds; and, (iii) in the case of broadcasts, the
organization that transmits the broadcast.
g. "Work" means the literary and/or artistic work offered under the terms of this License including without limitation
any production in the literary, scientific and artistic domain, whatever may be the mode or form of its expression including
digital form, such as a book, pamphlet and other writing; a lecture, address, sermon or other work of the same nature; a
dramatic or dramatico-musical work; a choreographic work or entertainment in dumb show; a musical composition with
or without words; a cinematographic work to which are assimilated works expressed by a process analogous to
cinematography; a work of drawing, painting, architecture, sculpture, engraving or lithography; a photographic work to
which are assimilated works expressed by a process analogous to photography; a work of applied art; an illustration, map,
plan, sketch or three-dimensional work relative to geography, topography, architecture or science; a performance; a
broadcast; a phonogram; a compilation of data to the extent it is protected as a copyrightable work; or a work performed
by a variety or circus performer to the extent it is not otherwise considered a literary or artistic work.
h. "You" means an individual or entity exercising rights under this License who has not previously violated the terms of
this License with respect to the Work, or who has received express permission from the Licensor to exercise rights under
this License despite a previous violation.
i. "Publicly Perform" means to perform public recitations of the Work and to communicate to the public those public
recitations, by any means or process, including by wire or wireless means or public digital performances; to make available
to the public Works in such a way that members of the public may access these Works from a place and at a place
individually chosen by them; to perform the Work to the public by any means or process and the communication to the
public of the performances of the Work, including by public digital performance; to broadcast and rebroadcast the Work
by any means including signs, sounds or images.
j. "Reproduce" means to make copies of the Work by any means including without limitation by sound or visual
recordings and the right of fixation and reproducing fixations of the Work, including storage of a protected performance
or phonogram in digital form or other electronic medium.
2. Fair Dealing Rights. Nothing in this License is intended to reduce, limit, or restrict any uses free from copyright or
rights arising from limitations or exceptions that are provided for in connection with the copyright protection under
copyright law or other applicable laws.
3. License Grant. Subject to the terms and conditions of this License, Licensor hereby grants You a worldwide, royalty-free,
non-exclusive, perpetual (for the duration of the applicable copyright) license to exercise the rights in the Work as stated
below:
■ a. to Reproduce the Work, to incorporate the Work into one or more Collections, and to Reproduce the Work as
incorporated in the Collections;
■
b. to create and Reproduce Adaptations provided that any such Adaptation, including any translation in any medium,
takes reasonable steps to clearly label, demarcate or otherwise identify that changes were made to the original Work.
For example, a translation could be marked "The original work was translated from English to Spanish," or a modification
could indicate "The original work has been modified.";
■
c. to Distribute and Publicly Perform the Work including as incorporated in Collections; and,
■
d. to Distribute and Publicly Perform Adaptations.
The above rights may be exercised in all media and formats whether now known or hereafter devised. The above rights
include the right to make such modifications as are technically necessary to exercise the rights in other media and formats.
Subject to Section 8(f), all rights not expressly granted by Licensor are hereby reserved, including but not limited to the
rights described in Section 4(e).
4. Restrictions. The license granted in Section 3 above is expressly made subject to and limited by the following
restrictions:
■ a. You may Distribute or Publicly Perform the Work only under the terms of this License. You must include a copy of,
or the Uniform Resource Identifier (URI) for, this License with every copy of the Work You Distribute or Publicly
ii | Autodesk Legal Notice
Perform. You may not offer or impose any terms on the Work that restrict the terms of this License or the ability of
the recipient of the Work to exercise the rights granted to that recipient under the terms of the License. You may not
sublicense the Work. You must keep intact all notices that refer to this License and to the disclaimer of warranties with
every copy of the Work You Distribute or Publicly Perform. When You Distribute or Publicly Perform the Work, You
may not impose any effective technological measures on the Work that restrict the ability of a recipient of the Work
from You to exercise the rights granted to that recipient under the terms of the License. This Section 4(a) applies to
the Work as incorporated in a Collection, but this does not require the Collection apart from the Work itself to be
made subject to the terms of this License. If You create a Collection, upon notice from any Licensor You must, to the
extent practicable, remove from the Collection any credit as required by Section 4(d), as requested. If You create an
Adaptation, upon notice from any Licensor You must, to the extent practicable, remove from the Adaptation any
credit as required by Section 4(d), as requested.
■
b. You may Distribute or Publicly Perform an Adaptation only under: (i) the terms of this License; (ii) a later version
of this License with the same License Elements as this License; (iii) a Creative Commons jurisdiction license (either
this or a later license version) that contains the same License Elements as this License (e.g.,
Attribution-NonCommercial-ShareAlike 3.0 US) ("Applicable License"). You must include a copy of, or the URI, for
Applicable License with every copy of each Adaptation You Distribute or Publicly Perform. You may not offer or impose
any terms on the Adaptation that restrict the terms of the Applicable License or the ability of the recipient of the
Adaptation to exercise the rights granted to that recipient under the terms of the Applicable License. You must keep
intact all notices that refer to the Applicable License and to the disclaimer of warranties with every copy of the Work
as included in the Adaptation You Distribute or Publicly Perform. When You Distribute or Publicly Perform the
Adaptation, You may not impose any effective technological measures on the Adaptation that restrict the ability of a
recipient of the Adaptation from You to exercise the rights granted to that recipient under the terms of the Applicable
License. This Section 4(b) applies to the Adaptation as incorporated in a Collection, but this does not require the
Collection apart from the Adaptation itself to be made subject to the terms of the Applicable License.
■
c. You may not exercise any of the rights granted to You in Section 3 above in any manner that is primarily intended
for or directed toward commercial advantage or private monetary compensation. The exchange of the Work for other
copyrighted works by means of digital file-sharing or otherwise shall not be considered to be intended for or directed
toward commercial advantage or private monetary compensation, provided there is no payment of any monetary
compensation in connection with the exchange of copyrighted works.
■
d. If You Distribute, or Publicly Perform the Work or any Adaptations or Collections, You must, unless a request has
been made pursuant to Section 4(a), keep intact all copyright notices for the Work and provide, reasonable to the
medium or means You are utilizing: (i) the name of the Original Author (or pseudonym, if applicable) if supplied,
and/or if the Original Author and/or Licensor designate another party or parties (e.g., a sponsor institute, publishing
entity, journal) for attribution ("Attribution Parties") in Licensor's copyright notice, terms of service or by other
reasonable means, the name of such party or parties; (ii) the title of the Work if supplied; (iii) to the extent reasonably
practicable, the URI, if any, that Licensor specifies to be associated with the Work, unless such URI does not refer to
the copyright notice or licensing information for the Work; and, (iv) consistent with Section 3(b), in the case of an
Adaptation, a credit identifying the use of the Work in the Adaptation (e.g., "French translation of the Work by Original
Author," or "Screenplay based on original Work by Original Author"). The credit required by this Section 4(d) may be
implemented in any reasonable manner; provided, however, that in the case of a Adaptation or Collection, at a
minimum such credit will appear, if a credit for all contributing authors of the Adaptation or Collection appears, then
as part of these credits and in a manner at least as prominent as the credits for the other contributing authors. For the
avoidance of doubt, You may only use the credit required by this Section for the purpose of attribution in the manner
set out above and, by exercising Your rights under this License, You may not implicitly or explicitly assert or imply
any connection with, sponsorship or endorsement by the Original Author, Licensor and/or Attribution Parties, as
appropriate, of You or Your use of the Work, without the separate, express prior written permission of the Original
Author, Licensor and/or Attribution Parties.
■
e. For the avoidance of doubt:
■ i. Non-waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through
any statutory or compulsory licensing scheme cannot be waived, the Licensor reserves the exclusive right to collect
such royalties for any exercise by You of the rights granted under this License;
■
ii. Waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through
any statutory or compulsory licensing scheme can be waived, the Licensor reserves the exclusive right to collect
such royalties for any exercise by You of the rights granted under this License if Your exercise of such rights is for
Autodesk Legal Notice | iii
a purpose or use which is otherwise than noncommercial as permitted under Section 4(c) and otherwise waives the
right to collect royalties through any statutory or compulsory licensing scheme; and,
■
■
iii. Voluntary License Schemes. The Licensor reserves the right to collect royalties, whether individually or, in the
event that the Licensor is a member of a collecting society that administers voluntary licensing schemes, via that
society, from any exercise by You of the rights granted under this License that is for a purpose or use which is
otherwise than noncommercial as permitted under Section 4(c).
f. Except as otherwise agreed in writing by the Licensor or as may be otherwise permitted by applicable law, if You
Reproduce, Distribute or Publicly Perform the Work either by itself or as part of any Adaptations or Collections, You
must not distort, mutilate, modify or take other derogatory action in relation to the Work which would be prejudicial
to the Original Author's honor or reputation. Licensor agrees that in those jurisdictions (e.g. Japan), in which any
exercise of the right granted in Section 3(b) of this License (the right to make Adaptations) would be deemed to be a
distortion, mutilation, modification or other derogatory action prejudicial to the Original Author's honor and reputation,
the Licensor will waive or not assert, as appropriate, this Section, to the fullest extent permitted by the applicable
national law, to enable You to reasonably exercise Your right under Section 3(b) of this License (right to make
Adaptations) but not otherwise.
5. Representations, Warranties and Disclaimer
UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING AND TO THE FULLEST EXTENT PERMITTED
BY APPLICABLE LAW, LICENSOR OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
ANY KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT
LIMITATION, WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT,
OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER
OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO
THIS EXCLUSION MAY NOT APPLY TO YOU.
6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL LICENSOR
BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR
EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN
ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
7. Termination
■ a. This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms
of this License. Individuals or entities who have received Adaptations or Collections from You under this License,
however, will not have their licenses terminated provided such individuals or entities remain in full compliance with
those licenses. Sections 1, 2, 5, 6, 7, and 8 will survive any termination of this License.
■
b. Subject to the above terms and conditions, the license granted here is perpetual (for the duration of the applicable
copyright in the Work). Notwithstanding the above, Licensor reserves the right to release the Work under different
license terms or to stop distributing the Work at any time; provided, however that any such election will not serve to
withdraw this License (or any other license that has been, or is required to be, granted under the terms of this License),
and this License will continue in full force and effect unless terminated as stated above.
8. Miscellaneous
■ a. Each time You Distribute or Publicly Perform the Work or a Collection, the Licensor offers to the recipient a license
to the Work on the same terms and conditions as the license granted to You under this License.
■
b. Each time You Distribute or Publicly Perform an Adaptation, Licensor offers to the recipient a license to the original
Work on the same terms and conditions as the license granted to You under this License.
■
c. If any provision of this License is invalid or unenforceable under applicable law, it shall not affect the validity or
enforceability of the remainder of the terms of this License, and without further action by the parties to this agreement,
such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
■
d. No term or provision of this License shall be deemed waived and no breach consented to unless such waiver or
consent shall be in writing and signed by the party to be charged with such waiver or consent.
■
e. This License constitutes the entire agreement between the parties with respect to the Work licensed here. There are
no understandings, agreements or representations with respect to the Work not specified here. Licensor shall not be
iv | Autodesk Legal Notice
bound by any additional provisions that may appear in any communication from You. This License may not be
modified without the mutual written agreement of the Licensor and You.
■
f. The rights granted under, and the subject matter referenced, in this License were drafted utilizing the terminology
of the Berne Convention for the Protection of Literary and Artistic Works (as amended on September 28, 1979), the
Rome Convention of 1961, the WIPO Copyright Treaty of 1996, the WIPO Performances and Phonograms Treaty of
1996 and the Universal Copyright Convention (as revised on July 24, 1971). These rights and subject matter take effect
in the relevant jurisdiction in which the License terms are sought to be enforced according to the corresponding
provisions of the implementation of those treaty provisions in the applicable national law. If the standard suite of
rights granted under applicable copyright law includes additional rights not granted under this License, such additional
rights are deemed to be included in the License; this License is not intended to restrict the license of any rights under
applicable law.
Creative Commons Notice
Creative Commons is not a party to this License, and makes no warranty whatsoever in connection with the Work. Creative
Commons will not be liable to You or any party on any legal theory for any damages whatsoever, including without
limitation any general, special, incidental or consequential damages arising in connection to this license. Notwithstanding
the foregoing two (2) sentences, if Creative Commons has expressly identified itself as the Licensor hereunder, it shall
have all rights and obligations of Licensor.
Except for the limited purpose of indicating to the public that the Work is licensed under the CCPL, Creative Commons
does not authorize the use by either party of the trademark "Creative Commons" or any related trademark or logo of
Creative Commons without the prior written consent of Creative Commons. Any permitted use will be in compliance
with Creative Commons' then-current trademark usage guidelines, as may be published on its website or otherwise made
available upon request from time to time. For the avoidance of doubt, this trademark restriction does not form part of
this License.
Creative Commons may be contacted at http://creativecommons.org/.
Certain materials included in this publication are reprinted with the permission of the copyright holder.
Creative Commons FAQ
Autodesk's Creative Commons FAQ can be viewed online at http://www.autodesk.com/company/creative-commons, and
is reproduced here for offline users.
In collaboration with Creative Commons, Autodesk invites you to share your knowledge with the rest of the world,
inspiring others to learn, achieve goals, and ignite creativity. You can freely borrow from the Autodesk Help, Support and
Video libraries to build a new learning experience for anyone with a particular need or interest.
What is Creative Commons?
Creative Commons (CC) is a nonprofit organization that offers a simple licensing model that frees digital content to
enable anyone to modify, remix, and share creative works.
How do I know if Autodesk learning content and Autodesk University content is available under Creative
Commons?
All Autodesk learning content and Autodesk University content released under Creative Commons is explicitly marked
with a Creative Commons icon specifying what you can and cannot do. Always follow the terms of the stated license.
What Autodesk learning content is currently available under Creative Commons?
Over time, Autodesk will release more and more learning content under the Creative Commons licenses.
Currently available learning content:
■ Autodesk online help-Online help for many Autodesk products, including its embedded media such as images and
help movies.
■
Autodesk Learning Videos-A range of video-based learning content, including the video tutorials on the Autodesk
®
YouTube™ Learning Channels and their associated iTunes podcasts.
Autodesk Legal Notice | v
■
Autodesk downloadable materials-Downloadable 3D assets, digital footage, and other files you can use to follow along
on your own time.
Is Autodesk learning and support content copyrighted?
Yes. Creative Commons licensing does not replace copyright. Copyright remains with Autodesk or its suppliers, as applicable.
But it makes the terms of use much more flexible.
What do the Autodesk Creative Commons licenses allow?
Autodesk makes some of its learning and support content available under two distinct Creative Commons licenses. The
learning content is clearly marked with the applicable Creative Commons license. You must comply with the following
conditions:
■ Attribution-NonCommercial-ShareAlike (CC BY-NC-SA) This license lets you copy, distribute, display, remix,
tweak, and build upon our work noncommercially, as long as you credit Autodesk and license your new creations
under the identical terms.
■
Attribution-NonCommercial-No Derivative Works (CC BY-NC-ND) This license lets you copy, distribute, and
display only verbatim copies of our work as long as you credit us, but you cannot alter the learning content in any
way or use it commercially.
■
Special permissions on content marked as No Derivative Works For video-based learning content marked
as No Derivative Works (ND), Autodesk grants you special permission to make modifications but only for the purpose
of translating the video content into another language.
These conditions can be modified only by explicit permission of Autodesk, Inc. Send requests for modifications outside
of these license terms to [email protected].
Can I get special permission to do something different with the learning content?
Unless otherwise stated, our Creative Commons conditions can be modified only by explicit permission of Autodesk, Inc.
If you have any questions or requests for modifications outside of these license terms, email us at [email protected].
How do I attribute Autodesk learning content?
You must explicitly credit Autodesk, Inc., as the original source of the materials. This is a standard requirement of the
Attribution (BY) term in all Creative Commons licenses. In some cases, such as for the Autodesk video learning content,
we specify exactly how we would like to be attributed.
This is usually described on the video's end-plate. For the most part providing the title of the work, the URL where the
work is hosted, and a credit to Autodesk, Inc., is quite acceptable. Also, remember to keep intact any copyright notice
associated with the work. This may sound like a lot of information, but there is flexibility in the way you present it.
Here are some examples:
"This document contains content adapted from the Autodesk® Maya® Help, available under a Creative Commons
Attribution-NonCommercial-Share Alike license. Copyright © Autodesk, Inc."
"This is a Finnish translation of a video created by the Autodesk Maya Learning Channel @ www.youtube.com/mayahowtos.
Copyright © Autodesk, Inc."
"Special thanks to the Autodesk® 3ds Max® Learning Channel @ www.youtube.com/3dsmaxhowtos. Copyright © Autodesk,
Inc."
Do I follow YouTube's standard license or Autodesk's Creative Commons license?
The videos of the Autodesk Learning Channels on YouTube are uploaded under YouTube's standard license policy.
Nonetheless, these videos are released by Autodesk as Creative Commons Attribution-NonCommercial-No Derivative
Works (CC BY-NC-ND) and are marked as such.
You are free to use our video learning content according to the Creative Commons license under which they are released.
Where can I easily download Autodesk learning videos?
vi | Autodesk Legal Notice
Most of the Autodesk Learning Channels have an associated iTunes podcast from where you can download the same
videos and watch them offline. When translating Autodesk learning videos, we recommend downloading the videos from
the iTunes podcasts.
Can I translate Autodesk learning videos?
Yes. Even though our learning videos are licensed as No Derivative Works (ND), we grant everyone permission to translate
the audio and subtitles into other languages. In fact, if you want to recapture the video tutorial as-is but show the user
interface in another language, you are free to do so. Be sure to give proper attribution as indicated on the video's Creative
Commons end-plate. This special permission only applies to translation projects. Requests for modifications outside of
these license terms can be directed to [email protected].
How do I let others know that I have translated Autodesk learning content into another language?
Autodesk is happy to see its learning content translated into as many different languages as possible. If you translate our
videos or any of our learning content into other languages, let us know. We can help promote your contributions to our
growing multilingual community. In fact, we encourage you to find creative ways to share our learning content with your
friends, family, students, colleagues, and communities around the world. Contact us at [email protected].
I have translated Autodesk learning videos into other languages. Can I upload them to my own YouTube
channel?
Yes, please do and let us know where to find them so that we can help promote your contributions to our growing
multilingual Autodesk community. Contact us at [email protected].
Can I repost or republish Autodesk learning content on my site or blog?
Yes, you can make Autodesk learning material available on your site or blog as long as you follow the terms of the Creative
Commons license under which the learning content is released. If you are simply referencing the learning content as-is,
then we recommend that you link to it or embed it from where it is hosted by Autodesk. That way the content will always
be fresh. If you have translated or remixed our learning content, then by all means you can host it yourself. Let us know
about it, and we can help promote your contributions to our global learning community. Contact us at
[email protected].
Can I show Autodesk learning content during my conference?
Yes, as long as it's within the scope of a noncommercial event, and as long as you comply with the terms of the Creative
Commons license outlined above. In particular, the videos must be shown unedited with the exception of modifications
for the purpose of translation. If you wish to use Autodesk learning content in a commercial context, contact us with a
request for permission at [email protected].
Can I use Autodesk learning content in my classroom?
Yes, as long as you comply with the terms of the Creative Commons license under which the learning material is released.
Many teachers use Autodesk learning content to stimulate discussions with students or to complement course materials,
and we encourage you to do so as well.
Can I re-edit and remix Autodesk video learning content?
No, but for one exception. Our Creative Commons BY-NC-ND license clearly states that "derivative works" of any kind
(edits, cuts, remixes, mashups, and so on) are not allowed without explicit permission from Autodesk. This is essential for
preserving the integrity of our instructors' ideas. However, we do give you permission to modify our videos for the purpose
of translating them into other languages.
Can I re-edit and remix Autodesk downloadable 3D assets and footage?
Yes. The Autodesk Learning Channels on YouTube provide downloadable 3D assets, footage, and other files for you to
follow along with the video tutorials on your own time. This downloadable material is made available under a Creative
Commons Attribution-NonCommercial-ShareAlike (CC BY-NC-SA) license. You can download these materials and
experiment with them, but your remixes must give us credit as the original source of the content and be shared under
the identical license terms.
Can I use content from Autodesk online help to create new materials for a specific audience?
Autodesk Legal Notice | vii
Yes, if you want to help a specific audience learn how to optimize the use of their Autodesk software, there is no need to
start from scratch. You can use, remix, or enrich the relevant help content and include it in your book, instructions,
examples, or workflows you create, then Share-Alike with the community. Always be sure to comply with the terms of
the Creative Commons license under which the learning content is released.
What are the best practices for marking content with Creative Commons Licenses?
When reusing a CC-licensed work (by sharing the original or a derivative based on the original), it is important to keep
intact any copyright notice associated with the work, including the Creative Commons license being used. Make sure you
abide by the license conditions provided by the licensor, in this case Autodesk, Inc.
Trademarks
The following are registered trademarks or trademarks of Autodesk, Inc., and/or its subsidiaries and/or affiliates in the USA
and other countries: 123D, 3ds Max, Alias, ATC, AutoCAD LT, AutoCAD, Autodesk, the Autodesk logo, Autodesk 123D,
Autodesk Homestyler, Autodesk Inventor, Autodesk MapGuide, Autodesk Streamline, AutoLISP, AutoSketch, AutoSnap,
AutoTrack, Backburner, Backdraft, Beast, BIM 360, Burn, Buzzsaw, CADmep, CAiCE, CAMduct, Civil 3D, Combustion,
Communication Specification, Configurator 360, Constructware, Content Explorer, Creative Bridge, Dancing Baby (image),
DesignCenter, DesignKids, DesignStudio, Discreet, DWF, DWG, DWG (design/logo), DWG Extreme, DWG TrueConvert,
DWG TrueView, DWGX, DXF, Ecotect, Ember, ESTmep, FABmep, Face Robot, FBX, Fempro, Fire, Flame, Flare, Flint,
ForceEffect, FormIt 360, Freewheel, Fusion 360, Glue, Green Building Studio, Heidi, Homestyler, HumanIK, i-drop,
ImageModeler, Incinerator, Inferno, InfraWorks, Instructables, Instructables (stylized robot design/logo), Inventor, Inventor
HSM, Inventor LT, Lustre, Maya, Maya LT, MIMI, Mockup 360, Moldflow Plastics Advisers, Moldflow Plastics Insight,
Moldflow, Moondust, MotionBuilder, Movimento, MPA (design/logo), MPA, MPI (design/logo), MPX (design/logo), MPX,
Mudbox, Navisworks, ObjectARX, ObjectDBX, Opticore, P9, Pier 9, Pixlr, Pixlr-o-matic, Productstream, Publisher 360,
RasterDWG, RealDWG, ReCap, ReCap 360, Remote, Revit LT, Revit, RiverCAD, Robot, Scaleform, Showcase, Showcase
360, SketchBook, Smoke, Socialcam, Softimage, Spark & Design, Spark Logo, Sparks, SteeringWheels, Stitcher, Stone,
StormNET, TinkerBox, Tinkercad, Tinkerplay, ToolClip, Topobase, Toxik, TrustedDWG, T-Splines, ViewCube, Visual LISP,
Visual, VRED, Wire, Wiretap, WiretapCentral, XSI.
All other brand names, product names or trademarks belong to their respective holders.
Disclaimer
THIS PUBLICATION AND THE INFORMATION CONTAINED HEREIN IS MADE AVAILABLE BY AUTODESK, INC. "AS IS."
AUTODESK, INC. DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE REGARDING THESE
MATERIALS.
viii | Autodesk Legal Notice
Contents
Chapter 1
What's New in the Flame Family Shader Builder 2017 . . . . . . . . . . . . . . . . . . . . . 1
Chapter 2
Creating Your Own Shader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Chapter 3
Creating a Matchbox Shader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Matchbox Shader Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Chapter 4
Creating a Lightbox Shader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Lightbox Shader Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Chapter 5
Creating Shader Presets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Chapter 6
About shader_builder XML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Chapter 7
Shader API Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
i
ii
What's New in the Flame Family Shader
Builder 2017
1
Welcome to the Autodesk Shader Builder API Guide for the Flame Family 2017 release. Make sure to check http://www.autodesk.com/vxf for the latest documentation (including Installation Guides, Release Notes, and other documents).
Also, many new feature videos (as well as other workflow videos) are available at https://www.youtube.com/user/FlameHowTos
(The Flame Learning Channel is also available as an iTunes podcast). This Learning Channel is updated frequently, so be
sure to subscribe or bookmark the page.
The following is a summary of new shader features for the 2017 release:
■
Matchbox now supports the usage of its previous result buffer with the uniform adsk_accum_texture. This is a regular
sampler2D that automatically provides the previous frame result, and needs to be defined in both the XML and glsl
file. You can use the uniform adsk_accum_no_prev_frame (which is a bool) to determine what happens if there are no
previous results. There is an Accumulate (page 8) example provided in the EXAMPLES folder. A non-recursive
accumulation mode allows Matchbox developers to use this feature without the performance impact of the absolute
recursive mode.
■
You can now host a texture in a Matchbox shader, by bundling an image file as a texture grid, in the following formats
(RGB or RGBA):
■ OpenEXR
■
DPX
■
JPEG (RGB only)
■
SGI
■
Targa
■
TIFF
In the shader, you can define the content of the image file using the uniform sampler2D adsk_texture_grid (needs
to be defined in both the glsl and xml files). There are three GridFetching (page 9) examples in the EXAMPLES folder.
■
A perspective camera is available inside Matchbox in relation to providing the Action camera API. This provides
information about the current output camera, when the shader is used as a post-processing (Camera FX) effect in
Action. GMask input has been implemented in most Matchbox shaders, so they work properly with Camera FX.
■
Some existing Matchbox shaders have been updated to support the 3DSelective capabilities exclusive to Action Camera
FX (showcased in the Action3DSelective (page 9) Matchbox provided in the EXAMPLES folder). This functionality
allows you to segment the render of Action using different 3D techniques, applying the given effects to a specific
portion of the image. Effects that have been updated include: Blur, Glow, Exposure, Lightwrap, Colour Correct, Dots,
Fog, Rays, Ripples, Twirl, and Chromatic Aberration.
■
It is now possible to create presets in Matchbox and Lightbox, allowing shader developers to offer different sets of
starting values for a given shader, without having to modify the glsl code. The preset file is a sidecar xml file in which
you can declare as many sets of starting values as wanted, with a name to identify them. In the UI, a popup button
appears underneath the Change Shader button, listing all the different declared presets. A button in the Node Prefs
1
menu allows you to dump the current UI configuration to the shell, allowing for easy copy/pasting to create presets.
See Creating Shader Presets (page 21).
■
In Action, you can now enable or disable Adaptive Degradation in shaders from the Shader tab. This indicates if you
use the degraded result in the Interactive viewport for performance improvements.
■
It is now possible to define a custom display name for a channel inside the Animation window, using the ChannelName
token in the Matchbox XML.
■
It is now possible to define an OutputWidth and an OutputHeight for Matchbox shaders without inputs or with no
incoming connections.
■
In Batch, Batch FX, and the Modular Keyer, the Matchbox node's input tab colours are now based on the type of input
(for example, yellow for composite, blue for matte).
■
Matchbox packaging has been upgraded to offer better browsing performance.
■
Matchbox menus can now use an unlimited amount of pages, by changing the tabs with a popup button when reaching
more than five pages.
■
Apart from the EXAMPLES shaders mentioned above, the following new Matchbox shaders have been added:
■ Stingray Motion Blur
■
■
Stingray Ambient Occlusion
■
Stingray Bloom
■
Stingray Reflection
■
Stingray Depth of Field
■
Stingray Lens Effects
■
Lightwrap
■
Five new Matchbox shaders (LensBokeh, LensDirt, LensOptic, LensRefraction and LensSpatial) provide real lens
graphical elements to be used with Action Lens Flares.
■
Many existing Matchbox effects now have 3D Selective functionality (these are new Matchbox shaders denoted
with 3DSelective in their name, such as Dots3DSelective)
The Lightbox API has been updated, allowing you to use the Physically Based Shader attributes to perform IBL rendering,
for example (See PhysicallyBasedIBL (page 19) in the EXAMPLES folder).
2 | Chapter 1 What's New in the Flame Family Shader Builder 2017
2
Creating Your Own Shader
A great benefit of working with customized shaders in Autodesk Flame, Flare, Flame Assist, and Smoke is being able to
create your own effects, depending on your particular needs. Creating a custom shader can be as simple as copying and
pasting GLSL code snippets, or can be complex multi-pass effects with multiple inputs and dozens of user interface elements.
Custom shaders can also be encrypted for distribution.
TIP You can find many shaders by visiting the community-driven shader repository at https://logik-matchbook.org/. You can
download free shaders created by fellow users, or share your own custom shaders with other users.
Here's the high-level workflow to follow when creating custom shaders:
1 Write or copy/paste GLSL fragment shader code.
2 Use the provided shader_builder command line tool to test the shader and generate XML files for the user interface
and optional presets displayed in the application.
3 Fix any errors in the GLSL code.
4 Edit the XML output from the shader_builder to customize the user interface and optional presets.
5 Package and maybe encrypt the XML and GLSL code together.
Matchbox and Lightbox availability depends on the application being used.
Product
Lightbox
(in Action)
Matchbox (in Matchbox (in
Action)
Batch/BFX)
Matchbox (in
Timeline)
Matchbox (in
Modular Keyer)
Matchbox (in Tools tab)
Flame
Available
Available
Available
Available
Available
Available
Flare
Available
Available
Available
Available (as source
in Batch)
Available
Available
Flame Assist
Not available
Not available
Available
Available
Available
Not available
Smoke
Not available
Not available
Available (ConnectFX)
Available
Available
Not available
What is GLSL?
GLSL stands for OpenGL Shading Language, and is a language based on C syntax. GLSL, as its name indicates, is a low-level
API of OpenGL, the API used to render graphics on graphical processing units.
GLSL was created to facilitate the manipulation of the graphics pipeline by developers, without requiring deep machine
code knowledge. In GLSL, normals, texture maps, complex vector and matrices operations are all central to language,
3
making the creation of shaders simpler. The specifications for OpenGL and GLSL can be found at the OpenGL Foundation
website.
Lightbox and Matchbox shaders are all GLSL-created shaders.
You will also find resources on the web, such as Lighthouse 3D. When looking for online resources, keep in mind that on
Linux the supported version of GLSL is 130. If you want your Lightbox (or Matchbox) snippet to run on Mac OS X, you
must use GLSL version 120.
4 | Chapter 2 Creating Your Own Shader
Creating a Matchbox Shader
3
Here are the contents of a simple Add effect as a Matchbox shader:
uniform float adsk_result_w, adsk_result_h;
void main()
{
vec2 coords = gl_FragCoord.xy / vec2( adsk_result_w, adsk_result_h );
vec3 sourceColor1 = texture2D(input1, coords).rgb;
vec3 sourceColor2 = texture2D(input2, coords).rgb;
gl_FragColor = vec4( sourceColor1+sourceColor2, 1.0 );
}
Writing and Testing Matchbox Shader Code
A Matchbox shader is always structured as:
■ A forward declaration where all the uniforms and APIs are declared.
■
A main() function where the magic happens. Matchbox shaders are not part of an established shading pipeline like
Lightbox shaders are, hence the use of main().
You can re-purpose existing fragment shader code, or create an effect specific to your needs.
NOTE On Linux, the supported version of GLSL is 130. If you want your Matchbox code to run on Mac OS X, you must use
GLSL 120. Also, Action does NOT comply with OpenGL core profile.
Once you're done coding the shader, use shader_builder to validate and debug your code, and help you design user interface
elements via a sidecar XML file. Once validated, you can encrypt and package your custom shader. shader_builder also
has an extensive set of uniforms (including a number of Autodesk custom uniforms) and XML entities that allow you to:
■ Define the UI layout.
■
Define parameter names.
■
Define numerical intervals for specified parameters.
■
Disable or hide a button based on the status of another button.
■
Define a web link, to direct users to documentation on the shader you are providing.
Because Matchbox shaders can be used in Batch/Batch FX/ConnectFX, there are some Matchbox-only uniforms:
■ Setting an Input Type for a Matchbox Input socket (Front, Back, Matte).
■
Defining custom colours for a Matchbox Input Socket.
5
Limiting the number of Input Sockets displayed on the Matchbox node to the number of Textures required by the
current shader.
■
The shader_builder utility is found in /usr/discreet/<product_home>/bin. To access its Help file, from the bin directory, type
shader_builder --help. All this information is also available in About shader_builder XML (page 23).
The main command to process a Matchbox shader is shader_builder -m <name of shader>.glsl. You can use the
following options with this command:
Option
Verbose
Description
-p
--package
creates a '.mx' or '.lx' encrypted package file.
-u
--unpack
extracts the xml and thumbnail (.png, .p) files from a '.mx' or '.lx' package file.
-x
--write-xml
writes the sidecar .xml interface to a file.
-l
--lightbox
sets the shader type to a lightbox operator.
-m
--matchbox
sets the shader type to the standard matchbox operator.
-t
--presettemplate
writes the preset template to a file.
-o
--output
outputs all files to another folder.
-d
--do-notcompile
does not attempt compiling the shaders. Use with -p.
-h
--help
displays full documentation.
These options can be combined in one command. For example: shader_builder -m -x <name of shader>.glsl.
To create and test a fragment shader:
1 Write or copy your fragment shader code in a text editor. For example, here is a scaling effect:
uniform float size;
uniform sampler2D myInputTex;
void main (void) {
vec4 tex0 = texture2D(myInputTex, gl_TexCoord[0] * size);
gl_FragColor = vec4 (tex0.rgb, 1.0);
}
2 Save the file with the extension .glsl. For the purpose of this example, it is named scale.glsl.
3 Run your code through the test utility and generate a sidecar XML file.
shader_builder -m -x scale.glsl tests the above shader and outputs the results in the shell, while generating the
sidecar XML file named scale.xml. But produces the following result:
Shader pass 0:
Fragment info
6 | Chapter 3 Creating a Matchbox Shader
------------0(5) : warning C7011: implicit cast from "vec4" to "vec2"
compiling shader file scale.glsl ... [OK]
all shaders compiled ... [OK]
generating XML interface ...
creating XML file (scale.xml) ... [OK]
In the example above, the fourth line displays a compilation warning that you might want to fix, indicating the
number of the line where the error is located. In other cases, you'll receive errors that need to be fixed; shader_builder
builds the XML file only if it encounters no errors while testing the .glsl file.
4 Fix any errors, and rerun the code through the shader_builder utility.
5 Use the XML file generated by shader_builder to help you set up the UI of the effect. This can be especially useful
if different users are going to be working with these effects. In our example, you can edit scale.xml to add default
values, better names for inputs and other UI elements, and even tooltips to help the user.
In the example below, updated values are in bold-italics.
<ShaderNodePreset
SupportsAdaptiveDegradation="False" SupportsAction="False"
SupportsTransition="False" SupportsTimeline="False"
TimelineUseBack="False" MatteProvider="False" ShaderType="Matchbox"
SoftwareVersion="2016.0.0" LimitInputsToTexture="True"
Version="1" Description="" Name="Next Generation Scaling">
<Shader OutputBitDepth="Output" Index="1">
<Uniform Index="0" NoInput="Error"
Tooltip="" DisplayName="Front"
InputColor="67, 77, 83" Mipmaps="False"
GL_TEXTURE_WRAP_T="GL_REPEAT"
GL_TEXTURE_WRAP_S="GL_REPEAT"
GL_TEXTURE_MAG_FILTER="GL_LINEAR"
GL_TEXTURE_MIN_FILTER="GL_LINEAR"
Type="sampler2D" Name="myInputTex">
</Uniform>
<Uniform ResDependent="None"
Max="100.00"
Min="-100.00"
Default="0.0"
Inc="0.01"
Tooltip="Displays the percentage of scaling applied."
Row="0" Col="0" Page="0"
Type="float"
DisplayName="Scale"
Name="size">
</Uniform>
</Shader>
<Page Name="Page 1" Page="0">
<Col Name="Effect Settings" Col="0" Page="0">
</Col>
</Page>
</ShaderNodePreset>
Creating a Matchbox Shader | 7
6 Add the .glsl and sidecar .xml file to the same directory, with an optional .p or .png file to be used as a thumbnail
in the Matchbox browser. The existing shader files are located in /usr/discreet/presets/<application
version>/matchbox/shaders/.
7 If you want to encrypt and package the shader in the .mx format, from that location, run shader_builder -m -p
<name of shader>.glsl.
8 Try your effect in Smoke or Flame.
If you cannot see your shader in the Matchbox browser, try toggling the Matchbox box filter between Matchbox
and GLSL.
To help you in creating custom shaders, example shaders (page 8) are available in
/usr/discreet/presets/<application_version>/matchbox/shaders/EXAMPLES/.
Forward Declaration
Matchbox requires that you forward declare your uniforms and used APIs. This ensures that shader_builder provides
accurate file locations for warnings and errors.
Creating Multipass Shaders
In order to build more efficient, complex, or sophisticated effects, you can split your effects into multiple passes. In order
to do this, you separate your effect into multiple .glsl files using advanced adsk_ uniforms. For example, the existing
Pyramid Blur filter preset consists of PyramidBlur.1.glsl and PyramidBlur.2.glsl. In this case, when selecting this effect
from the Load Shaders browser in the application, you need to select the root group PyramidBlur.glsl file to incorporate
all of the passes as one effect. Use the -p switch to package everything into a single file, making it less confusing to load
from the browser.
About Cross-Version Compatibility
Due to updates to both the Matchbox API and the schema of the sidecar XML, you cannot use a Matchbox created for
2016 in a previous version. But you can use a Matchbox created in a previous version in 2016.
Optional: Create a Browser Proxy Files
Along with the .glsl and .xml files that comprise a fragment shader, you can also create a .png file that displays a proxy
of your effect in the Matchbox browser.
To use a .png file as the proxy:
1 Create an 8-bit, 126 pixels wide by 92 pixels high .png
2 Place the .png file in the same folder as the .glsl and .xml files of the same name.
Matchbox Shader Examples
To help you in creating custom Matchbox shaders, example shaders are available in
/usr/discreet/presets/<application_version>/matchbox/shaders/EXAMPLES/.
The following example Matchbox shaders are available:
Accumulate Shows an example using the accumulation texture feature which allows you to use the result
of the previous frame.
8 | Chapter 3 Creating a Matchbox Shader
Action3DSelective Shows the code used to add the selective 3D functionality to any other shader. This
creates a matte output based on the image segmentation of the scene using either Depth, Normals, or Motion
Vectors.
Blending Shows an example of both the usage of int popup, as well as the usage of the blend mode API.
BuildList Only shows the int as popup XML feature.
ColourWheel Shows how to use the Colour Wheel widget in both the xml and glsl files.
ConditionalUI Shows how to use the conditional UI xml functionality.
Curves Shows how to use the Curve widget with two different curve types, in both the xml and glsl files.
DecodeZDepthHQ Shows an example of how to decode the Action ZDepth HQ output, and create a 32-bit
depth image inside Matchbox to be used by other passes of the same shader.
GridFetchingComp Example/template on how to create your own Texture Grid shader to comp a logo to
a background image.
GridFetchingCompMulti Example/template on how to create your own Texture Grid shader to comp up
to four logos to a background image.
GridFetchingReplace Example/template on how to create your own Texture Grid shader to replace the
input by the texture Grid content. This could be useful to replace Action Lens Flare elements, for example.
ImageLighting Shows how to do a light in Matchbox.
ImagePosition Shows how to do image X and Y transforms.
ImageRotation Shows how to do image rotation.
ImageScaling Shows how to do image X and Y scaling.
InputSockets Shows how to define Input socket type and colour in the xml.
MatchboxAPI Shows how to use the different Matchbox API calls.
Mipmaps Shows how to use mipmaps to perform a blur in Matchbox.
MultiTargetCustomMipmaps Shows how to use the Custom Mipmaps feature of Matchbox.
PyramidBlur Shows how to do the equivalent of a fast Gaussian blur in Matchbox.
TemporalSampling Shows how to use previous and next frame input in both the xml and glsl files.
TransitionShader Shows how to create a Transition Matchbox shader to be used on the timeline.
UIOnly Shows how to create Matchbox that are only used to do UI for expression usage.
Matchbox Shader Examples | 9
10
Creating a Lightbox Shader
4
Here are the contents of a simple invert color effect as a Lightbox shader:
vec4 adskUID_lightbox(vec4 source)
{
source.rgb = vec3(1.0) - source.rgb;
return source;
}
Writing and Testing Lightbox Shader Code
A Lightbox shader is always structured as:
■ A forward declaration where all the uniforms and APIs are declared.
■
A vec4 adskUID_lightbox(vec4 source) function, where the magic happens. Lightbox shaders are part of the Action
shading pipeline.
You can re-purpose existing fragment shader code, or create an effect specific to your needs.
NOTE On Linux, the supported version of GLSL is 130. If you want your Lightbox (or Matchbox) snippet to run on Mac OS X,
you must use GLSL 120. Also, Action does NOT comply with OpenGL core profile.
Once you're done with coding the shader, use shader_builder to validate and debug your code, and help you design user
interface elements via a sidecar XML file. Once validated, you can encrypt and package your custom shader. The
shader_builder utility also has an extensive set of uniforms (including a number of Autodesk custom uniforms) and XML
entities that allow you to:
■ Define the UI layout.
■
Define parameter names.
■
Define numerical intervals for specified parameters.
■
Disable or hide a button based on the status of another button.
■
Define a web link, to direct users to documentation on the shader you are providing.
The shader_builder utility is found in /usr/discreet/<product_home>/bin. To access its Help file, from the bin directory,
type shader_builder --help. All this info is also available in About shader_builder XML (page 23).
11
The main command to process a Lightbox shader is shader_builder -l <name of shader>.glsl. You can use the following
options with this command:
Option
Verbose
Description
-p
--package
creates a '.mx' or '.lx' encrypted package file.
-u
--unpack
extracts the xml and thumbnail (.png, .p) files from a '.mx' or '.lx' package file.
-x
--write-xml
writes the sidecar .xml interface to a file.
-l
--lightbox
sets the shader type to a lightbox operator.
-m
--matchbox
sets the shader type to the standard matchbox operator.
-t
--presettemplate
writes the preset template to a file.
-o
--output
outputs all files to another folder.
-d
--do-notcompile
does not attempt compiling the shaders. Use with -p.
-h
--help
displays full documentation.
These options can be combined in one command. For example: shader_builder -l -x <name of shader>.glsl.
To create and test a fragment shader:
1 Write or copy your fragment shader code in a text editor, making sure to include the main function vec4
adskUID_lightbox () .
For example, here is the contents of a gain effect:
1
2
3
4
5
6
uniform float adskUID_gain;
vec4 adskUID_lightbox( vec4 source )
{
source.rgb = source.rgb * adskUID_gain;
return vec4( source.rgb, source.a )
}
2 Save the file with the extension .glsl .
For the purpose of this example, it is named gain.glsl.
3 Run your code through the test utility and generate a sidecar XML file.
shader_builder -l -x gain.glsl tests the above shader and outputs the results in the shell, while generating the
sidecar XML file named gain.xml . But produces the following result:
uniform float adskUID_gain;
vec4 adskUID_lightbox(vec4 source)
{
source.rgb = source.rgb * adskUID_gain;
12 | Chapter 4 Creating a Lightbox Shader
return vec4( source.rgb, source.a)
}
0(6) : error C0000: syntax error, unexpected '}', expecting ',' or ';' at token "}"
0(2) : error C1110: function "adskUID_lightbox" has no return statement
In this case, instead of the expected xml output, we get a compilation error: line 5 in our glsl fragment is missing
an ending semi-colon. Errors must be fixed for the glsl fragment to work properly in Flame Premium. But in other
cases, you will just get a compilation warning: whether such a warning can be ignored or not depends on the
circumstances.
4 Fix any errors, and rerun the code through shader_builder. In the gain.glsl example, add the missing semi-colon at
the end of line 5 to fix the unexpected '}' error on line 6:
return vec4( source.rgb, source.a);
5 Use the XML file generated by shader_builder to help you set up the UI of the effect. This can be especially useful if
different users are going to be working with these effects. In our example, you can edit scale.xml to add default
values, better names for inputs and other UI elements, and even tooltips to help the user. Updated values are in
bold-italics.
In the example below, updated values are in bold-italics.
<ShaderNodePreset
SupportsAdaptiveDegradation="False"
OverrideNormals="False" CommercialUsePermitted="True"
ShaderType="Lightbox" SoftwareVersion="2016.0.0"
LimitInputsToTexture="True" Version="1"
Description=""
Name="Simple Gain">
<Shader OutputBitDepth="Output" Index="1">
<Uniform ResDependent="None"
Max="100.00"
Min="-100.00"
Default="0.0" Inc="0.01"
Tooltip="Defines the RGB multiplier."
Row="0" Col="0" Page="0"
Type="float"
DisplayName="Gain"
Name="adskUID_gain">
</Uniform>
</Shader>
<Page Name="Page 1" Page="0">
<Col Name="Effect Settings" Col="0" Page="0">
</Col>
</Page>
</ShaderNodePreset>
6 Add the .glsl and sidecar .xml file to the same directory, with an optional .png file to be used as a thumbnail in the
Lightbox browser. The existing shader files are located in
/usr/discreet/presets/<application_version>/action/lightbox/.
7 If you want to encrypt and package the shader in the .lx format, from that location, run shader_builder -l -p
<name of shader>.glsl .
8 Try your effect in Flame or Flare.
To help you in creating custom shaders, example shaders (page 19) are available in the
/usr/discreet/presets/<application_version>/action/lightbox/EXAMPLES .
Creating a Lightbox Shader | 13
Optional: Create a Browser Proxy Files
Along with the .glsl and .xml files that comprise a fragment shader, you can also create a .png file that displays a proxy
of your effect in the Lightbox browser.
To use a .png file as the proxy:
1 Create an 8-bit, 126 pixels wide by 92 pixels high .png,
2 Place the .png file in the same folder as the .glsl and .xml files of the same name.
Forward Declaration
Lightbox requires that you forward declare your uniforms and used APIs. This ensures that shader_builder provides accurate
file locations for warnings and errors.
About Lightbox Structure and the Action Shading Pipeline
Some contextual information about Action's rendering pipeline.
Action's fragment shader is split in 3 blocks:
1 Lighting loop, where shading/IBL and shadows are rendered
2 Fog
3 Blending
The Lightbox framework allows you to extend Action's lighting capabilities. By defining a function adskUID_lightbox in
a GLSL file, Lightbox appends the shader snippet to Action's fragment shader, and can then call it within the lighting
loop.
A simple Lightbox example:
uniform vec3 adskUID_lightColor;
vec4 adskUID_lightbox( vec4 source )
{
vec3 resultColor = source.rgb + adskUID_lightColor;
return vec4( resultColor, source.a );
}
The adskUID_ prefix is required for any global symbol in the shader (functions, uniforms, constants...) because namespaces
aren't available in GLSL. You must identify uniquely every global symbol in the Lightbox code with adskUID_ to avoid
symbol clashes when the shader snippet is appended to the Action shader string, or users will not be able to load more
than one copy of your Lightbox in Action; symbol clashes actually disable all loaded Lightboxes.
Also, when figuring out the input of your shader, remember that the Priority Editor in Action allows the user to reorder
lights and their Lightboxes: the order in which lights are applied now matters.
Finally, keep in mind that some Lightbox options are defined in the parented light and affect the behaviour of the attached
Lightbox:
Pre-/Post- When the light is active, the attached Lightboxes can render the pixel without the light effect (Pre), or the
Lightboxes can render the pixel with the light effect (Post).
Lightbox Normals Even with the light inactive, the user can decide to feed the normals information to the Lightbox
shader. Or not.
Additive Light/Solo Light This defines the contribution of the light and its attached Lightboxes. The default is Additive.
In the API, bool adsk_isLightAdditive() gives you its status.
■ Additive: The input of the light is the output of the light listed before it in the Priority Editor.
14 | Chapter 4 Creating a Lightbox Shader
■
Solo: The input of the light is the diffuse value, creating a "punch through" effect.
Lightbox Change Shader mix The vec4source is the incoming fragment rendered by the previous light or Lightbox in
the shading pipeline. The return value is mixed according to the alpha returned by the function and the mix amount
from the Lightbox's Shader tab. This alpha blending is the reason why every Lightbox must return a valid source.a .
Actually, you can override the shape of the light by overriding the alpha component of return vec4 with an alpha of
your own, computed within the Lightbox.
Lightbox Processing Pipeline
Below is commented pseudocode that should help you understand the Lightbox processing pipeline.
The scene ambient light if enabled is the first light to be processed. IBL environment maps are then processed next for all other lights, the light loop compute
shadings and lightbox sorted according to priority editor.
vec3 computeShading()
{
vec3 shadedColor = computeSceneAmbientLight();
shadedColor = applyIBL( shadedColor );
for ( int i = 0; i < nbLights; ++i )
{
The light UI settings are:
[ light : {active, inactive},
lightbox rendering : {pre, post lighting},
light blend mode: {additive, solo} ]
The different combinations that can affect the input colors to lightbox:
1 [inactive, n/a, additive] : the current fragment (un-shaded by the current light)
2 [active, post-light, additive] : the current fragment (shaded by the current light)
3 [inactive, n/a, solo] : simply the diffuse value (un-shaded)
4 [active, post-light, solo] : the diffuse value shaded by the current light.
Compute the light alpha: GMask alpha * decay * spotlightAttenuation
float alpha = getLightAlpha( i );
The diffuse color is the diffuse material color modulated by the diffuse map.
vec3 lightboxInputColor = isLightSolo( i ) ? getDiffuseColor() : shadedColor;
Light is active and renders before lightbox
if ( isLightActive( i ) && isLightPre( i ) )
{
computeLight performs the standard (non PBR) shading equation and could be additive or solo. Solo replaces the current color with the computed light
color.
lightboxInputColor = computeLight( i, lightboxInputColor );
}
If available process lightboxes.
Creating a Lightbox Shader | 15
float nbLightboxes = getNbLightboxes( i );
vec4 lightboxColor = vec4( lightboxInputColor, alpha );
for ( int lx = 0; lx < nbLightboxes; ++lx )
{
lightboxColor = computeLightbox( lx, lightboxColor );
}
vec4 lightboxResultColor = lightboxColor;
If the "use lightbox" option is enabled, the combined lightbox effects for this light can be applied according to the Lightbox effect.
if ( useLightboxNormals( i ) ) {
lightboxResultColor.a = mix( lightboxResultColor.a,
lightboxResultColor.a * nDotL,
// you can dose the shading of a lightbox.
// light's lightbox panel effect numeric.
getLightboxEffect( i ) );
}
Light is active and renders after lightbox.
if ( isLightActive( i ) && !isLightPre( i ) )
{
lightboxResultColor.rgb = computeLight( i, lightboxColor );
}
shadedColor = mix( lightboxInputColor, lightboxResultColor, lightboxResultColor.a );
}
return shadedColor;
}
vec4 computeLightbox( int lxInstance, vec4 inputColor )
{
adskUID is replaced by UID. Given the lx instance we find the corresponding adskUID_lightbox signature.
vec4 lightboxColor = adskUID_lightbox( inputColor );
Each lightbox has mix numeric in its UI.Allows you to dose the lightbox color and NOT the alpha.
return vec4( mix( inputColor.rgb, lightboxColor, adskUID_mix ), lightboxColor.a );
}
Action fragment shader.
void main()
{
vec4 finalColor = vec4( computeShading(), 1.0 );
applyFog( finalColor );
applyBlending( finalColor );
gl_FragColor = finalColor;
}
Why Create a Lightbox
Lightbox is a unique blend of concepts inherited from 3D lighting, color grading, and Photoshop adjustment layers,
delivering an entirely new take on look development for images and 3D geometry. The Lightbox framework provides users
the ability to define custom color lighting effects within Action, Flame's 3D compositing engine.
16 | Chapter 4 Creating a Lightbox Shader
When working within Lightbox, defining the task to accomplish will help you measure the complexity of the task at hand.
Starting User
You want to create simple effects to relight your scene; inverse the colours of a specific object, in the scene using all the
familiar light controls and behaviors, taking into account the characteristics of the object such as its specularity and
normals. For example, the following Lightbox adds red colours wherever it is pointed.
vec4 adskUID_lightbox( vec4 source )
{
vec3 red = vec3 (1.0, 0.0 ,0.0 );
return vec4( source.rgb + red , source.a );
}
It is a very simple Lightbox, but it goes to show that you do not need complex mathematics to create a Lightbox.
Or you can leverage the available Lightbox API to change colour space, as in the following example, where the lighted
area is converted from RGB to YUV.
vec4 adskUID_lightbox( vec4 source )
{
vec3 converted_to_yuv = adsk_rgb2yuv( source.rgb )
return vec4( converted_to_yuv , source.a );
}
But whereas Matchbox can use the MatteProvider xml property to define whether a children node should use its matte
or not, Lightbox must always return a matte. And this brings us to the second type of user.
Intermediate User
You need to modify the shape or other parameters of the light, such as decay, and this means actually editing the alpha
of the Lightbox.
In the example below, the Lightbox queries the Action scene to do more advanced processing while still using the Lighting
framework.
vec3 adsk_getLightPosition(vec3 LightPos);
vec3 adsk_getVertexPosition(vec3 VertexPos);
//Used to create the near clipping plane,
//from a UI element created by the Lightbox.
uniform float adskUID_near;
//Used to create the far clipping plane,
//from a UI element created by the Lightbox.
uniform float adskUID_far;
//This value is from a UI element created by the Lightbox.
uniform vec3 adskUID_tint;
vec4 adskUID_lightbox( vec4 source )
{
vec3 colour = source.rgb;
//We are using the Light position and vertex position information
//to determine the distance in between the two to then allow
//to modulate the color based on Light versus vertex distance
float alpha = clamp(length(adsk_getLightPosition() - adsk_getVertexPosition())
/ (adskUID_far-adskUID_near), 0.0, 1.0);
vec3 result = colour * adskUID_tint;
Creating a Lightbox Shader | 17
colour = mix(result, colour, alpha);
return vec4 (colour, source.a);
}
In another example, a simple grayscale effect is applied to a target offset, defined by the end-user using
adskUID_targetPosition.
vec3
float
uniform
uniform
adsk_getVertexPosition();
adsk_getLuminance( vec3 rgb );
float adskUID_distanceMax;
vec3 adskUID_targetPosition;
vec4 adskUID_lightbox( vec4 source )
{
vec3 vertexPos = adsk_getVertexPosition();
// Get the radius of the effect
float distMax = max( adskUID_distanceMax, 1.0 );
// Get the distance from the centre of the effect
float dist = length( vertexPos - adskUID_targetPosition );
float alpha;
if ( dist > distMax )
alpha = 0.0; // outside the range of the effect
else
alpha = clamp( dist / distMax, 0.0, 1.0 );
// The effect is simply a conversion to grayscale
vec3 rgbOut = vec3( adsk_getLuminance(source.rgb) );
//Since we edited the alpha in this Lightbox, we need to make sure
//not to override the alphas that was calculated by the previous
//light in the shading pipeline.
return vec4( rgbOut, source.a * alpha );
}
NOTE Be careful to not white out the alpha, or you will lose the whole scene information whenever you use that Lightbox.
Unless you are an advanced user, whenever you edit the alpha, make sure to always multiply your result by the entering alpha,
as in the example above: source.a * alpha.
Advanced User
The advanced user wants to actually modify the rendering pipeline, ignoring all that was computed upstream from the
light, and substitute their own render calculations. This is possible because lighting calculations happen at the end of the
rendering pipeline, and means . While this is an interesting proposition that allows truly unique renders, it is also a very
expensive one, computationally speaking. The Action render pipeline is static, and substituting your own methods by
using a Lightbox essentially means rendering a scene twice: once by Action, and once again by the Lightbox.
While creating such a Lightbox is possible, it is way beyond the scope of this document. But there is an expansive,
un-optimized example available, providing an alternative to the current IBL implementation. See
/usr/discreet/presets/<application_version>/action/lightbox/EXAMPLES/GGXIBLExample.glsl.
18 | Chapter 4 Creating a Lightbox Shader
Lightbox Shader Examples
To help you in creating custom Lightbox shaders, examples are available in the
/usr/discreet/presets/<application_version>/action/lightbox/EXAMPLES .
The following example Lightbox shaders are available:
GGXIBLExample Similar to GGXMaterial, but it doesn't hijack the Material node, and all controls are
present in the Lightbox itself. Also it doesn't support object texture and only a BaseColor which is set in the
Lightbox itself.
GGXMaterial This shader performs a rendering of the scene using a physically based shading algorithm
which requires three distinct values from each material in the scene; the Specular, Metallic, and Roughness
component values. These components are not available natively in the Material settings, so they are mapped
as followed in the GGXMaterial Lightbox shader: Specular Red Channel for the Specular value, the Specular
Green Channel for the Metallic value and the Shine parameter to define the Roughness.
LightboxAPISimple This shader shows all possible API calls to the Lightbox API and shows a simple decay
example using vertex and light position.
LightboxBasics This is the most basic usage of Lightbox, only applying a Gain without having to use the
API at all.
PhysicallyBasedIBL Shows how to use the Shader Physically Based mode API with Ligthbox; in this case it
is computing the IBL based on these values.
SimpleLight This is an example re-creating an Action light in Ligthbox using the API.
Lightbox Shader Examples | 19
20
Creating Shader Presets
5
You can create presets from the settings in a shader directly from within the application. Users of your shader can then
select different starting points, by selecting Sepia in the Duotone shader, for example.
Creating presets requires the use of a working shader within the application.
To create shader presets:
1 Within the application, load the Matchbox or Lightbox shader that you want to create presets for.
2 Use the existing shader menu settings to create the exact look you want.
NOTE Curve position and tangent menu settings are not supported in shader presets.
3 Click the UI XML Shell Printout button (found within the Shader tab, if accessed from Action; other found in the
Setup menu). If you launched the app from a shell command, this shell is used for the output (on a Mac system, it
is preferable to launch the application from a shell command to avoid issues in the preset shell output).
4 Navigate to the shell to find the XML output for the preset you created. For example, here is the shell output for a
new preset in the Duotone shader:
//-----------------------------------------------------------Copy&Paste this XML in the preset file:
<Presets>
<Preset Name="Preset Name">
<Shader Index="1">
<Uniform Type="vec3" DisplayName="Custom Black" Name="adskUID_customBlack">
21
<SubUniform Value="0.731429">
</SubUniform>
<SubUniform Value="0">
</SubUniform>
<SubUniform Value="2.61579e-07">
</SubUniform>
</Uniform>
<Uniform Type="vec3" DisplayName="Custom White" Name="adskUID_customWhite">
<SubUniform Value="1">
</SubUniform>
<SubUniform Value="1">
</SubUniform>
<SubUniform Value="1">
</SubUniform>
</Uniform>
<Uniform Value="95.6001" Type="float" DisplayName="Contrast"
Name="adskUID_contrast">
</Uniform>
<Uniform Value="0.82" Type="float" DisplayName="Pivot" Name="adskUID_pivot">
</Uniform>
<Uniform Value="0" Type="bool" DisplayName="Use GMask Input" Name="gmaskInput">
</Uniform>
<Uniform CurveShape="0" Type="int" DisplayName="Luminance"
Name="adskUID_lumaCurve">
</Uniform>
<Uniform Value="-1" Type="int" DisplayName="Blend Modes"
Name="adskUID_blendModes">
</Uniform>
<Uniform Value="100" Type="float" DisplayName="Mix" Name="adskUID_inputMix">
</Uniform>
</Shader>
</Preset>
</Presets>
//-----------------------------------------------------------TIP A user can perform the above steps and send you this shell output for you to include as a preset in future iterations of
your shader.
5 Copy and paste the contents into an XML file, changing Preset Name to something more meaningful. You can have
multiple <Preset Name> </Preset> instances within a file, as long as they are within a <Presets> </Presets> tag.
You can also create a blankpreset.xml template from an existing GLSL with the –t option, and use this to paste the
shell output.
6 Name the XML file as <name of shader>.preset.xml, and include this file when packaging your shader.
7 The next time the shader is loaded in the application, the new preset is available from the Presets list.
22 | Chapter 5 Creating Shader Presets
About shader_builder XML
6
In its most basic form, a Matchbox or Lightbox is only a .glsl file that contains all the shader information. That single file
is enough for the application to generate both the shading result and a rough UI for the end user to manipulate the shader
parameters.
But to create a useful UI, you need a sidecar .xml file. This file is generated by the running shader_builder with the -x
switch. Once it's been created by shader_builder, you can edit the xml to tweak the UI to your needs, such as substituting
curves for numeric fields.
NOTE Any uniform with a name that starts with "adsk_" is not shown in the user interface and not considered by shader_builder.
XML Structure
<!DOCTYPE ShaderNodePreset [
<!ELEMENT
<!ELEMENT
<!ELEMENT
<!ELEMENT
<!ELEMENT
<!ELEMENT
<!ELEMENT
<!ELEMENT
]>
ShaderNodePreset (Shader+, Page+)>
Shader (Uniform+)>
Uniform (SubUniform* | PopEntry* | Duplicate*)>
SubUniform EMPTY>
PopEntry EMPTY>
Duplicate EMPTY>
Page (Col+)>
Col EMPTY>
<ShaderNodePreset>
Parent
■
None. ShaderNodePreset is the root element.
Children
■
<Shader> : At least one for a Matchbox. Only one for a Lightbox . See <Shader> usage definition.
■
<Page>: At least one.
23
Usage
■
Root element. Mandatory.
Attribute
Description
Allowed Values
Default
Description
A description of the Preset. The
description appears in the
Matchbox node Note available
from the Schematic.
Character data
EMPTY
Name
The name of the Preset. The
name appears in the Name field
of the Node interface. The Name
attribute overrides the filename,
so if the .xml file is present, even
if the user loads the .glsl file, the
Name attribute is displayed in the
UI.
Character data
Name of the preset
HelpLink (optional)
Allows you to specify an URL that
can be used for external documentation (only valid XML characters are allowed in the URL). A
Help button is added to the
Matchbox interface when this
token is detected.
Character data
EMPTY
LimitInputsToTexture (optional)
Allows you to limit the number of
Input Sockets on the Matchbox
node to the number of textures
required by your shader.
■
True
False
■
False
Matchbox only
Specifies if the Matchbox shader
provides a matte to its child node,
or if it is a pass through, where
the Matchbox's child node uses
the matte from the Matchbox's
parent. If the Matchbox operates
on the alpha and you want that
alpha to be passed on the child
node, you must set MatteProvider
= True.
■
True
■
False
Matchbox only
Hints to the usage of the Matchbox, in this case as an Action
node. Batch is always supported.
■
True
■
False
Matchbox only
Hints to the usage of the Matchbox, in this case as a transition in
■
True
■
False
MatteProvider
SupportsAction
SupportsTransition
24 | Chapter 6 About shader_builder XML
False
False
False
Attribute
Description
Allowed Values
Default
Matchbox only
Defines if the Matchbox node
supports Batch adaptive degradation. Use in combination with the
adsk_degrade uniform to create
a less costly data path, or even
completely bypass the Matchbox
to enhance Batch interactivity.
Note that the Matchbox must be
coded with alternate paths using
the adsk_degrade for adaptive
degradation to work: simply setting SupportsAdaptiveDegradation = True does not make the
node turn off when adaptive degradation is turned on.
■
True
False
■
False
Indicates if the shader should be
used for commercial purposes.
This attribute is not enforced by
the application. Set by the creator
of the shader to indicate if the
shader can be used for commercial purposes. The user of the
shader is responsible for verifying
this attribute and using the
shader accordingly.
■
True
■
False
the timeline. Batch is always supported.
SupportsAdaptiveDegradation
CommercialUsePermitted
True
AccumulatePass
Numeric value that allows the
matchbox to accumulate an intermediate pass. ( ShaderIndex )
rather than the final result: Onebased.
AccumulationFromStartFrame
Bool that specifies if accumulation
should proceed recursively. There
is an Accumulate (page 8) example provided in the EXAMPLE
folder.
■
True
■
False
ShaderType
Defined by shader_builder, determines the type of shader,
Lightbox or Matchbox.
Matchbox / Lightbox
Value depends on the .glsl file
used to create the XML.
SoftwareVersion
Defined by shader_builder, indicates the version of the application
used to build the .xml.
Character data
shader_builder defined
True
About shader_builder XML | 25
Attribute
Description
Allowed Values
Default
TimelineUseBack
Matchbox only
Defines if the Matchbox uses the
background of the timeline
(True), or not (False). Only used
in context of the timeline.
■
True
True
■
False
Version of shader. Metadata
which is user-defined and not
processed by the application.
Character data
Version
1
<Shader>
Parent
■
<ShaderNodePreset>
Children
■
<Uniform> : At least one.
Usage
■
Mandatory.
■
There is one <Shader> for each shader pass defined in the .glsl file: a Matchbox can have multiple shader passes, but
a Lightbox can only ever have one. <Shader> lists the uniforms required for the associated shader pass.
Attribute
Description
Allowed Values
Default
Index
The index of the associated
shader pass. Indexed from 1.
Integer
1
OutputBitDepth
Bit depth of the render target for
this render pass.
■
Output
Output
■
8
■
16
■
Float16
■
Float32
OutputWidth
Width of the render target to use
for this pass if none can be determined from the inputs (nonexisting or no connection). In
multi-pass shader, only the last
pass need specify this value. Ignored in Action and on the
Timeline.
Integer
OutputHeight
Height of the render target to use
for this pass if none can be determined from the inputs (non-
Integer
26 | Chapter 6 About shader_builder XML
Attribute
Description
Allowed Values
Default
existing or no connection). In
multi-pass shader, only the last
pass need specify this value. Ignored in Action and on the
Timeline.
OutputWidthScaleFactor
OutputHeightScaleFactor
OutputScaleFactorEffect
Scale the width of the render target for this pass relative to the
output resolution.
■
1 = no scaling
■
0.5 = half the size
Scale the height of the render
target for this pass relative to the
output resolution.
■
1 = no scaling
■
0.5 = half the size
Define the effect of the scale
factors on the sizes.
■
0 = floor
■
1 = round
■
2 = ceiling
OutputNbLevels
Specify the number of levels for
a custom mipmap intermediate
pass.
OutputNbResults
Specify the number of textures
produce by an intermediate pass.
<Uniform>
Parent
■
<Shader>
Children
■
<SubUniform> : As many as required by the uniform, as defined by the Type attribute, and if ValueType <> PopUp.
■
<PopupEntry> : Only if attribute ValueType = PopUp, in which case there can be as many as required.
■
<Duplicate>: Only one, only if parent <Uniform> is a duplicate. See <Duplicate> definition.
Usage
■
One for each uniform in the current pass.
Attribute
Description
Allowed Values
Type
Type of uniform.
float vec2 vec3 vec4 int ivec2 ivec3 ivec4 bool
bvec2 bvec3 bvec4 mat2 mat3 mat4 mat2x3
mat2x4 mat3x2 mat3x4 mat4x2 mat4x3
sampler2D
About shader_builder XML | 27
Attribute
Description
Allowed Values
Tooltip
The text for this uniform tooltip.
Character data
DisplayName
The name displayed for this uniform in the
user interface.
Character data
ChannelName
The name displayed for this uniform's Animation Channel.
Character data
Name
The name of the uniform used in the GLSL
file, set by shader_builder. It cannot be
changed as this is used to indicate which
uniform in the .glsl file uses this UI element.
Character data
Row
The row where the uniform is positioned in
the UI.
0-4
Col
The column where the uniform is positioned
in the UI.
0-3
Page
The page where the uniform is positioned in
the UI.
0-6
Default
The default value of this uniform.
■
Values allowed based on type of the uniform:
■
True or False: bool, bvec2, bvec3, bvec4
■
An Integer: int, ivec2, ivec3, ivec4
■
A Float: float, vec2, vec3, vec4, mat2,
mat3, mat4, mat2x3, mat2x4, mat3x2,
mat3x4, mat4x2, mat4x3
■
Values allowed based on type of the uniform:
■
An Integer: int, ivec2, ivec3, ivec4
■
A Float: float, vec2, vec3, vec4, mat2,
mat3, mat4, mat2x3, mat2x4, mat3x2,
mat3x4, mat4x2, mat4x3
■
None
■
Pick (Pick in the Viewport)
■
Axis (Axis icon in the Viewport)
■
Light (Light icon in the Viewport)
Inc
IconType
The stepping used when dragging in the
uniform.
vec2/vec3 only
Defines the type of icon used to control the
uniform in the Viewport.
NOTE Only "None" and "Pick" are available
in the Timeline Player. "Light" and "Axis" are
automatically replaced by Pick in this case.
28 | Chapter 6 About shader_builder XML
Attribute
Description
Allowed Values
IconDefaultState
bool Defines the default On/Off state for the
icon.
■
False (default)
■
True
Maximum allowed value for the uniform.
■
Values allowed based on type of the uniform:
■
An Integer: int, ivec2, ivec3, ivec4
■
A Float: float, vec2, vec3, vec4, mat2,
mat3, mat4, mat2x3, mat2x4, mat3x2,
mat3x4, mat4x2, mat4x3
■
Values allowed based on type of the uniform:
■
An Integer: int, ivec2, ivec3, ivec4
■
A Float: float, vec2, vec3, vec4, mat2,
mat3, mat4, mat2x3, mat2x4, mat3x2,
mat3x4, mat4x2, mat4x3
■
None
■
Width (values are scaled based on width)
■
Height (values are scaled based on height)
vec2/vec3/vec4 only
Specifies that the widget is measured in Action
space ( Origin is center of the image and Top
Right is ( W/2, H/2) )
■
False (default)
■
True
vec3, ivec2, ivec3, ivec4 and int only
XYZ/RGB/Popup modes.
■
Position: Values are presented as numerics.
■
Colour: Values are presented as a colour,
with a colour pot.
■
ColourWheel: Values are presented as a
HGS colour wheel. You can also name the
channels with the tokens: AngleName,
IntensityName1, IntensityName2. The
bool HueShift tag controlls if the outer
wheel rotates with the chosen Hue.
■
PopUp: Values are presented as a popup
menu. You must add a <PopupEntry>
element within this <Uniform> to specify
the names and their associated Int values.
■
Curve: Values are presented as curves. The
int (ivec2, ivec3 or ivec4) value is a handle
on 1 (2,3 or 4) curve(s). The curve(s) can
be evaluated using the function adskEval-
Max
Min
ResDependant
Action3DWidgets
ValueType
Minimum allowed value for the uniform.
float/vec2/vec3/vec4 only
Defines which resolution dependance this
uniform has, if any.
About shader_builder XML | 29
Attribute
Description
Allowed Values
DynCurves taking as arguments the
handle and a float (vec2, vec3 or vec4)
representing the point to evaluate and
returning a float (vec2, vec3 or vec4)
representing the output(s) of the curve(s)
Index
sampler2D only
The position of the sampler in the user interface.
Integer
GL_TEXTURE_MIN_FILTER, GL_TEXTURE_MAG_FILTER
sampler2D only
Interpolation modes.
■
GL_NEAREST
■
GL_LINEAR
■
GL_NEAREST_MIPMAP_NEAREST
■
GL_LINEAR_MIPMAP_NEAREST
■
GL_NEAREST_MIPMAP_LINEAR
■
GL_LINEAR_MIPMAP_LINEAR
■
GL_CLAMP
■
GL_CLAMP_TO_BORDER
■
GL_CLAMP_TO_EDGE
■
GL_REPEAT
■
GL_MIRRORED_REPEAT
■
Error (Generates an error)
■
Black (Replaces missing input with Black)
■
White (Replaces missing input with White)
■
True
■
False
■
Front (Red)
■
Back (Green)
■
Matte (Blue)
GL_TEXTURE_WRAP_T, GL_TEXTURE_WRAP_S
NoInput
Mipmaps
sampler2D only
Wrapping modes.
sampler2D only
Defines the behaviour of a missing input.
sampler2D only
Enable to use mipmaps on this sampler.
GL_TEXTURE_MIN_FILTER must be set to one
of the following: GL_NEAREST_MIPMAP_NEAREST, GL_LINEAR_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_LINEAR, GL_LINEAR_MIPMAP_LINEAR.
GL_TEXTURE_BORDER_COLOR
(Optional) Allows you to specifiy GL_TEXTURE_BORDER_COLOR values in the "r,g,b"
format.
InputType
(Optional) Specifies the colour of an Input
socket on the Matchbox node.
30 | Chapter 6 About shader_builder XML
Attribute
Description
Allowed Values
InputColor
(Optional) Allows you to specify a custom RGB
colour. If InputType is also specified, InputType takes precedence over InputColor.
Refer to /usr/discreet/presets/<application_version>/matchbox/shaders/EXAMPLES/InputSockets.xml for an example.
r,g,b format, where each component is 0-255.
UIConditionSource
(Optional) The name of the uniform used to
conditionally disable or hide the current uniform in the user interface.
Name of a uniform
UIConditionValue
(Optional) The value of the UIConditionSource required for the uniform to be active.
Character data
UIConditionInvert
(Optional) Allows you to invert the logic of
UIConditionValue.
■
True
■
False
(Optional) Allows you to choose between
disabling or hiding the current uniform, based
on the UIConditionSource status.
Refer to /usr/discreet/presets/<application_version>/matchbox/shaders/EXAMPLES/ConditionalUI.xml for an example.
■
Disable
■
Hide
UIConditionType
The following attributes are only used to define a curve-based UI, when <Uniform ValueType = Curve>. For an example
in context, see /usr/discreet/presets/<application_version>/matchbox/shaders/EXAMPLES/Curves.glsl.
Attribute
Description
Allowed Values
Default
CurveMinX, CurveMaxX,
CurveMinY, CurveMaxY
Define the x/y range of the
curves.
Float.
■
CurveMinX and CurveMinY:
0.0
■
CurveMaxX and CurveMaxY:
1.0
CurveBackground
CurveWrapArround
Defines the type of background
for the curve editor.
Defines the behaviour of the
curve(s) at the border.
0
■
0 : empty background
■
1 : hue gradient background
■
2 : intensity gradient background
■
0 : no wraparound
■
1 : wraparound
0
About shader_builder XML | 31
Attribute
Description
Allowed Values
Default
CurveShape
Defines the default shape of the
curves.
■
0 : linear shape from
(CurveMinX,CurveMinY) to
(CurveMaxX,CurveMaxY).
0
■
1 : linear shape from
(CurveMinX,CurveMaxY) to
(CurveMaxX,CurveMinY).
■
2 : S shape. 3 : inverse S
shape.
■
4 : constant with MaxY value.
■
5 : constant with MinY value.
■
6 : constant with MinY +
0.5*(MaxY-MinY) value.
CurveR
Defines the R colour of all the
curves attached to this uniform.
Integer
0
CurveG
Defines the G colour of all the
curves attached to this uniform.
Integer
0
CurveB
Defines the B colour of all the
curves attached to this uniform.
Integer
0
<SubUniform>
Parent
■
<Uniform>
Child
■
EMPTY
Usage
■
There is one <SubUniform> element for each value required by the <Uniform> parent, based on the Value attribute:
vec3 requires 3 <SubUniform>, float requires none. How this gets translated in the UI depends on the ValueType
defined: Colour displays a colour pot, which means that the SubUniform defines the starting RGB values for that
uniform, whereas Position with a vec3 displays three numeric fields defined by the attributes of 3 <SubUniform>.
Attribute
Description
Allowed Values
Default
The default value of the parent uniform.
■
Values allowed based on type of the uniform:
■
True or False: bool, bvec2, bvec3, bvec4
■
An Integer: int, ivec2, ivec3, ivec4
■
A Float: float, vec2, vec3, vec4, mat2,
mat3, mat4, mat2x3, mat2x4, mat3x2,
mat3x4, mat4x2, mat4x3
32 | Chapter 6 About shader_builder XML
Attribute
Description
Allowed Values
Inc
The stepping used when dragging in the
SubUniform. Overrides the <Inc> defined in
the parent <Uniform>.
■
Values allowed based on type of the uniform:
■
An Integer: int, ivec2, ivec3, ivec4
■
A Float: float, vec2, vec3, vec4, mat2,
mat3, mat4, mat2x3, mat2x4, mat3x2,
mat3x4, mat4x2, mat4x3
■
Values allowed based on type of the uniform:
■
An Integer: int, ivec2, ivec3, ivec4
■
A Float: float, vec2, vec3, vec4, mat2,
mat3, mat4, mat2x3, mat2x4, mat3x2,
mat3x4, mat4x2, mat4x3
■
Values allowed based on type of the uniform:
■
An Integer: int, ivec2, ivec3, ivec4
■
A Float: float, vec2, vec3, vec4, mat2,
mat3, mat4, mat2x3, mat2x4, mat3x2,
mat3x4, mat4x2, mat4x3
■
None
Max
Min
ResDependant
Maximum allowed value for the SubUniform.
Minimum allowed value for the SubUniform.
float/vec2/vec3/vec4 only
Defines which resolution dependance this
uniform has, if any.
Width (values are scaled based on
width)
Height (values are scaled based on
height)
The following attributes are only used to define a curve-based UI, when <Uniform ValueType = Curve>. These values
override the more general values from the parent <Uniform>.
Attribute
Description
Allowed Values
Default
CurveMinX, CurveMaxX,
CurveMinY, CurveMaxY
Define the x/y range of the
curves.
Float.
■
CurveMinX and CurveMinY:
0.0
■
CurveMaxX and CurveMaxY:
1.0
CurveBackground
Defines the type of background
for the curve editor.
0
■
0 : empty background
■
1 : hue gradient background
■
2 : intensity gradient background
About shader_builder XML | 33
Attribute
Description
Allowed Values
Default
CurveWrapArround
Defines the behaviour of the
curve(s) at the border.
■
0 : no wraparound
0
■
1 : wraparound
Defines the default shape of the
curves.
■
0 : linear shape from
(CurveMinX,CurveMinY) to
(CurveMaxX,CurveMaxY).
■
1 : linear shape from
(CurveMinX,CurveMaxY) to
(CurveMaxX,CurveMinY).
■
2 : S shape. 3 : inverse S
shape.
■
4 : constant with MaxY value.
■
5 : constant with MinY value.
■
6 : constant with MinY +
0.5*(MaxY-MinY) value.
CurveShape
0
CurveName
The name of the curve represented by this SubUniform.
Character data
CurveR
Defines the R colour of this SubUniform's curve.
Integer
0
CurveG
Defines the G colour of this SubUniform's curve.
Integer
0
CurveB
Defines the B colour of this SubUniform's curve.
Integer
0
<Duplicate>
Parent
■
<Uniform>
Children
■
EMPTY
Usage
■
When a uniform is present in more than one shader pass, it is only shown once in the user interface. This is indicated
by the <Duplicate> element.
For example, if a two-pass preset uses a bool uniform named filtering, the XML file defines it in the first <Shader>
element:
<Uniform Row="0" Col="0" Page="0" Default="True" Tooltip="" DisplayName="Filtering"
Type="bool" Name="filtering">
</Uniform>
34 | Chapter 6 About shader_builder XML
In the second <Shader> element, it is defined as a duplicate.
<Uniform Type="bool" Name="filtering">
<Duplicate>
</Duplicate>
</Uniform>
If the second uniform isn't defined as a duplicate, it appears twice in the node UI.
Attributes
■
NONE
<PopupEntry>
Parent
■
<Uniform>
Children
■
EMPTY
Usage
■
Only used if <Uniform ValueType = Popup>. Each <PopupEntry> is an element of the drop-down list.
<PopupEntry Title="ReplaceMe" Value="0">
</PopupEntry>
Refer to /usr/discreet/presets/<application_version>/matchbox/shaders/EXAMPLES/BuildList.xml for an example.
Attribute
Description
Allowed Values
Title
The entry displayed in the drop-down list.
Character data
Value
The actual value passed to the uniform.
Character data
<Page>
Parent
■
<ShaderNodePreset>
Children
■
<Col> : Up to 4 children.
Usage
■
Defines the name of a page.
Attribute
Description
Allowed Values
Default
Name
Name of the page to be displayed
in the UI.
Character data
Page 1
About shader_builder XML | 35
Attribute
Description
Allowed Values
Default
Page
Index of the page.
Indexed from 0, max value of 6.
0
<Col>
Parent
■
<Page>
Children
■
EMPTY
Usage
■
Defines the name of a column within a page.
Attribute
Description
Allowed Values
Default
Name
Name of the column to be displayed in the UI.
Character data
Column 1
Col
Index of the column.
Indexed from 0, max value of 3.
0
Page
Index of the <Page> where the
column appears.
Indexed from 0, max value of 6.
0
36 | Chapter 6 About shader_builder XML
Shader API Documentation
7
In the following API, all positions and directions are in camera space: their local positions are multiplied by the modelView
matrix. Apart from that, most of the calls are self- explanatory or are mapped directly to the UI.
NOTE Any uniform with a name that starts with adsk_ is not shown in the user interface.
Lighting and Shading (Lightbox only)
vec3 adsk_getNormal(); Returns unaltered interpolated normal, before any maps are applied. Use adsk_getComputedNormal
to get the value computed after the maps. The normal, binormal and tangent form an orthonormal basis where the origin
is at the vertex position.
vec3 adsk_getComputedNormal(); Returns the computed normal once the maps are applied. Use adsk_getNormal to get
the value before the maps.
vec3 adsk_getBinormal(); Returns the interpolated binormal.
vec3 adsk_getTangent(); Returns the interpolated tangent.
vec3 adsk_getVertexPosition(); Returns the interpolated vertex position for the current fragment after all maps have
been processed.
vec3 adsk_getCameraPosition(); Returns the camera position.
bool adsk_isLightActive(); Returns the activity status of the parent light.
bool adsk_isLightAdditive(); Returns TRUE if the light attached to the Lightbox is set as additive, or FALSE if the light
is set to solo.
vec3 adsk_getLightPosition(); Returns the position of the light attached to the Lightbox.
vec3 adsk_getLightColour(); Returns the colour of the light parented to the Lightbox, but modulated by the intensity
(lightColour * intensity).
vec3 adsk_getLightDirection(); Returns the direction of the light attached to the Lightbox, if that light is directional.
The direction is computed whether the light is in target or free mode.
vec3 adsk_getLightTangent(); Given the light direction, the light tangent vector is an orthogonal vector where the origin
is at the light position. For example, given the light direction looking down negative z-axis. The light tangent would be
the x-axis.
void adsk_getLightShadowDecayType( out int lightDecayType, out int shadowDecayType ); Returns the type of decay
selected by the user for the light parented to the Lighbox, using Profile > Decay Type box.
■ const int NO_DECAY = 0;
■
const int LINEAR_DECAY = 1;
37
■
const int QUADRATIC_DECAY = 2;
■
const int CUBIC_DECAY = 3;
■
const int EXP_DECAY = 4;
■
const int EXP2_DECAY = 5;
float adsk_getLightDecayRate(); Returns the decay rate selected by the user for the light parented to the Lighbox, using
Profile > Decay field.
bool adsk_isSpotlightFalloffParametric(); Returns TRUE if the user set Profile > Falloff Model box to Parametric for the
light parented to the Lightbox. Returns FALSE if the user set the Falloff Model box to Custom.
float adsk_getSpotlightParametricFalloffIn(); Returns the value selected by the user for Profile > Falloff In field. Only
enabled if adsk_isSpotlightFalloffParametric returns TRUE.
float adsk_getSpotlightParametricFalloffOut(); Returns the value selected by the user for Profile > Falloff Out field. Only
enabled if adsk_isSpotlightFalloffParametric returns TRUE.
float adsk_getSpotlightSpread(); Returns the spread angle selected by the user for Basics > Spread field.
float adsk_getLightAlpha(); Returns the precomputed alpha of the light attached to the Lightbox, calculated from its
cutoff, decay, and GMask.
bool adsk_isPointSpotLight(); Returns TRUE if the user sets Basics > Light Type box to Point/Spot for the light parented
to the Lightbox.
bool adsk_isDirectionalLight(); Returns TRUE if the user sets Basics > Light Type box to Directional for the light parented
to the Lightbox .
bool adsk_isAmbientLight(); Returns TRUE if the user sets Basics > Light Type box to Ambient for the light parented to
the Lightbox .
bool adsk_isAreaRectangleLight(); Returns TRUE if the user sets Basics > Light Type box to Rectangle Area for the light
parented to the Lightbox .
bool adsk_isAreaEllipseLight(); Returns TRUE if the user sets Basics > Light Type box to Ellipse Area for the light parented
to the Lightbox.
float adsk_getAreaLightWidth(); Returns the width of the light attached to the Lightbox. Only applicable if
adsk_isAreaRectangleLight or adsk_isAreaEllipseLight is TRUE.
float adsk_getAreaLightHeight(); Returns the height of the light attached to the Lightbox. Only applicable if
adsk_isAreaRectangleLight or adsk_isAreaEllipseLight is TRUE.
bool adsk_isLightboxRenderedFromDiffuse(); Returns FALSE if the Lightbox is rendered from the currently lit fragment.
Returns TRUE if Lightbox is being applied on the unlit raw diffuse value.
bool adsk_isLightboxRenderedBeforeLight(); Returns FALSE if the Lightbox is rendered after the attached light.
vec3 adsk_getComputedDiffuse(); Returns the computed diffuse value for the current fragment, before shading but after
all the maps have been processed.
float adsk_getShininess(); Returns the shininess material property.
vec3 adsk_getComputedSpecular(); Returns the computed specular value for the current fragment, before shading but
after all the maps have been processed.
Map Access (Lightbox only)
The getMapValue functions give raw access to the texture maps. The getMapCoord functions return the interpolated
coordinates used to fetch in those texture maps. The coordinates need to be safe divided (to avoid divisions by 0) by the
returned z value to get a UV texture coordinate.
38 | Chapter 7 Shader API Documentation
vec4 adsk_getComputedDiffuseMapValue (in vec3 vertexPos); Returns the computed diffuse map value once all maps
have been processed.
The following return the raw map values. Use the getMapCoord functions below to compute the texture map coordinates
(texCoord) required for the current fragment.
vec4
vec4
vec4
vec4
vec4
vec4
vec4
adsk_getDiffuseMapValue (in vec2 texCoord);
adsk_getEmissiveMapValue (in vec2 texCoord);
adsk_getSpecularMapValue (in vec2 texCoord);
adsk_getNormalMapValue (in vec2 texCoord);
adsk_getReflectionMapValue (in vec2 texCoord);
adsk_getUVMapValue (in vec2 texCoord);
adsk_getParallaxMapValue (in vec2 texCoord);
The following return the interpolated coordinates that will need to be safe divided by z to fetch the corresponding map
value for the current fragment.
vec3
vec3
vec3
vec3
vec3
adsk_getDiffuseMapCoord();
adsk_getEmissiveMapCoord();
adsk_getSpecularMapCoord();
adsk_getNormalMapCoord();
adsk_getParallaxMapCoord();
vec2 adsk_getReflectionMapCoord( in vec3 vrtPos, in vec3 normal );
Transforms (Lightbox only)
mat4 adsk_getModelViewMatrix(); Converts local coordinates to camera space.
mat4 adsk_getModelViewInverseMatrix(); Converts camera space to local coordinates.
Image Based Lighting (Lightbox only)
NOTE There is significant performance degradation with shaders that use an IBL-based API call if that shader is used in combination
with Hardware Anti-Aliasing and high resolution maps. To mitigate this, disable HWAA, or use lower-resolution maps.
int adsk_getNumberIBLs(); Returns the supported the number of IBL maps.
bool adsk_isCubeMapIBL( in int idx ); Returns TRUE of the IBL map with the idx index is Cubic. FALSE if the map is
Angular or Cylindrical. If both adsk_isAngularMapIBL and adsk_isCubeMapIBL are FALSE, the map is Cylindrical.
bool adsk_isAngularMapIBL( in int idx ); Returns TRUE of the IBL map with the idx index is Angular. FALSE if the map
is Cubic or Cylindrical. If both adsk_isAngularMapIBL and adsk_isCubeMapIBL are FALSE, the map is Cylindrical.
vec3 adsk_getCubeMapIBL( in int idx, in vec3 coords, float lod ); Where lod is the Level of Detail of the IBL with the
idx index.
vec3 adsk_getAngularMapIBL( in int idx, in vec2 coords, float lod ); Where lod is the Level of Detail of the IBL with
the idx index.
bool adsk_isAmbientIBL( in int idx ); Returns TRUE if the IBL mapping option is set to Ambient, FALSE if it is set to
Reflection.
float adsk_getIBLDiffuseOffset( in int idx ); The Diffuse Offset defined in the UI for the IBL with the idx index.
mat4 adsk_getIBLRotationMatrix( in int idx ); The rotation matrix defined in the UI for the IBL with the idx index.
Shader API Documentation | 39
Material Information (Lightbox only)
vec4 adsk_getMaterialDiffuse(); Material node's Diffuse property.
vec4 adsk_getMaterialSpecular(); Material node's Specular property.
vec4 adsk_getMaterialAmbient(); Material node's Ambient property.
float adsk_getMaterialRoughness(); Material node's Roughness property.
float adsk_getMaterialSpecularity(); Material node's Specularity property.
float adsk_getMaterialMetalness(); Material node's Metalness property.
float adsk_getMaterialAnisotropy(); Material node's Anisotropy property.
float adsk_getMaterialSubSurfaceScattering(); Material node's Sub-Surface Scattering property.
Colour Management and Colour Space Conversion (Lightbox and Matchbox)
The following return the value of a curve uniform in the UI (dynCurveId) read at x.
float adskEvalDynCurves(in int dynCurveId, in float x);
vec2 adskEvalDynCurves(in ivec2 dynCurveId, in vec2 x);
vec3 adskEvalDynCurves(in ivec3 dynCurveId, in vec3 x);
vec4 adskEvalDynCurves(in ivec4 dynCurveId, in vec4 x);
vec3 adsk_scene2log( in vec3 src ); Converts src from scene linear colour space to Cineon log colour space. Inverse
operation of adsk_log2scene.
vec3 adsk_log2scene( in vec3 src ); Converts src from Cineon log colour space to scene linear colour space. Inverse
operation of adsk_scene2log.
vec3 adsk_rgb2hsv( in vec3 src ); Converts src from RGB colour space to HSV colour space. Inverse operation of
adsk_hsv2rgb.
vec3 adsk_hsv2rgb( in vec3 src ); Converts src from HSV colour space to RGB colour space. Inverse operation of
adsk_rgb2hsv.
vec3 adsk_rgb2yuv( in vec3 src ); Converts src from RGB colour space to YUV colour space. Inverse operation of
adsk_yuv2rgb.
vec3 adsk_yuv2rgb( in vec3 src ); Converts src from YUV colour space to RGB colour space. Inverse operation of
adsk_rgb2yuv.
vec3 adsk_getLuminanceWeights(); Returns the weights used to compute the Luminance value.
float adsk_getLuminance( in vec3 color ); Returns the luminance value.
float adsk_highlights( in float pixel, in float halfPoint ); Parametric blending curves suitable for blending effects for
Shadows, Midtones, Highlights. The parameters are:
■ pixel: the colour of the pixel.
■
halfpoint: the X-axis location where the curve is 50% .
To get the midtone weight, you compute for the same pixel colour: 1 - adsk_shadows - adsk_highlights
float adsk_shadows( in float pixel, in float halfPoint ); Parametric blending curves suitable for blending effects for
Shadows (of the Shadows-Midtones-Highlights triumvirate). The parameters are:
■ pixel: the colour of the pixel.
■
halfpoint: the X-axis location where the curve is 50%.
40 | Chapter 7 Shader API Documentation
To get the midtone weight, you compute for the same pixel colour: 1 - adsk_shadows - adsk_highlights
Shadows (Lightbox only)
vec3 adsk_getComputedShadowCoefficient(); Returns a coefficient which is computed from all the shadow parameters.
The coefficient needs to be multiplied against the light colour. The parent light must be a shadow caster. See the example
/action/lightbox/EXAMPLES/SimpleLight.glsl.
Blending (Lightbox and Matchbox)
vec4 adsk_getBlendedValue( int blendType, vec4 srcColor, vec4 dstColor ); Blends srcColor and dstColor using the
blendType.
■ Add = 0
■
Sub = 1
■
Multiply = 2
■
LinearBurn = 10
■
Spotlight = 11
■
Flame_SoftLight = 13
■
HardLight = 14
■
PinLight = 15
■
Screen = 17
■
Overlay = 18
■
Diff = 19
■
Exclusion = 20
■
Flame_Max = 29
■
Flame_Min = 30
■
LinearLight = 32
■
LighterColor = 33
General Purpose (Lightbox only)
bool adsk_isSceneLinear(); Return TRUE if the Action scene is in linear colour space, or FALSE if Log.
General Purpose (Lightbox and Matchbox)
float adsk_getTime(); Returns the current time as a frame number. 1-based float.
General Purpose (Matchbox only)
The following float uniforms are unconditionally sent to each pass. You can use them in the shader you are creating, if
needed. Unless indicated otherwise, the following uniforms are only available to Matchbox shaders.
The following can be used to set the result resolution.
adsk_result_w
adsk_result_h
adsk_result_frameratio
adsk_result_pixelratio
Shader API Documentation | 41
adsk_results_pass{pass_index}(); Can be used to refer to a previous pass result texture. For example, adsk_results_pass1
refers to the first pass result and can be used in any subsequent pass. The sampler must be declared and used normally.
adsk_results_pass{pass_index}_w adsk_results_pass{pass_index}_h Can be used to refer to a previous pass result texture
size.
adsk_previous_frame_{sampler_name}(); adsk_next_frame_{sampler_name}(); Not available if the Matchbox is loaded
in Action.
Can be used to fetch the texture of the previous or next {sampler_name} frame. All uniform sampler parameters for previous
and next will come from the {sampler_name} uniform xml entry. For example, to use both current and previous frames
given a sampler input1 the XML entries would look like this.
<Uniform Type="sampler2D" Name="adsk_previous_frame_input1"> xml entry.
<Uniform Index="0" NoInput="Error" Tooltip="" DisplayName="input1" Mipmaps="False"
GL_TEXTURE_WRAP_T="GL_REPEAT" ....>
NOTE Requires that the sampler "sampler_name" for the current frame be declared and used in the fragment shader. Refer to
/usr/discreet/presets/<application_version>/matchbox/shaders/EXAMPLES/TemporalSampling.xml for an example.
adsk_time This 1-based float uniform can be used to obtain the current time in the timebar.
bool adsk_degrade(); This boolean uniform can be used to obtain the process degradation setting. When True, a degraded
frame was requested. When False, a full rendered frame or a preview frame was requested.
float adsk_{sampler_name}_w (); float adsk_{sampler_name}_h (); This uniform gives access to each texture's resolution.
For example, adsk_frontTex_w & adsk_frontTex_h refer to the resolution of the sampler2D named frontTex.
float adsk_{sampler_name}_frameratio This gives access to texture frame ratio. For instance, adsk_frontTex_frameratio
refers to the frame ratio of the sampler2D named frontTex.
float adsk_{sampler_name}_pixelratio This gives access to texture pixel ratio. For instance, adsk_frontTex_pixelratio
refers to the pixel ratio of the sampler2D named frontTex.
adsk_accum_texture sampler2D that contains the previous output of the matchbox. Useful when creating temporal
effects. Turns on the support for adaptive degradation.
adsk_accum_no_prev_frame Boolean uniform. True if there is no history available. Uniform is useful together with
adsk_accum_texture.
42 | Chapter 7 Shader API Documentation