Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Making a forest with good fps?(DBPro)

Author
Message
Twu Kai
18
Years of Service
User Offline
Joined: 2nd Oct 2005
Location:
Posted: 22nd Apr 2006 18:58
I'm trying to make a forest using CShop, but seeing as it's a forest, it'll make the fps go down quite a bit. Do you know how I can reduce lag? I've searched by the way.

One idea is to have plains that have a tree texture on them, but I'd have to put hundreds of them in manually to create a forest, and the collision wouldn't be very good...

Maybe if you knew how they did it in Guild Wars, their method might work in DBPro.

Hopefully you can help me!

Join The Clan! http://www.torak.info

Desteya colatiata hethayas thorian helltastha lutanithan atelthuron ilonthes!
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 22nd Apr 2006 19:10
Its been mentioned quite a bit, and there are a lot of methods. I've got to go out pretty soon so this wont be too much of a detailed respone, but when I get back if nobody else has answered Ill try throwing together a code snippet for you or something.

Basically, you only really use maybe 10 or 20 trees, seeing as the user can usually only see 10-20. These trees would be the main, high quality ones. Then youd have a few filler trees of really low detail, like you mentioned, plains, positioned throughout to make the forest look more "full".

The idea then is to have a sort of leapfrog system, whenever a tree goes off the screen behind you, it gets positioned infront of you a fair distance away so the user doesnt just see a tree pop out of nowhere. The same goes for trees going off the screen to the right, you'd position them to the left just off screen a bit so that when the user turned to the left theyd have no clue the tree just popped there.

Aside from that you'd have some sort of a large plain textured with a bunch more trees always positioned at a distance (like a skybox) to make the forest seem even denser (if you want it that dense without upping the FPS).

If youre concerned the trees would get boring to the user, seeing the same 20 trees all the time, you've got 2 main work arounds. 1. Model each side of the tree fairly differently, so that in essense you get maybe 4 trees out of one just by turning it to a different orientatino to the camera (though in FPSs this doesnt work too good). The other would be to obviously make more trees, but that would up the FPS ofcourse.

Either way the method is pretty much used in a lot of games, as far as the tree quality goes, I've never heard one of my friends say "woah... that tree has the same branch as the other tree...freaky...", so using something like 10-20 trees should suffice.

Sorry I couldnt help more,
- RUC'

Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 22nd Apr 2006 21:24
Hey RUCCUS, that's a pretty awesome sig

RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 22nd Apr 2006 21:32 Edited at: 23rd Apr 2006 15:51
Thanks, came up with it last night I thought it was pretty cool. Might have to resize it a bit though, border-line too big.

Twu Kai
18
Years of Service
User Offline
Joined: 2nd Oct 2005
Location:
Posted: 23rd Apr 2006 11:25 Edited at: 23rd Apr 2006 11:25
Ruccus, thank you for explaining it so clearly, I'll try to use those methods in future!

I'm trying to make an area where there is forest combined with open land, so that might not be the best method to do with that. I've made a low-polygon tree though, so I'll test it out, and if it doesn't work I'll try to use "Zones", using your method of trees!

Thanks very much!

Join The Clan! http://www.torak.info

Desteya colatiata hethayas thorian helltastha lutanithan atelthuron ilonthes!
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 23rd Apr 2006 17:58 Edited at: 23rd Apr 2006 18:01
Quote: "hanks, came up with it last night I thought it was pretty cool. Might have to resize it a bit though, border-line too big.
"


I think it is a good siggy, but IMO it would look better with the two C's side by side on the top of the other hexagons, instead of just one C up there.

Some people make the trees rotate to face the camera all of the time. The military used to do that in their simulators.

RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 23rd Apr 2006 18:46
They're cubes with shadows taken off , Damn, now people think they're hexagons

The constant rotation to camera thing looks reallt crappy though, unless the trees are perfectly symmetrical and spherical, it looks like a piece of cardboard blowing in the wind.



, anyways, dont wana hijack the thread with my sig

Mr X
18
Years of Service
User Offline
Joined: 25th Sep 2005
Location: Universe, milkyway, sol-system, Earth...
Posted: 24th Apr 2006 16:18
You can store the position of the trees in the forest in an array. So when you are out in the open, it wont "teleport" a tree right infront of you. But when you enter the forest, the system makes so it seems so you are in a forest. And about those plaints, you can make so they will only be visual if they are in the forest, but when they come yout of it, you hide them or something. Hope it helps. And now, about that sig... No, just kidding.
Medieval Coder
18
Years of Service
User Offline
Joined: 31st Dec 2005
Location:
Posted: 24th Apr 2006 16:25 Edited at: 24th Apr 2006 16:27
Interesting.....I think there is another way to make a forest with high FPS....just I cant remeber how....

