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.

Dark GDK / Frustrum Occlusion Culling - Got it Working in Dark GDK... 95% Anyways....

Author
Message
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 27th Dec 2007 04:44
Thanx Lost In Thought!

Yeah - it works - just need to refine my limb culling... works with objects. I'm trying to make the limb part fairly optiized - but I ran out of time for this evening - I was just so thrilled though when I saw poly counts dip and rise accordingly!

I just had to post!

... And ... I'll be doing that tomorrow and hopefully hitting some cool shader info I recieved from someone here - might help me get up to speed quickly on writing shaders - looks like it might! Well - if so I'll pass on what I can

Cellbloc Studios
20
Years of Service
User Offline
Joined: 15th Mar 2004
Location: Atlanta, GA
Posted: 27th Dec 2007 06:52
That's great news. Would like to see a demo of it if at all possible.

Your mod has been erased by a signature
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 27th Dec 2007 10:53
Glad you got it going man

jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 27th Dec 2007 17:07
I'll post something soon - nothing graphically fancy - but while I have a working "demo'ish" codebase using it.

Note - It's 100% now... and I noticed that some things cull to soon, and there was code to "shrink" the eclipsex etc. Like

SIZEX * 0.5 or something resembling that for each plain - the fudge was making those 1.2 (Bigger Cull SPhere , box, cube etc) but I want to revisit this and make it pixel perfect if possible - by really analyzing how the coord's are stored.

One thing I did successfully - is FOR EVERY OBJECT - I store info about it's total SIZE, even the ones I want to LIMB CULL. THEN I check if the OBJECT is in frustrum first. If its for Object culling, then I show/hide (only if not already showing/hidden respectiviely) Then if that object is IN FRUSTRUM - and its to be LIMB CULLED - thats when I go through all the limb info.

This allows a exponential increase in performance when you make many objects - and each is made of many limbs... to cut down on looping through limbs if the whole object isn't onscreen.

Note - Occlusion Culling Objects that move around is OK with this system - but trying to LIMB CULL those objects is not supported.

I'm told (and have seen) Limb Position function are slow.

I've seen them not always be up to date depending on the last "rotate command" - I think if you rotate objects or limbs on a given axis, then query that axis immediately, the results are skewed until you move the object on another zxis (even you put it back) ...this describes a fudge I need in my code often.

Pseudo Example:


jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 28th Dec 2007 00:42 Edited at: 28th Dec 2007 00:52
I said I would here it is - BUT here is your Read ME:

Its a work in progress - I was trying to fix a bug - but I wanted to get it out there - the bug is I THINK the smoothing FLATS the root limb.. I stopped mid debug session - to get this out while it still was kinda a good toy for playing with.

Use Keypad. When You Start, you're at 0,0,0, so MOVE UP - then BACK.

NumPad Directions
8,2 fwd/back
4,6 turn left/right
7,1 Pitch fwd/back
9,3 up/down
/=fwd faster
0=backward faster
numlock=bank left
-=bank right
5=Face North, rotate 0,0,0 (Levels the cam - cheap way)


H=load height map (Better remove the dbSync in the ApplyHeightmap if you want to load the big meight map!...but as is - just fine)

S=Smooth

REGULAR NUMBERS
1 = Normalize Normals - Method 1
2 = Normalize Normals - Method 2 (hosed I think)
3 = Normalize Normals - Method 3 .. eh
4 = Normalize Normals - Method 4 COOLEST (IMHO)

N=Reset Normals to 0,1,0 (x,y,z)

CNTL-ALT-DEL = Don't do it!

Seriosly - if you want to play - scan the code for JM->CreateMesh call. The intellisense should help ya figure out the parameters.

Changes the sizes of stuff... tiles, faces per mesh, etc. Have fun!

(Below that is the culling stuff)

Altruism - Donated from Lost In Thought (Greetz bro) - I'm just passing the torch

http://www.jasonpetersage.com/GDK_FrustrumLimbCulling.zip

Cellbloc Studios
20
Years of Service
User Offline
Joined: 15th Mar 2004
Location: Atlanta, GA
Posted: 28th Dec 2007 16:23 Edited at: 28th Dec 2007 16:23
@jason p sage:

Not too shabby. I will try and take a look at it this weekend.

P.S.
Do you actually have three first names?

Your mod has been erased by a signature
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 28th Dec 2007 16:50 Edited at: 28th Dec 2007 16:52
No - I used my Real (full) Name: Jason Peter Sage

Oh - and while I'm here - You got to see my latest terrain triumph (less frame rates but I'll get that - its shaders run like AHHH on my slow pc)


Fullsize:http://www.jasonpetersage.com/img/TankGame43TerrainBlending.png

