Meteor Engine source code is now public

I have finally published the code to the Meteor rendering engine, and it’s available on CodePlex. Actually, it’s been up for several days, and I faced the pressure of not making the 30 day deadline CodePlex places on setting up the project area before making it public. For now there are no official downloads- you can only browse the source code. Anyone daring enough can get the latest revision of the source code and build a library from it. How to use the library is a different thing altogether.

It’s still continually being worked on and improved, so what I will describe below may be subject to change. I have added a new blog category, Meteor Engine, to better keep track of all the updates for this project. It is published under the MIT licence.

The source code is organized into two project folders- MeteorContentProcessor and MeteorEngine. Although there’s still some cleaning up to to do, the engine is small enough to easily describe the source files in a single post. So here we go.

MeteorContentProcessor files

MeteorContentProcessor is self-explanatory- it’s the content building pipeline for the models and other resources. It’s very similar to the content processor of XNA’s normal mapping sample, although there are a few tweaks to it.

It has very few files, and here are short descriptions for what they do:

  • DeferredMaterialProcessor.cs – Overrides MaterialProcessor.BuildTexture to convert normal maps to a signed format.
  • DeferredModelProcessor.cs – All models enter through here. Checks to see if it has normal maps and adds them, and also integrates the GBuffer effect. Specular map support is still in progress.
  • DeferredRendererModel.cs – A leftover from Catalin Zima’s deferred renderer, it also handles models but currently not supported. It’s just there for reference now.
  • DeferredTextureProcessor.cs – Used by DeferredMaterialProcessor to encode the normal maps.

MeteorEngine files

The MeteorEngine folder contains the main engine project code. The single source file in the root of this folder, Core.cs, is the entry point for the setup and execution of the engine’s processes. 90% of the code is in the Graphics folder, which is further split into rendering components, shader classes, helpers and render profiles.

Here is a rundown of what the code for the source files do. For completeness I will also list the shader files that derive from the base shader class. Because I did not plan as well as I expected to launch the project, there are redundant, unused files all over the place, so these need to be removed soon. I grayed these out in the file list, so they won’t be used any time soon. The file list will get shorter after I update.

Core

Core.cs – This containes the Core class, the entry point of the engine which is responsible for loading and using cameras, scenes, and rendering profiles. It’s a bit of a mess right now- the class is not terribly long but it’s still disorganized and a bunch of stuff is hardcoded just for debugging purposes. This will likely be split into more classes in order to distinguish the functionality better.

Graphics

  • Graphics/ – If Core.cs can be thought of as the hood of a car, here’s what’s under it.
  • Graphics/Scene.cs – Defines a scene, which consists of several static and/or skinned models, and different types of lights. Also provides a way to add them.

Components

  • Graphics/Components/ – This includes custom extensions to XNA components, which are used by renderer classes.
  • Graphics/Components/DrawableComponent.cs – Implements IDrawable interface and extends MeteorComponent. Provides and handles the graphicsDevice service. The Core class extends from this.
  • Graphics/Components/MeteorComponent.cs – Implements IGameComponent, for the purpose of using component services instead of directly accessing the Game class.

Cameras

  • Components/Cameras/ – Contains different kinds of cameras based on behavior.
  • Components/Cameras/Camera.cs – Base camera class, which defines and sets up a FPS style (euler angle) camera. It can be used as-is, but it provides no interactivity.
  • Components/Cameras/ChaseCamera.cs – A camera that follows a specific point.
  • Components/Cameras/DragCamera.cs – Camera that rotates when the mouse is dragged and uses WASD keys for movement along its view.
  • Components/Cameras/FreeCamera.cs – Camera that rotates when the mouse is moved, also uses WASD keys for movement.

Drawables

  • Components/Drawables/ – Define different types of geometry that can be drawn onto the screen.
  • Components/Drawables/EntityInstance.cs – A possible holdover for supporting instanced meshes in the future.
  • Components/Drawables/InstancedModel.cs – Loads model files, prepares them, and also does manipulation such as scaling, moving and rotation.
  • Components/Drawables/QuadRenderer.cs – Creates and draws a quad that is typically used in screen space.

Lights

  • Components/Lights/ – Defines different types of lights used for shading geometry.
  • Components/Lights/DirectionalLight.cs – Structure for directional light data.
  • Components/Lights/PointLight.cs – Structure for point light data. It is treated as an instanced mesh for deferred rendering.

Helpers

  • Graphics/Helpers/ – Functionality that aids or supplements the rendering process, but generic enough that they do not fit in any particular context.
  • Graphics/Helpers/CopyShader.cs – Produces a deep copy of a render target with a basic effect while keeping the original. I thought about putting this shader in RenderShaders, but the purpose seems very much more like an added utility than a visual effect.
  • Graphics/Helpers/GaussianBlur.cs – This was adapted from the XNA bloom shader example. A Gaussian blur filter meant for offline computation, and can be used for screen-space blur or textures.
  • Graphics/Helpers/RenderInput.cs – Used by shader classes to keep inputs for any given combination of resources to run effects with. These input types are cameras, scenes, and render targets.
  • Graphics/Helpers/RenderStats.cs – Provides simple profiling functions to measure time elapsed for different processes. Mostly used in the shader classes.
  • Graphics/Helpers/StringBuilderNumeric.cs – A StringBuilder class by Gavin Pugh, it outputs garbage-free strings converted from numeric types. Useful for debug rendering.

