Blur, Bloom etc

May 2, 2009 at 3:20 AM
Quick question.  I see in Ox.Engine that you have a gaussian blur effect.  I am digging through all the code, but maybe you can help nudge me towards where I need to look.  I want to apply effects like blur,bloom, sepia to the entire scene.  Where should I be digging to make this happen.

Another question, you said that shadows don't work on the 360.  I would like to get them to work, if you could point me in the right direction on what needs to be done for this I would appreciate it, thanks.
May 2, 2009 at 10:24 PM
Scratch my first question, I have post processing working just fine now.  Still would like to know about shadows and also what is the easiest way to get rid of a scene, thanks.
Coordinator
May 6, 2009 at 11:16 PM
Hi!

Sorry for the delay in replying - I've been working hard on testing Ox and ironing out its bugs.

You don't really get rid of a scene directly. What you do is work with domains. Essentially, you create a domain with engine.CreateDomain("someDomain"). Then you load a scene into that domain. The engine.LoadDocument(...) has a parameter called domainName. Into this you would pass the name of the newly-created domain, "someDomain". When you are done with the scene, you clean it all up by calling engine.DestroyDomain("someDomain").

Does this make sense?
May 7, 2009 at 2:46 AM
Got it changing scenes now when I need it to, thanks.
May 7, 2009 at 11:35 PM
New question for you.  I am trying to manually add components to a scene.

player1 =

new SkinnedModelComponent(ScreenManager.GameEngine, "Application", true, "Ox//Models//PlayerMarine", new Ox.Engine.Primitive.SpherePrimitive());

 

player1.LocalPosition = player1Position;

player1.LocalScale =

new Vector3(0.125f, 0.125f, 0.125f);

 

player1.Visible =

true;

 

player1.LocalEnabled =

true;

 

player1.DrawPriority = 0;

player1.DrawStyle = Ox.Scene.Component.

DrawStyle.Opaque;

 

player1.FaceMode = Ox.Engine.GeometryNamespace.

FaceMode.FrontFaces;

 

player1.AnimationController.StartClip(player1.SkinnedModel.AnimationClips[

"Idle"]);

The code executes just fine, but I can't see the model, any help appreciated, thanks.

 

Coordinator
May 8, 2009 at 1:08 AM
Edited May 8, 2009 at 2:20 AM

Most of that code is superfluous. The thing you're forgetting is to add the component to the dependency graph. In your case, forgetting to add the component to the dependency graph causes it to not update. Try this code instead -

 

player1 = new SkinnedModelComponent(engine, "Application", true, "Ox//Models//PlayerMarine", new Ox.Engine.Primitive.SpherePrimitive())
{
    LocalPosition = player1Position,
    LocalScale = new Vector3(0.125f, 0.125f, 0.125f),
    Parent = engine.Root // this adds the component to the dependency graph
};

player1.AnimationController.StartClip(player1.SkinnedModel.AnimationClips["Idle"]);

 

Let me know how that works out for ya :)

May 8, 2009 at 1:27 AM

Works great.

Yeah I figured most that stuff was useless, that was me trying any and everything to get it to work lol.

May 8, 2009 at 1:50 PM

Thanks for the quick responses to all my questions. 

My main question this time is about performance.  As I work with post process effects and the like, 60fps seems to be the performance cutoff for me. 

What I mean is that if my player is walking around the world, whenever the fps dips down to <=  60 fps, the engine can't seem to keep up things.  Is this a limit you have also seen?

I haven't dug deep with if/how ox uses quad trees and the like.  Any insight would be great, at this point I see no reason to invest time in making xbox shadows for me.  Shadows would lower the fps even more and with a cutoff of 60 I can't do much more fancy stuff, thanks.

Coordinator
May 8, 2009 at 11:01 PM

"whenever the fps dips down to <=  60 fps, the engine can't seem to keep up things."

Can you be (much) more descriptive? I have no clue what you mean by, "can't seem to keep up (with?) things." Precisely what behavior are you seeing?

