Mark Wayland | 1 Oct 2007 03:11
Picon
Favicon

Re: [Algorithms] Entity Management, Messaging and Traversal

> I should also remind people of something mentioned in last year's
> sweng-gamedev thread: Someone much wiser than me pointed out that Halo 2
> used a fairly bare-bones C system written for ultimate efficiency, and
> Stranger's Wrath used a flexible C++ multiple-inheritance component
> scheme. They both got extremely high quality results from the same
> hardware, which might suggest that entity systems aren't something to be
> too religious about. (Pendantry: I guess the Xbox CPU is better at virtual
> method calls than most other consoles, but that doesn't totally invalidate
> the point.)

My understanding of the whole entity thing: do whatever you need to. Odds 
are your entity updates are not on top of your game's performance profile 
anyway. I think ours take about 2-3% of a frame.
Our top 3 offenders are almost always renderer, physics and sound systems 
(on consoles anyway).

We use a hard-coded component aggregation mechanism rather than the generic 
"bucket-o-bits" technique to avoid the "what the hell are you" RTTI or GUID 
thing. I should mention we're almost totally pure "C" so we obviously don't 
use abstract interfaces per-se or multiple inheritance or any such stuff. 
Basically our designers have a palette of pre-built components and they can 
link them together so that one (or more) outputs can trigger inputs. We 
haven't needed anything more complex than that, but we've yet to work on a 
full RPG scenario :-)

For those interested, there's a neat set of slides over at Insomniac's R&D 
page with relevance to this topic: 
http://www.insomniacgames.com/tech/articles/0807/a_gameplay_architecture_for_performance_clean.php

Cheers,
(Continue reading)

Jason Hughes | 1 Oct 2007 04:06

Re: [Algorithms] Normal Reconstruction

Joe,

Maybe they're suggesting this optimization only works when you're doing backface culling...?  That way, you know the Z must always point toward the camera, or the triangle would have been culled.  It's true that the sign of the normal of a triangle cannot change over Cartesian projections, so this seems to be a valid optimization.  That is, assuming culling, which most of us do.

I hope I'm not barking mad on this.  :-)

Thanks,
JH

Joe Meenaghan wrote:

Hi All,

From time to time I come across a statement, typically associated with optimizations for deferred shading, that says that, given two out of three original components, you can reconstruct a normal using a bit of pixel shader math. Fair enough, but it goes on to say, that by working in view space, we are assured a consistent sign for the (z) result and consequently, we don't need to tuck it away elsewhere (say by making something that is normally unsigned signed, and then abs'ing it later after extracting the sign for the normal component). Now while I fully understand how the magnitude of the missing component can be reproduced, it is the sign part that I struggle with. 

I consider just the simplest of scenarios with a camera located at the origin facing down the positive Z axis (i.e., an identity view matrix in D3D). Assume the camera is looking down a hallway with two parallel flat wall polygons to either side, with opposing normals (x = +/- 1). Now, the moment we just slightly rotate the camera (or better yet, leave the camera fixed, and just slightly rotate the hallway) left or right, we get a situation where one of those plane normals will have a positive z value in view space and the other will have a negative one. Mind you, we can still see both polygons here; it's not like one of them is now suddenly being clipped or backface culled away as we've only changed orientation ever so slightly. But these two guys now clearly have z components with opposite signs in view space.

I've now seen this statement concerning the consistency of the sign of z in view space made in a couple of popular shader programming books, a research paper on deferred shading, and here and there on the net (message boards, presentations, etc.). Thus, I have to be missing a key element that is critcal to making this technique work, no? It would be virtually impossible for all of these various folks not to have considered just the simple case stated above, so the misread must clearly be mine. I would really appreciate it if someone who might be using this reconstruction approach could clear this up for me, because it's been driving me and one of my colleagues nuts trying to figure out how it can possibly work reliably. In practice, we've been happily storing all three components of our normal in our deferred renderer and everything works just fine, but I might be able to make use of an extra storage slot if it were to open up. But even if I don't, I sure would not mind clearing up my apparent misconceptions either way.