Ruccus wouldnt your sig look better like this?

Attachments

Login to view attachments
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 24th Apr 2006 19:14 Edited at: 24th Apr 2006 19:15
Too big plus the other way makes people think a bit more. I like simpler designs, though eventually I might switch to that.

K, nuff bout my sig! (just kidding, keep it coming folks )

TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 24th Apr 2006 22:11
This is something I've thought about on numerous occasions, but never got around to having a go at it. So I thought I'd give it a go...

I had a few ideas on how to go about it so that it would work in DBC as well as DBP. As you'd expect, DBP's main advantage over DBP in this case is speed, so anything that works OK in DBC would really fly in DBP.

Anyway, the basic principle of my idea was to create a type of 'radar' to detect when objects are in the field of view (DBC's Object In Screen is practically useless for this). My first attempt was to create an invisible 'sweeping arm'.

This is where I was in unknown territory... and hit the first obstacle.

I made a simple sphere and a cube scaled up along the X axis to create a long arm, (the length of the viewing distance). I then glued it onto the sphere with the intention of rotating it and detecting when the arm hit an object in front of it.

All works fine until the arm hits another object - no collision is detected! So, if object 2 is glued onto object 1, does object 2 not have any collision detection?

TDK_Man

RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 24th Apr 2006 22:23
I havent used DBC and Im not too fluent with DBP's native collision commands other than intersect object, so I cant be of much help in that field. However, to see if the glue object method is the culprate Id say try using a poor man's version of the gue object command. Im sure you could figure this out but basically position the box at the cam position, rotate it to the cam coordinates, and move it forward by whatever distance (probably half of it's z size Im assuming). This'd probably work;



The object will still appear to be glued, just...not.

Mr X
18
Years of Service
User Offline
Joined: 25th Sep 2005
Location: Universe, milkyway, sol-system, Earth...
Posted: 24th Apr 2006 22:38
TDK, Im still a noob, but can you just create one big sphere, make it invisible and let it detect the collision. On the other hand, what happens if it collides with multiple targets? Goodluck, anyway.
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 24th Apr 2006 23:12
Ruccus:

Quote: "I havent used DBC and Im not too fluent with DBP's native collision commands other than intersect object"


Unfortunately, the problem is that in DBC there is no intersect object command!

Whenever I write anything, I like it to be usable in Classic as well as Pro, so I do it in DBC first. I know a lot of people still use DBC, so I try to support both versions.

Anyway, here's a bit of code to demonstarte what I was thinking about:



Use 'W', 'S' and the mouse (and buttons) to control the camera.

Use the Up, Left and Right cursor keys to move the player (red box) around the screen.

To make matters worse, although you can run the above code in DBC and DBP, they both do different things wrong!

In DBC, when you wander around, no collision is detected at all when you check the glued object (503) for collisions with line:

ObjInView = Object Collision(503,0)

In DBP, strangely, the very same line detects collisions with object 502 (the sphere) - not object 503!

Mr X:

A big sphere wouldn't work because it can't detect a single tree at a time. What is needed is to know exactly how many trees are in the area immediately in front of you - so you know which ones are behind you in order to hide them.

You also have to calculate how far you are away from them, so that once you reach a certain distance from one it can be deleted and it's place in the system freed up ready to hold another one.

In essence, the way I have been thinking about this, if I can get it working, it will effectively be a particle system for trees!

TDK_Man

Zone Chicken
20
Years of Service
User Offline
Joined: 25th Jan 2004
Location: `~-..-~`~-..-~`
Posted: 24th Apr 2006 23:15
Basicaly same as ruccus you could just make a cone or cube object outside of dbp in a modeler. Set the object up the distance from the camera you want from the modelers x0,y0,z0 say you want the object 25 in front of your camera. Position it x0,y0,z25 then move the axis/rotating point back to x0,y,0,z0. Then in db use



that will keep the object in front of the camera the predetermined distance away from the camera of 25 with rotation and moving at 0 or the cameras point. Pretty much same as ruccus and allows for collision with the object.

Your signature has been erased by a mod -- please resize to under 600x120...
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 25th Apr 2006 00:53
Quote: "that will keep the object in front of the camera the predetermined distance away from the camera"


Unfortunately, that wouldn't really help. I need to be able to detect every object within a certain distance, in the direction the camera is pointing, (whether visible or not).

In my code above, the 'arm' sweeps round detecting all the trees (cubes) and depending on the sweep angle, you can decide whether the tree is visible to the player or not and hide those that aren't.

This area is the area where higher poly trees will be used while outside this area lower poly shapes are used.

Correct me if I'm wrong, but the method you suggest is mainly for detecting collision as you are walking around with the object of not walking into them.

I want to be able to detect trees currently not seen - so when you walk around any tree, it's removed and placed somewhere in front of you.

TDK_Man

RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 25th Apr 2006 01:45
TDK I know DBC doesnt have Intersect Object, but if you read a bit further you would've seen my suggestion on how to fix the GLUE OBJECT problem

Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 25th Apr 2006 02:00 Edited at: 25th Apr 2006 02:02
Some of these ideas sound like they could just be replaced by the distance formula.



function distance(x1,x2,y1,y2,z1,z2)
endfunction sqrt(((x2-x1)^2)+((y2-y1)^2)+((z2-z1)^2))

TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 25th Apr 2006 02:40 Edited at: 25th Apr 2006 02:43
RUCCUS

Quote: "I know DBC doesnt have Intersect Object, but if you read a bit further you would've seen my suggestion on how to fix the GLUE OBJECT problem"


Of course I read all of your post - including the code snippet. But I have to admit to mis-reading the line which I quoted. I thought it said "I havent used DBC and Im not too fluent with DBC's native collision commands other than intersect object". Sorry - my error.

Your code snippet would have worked with a symetrical object like a cube, but not with my long stretched cube. However, the basic principle was on the right track and reminded me of the NewXValue and NewZValue functions. So as you suggested, the arm is now no longer glued, but rotates independently - and the collision works. So thanks for that!



Will post some more code (if anyone is interested) if the next stage works...

[Edit] Oops - forgot to respond to Pincho Paxton's post:

Without the routine we've been discussing, there's no way to know which trees to apply the distance function to. Unless there's something glaringly obvious we've been missing?...

TDK_Man

RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 25th Apr 2006 02:46
Glad it worked but, I dont see the problem in using a long stretched out cube. Either way the cube will be positioned/rotated correctly.



Thats a basic example and it works fine... I'd comment it but Im pretty sure you can pick it apart

Either way, newx and newz value commands are more efficient so as long as you got it working its all gewd in the hewd.

- RUC'

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 25th Apr 2006 02:46
It'd be cool if someone got SpeedTree to work in DBP


RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 25th Apr 2006 03:10
Oh yeah and TDK, there is a way to apply the distance check to all of the trees... use a for/next loop starting from the first tree model and ending at the last (assuming the trees are in order). The only problem I could see is that the distance formula without vectors tends to slow down the program a lot, so if you get too many trees in there this system wouldnt be too good.

TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 25th Apr 2006 03:51
Quote: "he only problem I could see is that the distance formula without vectors tends to slow down the program a lot"


Yes I agree - that's why I'm trying to eliminate the trees behind the player from the equation.

TDK_Man

indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 25th Apr 2006 04:22
from a design point of view the 3d logo makes more sense.

If no-one gives your an answer to a question you have asked, consider:- Is your question clear.- Did you ask nicely.- Are you showing any effort to solve the problem yourself 
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 25th Apr 2006 04:29
Yeah Im thinking of changing it

Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 25th Apr 2006 10:51
Distance formula could be made faster if you divide the map up into square zones. Like a tile map of huge 500*500 tiles. Then check how far the player moves, and know what zone the player is in. Then just check the zones in front of the player with the distance formula, knowing what trees are in those zones.

Twu Kai
18
Years of Service
User Offline
Joined: 2nd Oct 2005
Location:
Posted: 25th Apr 2006 17:00 Edited at: 25th Apr 2006 17:16
Wow, a lot of posts!

Is there a way to detect if a polygon is on or off the screen, and to hide or show it according to that?

You could apply fog, and then detect how close the tree is, and if it's far away, hide it?

Like this:


Would that work? I get around 900 fps!

Join The Clan! http://www.torak.info

Desteya colatiata hethayas thorian helltastha lutanithan atelthuron ilonthes!
David iz cool
19
Years of Service
User Offline
Joined: 21st Sep 2005
Location: somewhere lol :P
Posted: 25th Apr 2006 17:27
hey,im trying to do the same thing as mojo.make a huge forest.

im understanding u should have a function that hides & moves trees around depending on how far away they are,but one thing i dont understand is how do u replace the tree exactly where it was the last time? use arrays somehow?
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 25th Apr 2006 17:52
Quote: "how do u replace the tree exactly where it was the last time?"


You can use array, but you shouldn't have to place trees in exactly the same position because when you are in a forest, no matter where you are it always looks the same anyway. SO random positioning should work OK.

If it was important to have trees located exactly for an aspect of your game, you could create all your forest's tree locations before building the level and put them in an array - without creating the actual tree objects.

You could then have the locations for say 1000 trees, but only have say 20 tree objects - which are placed near the player object as it moves around. Very much (as I mentioned a little earlier) like a particle system.

TDK_Man

Medieval Coder
18
Years of Service
User Offline
Joined: 31st Dec 2005
Location:
Posted: 25th Apr 2006 17:55
Quote: "I get around 900 fps"


How can you get 900 fps???
The max I can get with just a small cube not textured is 160!!!
Twu Kai
18
Years of Service
User Offline
Joined: 2nd Oct 2005
Location:
Posted: 25th Apr 2006 18:10
We've probably got quite different computers!

I'm going to use my method for the moment, but I'll be looking for other ideas.

Join The Clan! http://www.torak.info

Desteya colatiata hethayas thorian helltastha lutanithan atelthuron ilonthes!
David iz cool
19
Years of Service
User Offline
Joined: 21st Sep 2005
Location: somewhere lol :P
Posted: 25th Apr 2006 18:25
hey mojo,whats your pc's specs??

im just curious.if your really getting 900 fps,i might want to upgrade to something like yours.
Twu Kai
18
Years of Service
User Offline
Joined: 2nd Oct 2005
Location:
Posted: 25th Apr 2006 18:58
How do you find out?

Join The Clan! http://www.torak.info

Desteya colatiata hethayas thorian helltastha lutanithan atelthuron ilonthes!
Zone Chicken
20
Years of Service
User Offline
Joined: 25th Jan 2004
Location: `~-..-~`~-..-~`
Posted: 26th Apr 2006 00:03 Edited at: 26th Apr 2006 00:39
Quote: "How can you get 900 fps???
The max I can get with just a small cube not textured is 160"


single cube pushes this for me.





Quote: "Correct me if I'm wrong, but the method you suggest is mainly for detecting collision as you are walking around with the object of not walking into them."


Nope, you are correct and i misunderstood what you where saying. However you could use it pretty easy if you kill the rotation to camera part and xrotate object cone,.1*timer()/10 in the loop.

That would rotate the cone around your cubes or cameras center point in a radius of whatever set by the axis point offset.

It would also needed a set object collision to polygons or the same thing would have happened with your stretched box and detected the collision from the axis point instead of the object(not sure if that would have solved the dbo collision though, but it works for .x models). But glad to see you got it working a different way.

Your signature has been erased by a mod -- please resize to under 600x120...
Medieval Coder
18
Years of Service
User Offline
Joined: 31st Dec 2005
Location:
Posted: 26th Apr 2006 01:08
Im buying a new graphics card
Daemon
18
Years of Service
User Offline
Joined: 16th Dec 2005
Location: Everywhere
Posted: 26th Apr 2006 03:43
To Mojo 10

I played around with your code to try to make it faster. This is faster for me.


Insanity is just a state of mind
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 26th Apr 2006 06:26
Making some progress (in DBC):



Though in DBP, despite being a damn site faster, it looks absolutely terrible - though I guess that will be down to me not being used to the changes from DBC. (ATM, all the .X trees have a cel-shading effect around the edges - but it's not black, it's bright blue)!

TDK_Man

Twu Kai
18
Years of Service
User Offline
Joined: 2nd Oct 2005
Location:
Posted: 26th Apr 2006 12:38
@ Daemon

Wow! I easily get 1700 fps with that!

Join The Clan! http://www.torak.info

Desteya colatiata hethayas thorian helltastha lutanithan atelthuron ilonthes!
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 26th Apr 2006 17:46
Mojo10

I have what I thought was a reasonable machine - an AMD Athlon64 3200+ with 1.5Gig of DDR memory), but with your code snippet I only get around 550-600 FPS.

I guess this could be down to my GFX card which is getting a little on the old side now - an nVidia Fx5900 XT.

Zone Chicken's code gives me 685 FPS.

What systems are you two getting those FPS scores on?

TDK_Man

NeX the Fairly Fast Ferret
19
Years of Service
User Offline
Joined: 10th Apr 2005
Location: The Fifth Plane of Oblivion
Posted: 26th Apr 2006 18:49
That? Old? You're kidding, right?


At least farting ferrets are better than stinky stoats.
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 26th Apr 2006 23:45
Quote: " That? Old? You're kidding, right?"


Well in computer terms, yes - it is old. Computer equipment is generally classed as obsolete within 6 months these days. In fact, I would hazard a guess that you couldn't buy a new FX5900 XT now even if you wanted one because they are that old.

Besides, the rest of my system ain't too bad, so it's got to be my GFX card which is causing the biggest bottleneck...

TDK_Man

Whirlwind
18
Years of Service
User Offline
Joined: 27th Mar 2006
Location:
Posted: 28th Apr 2006 04:13
You should add a function to randomly rotate and slightly scale each tree to add some variety.

Login to post a reply

Server time is: 2024-09-24 21:38:09
Your offset time is: 2024-09-24 21:38:09