If your post-processing is weighing down the drawing, I don't think that has anything to do with Ox's performance. Ox doesn't intervene in the post-processing phase, so there's literally nothing I can take out to lessen your post-processing bottleneck. You could try using the Quad or CubeTree functionality to boost Ox's performance, but if the bottleneck is in your post-processors, this probably won't help much.

Hopefully you didn't just grab some random post-processors off the internet and integrate them without first understanding their performance costs... :)

May 28, 2009 at 3:03 PM
Edited May 28, 2009 at 3:03 PM

Sorry for taking so long to reply.  Been working on menus and my combat engine and other things but now I wanna focus again on these issues.

I really did give a bad description of what I was seeing.  I will take a screenshot to show you, it is really hard to explain.  It occurs even without my post-processing effects.  I wouldn't be a very good programmer if I didn't know post processing has its costs lol :).

Few questions below:

1. Do you have any information to help me tap into that quad/cube tree functionality?  Anything that helps me and saves me time sifting through code to find the right place to harness that functionality would be helpful.

2. I noticed that the highest and lowest elevations appear to be lighted differently than the rest of the scene.  For example, look at a heightmap with no water and you will see that the lowest elevations appear noticeably darker.  This also happens at the highest elevations.  Is this by design?  And if so where in the engine code could I remove this effect.

3. Is there any built in way to limit the FPS draw rate of the engine?  Right now it seems to draw as fast as possible, any way to draw at a more constant rate or do I have to implement this myself?

4. Call me an idiot, but I can't get lights to shine at an angle.  When using a directional light, it only shines down a specific axis regardless of what changes I make.  Any insight to help would be great.

5. Any guidance on where to start with shadows on the XBOX 360?  As stated before I really wanna get this working, if you could tell me where to go and why it works on the PC only, you would greatly help the amount of time it will take me to get this feature up and running.

I apologize for all the questions.  It has been long since I posted here and my questions list has grown as a result.  I appreciate your engine and it has served as a great framework from which I have built my own game's engine.  I have tweaked ox, jiglibx, and even xnanimation quite alot and the combination has really resulted in a solid engine for our next xblcg.  Ox Engine is by far the best 3D engine out there for the XNA crowd.  Great work.

Coordinator
May 28, 2009 at 7:42 PM

Hey man :)

>> 1. Do you have any information to help me tap into that quad/cube tree functionality?

A little background - The DefaultEngine type is the default Ox engine that comes out-of-the-box. It extends the abstract OxEngine type and creates the services needed by the subsystems as well as the subsystems themselves. To configure Ox in a deep way, including configuring the scene partition structure, you must replace the use of DefaulEngine with your own object type.

Currently, the best way to do this is to copy and paste the DefaultEngine class, then mutate the code as you see fit.

(I know copy-paste sucks a great deal, but once you build your own engine type, you have extreme control over Ox, so it's worth it if you're making a non-trivial Ox app.)

Now, notice how DefaultEngine constructs a new SceneSystem by passing it an ISpatialContainer factory delegate. This factory delegate currently creates a SimpleSpatialContainer. This is basically a dummy spatial partitioning system that offers no speed-ups. You want the factory delegate to instead construct either an Octree or a Quadtree that will be big enough to cover your play area and just granular enough to speed up your drawing performance.

>> 2. I noticed that the highest and lowest elevations appear to be lighted differently than the rest of the scene.

This is just an illusion due to the textures used. Use your own textures and it'll dissappear :)

>> 3. Is there any built in way to limit the FPS draw rate of the engine?

That's a simple XNA operation. Set deviceManager.SynchronizeWithVerticalRetrace to true.

>> 4. When using a directional light, it only shines down a specific axis regardless of what changes I make.

Sounds weird. Are you normalizing the Vector3 before setting the Direction property? I wonder if I should automatically normalize the property when it's set... If normalizing doesn't work, please post a little code snippet.

>> 5. Any guidance on where to start with shadows on the XBOX 360?

