Implementation into my engine

Feb 27, 2011 at 7:07 PM

Hello,

i have a little problem implementing Krypton in my engine ...
My engine renders each Camera to the screen. The camera is a RenderTarget (with some additional things like Matrix, Scale, Position, ...) which only draws the visible objects.
I tried to edit the KryptonEngine-class to render only things with the current camera´s matrix and viewport.

I changed those things and it doesn´t cause any errrors, but the problem is, no matter whether i add lights and shadow hulls the result is an black screen.
If i render the cameras object after Krypton, the objects are visible. So the problem is Krypton.

 

I don´t know if the usage is wrong, because there isn´t any tutorial how to do, but i think it´s a problem after changing some methods...

Could you give me some tips what i have to edit, and how the rendering/updating cycle runs, so that i can fix this bug?

PS: My engine is an open source engine ;)

Thanks a lot, your engine is so cool!
I love it. Good work ;)

Coordinator
Feb 27, 2011 at 10:07 PM

Hey, Razor!

I'd love to help you out, and solve any problems you have, and possibly fix any bugs Krypton may have relating to this.

Having you state that your engine is open source, I presume it would be possible to take a look at the source code which is causing you problems? This would be the fastest way for me to figure out exactly what's going wrong, assume I can get everything to compile correctly :)

However, The rundown of krypton is as such (or at least this is how Krypton is *intended* to behave. let me know if it acts otherwise):

  1. Krypton needs to be instantiated, and various static settings need to be set (blur, ambient color, usually cull mode [if using a fancy transformation method, or using SpriteBatch for rendering]).
  2. Krypton needs to have lights and hulls added to draw with.
  3. Krypton's Matrix need be set, to match the current camera (It's possible your issue lies here).
  4. Krypton needs to "prepare" light maps. This means that Krypton will render the lights and hulls according to the settings you provide.
  5. All other rendering should be done at this point (unless your main back-buffer will retain it's values after having switched render targets, in which case this step and step and the prior step can be swapped).
  6. Krypton will draw (multiply) itself on top of the back-buffer, as to apply the light map.

Obviously, rendering can be done in different orders to achieve different effects (such as the backdrop [mountains, cityscape, etc] not being effected by the light map).

It sounds like you're using multiple cameras. Are you making sure to set Krypton's Matrix property to match the WVP matrix of each camera before drawing?

Also, Krypton currently only supports one light map at a time (multiple lights, but only one target), this drawing multiple cameras may be overwriting the current data in the light map for each individual camera. There's many things that can go wrong here, as I haven't added multiple camera support, etc.

Please let me know if this helps, and also where I can find the engine so I may further investigate the issue. Thanks! :)

Feb 27, 2011 at 10:59 PM
Edited Feb 27, 2011 at 11:03 PM

It´s a bit difficult to show you the source. It´s not because i don´t want to make the source public until the first stable Beta, but the engine is seperated in many special parts and it would be difficult to show them all you need to detect the bug ;)

But i think we can solve the problem also in such a way.

After you said i must set the CullMode, i tried it with "CullMode.None". So, the lights got drawn.
Nicely done :) But the lights are only some squares with no "light"-effect.

 

The Rendering is done like this:

  • Foreach Camera
    • Foreach Renderobject
      • Draw (optionally with shaders)
    • Draw Lightmap

And it works a bit. But no objects are visible by the lights. And yes, i´m using multiplie cameras, because this is a important thing for games ;)
I only changed the methods of Krypton so that it uses the properties of the current drawn camera.

 

What do you think is the reason for this bug?
I´m using the spritebatch-compatibility mode. The lights got drawn, but no objects are visible ...

Here i packed you some pieces of the source, the ones important for you:
http://twistedarts.bplaced.net/download/MysteriousBug.zip

Contains the sandbox-game for testing, the render-part, the modified engine-class and the modified RenderHelper ;)
Maybe you find something :)

EDIT: Something i want to tell you: Krypton needs a lot of time to render, don´t it? My framerate sways between 20-50FPS (without lights).
Maybe i optimize it to draw only visible lights :D but first of all i must fix this bug :D

Thanks
Razer

Coordinator
Mar 2, 2011 at 5:31 AM

Apologies, I haven't had time to review your code yet. I will get to it when I am able.

Mar 3, 2011 at 3:47 PM

I noticed your busy :D

But thats no problem. I have enough other things to work on - and by the way, i´m busy too ;)

Coordinator
Mar 16, 2011 at 6:36 PM

Razer,

Can you post a picture of the problem you're seeing? That would be very helpful.

Mar 19, 2011 at 2:12 PM

I would if my graphics card weren´t broken ...

I will post you a screenshot when i´m able to make one ;)

Apr 3, 2011 at 8:41 PM

Hello,
i were able to repair my graphics card and here is your image:

http://img534.imageshack.us/i/krypton.png/

greetings Razer

Coordinator
Apr 8, 2011 at 5:43 PM

Razer, I'll take a look at your source code in conjunction with the image as soon as I am able.

Jun 16, 2011 at 7:05 PM

Hello,
it would be nice if you could take a look at it the next time :)

Thanks
R

Coordinator
Jun 20, 2011 at 5:53 PM

Razor,

I took a look at the source code you provided some time ago, but I was unable to follow the code clearly in the amount of time I had to spend on the subject. I was hoping to spend more time later, but it be schedule is spread thin. I do not know when I will be able to find a solution for you.