Toolbag 3 Guide: Writing Custom Shaders
Events
Subscribe:  iCal  |  Google Calendar
7, Mar — 12, Jun
London GB   29, May — 1, Jun
Birmingham GB   1, Jun — 4, Jun
Taipei TW   5, Jun — 10, Jun
Los Angeles US   12, Jun — 15, Jun
Latest comments

We should talk more about this, all of us... I work multiple jobs in gaming and entertainment in general so I burn out once or twice a year and I need months to recover. Screw that.

by Pawel Stolecki
6 hours ago

That's really neat tool to have,leads me to dig dipper into pixel proccesor. Great job

by testure
12 hours ago

@alex if i had to guess, they just finished two back-to-back AAA games in the same franchise and some people are seeing it as a good time to transition without burning bridges? aka business as usual?

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