Mset Rendering April29 2014
Mset Rendering April29 2014
Toolbag
A Game Engine For Artists
Penn Engineering CIS 700
April 28, 2014
Marmoset
● Hi, I'm Jeff Russell (@j3ffdr)
● I work at Marmoset (www.marmoset.co)
○ Started early 2012
○ 3 partners + 1-3 contractors
○ All remote
○ The ‘t’ is not silent
○ We do graphics stuff!
Marmoset Toolbag
● Toolbag is a standalone real-time renderer for artist use
● “Game Engine for Artists”
● WYSIWYG final renders
● Basic scene, lighting, material editing
● Used for sharing, preview, presentation, material setup
● Output options for high quality screenshots, turntables
○ More to come ;)
Marmoset Toolbag
● Grew from a simpler in-house game dev tool
○ “Darkest of Days” at 8monkey
● Joe Wilson: “You guys should sell this”
● Initially free, now $129 / seat
● We’ve grown mainly by word of mouth
○ www.polycount.com
Marmoset Toolbag
● Version 2 (December 2013) is a full rewrite
● Windows 7/8 and OS X 10.9
● 64-bit only, C++
● Rough size:
○ Toolbag: ~60k lines
○ libCPR: ~15k
○ Shaders: ~5k
○ Server: ~3k
Demo!
Art by Yosuke Ishikawa
Render Overview
● Toolbag 2 is a forward renderer (mostly), not deferred
● Need the flexibility of completely different shaders
○ skin, cloth, anisotropy, different spec models
● Dynamic light sources and shadow casting is "sort of
deferred"
Render Order
1. Depth/normal pass
2. Reflection ray casts
3. SSAO
4. Main IBL pass
5. Reflection ray gather & composite
6. Dynamic lights & shadows
7. Wireframes & misc.
8. Post effects, AA & present
Depending on settings, only 4 & 8 will always run
Material System
● Swappable subroutines for various shading inputs
● Subroutines mainly focus on varying workflows
○ e.g. spec mask vs. metalness vs. IOR
● UI maps to shader subroutines more or less directly
● NOT a full shader graph system
○ User-friendly and approachable is a primary design goal
● Several million shader permutations
○ Requires runtime compilation as user edits
○ HLSL builds really slowly, especially loops >:|
○ If I were Microsoft I would work on this, but hey
○ Hash & cache to disk for later reuse, so only first hit is slow
Material System
● Quick list of some current modules:
○ Subdivision: Flat, PN Triangles
○ Displacement: Height, Vector
○ Surface: Normal Map, Detail Normal Map, Traced Parallax
○ Microsurface: Gloss/Roughness
○ Albedo: Albedo Map, Vertex Color
○ Diffusion: Unlit, Lambertian, Microfiber, Skin
○ Reflectivity: Specular Map, Matlaness Map, IOR
○ Reflection: Mirror, Blinn-Phong, Anisotropic
○ Occlusion: Occlusion Map, Vertex AO
○ Emissive: Emissive Map, Heat
○ Transparency: Cutout, Dither, Blend
○ + some extras (e.g. Dota 2, Substance support)
CPR
● Toolbag uses Direct3D 11 (Win) & OpenGL 3/4 (Mac)
● Future APIs?
○ GLES, WebGL, Consoles? Direct3D 12? OpenGL 5??
● Need to avoid rewriting everything for each platform!
○ Including shaders!
● How can we do this?
CPR
● CPR (Cross-Platform Render)
● In-house graphics abstraction library
● Supports backends for:
○ Direct3D 11
○ OpenGL 3
○ OpenGL ES 2
○ No-Op
● Recently dropped (we consider these dead):
○ Direct3D 9 (win + xbox 360)
○ OpenGL 2
○ GCM (ps3)
CPR
● CPR is a full wrapper
● Graphics API fully hidden
○ not even #include
● Exposes similar primitives
○ Buffers, textures, render states,
shaders, draw commands
● Statically linked C++
● Basically a new API of its own
CPR
● Interface must match common subset of backends
● Fortunately this subset is large
○ Mostly what you’d be working with anyway for cross-platform dev
● Opportunity to design our own interface to gfx
● Potential for all kinds of debugging, verification, etc.
CPR
● Which shader language to use?
○ GLSL?
○ HLSL?
○ NVIDIA’s Cg is dead :-/
● Exact language conversion is nontrivial
○ Existing solutions often don’t expose newest features
● Any compiler must work on all platforms
○ Precompilation not possible for us
CPR
● GLSL and HLSL are similar & have good preprocessors
● Insert macros to give both sets of key words
○ e.g. both float4 and vec4, lerp and mix, etc.
● Insert more macros to unify divergent syntax
○ e.g. main entry point, interpolants, texture samples, etc.
● Shaders written with these changes compile in both!
● Can always #ifdef platform-specific code too
CPR
Simple shader code syntax examples:
(please excuse the vertex shader)
Image-Based Lighting