# wild_pointer

Members

1985

291 Neutral

• Rank
Contributor
1. ## Horizon:zero Dawn Cloud System

My results look a bit like yours, taylorswift: If I drop the absorption rate to get rid of the dark areas then the clouds get blown out. But I'm not modeling scattering yet, so I think this makes sense. The only light is that which comes directly from the sun but isn't absorbed on the way. I'll see what happens when I add ambient lighting and the henyey greenstein term but right now I'm trying to make sure what I already have is correct-ish. But it looks like you already have both. What happens if you remove them? I'm not very happy with my cloud shapes either. I don't get very clean edges even at really high sample counts. It ends up looking pretty fuzzy. Your first image looks really good in that respect. Maybe I need some kind of exponential ramp on the density. I also don't like how the clouds appear near the horizon but in that case I might just need some fog. Really looking forward to Andrew's talk in a couple weeks.
2. ## How to find PDF to use with importance sampling

I was looking at this post: http://blog.tobias-franke.eu/2014/03/30/notes_on_importance_sampling.html which shows how to derive the sampling function for both Phong and GGX distributions given the PDF, but I'm not sure how the author got the PDF to start with?
3. ## Terminology regarding splines

I'm curious. Given a spline we can evaluate it's position at any point P=[0..1] along a segment. Does P have a name? Similarly, if we have a point P=[0..N] where N is the entire length of the spline, does that P have a name? I'm trying to make it easier to distinguish between position as a float and position as a point in some code I've written
4. ## World Space to Clip Space

From world coordinates i'd like to get back coordinates in 2D in the range [-1, 1]. I can get there by discarding the Z component if I transform into clip space, right? I'm having trouble trying to remember how this works and when I google it I usually just get suggestions to use some handy-dandy API function that isn't available to me If I have... [code] vec3 p(30, 30, -1500); p = vec3.transform(p, viewMatrix); p = vec3.transform(p, projMatrix); [/code] Now what space is 'p' in?
5. ## Ignoring contacts involving seams between tiles

I'm working on a game where the world is composed of tiles. I'm using a simple SAT implementation to generate contacts. This works fine for the most part except for the following situation:[img]http://content.screencast.com/users/hahanoob/folders/Jing/media/06e0ec1e-be14-46db-bf97-74f64d4b5954/2011-09-12_1629.png[/img] The blue box is my player and is separated from the yellow box by 0 units along the Y-axis and so I generate a contact between the blue box and the yellow box with the normal <0, 1, 0> and distance 0. Which is fine. Now the player is trying to move left and it finds that it's also 0 units from the red box but on both the X-axis and the Y-axis. If I'm allowed to move over the seam comes down to the order I test the axes. If I test the Y-axis first I generate a contact with normal <0, 1, 0> and distance 0. Then I test the X-axis and I get <-1, 0, 0> and distance 0 but that's ignored because the distance isn't any closer to the first one. That's fine too. But if I test the X-axis and then the Y-axis I'm prevented from going over the seam. Obviously I can just always test the Y-axis first but then my problem just becomes sliding along walls instead of sliding along the floor. Is there some common approach to dealing with this problem? I've looked a little into welding but in my game you can add and remove tiles during gameplay so it would need to be something that could be done really quickly. I could also probably do something like tagging the faces of the blocks as obscured/ignored but that's starting to seem hacky and would start to add coupling between my physics systems and game code. Hoping for a more general solution and I'm sure I'm not the first to run into this anyways
6. ## Speculative contacts and AABB vs AABB

