Jump to content
• Advertisement

# Harry Hunt

Member

671

542 Good

## About Harry Hunt

• Rank
Advanced Member
1. ## Normal generation for terrain

That was exactly it! Thanks a bunch! Guess I should stick to DirectX ;-)
2. ## OpenGL Normal generation for terrain

Hi everybody! I'm playing around with OpenGL and .NET and I've run into some difficulties (being a DirectX kind of guy). Basically what I want to do is render a heightmapped terrain. I generate the terrain as follows: for (int y = 0; y < patchHeight; y++) { for (int x = 0; x < patchWidth; x++) { Vertex vertex = new Vertex(); vertex.x = x * quadSize; vertex.y = -(y * quadSize); vertex.z = HeightForCoordinate(x, y); patch[y * patchWidth + x] = vertex; } } and render it like this: for (int y = 0; y < patchHeight - 1; y++) { for (int x = 0; x < patchWidth - 1; x++) { Vertex topLeft = patch[y * patchWidth + x]; Vertex topRight = patch[y * patchWidth + x + 1]; Vertex bottomLeft = patch[(y + 1) * patchWidth + x]; Vertex bottomRight = patch[(y + 1) * patchWidth + x + 1]; GL.Begin(BeginMode.TriangleStrip); GL.Vertex3(bottomLeft.x, bottomLeft.y, bottomLeft.z); GL.Normal3(bottomLeft.normal); GL.Vertex3(topLeft.x, topLeft.y, topLeft.z); GL.Normal3(topLeft.normal); GL.Vertex3(bottomRight.x, bottomRight.y, bottomRight.z); GL.Normal3(bottomRight.normal); GL.Vertex3(topRight.x, topRight.y, topRight.z); GL.Normal3(topRight.normal); GL.End(); } } The z-value is within the range of 0.0 to 1.0. This works as expected. Now I want to generate normals for my terrain and I do so using the method described here. for (int y = 0; y < patchHeight; y++) { for (int x = 0; x < patchWidth; x++) { int xPred = Math.Max(0, x - 1); int xSucc = Math.Min(patchWidth - 1, x + 1); int yPred = Math.Max(0, y - 1); int ySucc = Math.Min(patchHeight - 1, y + 1); float sx = patch[y * patchWidth + xPred].z - patch[y * patchWidth + xSucc].z; float sy = patch[yPred * patchWidth + x].z - patch[ySucc * patchWidth + x].z; patch[y * patchWidth + x].normal = new Vector3(sx, sy, 2.0f * quadSize); patch[y * patchWidth + x].normal.Normalize(); } } For some reason however, this looks really broken: I've re-read the form post explaining the algorithm a couple of times but I can't figure out what I'm doing wrong. So I was hoping that someone in here might be able to point me in the right direction. Thanks a lot in advance!
3. ## So, how does GTA IV do it?

Awesome, thanks! I'll look into that...
4. ## So, how does GTA IV do it?

Thanks! I half expected you couldn't reveal any details... I don't really know what to make of "(the) PostFX work (that) was covered on GDC"... I'm assuming GDC is the Game Developers Conference, but I can't find anything from 2008. I tried archive.org but all I get the is the gdconf.com homepage. Oh well, maybe I'll never find out ;-) Everything dynamic sounds good though.
5. ## So, how does GTA IV do it?

Thanks for the answers! The shadows definitely play an important role in the realism of the game (although I wish they had blurred them a little like they did in Crysis). What I'm wondering is how they did the ambient lighting. I think that's where both GTA IV and Crysis really excel and where FarCry 2 fails. I can't see any ambient occlusion in GTA IV (maybe it's there and I just don't see it), but the quality of the ambient lighting is very close to what you'd get from an offline GI solution. Very impressive stuff. Thanks!
6. ## So, how does GTA IV do it?

