Author Topic: LOD system  (Read 1097 times)

0 Members and 1 Guest are viewing this topic.

argoon

  • Sr. Member
  • ****
  • Posts: 267
  • Karma: +21/-80
  • Doom Newbie
    • View Profile
Re: LOD system
« Reply #15 on: December 01, 2016, 07:25:11 PM »
Hello VGames on simple scenes or interior scenes where portals are very effective you don't get that much of a gain if any, the model change also takes performance, this is for outdoor scenes with a big number of models, like forests (for what i'm really trying to do this LOD system), open spaces and stuff, levels where portals are very inefficient and hard to optimize, for anyone making Doom 3 kind of levels LOD is really not necessary that is why id never implemented it.

I'm also making it because i want to see if i can.   

VGames

  • PD3 Beta Testers
  • Hero Member
  • *
  • Posts: 752
  • Karma: +17/-69
    • View Profile
Re: LOD system
« Reply #16 on: December 02, 2016, 08:14:33 AM »
Oh ok. I hope you can get it working properly. I'd love to see bigger opened up maps. Especially a forest. Good luck.
Get the latest on Perfected Doom 3 here - http://www.moddb.com/mods/perfected-doom-3-version-500

motorsep

  • Hero Member
  • *****
  • Posts: 960
  • Karma: +74/-127
  • Artist
    • View Profile
    • Kot in Action Creative Artel
Re: LOD system
« Reply #17 on: December 02, 2016, 02:10:51 PM »
I'd love to see bigger opened up maps. Especially a forest. Good luck.

Except you can't. LOD only remedies polycount, but not drawcalls. Engine would need dynamic/static batching and instancing, on both meshes and materials. And it needs to be multithreaded, plug some of it needs to be offloaded to GPU. And top of that you need occlusion culling.

MrC

  • Jr. Member
  • **
  • Posts: 58
  • Karma: +8/-24
  • Doom Newbie
    • View Profile
Re: LOD system
« Reply #18 on: December 02, 2016, 02:18:46 PM »
I'd love to see bigger opened up maps. Especially a forest. Good luck.

Except you can't. LOD only remedies polycount, but not drawcalls. Engine would need dynamic/static batching and instancing, on both meshes and materials. And it needs to be multithreaded, plug some of it needs to be offloaded to GPU. And top of that you need occlusion culling.

Even for a small forest?

argoon

  • Sr. Member
  • ****
  • Posts: 267
  • Karma: +21/-80
  • Doom Newbie
    • View Profile
Re: LOD system
« Reply #19 on: December 03, 2016, 12:15:20 PM »
I'd love to see bigger opened up maps. Especially a forest. Good luck.

Except you can't. LOD only remedies polycount, but not drawcalls. Engine would need dynamic/static batching and instancing, on both meshes and materials. And it needs to be multithreaded, plug some of it needs to be offloaded to GPU. And top of that you need occlusion culling.

You are right it doesn't resolve the drawcall problem but i assume it helps reduce their complexity, specially on the perpixel lighting system of idtech 4 plus you have the option to disable shadow casting and physics calculation in the distance.
Yes dynamic/static batching and instancing / impostors would be awesome to have, but we don't so we need to play with what we have.
Automatic Occlusion culling like Umbra would be nice to have but we don't, so again use what we have, i'm thinking of ways to also script a pseudo Occlusion Culling system by using the bounding box size and traces, is not perfect far from it but i think it would work.

About forest size, of course this will not make us able to do Crysis like forests but at lest will help us make bigger ones compared to no LOD at all.   

argoon

  • Sr. Member
  • ****
  • Posts: 267
  • Karma: +21/-80
  • Doom Newbie
    • View Profile
Re: LOD system
« Reply #20 on: December 06, 2016, 11:42:40 AM »
A update on this, i found that i add hide all the objects at init() time including lod0, so it worked better BUT i'm still not able to make the LOD system not flicker but now i'm pretty sure it is caused by the waitFrame(); or wait(); command on the while loop, why i think this, because by using wait(some number of time) with a very low number i was able to accelerate the change, at lest it felt like it, but still not to the point of no flicker, a number below a certain range would also stop the lod system from working.

In other news i was able to make a grass LOD system using this that performs well, unfortunately it also suffers from this blank frame problem but is not so obvious as i'm changing to relatively different models.

Here is a video, sorry about the resolution, google drive compresses even more the video, some things to note, the level is just a test level, I just took a doom 3 model with some open space and used that, the grass model and material is just a test so it looks funky and out of place i know, i could color the material very easily using a grayscale diffuse and a color stage but that is for another time.
About performance FRAPS took half the performance, normally it would run at constant 60+fps and this on a AMD GPU that idtech4 is not very friendly to.  :)

https://drive.google.com/open?id=0B_xD8k_3dkNpcXlaM2ZhY1NqTEU

I want to make this even better by not having to spawn all objects at init() time so i don't have hundreds of grass objects "thinking" at the same time even if hidden and way from the player, and i hope that some day i can resolve the blank frame problem.

BTW is it possible to detect by script the size of a model on screenspace? I mean detect how large an object is relative to the game resolution? If it takes 25% of screen, 50%, etc, i hope i'm making my self clear, i found this is how UE4 does its auto LOD system.     
« Last Edit: December 06, 2016, 11:44:16 AM by argoon »

motorsep

  • Hero Member
  • *****
  • Posts: 960
  • Karma: +74/-127
  • Artist
    • View Profile
    • Kot in Action Creative Artel
Re: LOD system
« Reply #21 on: December 06, 2016, 04:55:17 PM »
Don't you have YouTube channel to upload videos?  :-\

