This project is read-only.

Coordinate System and "Grouped Hulls"

Dec 13, 2011 at 8:35 PM

I have attempted to implement krypton in my project and found that a light drawn at (0,0) would appear in the middle of the view and that Y increases as you move up the view.

I would find it easier if krypton's coordinates where the same as sprite batch (with (0,0) being in the top left hand corner and Y increasing as you go down). Is this a stupid thing to want? If not how would I go about achieving this?

Many thanks for your help!

Dec 14, 2011 at 1:49 AM

Is this a stupid thing you want? No!

Is this a stupid thing to ask of us? No!... well... maybe a little. But that's only because we've already given you access to do this! :)

You can tell Krypton to account for Sprite Batch... I think there's a property called SpriteBatchCompatabilityMode, and you can set this to true. Then set Krypton's Matrix to an identity matrix, or the matrix you're passing to SpriteBatch.

Hope this helps!

I'm working on Krypton 3.0, which will also include a good amount of tutorials. If you need further help now, however...

  • First, I need to know what version of Krypton you're using (I presume 2.0, but I could be wrong).
  • Second, I need to see a portion of your drawing code (you're SpriteBatch.Begin, and at least one of you're SpriteBatch.Draw calls).
Dec 14, 2011 at 2:14 AM
Edited Dec 14, 2011 at 2:15 AM

Thanks for the swift reply!

I'm sorry I didn't manage to update my question sooner! I found another discussion where you had helped someone with a similar issue and managed to do as you described - all appears to be working :)

I do have one other question (or possibly a feature request I'm not sure!).

I am using Farseer physics engine to make convex hulls from Texture2D. This all appears to be working. The result of this is that my image is represented by several Shadow Hulls. Krypton lights these and they cast shadows on each other (as would be expected).

However I don't want these convex hulls to cast shadows on one another - the represent the same image! This causes some parts of the image to be lit while others are in shadow. What I do want is for them to collectively produce a shadow that can fall on other shadow hulls.

Would it be possible for me to "group" these hulls so they wont cast shadows on each other but will cast shadows on any other shadow hulls?

Many thanks again for you help, I'm sorry I didn't search harder before asking my first question :(

edit: Forgot to say I am using the newest version of Krypton.

Dec 14, 2011 at 4:14 PM

Boo, Krypton does not have the ability to do this... yet.

Here's a little story about how Krypton's "Occluded" light works (I believe this is what you're using, based on your comments):

  1. First, we draw (stretch) each shadow (all at the same time) based on the light's position. Each time we draw a shadow, we increment the stencil buffer by 1 for that pixel. This means that if we draw a shadow overlapping another shadow, the overlapping part has a stencil value of 2, the non-overlapping parts have a stencil value of 1, and the parts that were not drawn get a stencil value of 0.
  2. After all the shadows are drawn to the stencil, we change the stencil function to decrement, instead of increment. This means that when we draw, the stencil value will go *down* by one.
  3. Draw the shadow hull's again, but *this time* we don't stretch them. This means that we're making little cutouts where the hulls are, but ,leaving the actual shadows in place. Imagine holding a cookie cutter against a table and shining a flashlight at the side of it. The shadow extends past the cookie cutter onto the table (that's the stretching). Now imagine we allowed the center of the cookie cutter to be filled with light, illuminating that part of the table too, but still leaving the shadow in place. This is essentially what this step does (allows the center of the cookie cutter to be filled with light). But, if there's another cookie cutter in the half-way inside the shadow of the first, that one only gets "half" illuminated in the center, because the other half has been "occluded" (thus the name of the technique).
  4. Draw the lights only where the stencil is equal to 0. (non-occluded parts, and the cut-out parts).

I've explained all this to say... Krypton can't support what you're asking for, unless we write a new shader to support it. Which, I'm totally down for. I think I've got a solution. Couple of questions:

  1. Will your group of hulls ever overlap a *seperate* group of hulls? Or, an individual hull, as that would also be considered a group with only one hull in it (think Body/Fixture in Farseer).
  2. If so, what happens to the shadows? Try to explain what you might expect.

In the mean time, try using the Illuminated effect. It doesn't occlude anything, but it will keep you from seeing those nasty artifacts on top of your hulls.

Dec 14, 2011 at 4:15 PM

Also, I'd very much appreciate you openning  a feature request (I could do it, but I like for the community to open as many as possible) for this! :)

Dec 16, 2011 at 4:53 PM

Sorry about the slow reply. I will try to do some tests to find out exactly what I'm after then open a feature request - hopefully in the next day or two.

Dec 20, 2011 at 8:58 AM

I'm working on Krypton 3.0, which will also include a good amount of tutorials. If you need further help now, however...


Jan 13, 2012 at 7:09 PM

Pnikosis, It's under source control, you can find it under "Futures". It's got a different interface, so it's definitely a breaking change. The only improvement (so far) is code design, multiple view ports, and the ability to rotate the view matrix and still use culling. i'm going to add some of features mentioned under the issue tracker as soon as I get a chance.

Jan 16, 2012 at 10:17 AM

Great xixonia!

One small request: Please add access to the resulting rendertarget from outside (maging it public or through a Get call). I know it's a silly change that I could make myself (and I currently do), but it would be nice to have this out of the box, for just downloading nad plugging it in the game :D

I'll defenitively check the latest build now. Thanks!