Better Light Propagation Volumes

In my last entry I described how the interpolation was poor, so I decided to “smoothe” them out. I used the compute shader to “propagate” over the neighbouring cells. This progress was done 10 passes. Below is a comparison between new and old results, the new are much better!

New Versus Old:

Advertisements

CDK – Displacement Mapping – Planet Rendering

Hi guys,

In the graphical side of the engine I have Implemented displacement mapping, currently only for the terrain engine, but making that feature available for meshes is simply a matter of copy & pasting. 🙂

As a side project, I’m starting on a small planet rendering project, the terrain engine support planes and spherical objects for now. The planet for now I just a sphere which is tessellated and displaced on the GPU.

The ocean is on the way for now, just having some problems with the resources…

At some point I’m going to post some screenshots.

Tutorial – how to use FMOD with C++

Note: This was written a while ago, therefore the quality is not up to standards, although the tutorial is still valid.

Hi guys. In this tutorial I am going to teach you how to implement the sound system called, FMOD : http://www.fmod.org/

Downloading:

Go to the url: http://www.fmod.org/fmod-downloads.html and select your OS, this tutorial will be based on the windows platform. You will be given an installation file (exe), install it normally. If you choose to change the installation path you should note it down, as you’ll need it later on. For FMOD to work properly, you must do the following.

Installation

Include Directories:

  • %FMOD ROOT%\FMOD Programmers API Windows\api\inc

Library Directories:

  • %FMOD ROOT%\FMOD Programmers API Windows\api\lib

Copying: Then you should also copy these dll’s to your project output folder:

  • fmodex.dll
  • fmodex64.dll
  • fmodexL.dll
  • fmodexL64.dll

Linking: You should link this library:

  • fmodex_vc.lib

Initializing FMOD

To gain access to FMOD, you must include:


#include "fmod.hpp"
#include "fmod_errors.h" // Only if you want error checking

Lets create a class called SoundSystemClass shall we!

class SoundSystemClass
{
 // Pointer to the FMOD instance
 FMOD::System *m_pSystem;
 SoundSystemClass () {}
}

And for the simplicity, I typedef the default fmod sound class to my own name, as following:

typedef FMOD::Sound* SoundClass;

To initialize FMod, we create a contructor for the class, error checking is still minimal as that will come later.

SoundSystemClass ()
 {
    if (FMOD::System_Create(&m_pSystem) != FMOD_OK)
    {
       // Report Error
       return;
    }

    int driverCount = 0;
    m_pSystem->getNumDrivers(&driverCount);

    if (driverCount == 0)
    {
       // Report Error
       return;
    }

    // Initialize our Instance with 36 Channels
    m_pSystem->init(36, FMOD_INIT_NORMAL, NULL);
 }

When create FMod, you get a pointer to the instance as a result, which you will be able to use later, and as a security check, we checked that the current pc actually has a sound driver. To initialize this pointer, you call the method, ->init(..), which requires the number of channels, some flags, and some extra driver information if needed. We call the ->init(…), with 36 channels, which can be increased or decreased to your choice, each channel can hold ONE sound, so it all depends on your game, and we pass the normal initialization flag. To create a sound, we create a new method called createSound(…), which takes a pointer to our typedef SoundClass, and the sound file path:


void createSound(SoundClass *pSound, const char* pFile)
 {
    m_pSystem->createSound(pFile, FMOD_HARDWARE, 0, pSound);
 }

When we create a new sound with FMod, we specify the file path, could be any, and the creation flags, we specified HARDWARE, should be fine for now, and some info for the sound itself, and of course, a pointer in return. To play the sound, we need to specify the channel, and we can send some flags as well, therefore, we create the method called playSound(…):


void playSound(SoundClass pSound, bool bLoop = false)
 {
    if (!bLoop)
       pSound->setMode(FMOD_LOOP_OFF);
    else
    {
       pSound->setMode(FMOD_LOOP_NORMAL);
       pSound->setLoopCount(-1);
    }

    m_pSystem->playSound(FMOD_CHANNEL_FREE, pSound, false, 0);
 }

In this method, we have a boolean called bLoop, which is an option the user can take, weather the sound should loop or not. If not, we simply set the Mod FMOD_LOOP_OFF from the sound pointer (Simple, right?), but if the user chooses to loop the sound, we set the mode FMOD_LOOP_NORMAL and set the loop count to -1, which means unlimited, you can play with it if you want. And finally, we create a method for releasing the sound, called releaseSound(…), which takes a pointer to the sound.


void releaseSound(SoundClass pSound)
 {
    pSound->release();
 }

Example of usage of class:

// Initialize our sound system
SoundSystemClass sound;
sound.Initialize();

// Create a sample sound
SoundClass soundSample;
sound.createSound(&soundSample, "C:\\mysound.wav");

// Play the sound, with loop mode
sound.playSound(soundSample, true);

// Do something meanwhile...

// Release the sound
sound.releaseSound(soundSample);

Sound System Class code:

typedef FMOD::Sound* SoundClass;

class SoundSystemClass
{
    // Pointer to the FMOD instance
    FMOD::System *m_pSystem;

    SoundSystemClass ()
    {
       if (FMOD::System_Create(&m_pSystem) != FMOD_OK)
       {
          // Report Error
          return;
       }

       int driverCount = 0;
       m_pSystem->getNumDrivers(&driverCount);

       if (driverCount == 0)
       {
          // Report Error
          return;
       }

       // Initialize our Instance with 36 Channels
       m_pSystem->init(36, FMOD_INIT_NORMAL, NULL);
    }

    void createSound(SoundClass *pSound, const char* pFile)
    {
       m_pSystem->createSound(pFile, FMOD_HARDWARE, 0, pSound);
    }

    void playSound(SoundClass pSound, bool bLoop = false)
    {
       if (!bLoop)
          pSound->setMode(FMOD_LOOP_OFF);
       else
       {
          pSound->setMode(FMOD_LOOP_NORMAL);
          pSound->setLoopCount(-1);
       }

       m_pSystem->playSound(FMOD_CHANNEL_FREE, pSound, false, 0);
    }

    void releaseSound(SoundClass pSound)
    {
       pSound->release();
    }
};

Hope you enjoyed this tutorial. Feel free to post some advice on how to improve, though this is my first tutorial I have ever made. 🙂

Cuboid Engine – Forest and Instancing

I have now redone my instancing system to use quad trees for calculating the visible area, my next step is probably to implement frustum culling. This re-invented instancing system allows me to implement some cool stuff, like a small forest because of it’s speed. Please be aware that I’m not an artist 🙂

In this scene there is: (62650 Instances)

  • 50 000 Instances of Grass
  • 10 000 Instances of Grass B
  • 250 Instances of Tree A
  • 200 Instances of Tree B
  • 200 Instances of Tree C
  • 250 Instances of Tree D
  • 250 Instances of Bush A
  • 250 Instances of Bush B
  • 250 Instances of Flower A
  • 250 Instances of Flower B
  • 250 Instances of Fern
  • 500 Instances of Ground Plant