Archive for the ‘General’ Category

Particle Editor

Posted: August 29, 2011 in General, Real-Time Rendering

This is my Particle Editor, which was inspired by Unreals Cascade, I call it ‘AssCade’. Its got a lot of the same functionality, including being able to graph all sorts of effects. As you can see from the images, each particle system is made from a series of emitters, which are in turn affected by modifiers. All the computation is done on the CPU as it made it easier to do effects on sibling emitters. Once all the emitters have been processed, they are then sent to the GPU to render. Where each particle consists of a single vertex, and is then expanded into a quad in the Geometry shader. Rather than have each emitter manage a vertex buffer, I instead chose to use the more optimized route of having each particle system manage the vertex buffer, that is used by its child emitters, requiring only a single lock per Particle system, as opposed one for each emitter, which can really add up with effects usually having at least 3-4 emitters.

I am toying around with the idea of having all the computation performed on the GPU to increase performance, by compiling\creating a HLSL effect file from the particle system nodes, similar to what Epic does with their material editor, but I havent got around to that yet.

http://www.youtube.com/watch_popup?v=OT76CpuqoT0&vq=hd1080

Shader Editor

Posted: July 29, 2011 in General, Real-Time Rendering

This is a shader editor application I wrote that allows you to write and then test your shaders in the same editor. You write the shader in HLSL on the right and then see it rendered to a mesh on the left. The editor has a bunch of default meshs such as cubes, spheres and planes etc, but also allows you to import your own using my 3dsmax exporter. Ive written my Effect library to compile shaders for multiple vertex formats, so that if you have a shader you want to be used on different formats, you can use preprocess compilation techniques to break the HLSL code into a series of #if #else defines for each format your shader supports. The shader is then compiled for each format. When a mesh is then loaded in and an Effect is to be applied, its vertex format is compared against the compiled versions of the effect, and if a match is found( ie, if that shader was compiled for that particular vertex format), then that specialised shader is applied. The editor is pretty handy as it also reports back any compilation errors from fxc.exe in text window at the bottom of the editor, and also includes an assembler view, which allows you to see the code in assembly. Textures are supported by simply specifiying the location of the file within the Texture definition using Annotations, this is also made easier by using the snippet tool for common code. Once the effect is compiled and produces the correct results, the editor allows you to then make a material from that effect. A material within my engine defines an effect to be applied and the effect parameters(such as textures, samplers and material values), which are either created in code, or loaded\saved as an xml file. The editor creates a material file by parsing the effect file for values that the user can set, this being textures\samplers and any data within “cbMaterial”, which is the material constant buffer. Again, using annotations within the shader, the author can specify how the user sees this data within the editor. So a “float4 DiffuseColour” can be given the annotation “GUI_COLOUR”, which will present the user with a colour selection tool, or a “float SpecularPower” can be given the annotation “GUI_SLIDER MIN[0] MAX[100]”, which will present the user with a slider tool to set floating point values. This list of values are then presented to the user using GUI widgets, which they can use to set the values in a convenient way. As settings are changed, the results are again seen in the view window. Once the user is happy, they can then export to material to an XML file. The Effect is exported separately, and is only referenced by the material.

Swizzling

Posted: October 29, 2010 in General

Since using high level shader languages like DirectX HLSL, I’ve become quite the fan of vector swizzling, and wanted to use it with my maths libray. My solution was to write a quick console app to write the code for me, and then just include those files in my vector classes. Probably not the most ingenious solution there is, but it worked well for me. Using this technique does produce a fair number of new member functions though :

Vec2 = 2^2 + 2^3 + 2^4 = 28
Vec3 = 3^2 + 3^3 + 3^4 = 117
Vec4 = 4^2 + 4^3 + 4^4 = 336

But now I can write code like :

fsVec2 a = fsVec2( 1.0f, 2.0f );
fsVec4 b = a.xxxx();
fsVec3 c = b.xyz() + a.xyx() + b.www();

I chose not to add MACROS to enable the “.xxxx” syntax, as opposed to the “.xxxx()” as I don’t think the fewer keystrokes justify polluting the global namepspace, specially as I like to use names like “xy” and “xx” for local variables.

Below is the source for doing this.

3ds Max Exporter

Posted: October 29, 2010 in General

So I finally got around to writing my 3ds Max Exporter. Currently it exports :

  • Static Meshes
  • Skinned Meshes
  • Animation Clips
  • Skeletons
  • Collision Meshes

Floating Point Format

Posted: October 29, 2010 in General

One of the chapters in my ASM book I found really interesting was the one on how floating point numbers are stored and how they’re processing in calculations. Here are some C# apps to create and decompose a 32-bit floating point number.

Model Viewer

Posted: October 29, 2010 in General, Real-Time Rendering

This is a model Viewer I made to visualize Meshes and their materials that are exported using my 3dsMax plugin.

Curves

Posted: October 29, 2009 in General

I use curves in a lot of my applications such as for animation curves and so wanted to create some functions for my Maths library so that they can be reused easily. So far I’ve implemented :

  • Quadratic and Cubic Bezier
  • Hermite
  • Cubic B-Spline
  • Cubic B-Spline with end points
  • Quadratic and Cubic Bezier patches