These are chat archives for ZaneDubya/UltimaXNA

28th
Aug 2015
Jeff Boulanger
@jeffboulanger
Aug 28 2015 02:55
@ZaneDubya u should lighten the shadow the farther away it is, would look better :)
Zane Wagner
@ZaneDubya
Aug 28 2015 03:00
@jeffboulanger Wanted to ask you - know of any way to stop that layering effect?
Like - shadows don't layer?
I could just do what the legacy client does - only shadows for mounts and bodies - but that seems lame.
Jeff Boulanger
@jeffboulanger
Aug 28 2015 03:09
layering?
like 1 shadow on another?
oh i see what you mean
ill have to think about it
Jakob Fries
@serpis
Aug 28 2015 07:08
You could use the stencil buffer
only draw a shadow if there is no shadow there already
could use the stencil buffer for the gump transparency you mention above
reorder so the transparent marker is drawn first, and let it set up a mask in the stencil buffer
Jeff Boulanger
@jeffboulanger
Aug 28 2015 07:35
That's a good idea, I didn't think u could do anything with the stencil buffer in XNA, but apparently you can.
Zane Wagner
@ZaneDubya
Aug 28 2015 08:24
@serpis I like both of those ideas. Two follow up questions for you
Oh, wait. Never mind. I think I've just had a bit of a eureka moment with regards to your comment regarding the stencil buffer for shadows ;)
And I guess I need to do a little more experimentation with gumps before I follow up on the second ;)
Thank you - I've been thinking of using stencils, and hearing someone else say that they're a good solution gives me more confidence to explore using them. As a hobbyist, I have relatively little experience with various graphics and programming techniques, and I'm never quite sure what they're good for.
Zane Wagner
@ZaneDubya
Aug 28 2015 08:42
Screen Shot 2015-08-28 at 3.41.11 AM.png
@serpis Perfect.
Here is my stencil code, so easy:
DepthStencilState dss = new DepthStencilState();
dss.DepthBufferEnable = true;
dss.DepthBufferWriteEnable = true;

if (stencil)
{
    dss.StencilEnable = true;
    dss.StencilFunction = CompareFunction.Equal;
    dss.ReferenceStencil = 0;
    dss.StencilPass = StencilOperation.Increment;
    dss.StencilFail = StencilOperation.Keep;
}
Mind you, the legacy client only displays shadows for the mount and body, and layers them if both are present. We shadow for all items that are worn, and don't layer at all. So this is yet another circumstance where the xna client looks better than legacy.
Jakob Fries
@serpis
Aug 28 2015 09:07
Great!
I'm curious, how do you draw the shadow?
it is the same graphics as the avatar, but skewed?
Zane Wagner
@ZaneDubya
Aug 28 2015 09:20
Yes!
If you give me a moment, I'll link to the relevant code.
MobileView sets DrawShadow = true in its ctor, then draws a sprite for each of its layers here: https://github.com/ZaneDubya/UltimaXNA/blob/master/dev/Ultima/World/EntityViews/MobileView.cs#L120
(by calling base.Draw(); base is AEntityView)
And if it is true, calls SpriteBatch3D.DrawShadow() here: https://github.com/ZaneDubya/UltimaXNA/blob/master/dev/Core/Graphics/SpriteBatch3D.cs#L132
Could have a better name for that boolean, I think. IsShadowCasting? ;)
Zane Wagner
@ZaneDubya
Aug 28 2015 09:27
@serpis Back to stencils for gumps... part of my problem in implementing the transparency is that the gump drawing engine in the legacy client is not documented, at all. I don't know if the { checkertrans } element effects the transparency of all elements under it, or only gumppics, etc. Which is vital to know for drawing order.
Zane Wagner
@ZaneDubya
Aug 28 2015 09:35
Is it possible to draw to the stencil buffer without drawing to the texture buffer?
Jakob Fries
@serpis
Aug 28 2015 09:37
in general yes, but I don't know about XNA
it should be fairly easy to check the rules for transparency in the legacy client by just generating a bunch of combinations of gump commands and noting the result
why do you draw to something other than the output frame buffer, by the way?
Zane Wagner
@ZaneDubya
Aug 28 2015 09:39
Let me run a quick check in runuo...
Zane Wagner
@ZaneDubya
Aug 28 2015 09:45
It looks like transparent elements overwrite all elements below them, with the exception of HtmlGumplings.
In fact, it looks like htmlgumplings are not effected by transparent elements at all.
I don't think it's essential that we match the htmlgumpling edge case.
Jakob Fries
@serpis
Aug 28 2015 09:46
what about buttons
Zane Wagner
@ZaneDubya
Aug 28 2015 09:46
Buttons, yes.
Sanity check me here: we could draw the elements in reverse order, from top to bottom, decrementing Z as we do so. When we hit a transparent element, we write the transparency checkerboard texture to the stencil buffer. Then, as we continue drawing elements, we check the stencil buffer and fail if it has been written to. If that sounds good, my only remaining question would be how we could write to the stencil buffer while not writing to the texture buffer (frame buffer, you called it?)
Zane Wagner
@ZaneDubya
Aug 28 2015 09:52
"color buffer" perhaps.
I see that opengl has a glColorMask function! Perhaps XNA has something equivalent.
Yes! XNA encapsulates that behavior in the BlendState object. Cool.
I think I'm good to go then.
Jakob Fries
@serpis
Aug 28 2015 09:56
nice!
Zane Wagner
@ZaneDubya
Aug 28 2015 09:56
Thanks serpis!
I'm going to go back to bed, it's early here. Have a good on!
*one
Jakob Fries
@serpis
Aug 28 2015 09:57
no problem! good luck
Zane Wagner
@ZaneDubya
Aug 28 2015 19:37
The legacy client had some really clever ways to reduce overdraw without a depth buffer; one of these was to hide mobiles that were under a roof/surface tile, and there were also roof/surface tiles at tiles offset (x+1,y+1) and (x+2,y+2). I've implemented this in the xna client.
I've also fixed some deferred drawing bugs, making the xna client's deferred rendering better match the legacy client's, and closed issues #184 and #316. 24 open issues left in Milestone 0.7. :)
Zane Wagner
@ZaneDubya
Aug 28 2015 19:46
On a completely unrelated note, I'm sure you'll all get a kick out of this javascript: http://i.imgur.com/g96QleC.png
Jeff Boulanger
@jeffboulanger
Aug 28 2015 20:41
ya javascript is a mess, thats why they had to introduce strict comparisons
https://www.destroyallsoftware.com/talks/wat this guy pretty much describes all the wtf's ;)
{} + [] is a fun one
Zane Wagner
@ZaneDubya
Aug 28 2015 20:46
object + array?
haha, what does that equate to?
Jeff Boulanger
@jeffboulanger
Aug 28 2015 20:47
0
{} + {} = object
dmurphy22
@dmurphy22
Aug 28 2015 22:18
That is... hurting my brain.
Zane Wagner
@ZaneDubya
Aug 28 2015 22:36
I did a stint with javascript. The most mind-boggling behavior is that 'this' loses its context in a callback.
There's a workaround, of course. But seriously.