Thanks in advance for any insight you can provide.

Joe Meenaghan
 
 
------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ GDAlgorithms-list mailing list GDAlgorithms-list <at> lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list Archives: http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithms-list
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
GDAlgorithms-list mailing list
GDAlgorithms-list <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list
Archives:
http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithms-list
Jon Watte | 1 Oct 2007 04:15

Re: [Algorithms] Normal Reconstruction


Jason Hughes wrote:
> Maybe they're suggesting this optimization only works when you're 
> doing backface culling...?  That way, you know the Z must always point 
> toward the camera, or the triangle would have been culled.  It's true 
> that the sign of the normal of a triangle cannot change over Cartesian 
> projections, so this seems to be a valid optimization.  That is, 
> assuming culling, which most of us do.

But when normals are interpolated, you may actually end up drawing a 
normal that points into the screen. Vertex normal != face normal. For 
small-ish faces and well-behaved geometry, you won't get normals with an 
enormous amount of deviation, but I would expect to see small fringe 
effect at the edges of such polygons.

Cheers,

          / h+

--

-- 
-- Revenge is the most pointless and damaging of human desires.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
GDAlgorithms-list mailing list
GDAlgorithms-list <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list
Archives:
http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithms-list

Jason Hughes | 1 Oct 2007 04:38

Re: [Algorithms] Normal Reconstruction

Jon Watte wrote:
Jason Hughes wrote:
Maybe they're suggesting this optimization only works when you're doing backface culling...?
But when normals are interpolated, you may actually end up drawing a normal that points into the screen. Vertex normal != face normal. For small-ish faces and well-behaved geometry, you won't get normals with an enormous amount of deviation, but I would expect to see small fringe effect at the edges of such polygons.
You're right, of course.  And if you were committed to using geometric vertex normals (face area weighted shared normals) in any form, this issue still will crop up when a poly is almost edge-on to the camera and its normal should point away from the screen slightly. 

I haven't read these articles; my guess was intuitive but not definitive.  Is it possible the articles also assume normal maps, where you assume the normals do not point backward along the face normal?  You can effectively clamp any normals that would face backward anyway, since the triangle itself would be backfacing in order for that texel-normal to matter.  Still missing a trick here, perhaps?

Re-reading the OP's question, he seemed to be asking about how an object rotated so that its two opposing faces would have Z pointing in opposite directions but still be visible.  Those normals are still in either object or world spaces, not transformed to view space.  By the time they're in view space, their face normals would definitely point toward the camera or they'd be backfaced, so the shader would not (typically) see them as having opposing signs at all, except in the case Jon mentioned above.

HTH,
JH
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
GDAlgorithms-list mailing list
GDAlgorithms-list <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list
Archives:
http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithms-list
Gribb, Gil | 1 Oct 2007 14:09

Re: [Algorithms] Normal Reconstruction

No, you can’t really reconstruct the normal without the sign bit.

 

For polygon normals, maybe at a stretch you could get by without the sign bit, but when talking deferred shading, generally we are talking about normal mapping, in which case, there are essentially no restrictions on which way the normal mapped pixel faces, and it is quite independent of the direction that the polygon faces. You need the sign bit.

 

-Gil

 

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
GDAlgorithms-list mailing list
GDAlgorithms-list <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list
Archives:
http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithms-list
Nick Trout | 1 Oct 2007 17:10
Favicon

Re: [Algorithms] Entity Management, Messaging and Traversal


> Matthew Harmon
> While most operations we use (Draw(), Update (), etc.) are required by
most entities, there are some that only apply to a small number of
objects.  For example, a PhysicsUpdate() call [...] My initial reaction
is to create a publish/subscribe scheme [...]


