Regex Based Parser and Virtual Machine

With Visual Studio 2012 Microsoft dumped the DirectX SDK, and the effects library with it( along other things), which I needed for my engine. To compensate for that, I wrote some code to load an xml file that describes the outputs

Continue Reading...

PhysX Particles Simulation - Here Once Again

So I finally got to work again in the particles simulation, and I made some advances. Mainly, fixing the displacement of the particles and adding a "pseudo z culling" step. Actually, what I'm doing is compare the distance of the sample

Continue Reading...

Regex Helpers - Snippets

Working on a parser the other day, I decided to use the new <regex> library in C++ 11. It's awesome, once you get to know the regex sintax. To make development faster, I coded a couple functions. They are nothing fancy,

Continue Reading...

PhysX Particles Simulation - Take Two

Well, after a lot of fighting, I managed to get the volumetric render working. I'm using a 128*128*128 3D texture, and then I raymarch it in a compute shader. The results are quite good actually. I'm getting around 140 - 170

Continue Reading...

PhysX Particles Simulation - First Take

So, the other day I decided I wanted to try to add particles to my engine. I already have PhysX ( 3.3 beta ) working, so I grabbed the documentation and started from there. The documentation includes a guide that it's

Continue Reading...

Simple random numbers using std::random

Another of the great things added in C++11 was the random library. It provides a bunch of facilities to create random numbers, way better than the C rand(). As it happens a lot of time, its use is cumbersome, compared to

Continue Reading...

Here I present what I like to call a "Dynamic Struct".
The idea is to have a struct that you can define at run-time, and get the elements by a string.
What's the use, you might ask? Well, my reason to do this is to have a way to define a constant buffer in a text file, load and update it in the C++ side, and pass it to the GPU.
So, with that in mind, here's a partial implementation( partial in that it has just a couple types, but it's easy to extend ), and how to use it.

Code:


And to use it:


Or:


It should be noted that I'm using this in production code, with just a few changes, like clean-ups, proper ctors, etc.
Speed-wise, it shouldn't be that bad. I use a std::map instead of a std::hash_map, as constant buffer and structures in general tend to have few items, and a hash map suffers in that conditions. Also is O(1) in the creation of each element, so you can add all the elements TYPES you want( C++ 11 and lambda functions make it possible to throw the old switch() case away in a clearer and might even faster way. Functional programming to the rescue!)

PS: uint is just a typedef for unsigned int. Also XMFLOAT4X4 and XMFLOAT3 are from the DirectX Math Library ( DirectX 11).

Branchless Ternary Operator

Branches, while faster every day, can be slow in some systems, especially in GPUs. By slow I mean slower than some arithmetic operations. If the branch is operating with numeric values, and assuming that boolean operations are convertible to 0 and

Continue Reading...

Shaders - Tile Free Texturing

Tiling is a common technique to texture terrains, but suffer from repetition, as it IS the same texture repeated a lot of times. How can this be improved? You could add multiple textures, but that doesn't scale well when the number

Continue Reading...

Models - Guns Concepts

Here are some concept models ( and some not so concepts ) of guns for the Nanoattack demo. "...modern guns work by either electromagnetic propulsion ( aka Gauss Rifle ) or plasma acceleration. To provide that amount of energy, miniaturized Casimir

Continue Reading...

Models - ZBrush Shadow Box in Blender

I allways try to prove that Blender is as least as powerful as the other software arround. Shadow Box, a nice feature of ZBrush, that allows you to create a mesh from 3 projections ( x, y, z ) can be

Continue Reading...

Models - Roller Bug

Here's a model I found in the depths of my hard drive. Is a high-poly sculpt before of the times of Dynamic Topology in Blender, so there are a lot of polys. A lot.  Rendered in Cycles at 200 samples. No

Continue Reading...

Shaders - Simple Brightpass Filter

In HDR rendering ( and LDR too ) is common to add bloom to the scene. To create it, you need to mask the bright parts of the scene, blur it ( NVIDIA has a nice constant-time Gaussian blur ) and

Continue Reading...

Shaders - Fast Aproximate Screen Space Reflections

A while back, when working on my first engine, Atom Engine (DirectX 9), I played a bit with shaders for reflections. A fast but extremely hacky method to get them is to grab the pixel coordinates  (in screen space), and negate

Continue Reading...

Pages

Powered by Blogger.