利用者:Kupoman/BGE Custom Render Pipeline Proposal

提供: wiki
移動先: 案内検索

Name

Daniel Stokes

Email / IRC / WWW

My email is kupomail@gmail.com
My IRC nick is kupoman, and I can be found in the following channels: #gameblender, #blender, #blendercoders, #bgecoders
I have a blog that mostly has posts from last year's Summer of Code that can be found at kupoman.wordpress.com

Synopsis

The goal of this project is to provide more control of the rendering pipeline used for the Blender Game Engine. The end goal will be a system that offers the option between forward rendering, inferred lighting, and deferred shading while giving the end user complete control over the system. This project will focus on adding inferred lighting while keeping in mind support for deferred shading. Both inferred lighting and deferred shading require a shader pass before rendering to gather data. Adding support for this will be the first part of this project. However, to further the goal of end user control, this prerender filtering will be exposed to the end user and work with the current posrender filtering system (called 2D filters). This will allow the two systems to work together to produce effects that were previously difficult, such as using normal data to outline creases in a screen space outline shader.

Benefits to Blender

By allowing the end user as much control over the rendering pipeline as possible, artists are able to implement a wider variety of techniques to better enhance the style of their game projects in the Blender Game Engine.


Deliverables

The deliverables of this project will focus on giving the end user powerful control over the real-time rendering pipeline:
  • Support for custom Prerender filters (used to gather data)
  • New UI for controlling Prerender and Postrender (currently 2D filters) filters in the Render Panel
  • Customizable inferred lighting
  • Well organized code that should allow for Deferred Shading to be added later


Project Details

This project can be broken down into three stages setup, implementation, and optimizing and cleanup.
The setup stage includes two things, setting up the UI and setting up the internal mechanisms. In total three new UI elements will be needed. First an element for switching between inferred lighting and forward rendering (and later deferred shading)as well as settings unique to both methods will need to be setup. The remaining two new UI elements will be for controlling 2D Filters. One will be for filters run before the rendering stage, and one will be for controlling filters that occur after the rendering stage. Along with user defined filters, built in filters, such as those that will be used in inferred lighting, can be displayed here to show the user what is going on as well as perhaps being able to adjust some features (while others remain locked) of the built in filter.
Along with the UI, the first stage will require some backend changes to accommodate the new data. This data will likely be stored in a collection of filter structs stored in the scene. During conversion time this data will be passed to the rasterizer to deal with as it sees fit. The OpenGL rasterizer will use this data to build shaders and set up uniforms. Along with this shader data, the rasterizer will need light data to create the light map for inferred lighting. This will be a good opportunity to break the BGE's dependance on Blender lights. This will mostly involve a way to create GPULamps from BGE lights, and then storing this light list in the rasterizer, instead of the Blender scene (the viewport can continue doing things the way it is doing).
The second stage will involve the implementation of inferred lighting. With the changes done in the setup stage, this will mostly require writing the shader necessary to fill the geometry buffers (textures that contain information about the geometry, such as normals) and writing a shader for rendering each light type. The OpenGL rasterizer will make use of the light shaders, the GPULamp list, and the geometry buffers to create a light buffer/map by rendering lights as full screen quads. From there, gpu_material will need to be extended to handle using a light map instead of generating code for each lamp.
The final stage will focus on bug fixing and implementing optimizations outlined in the Kircher and Lawrance paper on inferred lighting. The most important optimization is to implement discontinuity sensitive filtering. This is the key component that distinguishes inferred lighting from light prepass rendering. This technique uses discontinuity data stored in the geometry buffers to help sample from the light map. This filtering allows inferred lighting to support alpha polygons as well as allowing the light buffer to be at a smaller resolution than the final output buffer. After the filtering is in place, it would be prudent to optimize the full screen quad rendering of light sources. A couple of techniques can be applied here, including stencil buffer testing and making use of a scissor rectangle. Finally, it would be convenient to pass normal and alpha data into the filter system to make it more usable and powerful. This last component can eventually be expanded into a more thorough shader API, but that will likely be a separate project.


Project Outline

The following items give a rough outline as to the sequence of tasks needed to complete the project:
  • Create a UI for filter settings in the render panel and the corresponding internal storage of the data
  • Move the 2D filter code into the rasterizer and connect 2D filters to the new UI
  • Add system to create necessary render targets based on UI settings
  • Modify the rasterizer to rely on GPULamps instead of Blender Lamps
  • Create a builtin geometry data fragment shader to use for inferred lighting
  • Create a shader for point lights as well as a system for rendering inferred lighting lights
  • Add support for remaining light sources
  • Modify the codegen system to use a light map instead of individual lights
  • Add discontinuity sensitive filtering, alpha support, and support for mismatched buffer sizes for inferred lighting
  • Look into optimizing the inferred lighting with stencils and scissoring
  • Generate uniforms for normal and alpha maps to pass into custom shaders
  • Clean up and bug fixing
Each of block of items represents a milestone for the project.

Bio

I am an undergraduate Computer Science student studying at Eastern Washington University (located in Cheney, Washington, USA). I have one quarter of undergraduate studies left before I continue on to graduate studies. I have been doing Blender development for over a year now, and participated in last year's Google Summer of Code in which I worked on various bug fixes and minor features for the Blender Game Engine. After completing the Google Summer of Code I began contributing in the Harmony branch in which I did work on implementing shadow support for sun lamps, reworked the shadow panel for BGE users, and added support for changing the shadow's color. One of my largest interests is in real time computer graphics, and the BGE has given me the opportunity to explore that interest.