DirectionalLight along with DirectionalShadow are the types that implements the shadowing behavior. It would be easier I think to simply modify the code in-place rather than replacing the type. Read through both classes and you'll immediately see why shadows don't appear on the Xbox :) You can get them to show up by using a different surface format in DirectionalShadow, but they won't draw correctly.

The problem is that I implemented VSM (Variatic Shadow Mapping). This, AFAIK, requires the use of an Rg32 surface format. This works fine on windows, but as you'll notice, will not work on the Xbox. This is because the Xbox does not have the Rg32 surface format available. It has been proven, though, that ESM (Exponential Shadow Mapping) works really well since it uses (I think) Single surface format and has far less artifacts than VSM. So, ya, implement ESM :) Or, maybe you can find a way to make VSM to work on a format that works on both platforms.

Implementing ESM will require you to modify the baseShadowReceiver.fx, baseLightReceiver.fx, and SkinnedModelEffect.fx in the XNAnimation source code. You'll also have to rebuild XNAnimation after pushing the new shader byte code to SkinnedModelBasicEffectCode.cs.)

There will probably be other places you'll discover the need to touch as well. The sad thing about shadow maps is that they cut across the whole engine. I tried hard to encapsulate the shadowing behavior, but it's just not containable AFAIK. If you manage to get reasonable shadowing working on both platforms, please please please send the code to me so I can share your fix with everybody else :) I'd love to fix it myself, but it's just not something I've got time for right now :(

Cheers!

Jun 4, 2009 at 7:10 AM

Thanks for the lengthy reply.  Ok working through these, here is what I have so far.

1. I change :

 

<font size="2">

 

</font>

 

 

<font size="2">

 

</font>

new SimpleSpatialContainer<ISceneComponent>(delegate

<font size="2" color="#0000ff"><font size="2" color="#0000ff">

 

</font></font><font size="2" color="#0000ff">

 

</font>

 

{

 

return new FastQueriableCollection<ISceneComponent>();

})

<font size="2">

 

</font>

to :<font size="2">

 

</font>

new Quadtree<ISceneComponent>(Vector3.Zero,Vector3.One, 1, delegate

{

<font size="2">

 

</font>

 

return new FastQueriableCollection<ISceneComponent

>();

 No chance in performance, should the scale be higher?  I have used numbers between 1 and 32 and no difference.  What am I missing?

2. Still happens with custom textures, highest and lowest elevations are shaded darker than the rest of the terrain

3. Add : <font size="2">

engine.GraphicsDeviceManager.SynchronizeWithVerticalRetrace =

</font>

true;

In the initialization of the Application file, is this not the same graphicsdevicemanager that is drawing the 3d scene?  This causes no frame rate sync at all.

4. Haven't touched this issue again, yet

5. I have been researching and disecting this issue very deeply.  Will probably switch everything to ESM, hope to have implemented by end of june.  Will share with you if and when I switch it to ESM, if that works :).

Coordinator
Jun 4, 2009 at 3:52 PM

Hi again!

1 -

new Quadtree<ISceneComponent>(Vector3.Zero,Vector3.One, 1, delegate

This makes the Quadtree start at Vector3.Zero and end at Vector3.One. This is waaaaaay to small to contain all the objects in your scene. Like this, it will only cause a slowdown in your perf. The Quadtree should be big enough contain all the objects in your scene.

2. Still happens with custom textures, highest and lowest elevations are shaded darker than the rest of the terrain.

Okay, this is the behavior of the terrain shader code then. I'll look into fixing it!

3. This -

engine.GraphicsDeviceManager.SynchronizeWithVerticalRetrace = true;

is the right code to synchronize the frame rate. The only reason why it wouldn't work is if your code is turning it to false somewhere else. What is your current frame rate?

Jun 5, 2009 at 4:45 PM

how did you do the object post processing tnt?

 

give us a clue please.

 

say a blur on the player object.

Many thanks. Hope your combat engine is coming along nicely.

Si.