Fog/Dust problem

Apr 14, 2010 at 8:06 AM

Hello,

 

I am using the latest revision (rev: 406) and I have a (weird) problem.

The absolute center of the world (0,0,0) looks great (the colors and lightning are good), but the further you move away from the center the more dustier/foggier the world looks. Colors are unclear and when you're far away they're completely gone.

The screen-shots below show this problem in a sample scene (with only the default skybox and default terrain). And the scene I use (with the default skybox, default terrain and a couple non-default models).

I haven't set any graphics parameter in the code and I am not sure how to solve this problem. I would be very thankful if anyone can point me in the right direction.

 

Jelle

 

Editor
Apr 14, 2010 at 11:44 AM

u definately got your lights set up correctly? if you can post your entire project up as a zip maybe one of us peons can find the problem :D

bubzy.

Apr 15, 2010 at 7:29 AM
Hey. I will post the project later on. I'm using the latest revision and I should try to beta first to see if it has the same problem. What exactly needs to be done to set up the light correctly? Is (default) ambient light in the scene enough?
Apr 16, 2010 at 5:09 AM

I solved the problem by changing the component type from StandardModel to BasicModel.

Don't know what caused the problem, but it's solved now.

Editor
Apr 16, 2010 at 10:17 PM

you need to add an ambient light in the scene editor, there is no light by default as such. (sorry if you already know this).  there should be no lighting issues with the standard model.

Apr 17, 2010 at 5:42 AM

Yea, I know. That's why I was struggling with it, I had the ambient light in the scene editor..

But changing the model type worked for me.

Editor
Apr 19, 2010 at 1:49 AM
Edited Apr 19, 2010 at 1:52 AM

it could be something to do with the camera updates, the engine seems to still be looking for the engine.camera.position value to draw fog and suchlike. however using the new setviewbymatrix etc. functions this does not move the actual camera's position, so the engine still thinks that you are in the middle of the terrain. (i think)

 

try this

 

engine.Camera.Position = (_worldMatrix.Translation); // yes im using kermitts camera code :D

Apr 19, 2010 at 3:27 AM

Good thinking. I also thought of that and how to move "that" to the same position the camera is, but the "Position" property is read only so I cannot use that line of code.

This thread explains why it is made readonly.

 

Editor
Apr 19, 2010 at 9:43 AM

yeah indeed. i have however edited the engine dll to include a set function for the camera position too. doesn't seem to have any negative effects so far. check out my new demo template on the other post.

Coordinator
Apr 20, 2010 at 1:36 AM

hey bubzy, thanks for helping out with this one as I seem to have totally screwed it up :)

the camera.SetViewByMatrix method is likely going to be replaced with this -

        /// <summary>
        /// Set the view directly with a position and a matrix.
        /// </summary>
        public void SetViewDirectly(Vector3 position, ref Matrix view)
        {
            this._position = position;
            this._view = view;
            UpdateBounds();
        }

I haven't tested this yet, but I think it will also solve the water rendering problems.

Should have a new build ready this evening.

cheers!

Apr 20, 2010 at 6:22 AM

Great news!

I'll rebuild the engine tomorrow and will let you know if it worked for me.

Thanks.

Apr 22, 2010 at 5:37 AM

Hey bryanedds,

Maybe I'm too fast, but I compiled the source today and it doesn't seem to contain the method SetViewDirectly. I searched all the code in the OxSolution solution and it isn't there.

Am I doing something wrong?

Thanks.

Coordinator
Apr 22, 2010 at 7:49 AM

ya. that method was removed entirely. now you call either SetViewByLookForward or SetViewByLookTarget.

also, don't use BasicModels; use StandardModels instead :)

cheers!

Apr 22, 2010 at 8:06 AM

SetViewByMatrix is replaced by SetViewByLookForward and SetViewByLookTarget, right?

Assuming this._engine is a handle to OxEngine and viewMatrix is the view matrix, I had the line _engine.Camera.SetViewByMatrix(ref viewMatrix) in my code. But the SetViewByLookForward and SetViewByLookTarget methods are not members of the OxEngine.Camera? When I open the Object Browser in Visual Studio I cannot find those two methods.

Am I doing something wrong, or missing something? I have compiled revision 420 and added the references:

  • JigLibX
  • Ox.DefaultEngine
  • Ox.Editor
  • Ox.Engine
  • Ox.Gui
  • Ox.Scene
  • Ox.Script
  • XNAnimation
  • XNAnimationPipeline

Hopefully my question is clear and thanks in advance.

Coordinator
Apr 22, 2010 at 8:45 AM

sry, I mis-remembered - it's SetTransformByLookForward or SetTransformByLookTarget.

Apr 22, 2010 at 10:42 AM

grrr.... I just get used to working with the view as a matrix and you take away the ability to set the view matrix directly.  Is it not possible to have both options?  Otherwise it leaves me in the situation where I already have a matrix, which I have to break up to call SetTransformByLookForward (using the line below), so that function can just build another matrix.  Seems a bit wasteful.  Surely there will always be cases where applying the view matrix directly would be useful.

_engine.Camera.SetTransformByLookForward(_worldMatrix.Translation, _worldMatrix.Up, _worldMatrix.Forward);

Coordinator
Apr 22, 2010 at 6:26 PM

Oh, it would be very useful. But there's no way to derive a reflected camera transform from a raw view matrix. So, if I allow you to set the matrix directly, water reflection cannot work (and other types of rendering). Even the current methods present problems because there's no way to derive a reflected camera transform when looking directly down.

Basically, the whole camera system has to be re-factored to allow you guys to write your own camera transformation methods. I'm working on this right now and will be in the next release.

Apr 23, 2010 at 5:52 AM

Thank you!

You are the hero of the day, this solved my problem.

Apr 23, 2010 at 8:54 AM

OK cool, that explains a lot.  Sounds like you're on top of it then.