and closer


Fullsize:http://www.jasonpetersage.com/img/TankGame42TerrainBlending.png

Attachments

Login to view attachments
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 28th Dec 2007 16:53
and the other shot in case my web svr is ever down

Attachments

Login to view attachments
Pixel Perfect
17
Years of Service
User Offline
Joined: 21st Feb 2007
Location: UK
Posted: 29th Dec 2007 12:13
Hi Jason, glad to see you have got frustrum culling up and running in GDK. Well done.

However, you can't 'pass the torch' if your link doesn't work. It's returning a '404 Not Found' error. Just thought I'd let you know

Terrains looking well nice too!

No matter how good your code is, someone will improve on it
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 29th Dec 2007 12:35
Send it to me and I'll put up a mirror. Or I can set you up with some hosting (250MB limit). My host hasn't went down, that I know of, but once in the 4 years I have had it.

jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 29th Dec 2007 12:52 Edited at: 29th Dec 2007 12:56
Sorry GUYS! I'm so embarrassed. I had it two directories higher than it needed to be - So Sorry. Please try again The link Works Now!!!

[edit]
Just noticed the hosting offer - its to big to email - but the link works. If you want to help host it - that's fine with me

You know I tried uploading it here, its under 50meg - but I always get errors on kinda big stuff.

Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 29th Dec 2007 17:26
Here's a mirror you can use. Let me know if you need an FTP account to upload.

http://www.mapmasterz.com/lit/GDK_FrustrumLimbCulling.zip

jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 31st Dec 2007 04:18
You are so cool LIT! I will only pester you for such privy's if I have something else that seems possibly helpful and worthy of such hosting... Demos, big howto, actual releases etc. With your permission of course!

Thank you very much. you're my "FileServer Space" ace in the hole for when I really need a favor

Thankx!

Pixel Perfect
17
Years of Service
User Offline
Joined: 21st Feb 2007
Location: UK
Posted: 4th Jan 2008 00:31
Had a chance to play with your code tonight Jason and the frustrum culling conversion seems to be working really well - well done!

The only thing I noticed was that the terrain update seems a little jerky when turning the camera angle, even though the frame rate seems high. Not quite sure whats going on there.

No matter how good your code is, someone will improve on it
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 4th Jan 2008 04:09
Awesome! Glad you got to check it out!

Quote: "The only thing I noticed was that the terrain update seems a little jerky when turning the camera angle, even though the frame rate seems high"


Check out the source code in the Frustrum if you like. It's my fault - easily fixable - but before I do let me explain You're the first to ask.

<evil grin> That means you checked it out for a little bit

See, LIT made it like this:

FIRST: SETUP EACH Object for either OBJECT CULLING or LIMBCULLING.

Ok... Now as the main loop goes... it checks EVERY OBJECT you SETUP either the LIMB WAY (Checks each limb approriately...can be time consuming) OR the Object Way - One Check Period for Whole Object.

What I did was TRY to optimize it a bit. I made it so that if you SET UP an Object for Object Culling, its just like LIT's way. If you set it up for Limb Culling, I set it up FIRST for OBJECT CULLING and LIMB CULLING also. The idea was that if the OBJECT a limb belongs to isn't even on the screen - don't bother looping thorugh its limbs. If it IS on screen... ok yup.. go check all the limbs.

This is more efficient but the difference in speed from CRANKING along to all of a sudden popping a few more objects on the screen... which might translate to a bunch of limbs being counted all of a sudden... yeah this explains the chuggyness most likely.

Now - I could tdo it the other way and lose the throughput but get a smoother overall "Flight" or I can take another stab it - knowing full well the mechanics work and concentrate on some sort of "throttle"... like maybe limit "counts" per cycle... rather than checking the WHOLE FRUSTRUM list, maybe force a certain number of iterations... (which might make noticable holes if not done with some wizardry.)

I Think the DBPro one does a certain amount of this but the performance difference of a couple objects being checked and a few LISTS of limbs is a big increase and definately would seem to make a chuggyness as you spun cam around.

You'll niotce flying along edges (lots of stuff culled) the thing flies .. but when looking in center of terrain or whatever----you'll notice immediate slow down... but I thought I did timer movement in that demo - so it at least would be proportional even though FPS can flucuate.

hmmm Thanx for checking it out.

tempicek
16
Years of Service
User Offline
Joined: 27th Nov 2007
Location: Prague
Posted: 9th Jan 2008 11:45 Edited at: 9th Jan 2008 11:47
Hello Jason,

I finally managed to take a look at it and have some notes/questions:

