Toolbag 3 Guide: Writing Custom Shaders
Events
Subscribe:  iCal  |  Google Calendar
Cologne DE   19, Aug — 21, Aug
Cologne DE   22, Aug — 26, Aug
Seattle US   28, Aug — 30, Aug
Atlanta US   30, Aug — 4, Sep
SEATTLE US   31, Aug — 4, Sep
Latest comments
by nayade.g.marin@gmail.com
1 hours ago

I'd love to have him as my teacher.

by Jeanette T. Clegg
15 hours ago

Your place is valueble for me. Thanks!… https://hotmail0909.weebly.com/blog

by mafhfuz@7cgi
18 hours ago

You have done an outstanding job. Greetings to Toivo Glumov and Natalie Kayurova.

Toolbag 3 Guide: Writing Custom Shaders
23 August, 2017
News

Marmoset has shared a new tutorial for users of Toolbag 3.03 that focuses on the custom shader system which is currently in beta. Toolbag provides a framework for users to customize the material shader system. This can be a powerful tool for users to extend Toolbag’s rendering capabilities, and for these improvements to be shared with others. The guide provides an introduction to shader development and languages to be used.

First of all, check out a video guide by Chris Perrella:

And here is a small teaser of the written tutorial: 

Language

Marmoset Toolbag uses a somewhat customized shader language, which is a kind of union of HLSL and GLSL syntax conventions. In many cases, both sets of keywords work (e.g. both vec3 and float3 are valid), and in other cases custom macros are required. This syntax allows Toolbag shaders to compile and run in Direct3D, OpenGL, and more recently Apple’s Metal. If you follow these conventions, your shader should work correctly on a wide variety of operating systems and hardware.

One common example of this unique syntax, which may seem unusual to those of you used to HLSL, relates to textures. Textures are declared with the USE_TEXTURE2D macro, and are accessed with GLSL-like commands. Here is a simple example of texture usage in a Toolbag shader:

USE_TEXTURE2D(myTexture);

void myFunc( inout FragmentState s )
{
   vec4 val = texture2D( myTexture, s.vertexTexCoord );
}

A full description of the shading language is beyond the scope of this article. Reading through other files for examples is likely to be the most productive route to learning the ins and outs. Some basic reference for GLSL may also be helpful as Toolbag’s shading language most closely resembles this.

Subroutines


Marmoset material shaders are organized as a collection of subroutines for various predefined ‘slots’, all of which are called from the main shader file, mat.frag. Custom shaders may extend or replace any of these subroutines, and by doing so significantly alter the rendering behavior of the material. For example, a custom shader my supply a new “Surface” subroutine to alter the standard normal mapping functions. The following shader extends the Surface subroutine to adjust the normal to point in a different direction. 

Marmoset 

You can find the full guide here

Source: Marmoset

Leave a Reply

Be the First to Comment!

avatar
wpDiscuz