Posts Tagged ‘shaderfx’

XNA Planet Custom Shader

2010/12/18 2 comments

Well I’ve been working on making my planet shaders to be something a bit more colourful.

Day and Night

First of all I wanted to map two diffuse textures that are alpha blended depending on whether the planet’s side is in the Sun’s shadow or not.  When it is you’ll see the city lights twinkle on.


Next I wanted to do some sort of atmospheric effect.  This was tricky and I’m still not absolutely happy with it – I think I need to read more on subsurface scattering.  Geometry-wise, it’s just a slightly larger sphere.  To shade it the atmospheric shell only renders when the surface normal is nearly perpendicular to the eye – in other words it only shades around the edges of the planet.  The dot product is raised to the 4th power or so to be used during the calculation for the alpha value.  The atmosphere is also emissive so as to illuminate when in shadow.

2010-12-18 vanquish planet atmosphere 1

2010-12-18 vanquish planet atmosphere 2

2010-12-18 vanquish planet atmosphere 3

2010-12-18 15-35 vanquish planet atmosphere

Categories: SpaceSim Tags: , , ,

XNA Cruiser? One “Bump” or Two?

2010/11/28 Leave a comment

I just love pipelines and Lumonix Shader FX makes no exception.  Yesterday I started off with a rather humble shader but today let’s beef it up a bit with a bump map to give it more of a 3-D look.  Here is the shader as seen in 3DS Max and Shader FX:


…and here it is in my space simulator:


That’s looking a bit better, though I must admit it needs a bit of colour and perhaps some glass effects – something for a future project. We noobies have to start somewhere.

Categories: SpaceSim Tags: , , , ,

Be Gone Wireframe – Hello Space Cruiser!

2010/11/27 2 comments

Vanquish 2010-11-27 15-44-45-87Today I spent time on my scene mechanics and imported a new space ship model to replace the test ring place-holder that I was using for the autonomous steering behaviour programming.  It served it’s purpose by indicating the steering, velocity and normal vectors but I know those around me were wanting to see a spiffy model. Anyway I found a rather nice free 3DS model by Mace24de (thanks buddy) on TurboSquid. Loading this into Max it was just a case of giving it a good paint job via Lumonix Shader FX via an interactive pipeline building process. Gotta love Shader FX. 


As you recall in a previous post, Shader FX is a must have for the generation of HLSL GPU shaders in the form of .FX files for use in the likes of XNA.  I’ll just do something fairly simple for now though – a diffuse texture map with a touch of glossiness should be a good start.  Later I’ll plonk in a normal map to make it more interesting.  Here’s a shot of Shader FX in 3DS Max.


…now let’s apply that to our model via Tools/Apply to Selection in Shader FX:


That’s more like it. Now let’s export the shader for XNA. In Shader FX choose File/Export FX…


Select XNA from the appearing dialog.  Make sure you pick Y-Up too – that is a requirement for XNA.


Remember that the XNA shader must be a different filename to the one being used in 3DSMax.  I like to merely give the XNA files a “XNA” suffix.  A no brainer Winking smile


…export your model. Make sure just your model is selected, no lights/cameras/etc. please unless your pipeline can handle that. Choose File/Export/Export Selected in 3DSMax:


Export as a FBX using Autodesk’s FBX export tool (its a free download from their site). My settings is pretty much the defaults except I’ve deselected cameras, animations etc. for now as I can’t handle them anyway). We don’t want cameras or lights because we’ll be doing that in game.


Eventually this gets into my game using my custom content importer pipeline for FBX that reattaches textures, FX etc. to achieve the following result. I only have to include the .FBX file in my Visual Studio project – there is no need to directly specify the FX, textures or other files because my custom pipeline finds them by reading the info in the original FBX file.  This is handy because I can leave shared art on a different drive and use it in other projects.  Yippee!

Here we are just to the side:

Vanquish 2010-11-27 15-31-53-11


Coming in for the kill!

Vanquish 2010-11-27 15-44-45-87


From above:

Vanquish 2010-11-27 15-47-24-01

Categories: SpaceSim Tags: , , , ,

HLSL/XNA FX Shader Editing with Lumonix ShaderFX

2009/08/23 Leave a comment

NVIDIA’s FX Composer whilst useful in certain cases is perhaps a rather daunting tool to use, especially for 3D noobs such as myself.  Sometimes I just want to make a shader for the typical things like diffuse, normal and environmental maps, or even just basic phong style materials.  Say I just modelled a tank and I want to put a camouflage texture on it, maybe some specular reflections on the glass window, and perhaps some different effects on the gun and tracks. Then say when I get more experienced I want to do spiffy vertex shaders for things like water effects.  I’m sure I can do all this in FXC but I be damned if I know how.  Did I mention I wanted to use my shader in XNA?  Well there’s a problem straight away. Many of the effects I downloaded via FXC produce annoying compile effects in Visual Studio 2008.  What is a 3D apprentice to do?

Well some brilliant chaps at LumonixBen Cloward and Kees Rijnen (Ben is the author of some great tutorials on his own site which saved my sanity) have made a 3ds Max plug-in that allows you to produce shaders (including DirectX and XNA) visually without programming. The editor appears inside Max so no more dodgy external tools and mucking about exporting and importing.  In a matter of minutes you can knock up some top-notch shaders and view them directly in 3ds Max.  The best part is that you can then export them to your favourite shader format including XNA!  There’s also support for FX Composer, DXSAS, Cgxx and many more.  And don’t think this program is only for basic effects because it’s not, there are some amazing things you can do with this gem.  Check out their site.

ShaderFX UI (my humble first shader):



An advanced shader from the ShaderFX site:



Shader export:



ShaderFX is “Free for individuals and companies smaller then 2 employees”.  You can’t beat that!

Categories: Development Tags: , ,