1) What you call (frustum) occlusion culling is actually called frustum culling (since you cull object on the basis of the fact whether they are in the view frustum or not). Occlusion culling is a technique of culling object on the basis of their occlusion by other objects (you can cull most of the terrain if you are just behind a hill for example). But I'm sure you will finish occlusion culling as well!

2) Your culling is performed on a 2D basis, isn't it? So you are taking in account only the projection of view direction to XZ plane. Is that right? Or how you do that?

3) Why is the loading of heightmap so slow? What you do there actually? (Or is it just me? It took several seconds to update all heightmap data.)

4) I noticed some textures in the package. Is this the terrain renderer you have mentioned? If so, how can I start it with the textured terrain?

5) I recommend using relative paths everywhere (and saying everywhere, I mean the project settings you use absolute paths for header files so you have to change it if you want to compile the project elsewhere)

6) What are you actually doing when performing "normals normalization"?

Good job! Thanks in advance for any response.

//rem
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 9th Jan 2008 13:49
Quote: "1) What you call (frustum) occlusion culling is actually called frustum culling "
thanx for the correction - I knew of the two types - but now I have my semantics down thanx to you

Quote: "2) Your culling is performed on a 2D basis, isn't it? So you are taking in account only the projection of view direction to XZ plane. Is that right? Or how you do that?
"
Well - the truth is myself - and even Lost In Thought don't understand everything about this - but there is a chunk of code that takes the Projection matrix and the display matrix - multiplies them somehow and derives the "6" sides of the frustrum. Then the code does checking (Sphere, or Sphere+cube or Sphere+Box) the current FRUSTRUM coords (which is where camera is each loop) against the stored list of coordinates for the various objects/limbs.

3: What code are you referring to? I have the TED loader sample and the frustrum example. The Frustrum example is building the meshes dynamically - stuffing them into a memblock, making the meshes, then a pass for smoothing I think as well as a pass for setting the normals. I'm using the Gherouad shading method - averaging. Also, that mesh design has a FVF/MESH format where EVERY vertice has its own "definition" ...i.e. not welded - this adds to processing time.

Weld's aside - I would load models that already are "lighting" normalized and smoothed, heights set etc.

4: No - I think I had and texturing happening dynamically if thats what you mean on that code... I don't think so... and if I did - it wasn't impressive. You might be able to look in the code and see if there is commented out Green Gandalf's Shader and maybe enable it - I forget - I've done a lot since then... There was I though just a basic texture in that demo...like a grass texture tiled.

5: Relative Paths - Yes I agree with you on that - I honestly don't care enough to go back and try to change stuff... especially since my code is on one drive, and my lib's includes for DarkGDK is on c:\...

6: What am I doing for Normals? On that VERSION of my mesh building from scratch - I have 4 different techniques.

Method 1: Old DBC code uses ATANFULL to figure out a decent solution for normal values... sometimes has a few funky spots - but 99% decent.