I've been playing with speculative contacts as described by Paul here: [url="http://www.wildbunny.co.uk/blog/2011/03/25/speculative-contacts-an-continuous-collision-engine-approach-part-1/"]http://www.wildbunny...pproach-part-1/[/url] My game world is made up mostly of AABBs which I use as tiles. The speculative contacts require that I supply a positive "penetration distance" to the contact solver so collisions can be dealt with before they're actually solved. To do this in the AABB vs AABB case, I just kinda adapted the normal overlap test: [code] public void Collide(Vector3 position, Shape otherShape, Vector3 otherPosition, ref List<Contact> contacts) { if (otherShape is AABB) { AABB otherAABB = (AABB)otherShape; Vector3 displacement = position - otherPosition; Vector3 seperation = Utils.Abs(displacement) - (HalfWidth + otherAABB.HalfWidth); bool overlapping = seperation.X < 0 && seperation.Y < 0 && seperation.Z < 0; if (seperation.X >= seperation.Y && seperation.X >= seperation.Z) { contacts.Add(new Contact(displacement.X > 0 ? Vector3.UnitX : -Vector3.UnitX, overlapping ? -seperation.X : seperation.X, seperation)); } else if (seperation.Y >= seperation.X && seperation.Y >= seperation.Z) { contacts.Add(new Contact(displacement.Y > 0 ? Vector3.UnitY : -Vector3.UnitY, overlapping ? -seperation.Y : seperation.Y, seperation)); } else if (seperation.Z >= seperation.X && seperation.Z >= seperation.Y) { contacts.Add(new Contact(displacement.Z > 0 ? Vector3.UnitZ : -Vector3.UnitZ, overlapping ? -seperation.Z : seperation.Z, seperation)); } } else { throw new NotImplementedException(); } } [/code] Kinda ugly but seemed to work well enough. The problem I ran into is this case: [img]http://content.screencast.com/users/hahanoob/folders/Jing/media/4c201ce5-ca4a-4058-9ab9-95c2e638ab77/2011-08-05_1729.png[/img] The red arrow represents the blocks velocity. The rest are static (my ground). In this case, the penetration in X and Y are equal so my logic above will just select the first case and a contact will be created along the X-axis with distance = 0. That is.. not quite right. I kinda hacked around this by just throwing away contacts that have 2 or more components of the penetration = 0 but obviously that's not right either. The problem seems to be that my distance check is completely wrong in the case where they are not overlapping as checking the distance along each axis like I'm doing is only really works when they overlap on at least one of those axes. Unfortunately, it seems finding the distance between 2 AABB is a fairly uncommon operation since google isn't much help. I think the minimum amount of work I would need to do is to find the distance between each point on 1 aabb and each face on the other? I think I'm mostly looking for a sanity check before I go forward, so any thoughts would be appreciated.
7. ## Walking - Logic

[quote name='Silenex' timestamp='1306784197' post='4817629'] The movement doesn't start after the button is released. It starts while the button is being pressed. I know my method doesn't work. I'm not a very experienced game developer and it's the small things like this that get me stuck. What I want to happen: If the button is pressed for a short period of time it will just turn the user. If the button is held for a longer period of time it will move the user continuously between tiles, without a short pause between tiles. [/quote] The formatting makes it seem so at a glance. At any rate, my advice stands. There's not really enough information to guess what might be wrong. I have no idea what your animate or move functions do or how you detect that you've reached a new tile and what you do then. Who knows, maybe the animation itself just doesn't loop seamlessly. There's nothing really special to game development in this case, if you're an experienced programmer then bring your standard deductive reasoning skills to to bear =P
8. ## Walking - Logic

[quote name='Silenex' timestamp='1306779872' post='4817601'] Sorry I wasn't clear. The player does move incrementally, it's a smooth animation during which there's also a walking animation played on the character. The reason there's a 6 frame delay for walking is because there's also the ability to turn in place. I didn't include that in the pseudo-code, but basically any pressing of the key less than 6 frames long will simply turn the player in place rather than move them. [/quote] How would you expect movement to continue through multiple tiles when movement only begins after you have held down the key and then release it? I'd suggest better separating the moving and turning states of the player and better defining exactly what you want to have happen when the player presses the movement button and then proceeding from there.
9. ## Detecting collisions between large numbers of static objects

[quote name='SimonForsman' timestamp='1305497695' post='4811232'] you should be able to deactivate any obstructed cubes, if a cube is removed all cubes it touched should become "active", if a cube is added you can check if any of the cubes it touches is completely covered (a cube would be completely covered if there are cubes on all sides of it) , This would basically mean that the majority of the cubes in your world won't be a part of your physics simulation. Its also a good idea to use sphere to sphere or AABB collision tests as an early test due to their low costs. If you can access your cubes based on their position (If you store them in a 3D array or similar structure it should be trivial to do so) then its also very easy to limit any test to cubes in a specific area. [/quote] I already only add visible blocks to the physics system. My question is more about only keeping the static objects nearby to dynamic ones in the simulation and if this is a usual way of dealing with lots of terrain (And if so how is there some generic way that my collision system could handle this for me? Otherwise I'd handle adding and removing objects in the game code).
10. ## Detecting collisions between large numbers of static objects

Not sure if this belongs here or in game programming, sorry. I'm working on a toy terrain engine that's made up of thousands of cubes just like Minecraft. I put some basic collision detection in but it's really slow as I'm naively testing against hundreds of thousands of objects. I can implement a broadphase and I will have to eventually but I think a better first step would be to take advantage of the fact that nearly everything is static and further that I can very quickly index my cubes by position. My idea is to only add and remove the static cubes from the physics simulation depending on if any dynamic objects are nearby (the player,. mostly). This way I'm not testing against them and I'm also not paying to keep all those objects in memory. This wouldn't be hard to do so I'm mainly asking because I'm sure not the first person to deal with this kind of problem and I want to know if this is the "right" way. Is there some reference implementation anyone knows of I could borrow from? I looked around a little and couldn't find any physics engines that seemed to do this but I'm not sure if that's because my approach is stupid or maybe my situation is relatively unique (though I imagine anyone doing collision with arbitrary terrain would run into the same thing). Thanks!
11. ## Distance between AABB