Renderer

  • Graphics/Renderer/ – All files related to the usage of inputs for rendering.
  • Graphics/Renderer/RenderProfile.cs – Extends DrawableComponent. Loads up different shaders used for a complete rendering profile. Pools render targets for rendering and debugging for each step, which is called a RenderTask.
  • Graphics/Renderer/SceneRenderer.cs – Renders through a list of meshes in a scene.  Any combination of scene and camera can be used. It’s also responsible for basic culling and organizing meshes.

Shaders

  • Graphics/RenderShaders/ – User-definable shaders for providing different effects.
  • Graphics/RenderShaders/BaseRenderer.cs – Base shader class which provides render inputs, universal shader parameters and profiling.

The PostProcessingShaders and SceneShaders folders reside in Graphics/Rendershaders.

Post-Processing Shaders

  • PostProcessingShaders/ – Post-processing (usually) screen-space effects. All shaders here only take render target inputs.
  • PostProcessingShaders/BloomShader.cs – Takes a bloom effect and does a 4-pass render. Additionally, change contrast and saturation.
  • PostProcessingShaders/BlurShader.cs – Screen-space blur using Gaussian blur.
  • PostProcessingShaders/DepthOfFieldShader.cs – Produces a soft-focus blur by interpolating a blurred image and a sharply focused image, and a depth map for adjustments.
  • PostProcessingShaders/FXAAShader.cs – Fast Approximate Anti-Aliasing. Typically used for deferred rendering setups, right after the color and lighting pass.
  • PostProcessingShaders/SSAOShader.cs – Reads a normal map and depth map to produce screen-space ambient occlusion, with a randomized normal texture.

Scene Shaders

  • SceneShaders/ – Scene effects. All shaders here use some combination of a camera and scene, with the exception of CombinationShader.cs.
  • SceneShaders/CombinationShader.cs – Combines lighting and diffuse/albedo render targets to provide a complete image. Used for deferred and light pre-pass rendering.
  • SceneShaders/DiffuseShader.cs – Draws diffuse/albedo textures from scene meshes.
  • SceneShaders/GBufferShader.cs – Produce a GBuffer with either two or three render targets using MRT. The larger GBuffer class extends from the small GBuffer class.
  • SceneShaders/LightShader.cs – Takes normal and depth maps to render directional and point lighting. Optionally does shadow mapping with drawing the scene from the light’s POV, and supports single-pass PSSM for up to 4 frustum splits.

Render Profiles

  • Graphics/SampleRenderProfiles/ – Contain rendering setups derived from RenderProfile.cs, as examples of different types of rendering that are possible.
  • Graphics/SampleRenderProfiles/DeferredRenderer.cs – Setup for deferred rendering, and some post-effects.
  • Graphics/SampleRenderProfiles/LightPrePassRenderer.cs – Setup for light pre-pass rendering, and some post-effects.

Properties/ – Contains the AssemblyInfo file for this project.

MeteorEngine.Content files

These files are loaded in the content project, and are used mainly by the shader and SceneRenderer classes. These include default textures for models that have no compatible texture types, a random noise texture, and the .fx files compiled by the shader objects that use them. Keep in mind that this is content only for the engine library, and is separate from the content of the game project that uses the engine.

Further updates

As I have some further cleaning up to do in the code repository, some files will be removed, and others may be renamed. I will explain a simple example use of the engine in a future post. Come back to this post soon to see the updates for the next build.

Advertisements

4 thoughts on “Meteor Engine source code is now public

  1. Hey Chris,
    This is really impressive stuff. I’m quite interested in using your work in a game engine I’m working on (I’m a developer by trade, but not in XNA/games. This is essentially a hobby for me too).

    I’ve downloaded your project and I have it all setup, but I am ignorant of how best to go about integrating mine and yours. On the one hand, I could carve out what I need from yours, but I don’t clearly know (yet) what I need. On the other, I want an easy way to obtain and use awesome fixes, updates, and progress that I suspect you will make. This must be a common problem.

    If I put together some specific questions about those issues, do you think you’d have a second to enlighten/advise me? I’ll keep looking at it and reading in the mean time.
    Best regards,
    -Colby

  2. Hi Chris!

    Thank you for uploading the sources! It is greatly appreciated! I’ve been waiting some time for the sources, ever since I read that you were going to release them. I am currently looking for solution that allows me to not reinvent the wheel in my game regarding render-tech.

    During the next days I’ll try to integrate some elements of my engine with your rendering pipeline to see how it behaves. I did the same thing with the engine released by J.Coluna.

    Do you think that there will be some compilable samples so people can see see how to set up a basic scene and rendering pipeline. Or is Core.cs all you need? It seems pretty self explanatory, so I’m sure I can figure it out ASAP and get started on the comparison.

    Thank you!

    • I have been on hiatus for a few months, but I’m back at working on the engine. Since this post there have been more high level changes, the most significant being the embedding of .xnb resources in the .dll, and addition of lazy loading to make scene building easier. The content pipeline still looks for the GBuffer effect file in the game project’s content directory, and not the engine’s content directory, which is a problem if I want to completely encapsulate the library.

      I can provide a sample project soon. Setting up a basic configuration should only take a few lines.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s