argoon

  • Sr. Member
  • ****
  • Posts: 267
  • Karma: +21/-80
  • Doom Newbie
    • View Profile
Re: LOD system
« Reply #22 on: December 06, 2016, 08:01:11 PM »
Don't you have YouTube channel to upload videos?  :-\

Was faster to upload to google drive, here is youtube version still not perfect it seams, i need to mess with fraps settings and see if i can make better videos the video comes very dark forcing me to edit it with virtual dub.


Even tho the frame ingame shows bellow 30fps the speed on youtube is right the grass LOD does runs at 60fps, it was just fraps making the game run slow but it recorded it at 60fps like it should.
« Last Edit: December 06, 2016, 08:07:56 PM by argoon »

motorsep

  • Hero Member
  • *****
  • Posts: 960
  • Karma: +74/-127
  • Artist
    • View Profile
    • Kot in Action Creative Artel
Re: LOD system
« Reply #23 on: December 06, 2016, 09:15:23 PM »
When I am at work, I can't watch non-youtube videos (either way it's just inconvenient).

Nice. I'd suggest making it darker where it meets the floor, kinda in a gradient fashing - darker at the bottom, lighter on top. Can even do that using vertex color so texture remains intact. Also might want to add a quad at the "root" (so it's right on the ground), with offset in the material and make a cloudy dark blob modulated texture - it will be fake AO.

What happens when you make a really dense grass? (if you have floor texture grassy, just like actual grass, it will look even better)

Do you use alpha test opacity on the grass ?

argoon

  • Sr. Member
  • ****
  • Posts: 267
  • Karma: +21/-80
  • Doom Newbie
    • View Profile
Re: LOD system
« Reply #24 on: December 07, 2016, 08:34:25 AM »
When I am at work, I can't watch non-youtube videos (either way it's just inconvenient).

Nice. I'd suggest making it darker where it meets the floor, kinda in a gradient fashing - darker at the bottom, lighter on top. Can even do that using vertex color so texture remains intact. Also might want to add a quad at the "root" (so it's right on the ground), with offset in the material and make a cloudy dark blob modulated texture - it will be fake AO.

What happens when you make a really dense grass? (if you have floor texture grassy, just like actual grass, it will look even better)

Do you use alpha test opacity on the grass ?

Thanks for the suggestions, they indeed would make this grass look better, about dense grass i'm still to test that, but like you say, the lack of density will be masked when the grass is used with a more suitable floor texture, about alpha, i use both alpha test and alpha blending by using the keyword translucent in the material, i have a material version with normal maps and capable of interacting with light but for the time it takes to much performance, compared to this version, this one is brighter but i can tweak that very easily.

motorsep

  • Hero Member
  • *****
  • Posts: 960
  • Karma: +74/-127
  • Artist
    • View Profile
    • Kot in Action Creative Artel
Re: LOD system
« Reply #25 on: December 07, 2016, 09:40:23 AM »
You shouldn't be using alpha blending as it's the most performance taxing solution. Alpha test with antialiasing should yield better performing grass than alpha blending.

Also, to reduce overdraw and fillrate, instead of having quad with grass texture on it, cut the mesh around the grass texture, to make mesh shape resemble outer contour of the grass (and still keep polycount to minimum of course). Drawing more triangles isn't an issue with modern GPUs. The problem is that while all those transparent pixels are not visible, they still render.

BielBdeLuna

  • Full Member
  • ***
  • Posts: 242
  • Karma: +8/-20
  • Doom Newbie
    • View Profile
    • my Github repositories
Re: LOD system
« Reply #26 on: December 08, 2016, 07:06:11 PM »
this thing is much better resolved in the rendering side of the engine, and as Motorsep pointed out this might need other tech in the engine than just simply replacing models.

argoon

  • Sr. Member
  • ****
  • Posts: 267
  • Karma: +21/-80
  • Doom Newbie
    • View Profile
Re: LOD system
« Reply #27 on: December 08, 2016, 08:16:57 PM »
I know this would be better in the engine side but i just don't want to mess with it for now, i'm still learning to code.

Motorsep i did what you said about
Quote
...cut the mesh around the grass texture...
and even tho i know that is generally true, it seams in this case it didn't worked as expect, first i didn't got any performance bump of note (i have still to do that to the lod0 tho) and second it caused the "deform sprite" material keyword to crash the engine, i need that to make the far away plane look always at the player. I tried to code my own "lookAt" code and even tho it worked it made everything too slow.

About your vertexcolors suggestion, worked like a charm but i also found out that if i use "deform sprite" in a material i can't use vertex colors at the same time it seams, causes the material to go black.   
« Last Edit: December 08, 2016, 08:32:29 PM by argoon »

motorsep

  • Hero Member
  • *****
  • Posts: 960
  • Karma: +74/-127
  • Artist
    • View Profile
    • Kot in Action Creative Artel
Re: LOD system
« Reply #28 on: December 08, 2016, 11:21:38 PM »
Why do you even use deform sprite ? Just make grass model with crossed planes and that's all. They don't need to "look" at you as you move. Just use regular material without deform sprite.

BielBdeLuna

  • Full Member
  • ***
  • Posts: 242
  • Karma: +8/-20
  • Doom Newbie
    • View Profile
    • my Github repositories
Re: LOD system
« Reply #29 on: December 09, 2016, 05:23:12 AM »
so every grass has a loop in script? every entity has a loop that runs every frame within the c++ code, look for the "think" function, you could code this in c++ and so you would not waste resources in the scripting side, you can also look into how The Dark Mod implemented their LOD system too.