[quote name='wildbunny' timestamp='1303687974' post='4802461'] From my blog article: [url="http://www.wildbunny.co.uk/blog/2011/04/20/collision-detection-for-dummies/"]http://www.wildbunny...on-for-dummies/[/url] For two AABBs A and B defined by their centres and half-extents (half width, half height), overlap can be determined quite simply: D = |centreB-centreA| – (halfExtentsA+halfExtentsB) D_x and D_y are the overlap in each axis (in 2d), extends into 3d as well... When negative in all axis, the AABBs intersect oh, and |a| = abs(a) Cheers, Paul. [/quote] Thanks for the replies. Sorry to dig this back up but I haven't had much time these last few days to think about it. Paul, your article on speculative contacts is actually what I'm working from. From what I understand, that requires I be able to supply the smallest distance between the 2 bodies so that a contact can be generated (hopefully) before they're actually intersecting. If I use the approach you and others outlined I end up with D but from what I can tell it's really only useful for deciding binary overlap. For example: centreA = (0, 0), centreB = (-1, -1), halfExtentsA = <1, 1>, halfExtentsB = <1, 1> D = |(0, 0) - (-1, -1)| - (<1, 1> + <1, 1>) = <1, 1> - <2, 2> = <-1, -1> So I can see they're overlapping. Now with centreB = (1, 1). D = |(0, 0) - (1, 1)| - (<1, 1> + <1, 1>) = <1, 1> - <2, 2> = <-1, -1> Also overlapping. But in a different way with the same resulting value for D. I mean, I can get the distance and normal between 2 points obviously. What it seems like I would then need to do is subtract from that distance the distances from the center of the AABB to the extents of the AABB along that normal. I'm not really sure how to do that though. There is probably some super elegant way to do this all that I am oblivious to.
12. ## Distance between AABB

I was wondering how I might best decide the minimum distance and normal between 2 AABB such that the distance is negative when overlapping. I've started writing some code but it's getting ugly and there must be a more elegant approach. As a related question why is it that when I search for intersection tests almost all of them only tell you if two shapes are colliding but nothing about the nature of the collision? A boolean result seems completely useless. For AABB I can understand since probably not many people are using them for actual collision response, but I find that to be the case with most tests I go looking for.
13. ## Serious slowdown!

Your problem is almost certainly this outer loop in your Logic function: [code] void Logic(OBJECT* ship, list<OBJECT> *bullets, list<OBJECT> *enemies, INPUTDATA* InputData) { static int time, start_time = GetTickCount(); time = GetTickCount() - start_time; start_time = GetTickCount(); for(int ms = 0; ms < time; ms++) // once per millisecond... { // ... } return; } }[/code] This is certainly not doing what you intended. It's almost as if you expect this to be running in another thread but I'll assume for the moment it is not. What does your game loop look like? How are you calling Logic? Assuming something like 30fps that's 33 ms a frame and that means your input handling and collision is going to run 33 times every time you call logic. And it's not going to run every ms, it will happen much more quickly. Think about it: you don't expect your other for loops to take 1ms per iteration so why would this one? In fact, once your framerate starts to drop you'll get crazy pathological behavior where your logic function starts running through that loop even more often due to the larger time delta.
14. ## Component-based entity system questions

[quote name='Nevadaes' timestamp='1299629591' post='4783341'] Thank you guys for your answers as well as suggestion. So is it considered OOP to have a public enum in the Component class, then having a static const int variable defined by the values in the enum in each of the subclasses to check if the type of component is the good one? Also, I would like to know if you have any input of my update procedure that I described in my first post? [/quote] My first suggestion would be to stop making "is it OOP" your first consideration when selecting a solution to a problem. The term is misunderstood to the point of being almost meaningless anyways. A better question might be to ask if given solution is it as simple as possible while satisfying all requirements and being easily maintainable. In which case I'd say an enum is probably fine. As for your updating of components the only things that jumps out at me is first what exactly your entity manager has to do? Why do components need to be enabled or disabled? And second, why are you storing pointers to components in both the entity and the component manager? Does the entity really need to be able to query it's components directly? Could you instead store a mapping from components to their owning entity in your component system and direct all queries through that? And at that point do you even really need an Entity class? Could your entities just be a unique id?
15. ## Serious slowdown!

While your approach isn't the most efficient it shouldn't be a problem doing all of 3*3=9 HitBox tests per frame. If you're experiencing slowdown with so few enemies and bullets your problem is elsewhere. Once you solve that problem and would like to be able to handle larger numbers of interactions you may want to look into some kind of spatial hierarchy, even something as simple as a grid.