Archive for the ‘Graphics Articles’ Category

OpenGL Engine in a WPF hosted Window.

Monday, February 8th, 2010

Wpf OpenGL

I have been working on my editor as of late in hopes of being able to use it to make my simple demo I have been talking about. I found a lot of doubt on the internet about the ability to interop OpenGL with the WPF rendering stack.

Well, we got it to work and it is very similar to the setup I had used to get it working in WinForms. Here is how we did it. First of all, you need a 3D Engine with the ability to take an HWND and use that for rendering. A complete tutorial on how to do this can be found in a gamedev article here.

Once you get this far, its only a matter of creating some xaml.

        <Window x:Class="GravEdit.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="GravEdit" Height="800" Width="800">
    <WindowsFormsHost x:Name="OpenGlPanel"/>        
    </Window>

And your C# for this xaml would look something like:

public partial class MainWindow : Window
        {
            private GravWrap gravWrap = new GravWrap(); //an instance of the engine
            ILua LuaPortal;
 
        public MainWindow()
            {
                InitializeComponent();
                System.Windows.Forms.Panel panel = new System.Windows.Forms.Panel();
                this.OpenGlPanel.Child = panel; //add the winform panel as a child to the winformhost
                IntPtr LuaState = this.gravWrap.Initialize(panel.Handle.ToInt32()); //pass the panels hwnd.

We created a Panel within the WinformsHost and that was it.

Cheers!

Update: Editor and Lua Lighting…

Monday, January 25th, 2010

I moved the lighting objects to lua, and more so removed some of the legacy lua code (no more sandbox). I’m running lua the way its intended to be run with the engine, initializing lua objects and relying on events for all of their updating.

I started converting my editor to wpf, which actually is not all that bad.

Update: Post-Processing and Lighting

Friday, January 8th, 2010

I added another framebuffer at the tail-end of the rendering pipe, this is where I do the culling of the lighting volumes for Deferred Shading.  This is also the beginnings of any future post-processing work I do (HDR/Tonemapping/ambient occlusion).

I feel like the lighting is done enough to move into Lua.

My next project is to make a realtime editing of light values in the editor I have (the purpose of its early existance).

Here is an example of where i hope to get with my editor eventually, but for now im just going to do lights =). I by no means have an Uber-Shader yet, but I’m working towards that.

Update: Point Lights getting there…

Monday, December 14th, 2009

I added point lights over the weekend.  Aside from getting the proper light volume shape (a sphere geometry) and proper values for my attenuation, its almost there. Here’s a pic.

Cube Point light w/ no attenuation

Cube Point light w/ no attenuation

Update: Deferred Shading

Thursday, December 10th, 2009

So my Deferred Shading shaders were messed up, and after some clarification on theory and math I am starting to see some real working results. here is a picture of a light moving from right to left right behind the camera.

directional light

directional light

Next is point lights and a bunch of lights moving around the screen.

Cheers!

PS. Once this is working and im comfy with it i will be sure to talk about it =)

A different approach, direction.

Tuesday, November 17th, 2009

Here is a link to someone who has given me some critiquing on my deferred renderer. We have similar goals with different tools and different things we are currently working on. Another great source for engine stuff.

Update: Moving Forward, Whats Next?

Friday, November 13th, 2009

So the whole point of me doing more Lua stuff right now is so I can go back to working on my lighting model. I want to be able to add cameras, lights and objects to anywhere in my scene by the click of a button, even change normal maps. This makes debugging an OpenGL lighting model easier, since the debugging tools aren’t as plentiful as DirectX.

However, I have also been trying to build up enough stuff to put out a demo to test how the engine is holding up with all of these structural changes. So, I am going to come up with a very very simple demo using the new lua structure.

So Be on the lookout for some future posts on Deferred Shading. If anyone has any requests about how this post should be tailored, I’m all ears. I was thinking about doing a 3 part post. 1st on ABSOLUTE beginner intro 2nd on architecture, and 3rd on implementation.