Method 2: Homebrew based on Gherouad shading - First you figure out poly normals for flatshading and store in vertex lighting normals (Can't do this part if verts welded) then you average them for each common vert based on sourround poly normals.

Method 3: Pure Flatshading - Basic - great during development to see polys clearly... it has its uses

Method 4: a Failed attempt of a algorythm I didn't understand - but I was close - it basically did 100% opposite of what I wanted... the result.... It's literally a mirror of what light should do - I didn't care enough to fix - I just use it when I want to see a lot of shadow to look at it differently.

Thanx for the "Good Job" - I'm still learnign this stuff

tempicek
16
Years of Service
User Offline
Joined: 27th Nov 2007
Location: Prague
Posted: 9th Jan 2008 16:20
Quote: "3: What code are you referring to? I have the TED loader sample and the frustrum example."


I meant the "ExampleTedLoader" you have providede here (http://www.jasonpetersage.com/GDK_FrustrumLimbCulling.zip). There if you hit "h" key, a heightmap is being loaded - that takes several seconds to finish during which all vertices are successively being raised to their new positions. That's where I'm curious.

Quote: "There was I though just a basic texture in that demo...like a grass texture tiled."


There's just this void image (as attached). But never mind, I was just curious about the terrain stuff as I spent a lot of time on terrains myself.

Quote: "6: What am I doing for Normals? On that VERSION of my mesh building from scratch - I have 4 different techniques."


Oh, now I see. I was confused as you mentioned (in previous post) 4 types of normals normalization. Since normalizing a normal vector means converting it to a form where x^2 + y^2 + z^2 = 1, there's always only one solution for that. What you were actually doing then is applying light on the surface or simply "shading" it.

Quote: "Thanx for the "Good Job" - I'm still learnign this stuff"


We all do, that's why it's "good". Once we stop learning and start stagnate, then it will be "bad job"

BTW, it refuses to start on my second machine where I have 1280*1024 resolution. It says "Display mode not supported" and hangs up. I didn't play with that though.

//rem

PS: It's "Gouraud" shading. Just that we understand each other

Attachments

Login to view attachments
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 9th Jan 2008 18:15
3: For ted Loader - I may have distributed the heightmap - but I'm loaded Direct.x meshes.

The attached image I'm surprised to see - that is what I use for development. You sure you're not looking at the frustrum demo - where I was making the mesh/objects dynamically from a heightmap?

Ugh... Now I'm confused

You are correct about I was talking about shading the stuff different ways - but again - this sounds like the Mesh Stuff I did in the Frustrum demo.

As for the doa display mode - I'm setting a window I think for 1024x768x32. Should be a quick fix (once you get those hardcoded lib references set - again - relative paths won't work for me because I hop drive letters and stuff... linux does this better then MS)

Gouraud - Got it - I never spell it right

tempicek
16
Years of Service
User Offline
Joined: 27th Nov 2007
Location: Prague
Posted: 9th Jan 2008 19:57
Quote: "relative paths won't work for me because I hop drive letters and stuff"


That's why we use relative paths because the absolute paths (using drive letters) are changing
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 9th Jan 2008 20:07 Edited at: 9th Jan 2008 20:12
But I can't relative path ACROSS Drives.

[edit]
d:\files\code\projects\jegasllc\gameclasses\I am Here

How do I Relative path to:

c:\program files\the game creators\darkgdk\stuff\more\stuff\headers (and libs) ???


In Linux you don't have this issue. Is there something I'm missing? (Besides the fact that I don't care if a FREE SOURCE release with literally thousands of lines of code doesn't work out the box if the downloader can't figure out how to change one or two paths for the linker...(Not being fresh... its just that I use the browse button - I gave away a ton of source and its not like its bad source - it has a link or two that are machine specific?!?!??
[/edit]

tempicek
16
Years of Service
User Offline
Joined: 27th Nov 2007
Location: Prague
Posted: 9th Jan 2008 21:39
I see, that was just a missunderstanding. What I had to change in your project to be able to compile was the "Additional Includes Directory" which is project-dependent setting and therefore needs only relative paths.

The common paths (for commonly used headers and libraries) are usually configured for the visual studio itself, where you can set those paths in absolute form.

Quote: "In Linux you don't have this issue."


That's right, but you shouldn't be facing this issue anyway, right? Because common paths are set per machine/installation/user and project dependent paths should always be relative (at least it sounds like a bad habbit to me to refer to locations outside of the project folder).

But now I'm a way off-topic my apologise
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 9th Jan 2008 22:30
No apology - now I know where you mean ... and yeah - that makes sense. So, where you ACTUALLY looking at Frustrum Port or Ted Terrain example?

tempicek
16
Years of Service
User Offline
Joined: 27th Nov 2007
Location: Prague
Posted: 9th Jan 2008 23:29
Quote: "So, where you ACTUALLY looking at Frustrum Port or Ted Terrain example?"


I would like to tell ya, but you should know better I ran the "ExampleTedLoader" project inside the package you have mentioned earlier in this thread - http://www.jasonpetersage.com/GDK_FrustrumLimbCulling.zip
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 10th Jan 2008 00:50
That would be the frustrum port (It has frustrum in the file name - now I see) - that would have had the void graphic, that does manipulate vertices, and that does build a memblock and make meshes, ok Yeah - Um... What was your question again? haha

Um... The Video thing IS DEFINATELY cuz I just a class that takes 4 param in the very top: (jgc_main.cpp I think it calls:


Which translates to:


and



Followed by



all that is buried in the init code that does other stuff - but I'd thought I break it down to the GDK native stuff so you knew how I was init'ing the display.

P.S. Neat Trick... simple yet effective... you know that little graphic pic you uploaded?

Look for this piece of code (or did you already see this?):


That is embedded media DarkGDK style

That does have texture terrain - I forgot if I made a single press thing to do it - That code is so different already now and I know it doesn't have any good dynamic texture creation. If you load a texture (Surprised if there isn't something in there) and just do: dbTextureObject(JM->ID); or JM->textureObject("filename");

before the loop - you should be good

tempicek
16
Years of Service
User Offline
Joined: 27th Nov 2007
Location: Prague
Posted: 10th Jan 2008 09:14
Quote: "P.S. Neat Trick... simple yet effective... you know that little graphic pic you uploaded?

Look for this piece of code (or did you already see this?):"


Hehe, nice. Reminds me that while when I was wondering where the bloody DXUT reads those GUI textures from

Login to post a reply

Server time is: 2024-09-29 09:26:34
Your offset time is: 2024-09-29 09:26:34