(Apologies for late reply, been on holiday. Hopefully I'm not repeating
anyone here. At least I haven't seen this version stated explicitly)

I think if you added a publisher-subscriber mechanism you're just adding
a generised interface registration system. Why not just add C++
interfaces? i.e. IRender, IPhysics, INpc, etc and register these at
construction time with the appropriate systems (*1)? One thing I've
noticed about making things overly generic is that it confuses people
(*2). If things aren't generic enough and people are limited that points
to a design flaw which you, well, have to design to fix (good!). P-S
will more than likely become a soup of crazy topic registrations which
obscures your game architecture (e.g. dependencies are no longer clear)
-- "Oh, I can't see how these two objects relate to each other, so they
obviously need a new topic to communicate..."

I agree with what has been said about inheritance, you should always use
sparingly (to avoid suck). I agree with what Tom says about components
as well (if you have to query for other components at some point you'll
break the encapsulation). I think the trick is to make sure you can wire
up you component at creation time, i.e. the entity constructor/factory
has all the necessary information to create an entity. This can be made
easier by having higher level, more specific entity types, which
generalise a specific behaviour (e.g. character, vehicle, building, etc)
and then you specialise these with data (e.g. hit points, meshes,
textures, LOD, damage, sounds etc). If you want to update particle
effect attached to object you do it in there. And you can add your
special cases there (*3).

Nick

(*1) They don't all have to be implemented by the same object. Objects
created by the entity at creation time (that implement, say, IRender)
might be registered. This is probably better OOP as well because IRender
is usually not an interface it's a RenderableObject IYGMD.  -- I think
this lends itself more to the AOP style mentioned in the Insomniac paper
(I think they've just used a C version of C++ AOP here because SPUs
don't like C++)

(*2) The very term "entity system" is a case in point. Ask 3 people what
it is and you'll get 3 different answers. Asset systems have also been
mentioned in this discussion, but they are for requesting and managing
assets, but some people call them components.

(*3) Oh come on! How many times have you had to put a hack in to ship or
provide a special mission functionality? Ship happens! Why not design it
in.


**********************************************************************************
Disclaimer

The information and attached documentation in this e-mail is intended for the use of the addressee only and
is confidential. If you are not the intended recipient please delete it and notify us immediately by
telephoning or e-mailing the sender. Please note that without Codemasters’ prior written consent any
form of distribution, copying or use of this communication or the information in it is strictly
prohibited and may be unlawful. 

Attachments to this e-mail may contain software viruses. You are advised to take all reasonable
precautions to minimise this risk and to carry out a virus check on any documents before they are opened.

Any offer contained in this communication is subject to Codemasters’ standard terms & conditions and
must be signed by both parties. Except as expressly provided otherwise all information and attached
documentation in this e-mail is subject to contract and Codemasters’ board approval.
Any views or opinions expressed are solely those of the author and do not necessarily represent those of Codemasters.

This footnote also confirms that this email message has been swept by
SurfControl for the presence of computer viruses.
**********************************************************************************

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
GDAlgorithms-list mailing list
GDAlgorithms-list <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list
Archives:
http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithms-list
Nick Trout | 1 Oct 2007 18:06
Favicon

[Algorithms] Asset management/rejection - was RE: Entity Management, Messaging and Traversal


> Conor Stokes:
> [...] All assets go into a single asset register [...]

I can see how you request assets (and having a separate asset management
system under your entity system is a good idea); but what you don't
mention is rejecting assets. I.e. world streaming console game.

Do you do any streaming and/or prioritisation? Situations may occur
where you have fragmentation and/or run out of memory. Do you stream
LODs, damaged objects? Do you prioritise loading order and rejection of
unnecessary (or lower priority assets)?

What other schemes do people have?

Nick

**********************************************************************************
Disclaimer

The information and attached documentation in this e-mail is intended for the use of the addressee only and
is confidential. If you are not the intended recipient please delete it and notify us immediately by
telephoning or e-mailing the sender. Please note that without Codemasters’ prior written consent any
form of distribution, copying or use of this communication or the information in it is strictly
prohibited and may be unlawful. 

Attachments to this e-mail may contain software viruses. You are advised to take all reasonable
precautions to minimise this risk and to carry out a virus check on any documents before they are opened.

Any offer contained in this communication is subject to Codemasters’ standard terms & conditions and
must be signed by both parties. Except as expressly provided otherwise all information and attached
documentation in this e-mail is subject to contract and Codemasters’ board approval.
Any views or opinions expressed are solely those of the author and do not necessarily represent those of Codemasters.

This footnote also confirms that this email message has been swept by
SurfControl for the presence of computer viruses.
**********************************************************************************

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
GDAlgorithms-list mailing list
GDAlgorithms-list <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list
Archives:
http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithms-list
Jamie Fowlston | 1 Oct 2007 18:35
Favicon

Re: [Algorithms] Asset management/rejection - was RE: Entity Management, Messaging and Traversal

Nick Trout wrote:
>> Conor Stokes:
>> [...] All assets go into a single asset register [...]
> 
> I can see how you request assets (and having a separate asset management
> system under your entity system is a good idea); but what you don't
> mention is rejecting assets. I.e. world streaming console game.
> 
> Do you do any streaming and/or prioritisation? Situations may occur
> where you have fragmentation and/or run out of memory. Do you stream
> LODs, damaged objects? Do you prioritise loading order and rejection of
> unnecessary (or lower priority assets)?
> 
> What other schemes do people have?

<shameless plug>

Our Q 2.0 middleware is built from the ground up to do streaming of 
everything on all platforms. It's a plugin framework, so the actual 
policy varies from plugin to plugin, allowing developers to take 
advantage of what they know about their world that we don't; but I can 
tell you the policies for the standard plugins.

Conceptually, we have a division between required and luxury objects. 
Required objects have to be loaded before you're ready to go, luxury 
objects don't. Luxury objects are kept on a priority queue, and managed 
in various ways (according to asset type, cache size, etc.) to keep 
things looking as nice as they can (which varies from app to app, of 
course).

The default plugins tie this closely to LOD. Textures and LOD objects 
have a minimum required level (i.e. a certain number of the lowest LODs 
are required, the rest are luxury), set per object.

An early version of this can be seen in our Earthsim project 
(http://www.earthsim.tv), which currently uses the prototype Q 1.x of 
our current tech; when both the Earth and the Moon are on screen at the 
same time, that's about 3GB of texture on screen (when decompressed). 
We've had it running on a 16MB graphics card, which was nice (it ran 
slowly because a card that old couldn't handle the vertex load well, but 
the texture management worked nicely).

As for fragmentation, we have a good allocator, and as long as it's got 
a bit of slack to play with, it's just worked so far; when you're 
streaming everything, you've much more memory to play with, so that 
slack is sensibly available. And if it ever doesn't work, it's easy to 
plug in a specialized allocator to handle the special case.

</shameless plug>

Jamie

> Nick
> 
> **********************************************************************************
> Disclaimer
> 
> The information and attached documentation in this e-mail is intended for the use of the addressee only
and is confidential. If you are not the intended recipient please delete it and notify us immediately by
telephoning or e-mailing the sender. Please note that without Codemasters’ prior written consent any
form of distribution, copying or use of this communication or the information in it is strictly
prohibited and may be unlawful. 
> 
> Attachments to this e-mail may contain software viruses. You are advised to take all reasonable
precautions to minimise this risk and to carry out a virus check on any documents before they are opened.
> 
> Any offer contained in this communication is subject to Codemasters’ standard terms & conditions and
must be signed by both parties. Except as expressly provided otherwise all information and attached
documentation in this e-mail is subject to contract and Codemasters’ board approval.
> Any views or opinions expressed are solely those of the author and do not necessarily represent those of Codemasters.
> 
> This footnote also confirms that this email message has been swept by
> SurfControl for the presence of computer viruses.
> **********************************************************************************
> 
> 
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2005.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> GDAlgorithms-list mailing list
> GDAlgorithms-list <at> lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list
> Archives:
> http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithms-list

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
GDAlgorithms-list mailing list
GDAlgorithms-list <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list
Archives:
http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithms-list
Jeff Russell | 1 Oct 2007 18:49
Picon

[Algorithms] water reflection clipping

I'm debugging some artifacts in our water rendering, and I'm wondering if anyone here has some suggestions. Basically our water reflection image is generated by rendering the scene upside down and clipping the geometry on the water plane. Standard deal. It's this clipping that is problematic.

Fast hardware support does not seem to exist for user clip planes, i.e. simply calling glClipPlane or d3d equivalent. I'd like to avoid doing this clipping in shader code, since i'd have to make a 'reflection' mode for all our shaders (and we have several), and alpha test is out because it's used for other things already on objects that need to be clipped. So instead I tried setting an oblique near plane with a custom projection matrix to get the same result (see http://www.terathon.com/code/oblique.php). It works, but now we are getting clipping artifacts. Seems like they come in two forms:

#1 - A tiny gap appears along an object's intersection with the water plane, which allows the viewer to see inside or behind the object's reflection. This is likely due to the distortion applied by our shader to the reflection image, and it occurred before we switched to using an oblique near plane so its probably always a problem with water reflections. A small bias to the reflection plane solves this for nearby objects, but large / distant objects such as terrain still exhibit this artifact, even with a large bias.

#2 - More specific to the oblique near plane, when the camera gets very close to the water plane, the reflection far plane seems to quickly creep forward and start chopping off distant objects in the reflection image. Not sure what's going on with this, it seems to be a difficult case for the oblique near plane projection matrix.

Anyone had these problems before? I like the idea of an oblique near plane, but its causing some fairly serious problems in the form of (#2).

Thanks

Jeff Russell
8Monkey Labs

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
GDAlgorithms-list mailing list
GDAlgorithms-list <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list
Archives:
http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithms-list
Jason Hughes | 1 Oct 2007 19:03

Re: [Algorithms] Asset management/rejection - was RE: Entity Management, Messaging and Traversal

Nick Trout wrote:
> I can see how you request assets (and having a separate asset management
> system under your entity system is a good idea); but what you don't
> mention is rejecting assets. I.e. world streaming console game.
>
> Do you do any streaming and/or prioritisation? Situations may occur
> where you have fragmentation and/or run out of memory. Do you stream
> LODs, damaged objects? Do you prioritise loading order and rejection of
> unnecessary (or lower priority assets)?
>
> What other schemes do people have?
>
> Nick
>   

Nick,

I've been working on a system on and off that gives control over some 
aspects that I haven't seen in my other work experiences.  Typically, a 
level is built by assembling the runtime assets required for the level.  
This is where the memory crunch can occur, and a lot of back-and-forth 
with artists and designers to get them to keep their assets small enough 
that they fit, often without knowing whether the level actually *fits* 
until you fail when loading.  The failure could be from memory allocator 
woes, actual lack of memory, or failing to stream in time for the 
transition (seek time or transfer rates on the edge of a disc, etc).

My system is based on an explicit graph, so I know all the possible 
streaming transitions, including GUI pages that pop up but aren't always 
loaded with another level, etc.  Each of these nodes represents a 
loadable game state.  The whole thing must load, so I don't have the 
notion of "rejectable" data... in a well-designed game, with a 
well-designed engine, you shouldn't need to put such a burden on the CPU 
during load time.  Loading should be dumb and move the smarts to the 
tools, IMO.

I can't talk too much about the system I'm working on, because it's 
something I plan to eventually license once it's built.  But, the 
feature set is: complete foreknowledge of the loading details, down to 
the address each chunk should load to burned into the chunk by the 
tools; automatic setting of memory budgets per chunk of the game based 
on streaming transitions; aggregating shared assets between transitions 
to reduce streaming time; and automatic detail reduction of assets to 
meet the necessary budgets.

In short, taking human error, memory allocators, and seek times out of 
the equation.  :-)

JH

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
GDAlgorithms-list mailing list
GDAlgorithms-list <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list
Archives:
http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithms-list


Gmane