Hi! I just played GTA IV on a friend's XBox 360 and I must say that it's great fun (I think I'll get myself a copy of the PC version for xmas). When I was playing the game, I realized that the lighting is absolutely gorgeous (especially the sunlight) and I was wondering how they do it. I played Far Cry 2 which, just like GTA IV, features a dynamic day-and-night cycle, and while the lighting in GTA IV looks absolutely realistic, Far Cry 2's lighting looks rather artificial. So does anybody know how they do their lighting? I know Wolfgang Engel is a member of this forum, but I don't know if he's at liberty to talk about these things. Thanks!
7. ## [java] Garbage Collection Issue

Be careful with recycling objects in Java! Java has a generational garbage collector and there's a different cost associated with collecting each generation. Short-lived objects are very cheap to collect and long-lived objects are collected so infrequently, that they don't add much of an overhead. It's objects that live long enough to survive the first generation but not long enough to be added to the pool of "old objects" that are the most expensive to collect. So if you choose to recycle objects, make sure you hold on to them for as long as your game/level is running. Otherwise the garbage collector will perform expensive "full collections" more frequently and your hickup problem will only become worse. Also note that the Java GC keeps track of past collections and will adjust its collection behavior accordingly. If it performs a full collection but doesn't actually reclaim any memory, it may choose to perform collections less frequently in the future. So make sure that while your game is running, the garbage collector only reclaims short-lived objects as they are treated differently. In general though, the hickup problem is something you'll ultimately have to live with (to some degree). The only generational collector I know that does not have this problem is the one used in Erlang, and that's because garbage collection in Erlang is a lot easier than it is in Java. That is also precisely the reason why the Adobe Flash VM relies primarily on reference-counting.
8. ## Fallout3, Farcry2 renderers

I've only played FC2 so I can't comment about Fallout 3, but here are my 2 cents: Far Cry 2 looks worse than Crysis for what I believe to be the following reasons: 1) No ambient occlusion Since pretty much everything in FC 2 is destructible, pre-rendered AO wouldn't have worked too well. SSAO would've been an option, but then it's a relatively expensive effect and maybe it wasn't in their shader budget anymore. 2) No SSS on leaves/grass This is a real bummer because I think that's what really sets apart Crysis from other games. The fake SSS used in Crysis (which is described in GPU Gems 3) sounds reasonably cheap and I wish they had implemented in in FC 2. 3) Mediocre material shaders This is the one I don't get. In FC 2, there is very little distinction between different materials. Everything looks "plastic" just like it did in Far Cry 1. Maybe there is some reasoning behind that, but I don't get it. But there are also a few things about the FC 2 visuals that are great: 1) Fire looks amazing 2) Shadows are nice (some akne, but most of the time they work just fine) 3) Great draw distance, virtually no popping 4) Nice weather effects 5) God rays never get old 6) Blood looks pretty realistic and you also need to acknowledge that Far Cry 2 is extremely stable and bug-free. Gameplay-wise, it didn't impress me, but neither did Crysis.
9. ## a problem im my array a new error with output plz check

for ( int a = 0 ; a < n ; i++) output_data(employee+i); should be for ( int a = 0 ; a < n ; a++) output_data(employee+a);
10. ## a problem im my array a new error with output plz check

Quote:Original post by chetoos i have a problem with my array the program compiles correctly but when i use it it doesnt work as it is supposed to do i want to have all employee data entered once and given in the output *** Source Snippet Removed *** You're only creating one database struct. What you want to do is create an array of database structs like so: database* employees; employees = new database[n]; You will also want to free the array somewhere like so: delete [] employees; You might also want to look at std::vector which does what an array does, but is much more convenient to work with.
11. ## What IDE are YOU using?

@Home: Visual Studio 2005 for C++ @Work: Eclipse for PHP/javascript/Java/HTML
12. ## [web] Browser MMO - Can MySQL + PHP support interaction between offline players?

Having the presentation scripts trigger the simulation scripts is a bad idea imho, because running the simulation logic, even for just a handful of events, can take up enough time to create a noticeable lag in the front-end. It's also much cleaner code-design-wise to keep the two things separate. Running the simulation script as a cronjob will work fine, until the work queues become long enough that the scheduler will run a new instance of the simulation script before the previous instance has completed. Using a non-terminating script doesn't have any major downsides in my experience. And if you run it from the shell, you can specifiy that the script should never timeout. That said, I still think that PHP is a bad choice for this kind of thing. If your simulation logic is easy enough, you might be able to do it with just stored procedures in the database. That should also be pretty fast.
13. ## [web] Browser MMO - Can MySQL + PHP support interaction between offline players?

You're going to need a dedicated hosting plan either way, because other plans generally don't allow you to run scripts and have them not terminate. In most browser games, the simulation process only uses the database and does not communicate with the "front-end" processes in any other way. That means, if someone issues an "attack" command, it is added to the database and the simulation process will pick it up as quickly as it can. A friend of mine has written a pretty successful browser game that has a PHP front-end. The backend (the never ending process) is written in C though. That is not to say that C is particularly well-suited for that type of thing. Since your never-ending PHP script will run in its own PHP interpreter, you can simply assign a priority to the process in your OS. It will have some impact on the performace of the system as a whole, but it shouldn't be too bad. Note though that on a virtual server you won't be able to support more than a few dozen concurrent users (a few hundred if you're lucky) like that. If you want thousands of users, you'll need dedicated hosting and you might even need more than one server. This may not be important now, but if you don't plan for that, you will be screwed once more players are coming in.
14. ## [web] Browser MMO - Can MySQL + PHP support interaction between offline players?

Most browser games are just a thin presentation layer on top of a database, i.e. the heavy lifting is done by the database. The form of interaction that you are suggesting is no different. What you will need though is a script that runs the actual simulation, independent of the users that are or are not currently playing. While this can be done with PHP (and in fact a lot of browser games use PHP for that purpose), it may not be the best language for the job. If you absolutely have to use PHP, you can launch a PHP interpreter from the command line and not have it time out. In all honesty though, I think PHP is a terrible choice for a browser game. I know there are a ton of really successful browser games written in PHP, but that's probably only because that's all the developers knew. To me, something like Java Servlets seems like a much better choice because it's easily made stateful and you can hold stuff in memory that otherwise would have to be write to adatabase. If I had to write a browser game however, I would probably write it in Erlang because that would make it much easier to scale.
15. ## Why do these games look so darn pretty

@Yann L: Thanks for the info and the paper! I will definitely check it out. @dd000hg: All I have are really old screenshots and since I'm messing with the renderer right now, I can't make new ones at the moment. Will post some, when the renderer is "functional" again.
• Advertisement
×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!