About Me

Hi. I'm Josh Ols. Lead Graphics Developer for RUST LTD.


View Joshua Ols's profile on LinkedIn


Entries in Unity3D (29)


Unity Shader Gotcha #9 - Reserved Samplers


Okay, so samplers don't count unless the compiled code actually uses them. Having said that, Unity 5 can potentially use as many as 7 samplers if the project happens to be using specular directional static & dynamic lightmaps while blending between two reflection probes. Though this is a pretty unlikely scenario, as most people will pick either static or dynamic lightmaps. 



So the culprit is in the auto-generated "PrePassFinal" pass for all surface shaders. Here we have a Light Accumulation Buffer plus two lightmaps (either Dual or Directional). Apparently it can go as high as four textures on the Xbox 360 in HDR mode. :(




Unity reserves 3 samplers for its own use in its surface shaders system. These transparently allow all surface shaders to support things like lightmaps, light cookies, shadowmaps, etc. This leaves exactly 13 samplers for the shader author to use for whatever they want in their custom surface shaders.



 For the vast majority of people, this is a non-issue. After all, when would a shader ever need 13 samplers? You'd have to be doing some really complex effects-heavy shaders with custom IBL...like the ones we are including in Alloy.

Once you have something like "Illumin/Detail Bumped MaskedIncan Rim Dissolve", you hit that limit pretty quickly.  Then you end up in the situation I'm in where you have to decide where you can squeeze out or just plain drop a texture in order to free that sampler up for use elsewhere. So it's better not to waste samplers by planning out EXACTLY how many you will need beforehand.


Update 05-31-2014

Just a quick little update to say what is going on with RUST and Alloy:

  1. Unity 4.5 is amazing, and you should start using it ASAP. The faster shader compilation is insane, and has saved a ridiculous amount of development time already.
  2. Our team finally got a code management server, so that will speed up development since we can more easily coordinate our efforts.
  3. Working on a new ubershader approach for Alloy that reduces the amount of shader switching, and enables cool new shader combinations. 
  4. We're working on integrating Alloy with Skyshop's new Sky tweening system. Both fortunately and unfortunately this requires changing the way we enable Box Projection mode since Marmoset wants us to use their new UI. 


Other than that, some worthwhile causes to look into:

  • https://www.kickstarter.com/projects/readingrainbow/bring-reading-rainbow-back-for-every-child-everywh
  • http://www.gofundme.com/8fbxk8

Alloy Skin Shader Prototype

Since I haven't posted much in a while, here is something cool I have been working on for Alloy. This is a prototype skin shader that employs all of the following:

  • Pre-Integrated SSS
  • Saturated AO
  • Two lobe specular
  • Alloy's standard BRDF + IBL


Check it out!

SSS Head test

Head Scan from Lee Perry-Smith and Infinite Realities


Alloy 2.0 Released!

After a brutal 3 month long rewrite of the framework and a slew of new features, Alloy 2.0 is now available. Among the many improvements is the addition of the following features:

  • Enhanced BRDF with an increased max specular power and improved visibility function
  • View-dependent specular occlusion
  • Packed material maps
  • Specular AA via precomputed Toksvig factor
  • Skyshop integration
  • Substance Designer 4 preview shader
  • A whole bunch more...



Alloy Physical Shader Framework by RUST LTD. forum thread

Alloy Asset Store page


Alloy Released!

At long last, our new physically-based shader framework has been released to the general public. Please feel free to check out the details in our anouncement thread: