Shader Surprise!

Posted by Mike Dailly on 24 June 2013

In previous posts, I've continually gone on about how we're targeting a cross platform shader model, so that you only have to write shaders once and that we've opted for GLSL ES to be that model. (see the image below for the "old" shader editor)

Old Shader Editor

Well, I'm afraid this does have some drawbacks. As it's effectively the lowest common denominator, it  doesn’t allow everything on higher end systems - like windows or mac, and this means if your not writing for mobile - or the web, you're not getting the full power available to you.

Yes, I know - this sucks.

So, what I've done is basically allow you to write in the native language type of the machine -IF you want to. This means if you only ever intend one writing games for Windows, you can write in HLSL, or if MAC/Linux is your thing, you can target GLSL. This doesn't restrict you either, because if you only intend on using desktop systems, you can write 2 shaders, one in GLSL and one in HLSL, and then select the one you need depending on the platform your actually on.

So, take a look at the NEW shader editor.....

NEW shader editor

You'll notice at the top you can now select GLSL ES (auto), GLSL, HLSL9 and HLSL11. if you select GLSL, HLSL9 or HLSL11, then your shader will NOT be auto converted, and you'll have to do everything manually. This isn't a huge deal, but if that auto conversion really matters to you, then you can always still use the GLSL ES shader and it'll work just as we had envisaged it before. The new editor also still supports colour syntax highlighting and full intellisense for HLSL, making it once again, increadibly simple to use and write for.

On the (huge) plus side.... using seperate shaders will now give you access to such cool things as multiple render targets, which will in turn let you do things like depth shadows, outlines, depth of field or even deferred rendering. 

So there you go.... it's not something we planned on, but we really wanted developers to get access to multiple render targets, and as GLSL ES just doesn't support that, we had to come up with another way. However when you think about it, this actually gives developers some serious power if they want to take advantage of it, so works out better all round, sa you are now only limited by the power of the machine your writing for, and not the cross platform compatibility of Studio.