Author Topic: LOD system  (Read 1080 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 #30 on: December 09, 2016, 01:25:43 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.

Yes i know that and it would even make me use a single material for all (that would bring the draw call's down even more) and i'm planing to have lod0 and lod1 be cross planes but i want to have the ability to have at the long distance "impostors" and those are flat planes, if i don't use deform sprite or a similar lookAt function they look odd.

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.


Yes every grass object has a loop in script if you know how to make it otherwise (make it so they don't "think" all at the same time) and tell me i would be very grateful.
About the engine code again my c++ knowledge is very limited, i know it sounds like i'm afraid of going to the engine side (and i'm a little) but in reality i don't want to mess with fhdoom engine source, for the simple reason that, is more complicated code and if eXistence updates the engine, my code changes could make it impossible or very hard to update to the new version, if i can do it in script, better, if not i try other stuff, i'm just experimenting and learning for now.

Btw i changed the script so the loop runs only if the player is moving if not the loop stops, improved performance even more.



Edit: For anyone using notepad++ code editor i made a custom language highlighter for idtech4 script, here, anyone can edit it, so be carefull, the colors are for a dark theme tho but you can easily edit them in the notepad++ user language editor , is not fully complete (you can help) but most of the script functions are there, there's also custom coder keywords like TODO: , NOTE: , WARNING: , to help organization, to use them just write the keyword after single/multi line comment like so ex: //NOTE: "my note"  and it will work, i also made a (very incomplete) code auto complete/auto function helping here, but unfortunately it doesn't seam to work and i don't know why.
« Last Edit: December 09, 2016, 03:20:09 PM by argoon »

argoon

  • Sr. Member
  • ****
  • Posts: 267
  • Karma: +21/-80
  • Doom Newbie
    • View Profile
Re: LOD system
« Reply #31 on: December 10, 2016, 07:14:04 PM »
My grass system work's for the most part, performs very well and everything but unfortunately still flickers like crazy,  :-\  i tried everything i could, i changed my script perhaps 5 times, i tried changing models at run time with setModel(), spawning and removing the models at run time with spawn() and remove(), this one gave me the option to use plenty of grass entities in a level, but unfortunately performance was not that great in the end i settled in a spawn all and hide at init(), this last one gets me the best performance, unfortunately eats the entity budget fast if i'm not careful.

About the grass material i use now the "real translucent" technique found by TDM developers and my grass now looks very nice and reacts to light and shadows. :) Happy on this at lest.

« Last Edit: December 10, 2016, 07:33:38 PM by argoon »

The Happy Friar

  • Happy Happy Joy Joy
  • Administrator
  • Hero Member
  • *****
  • Posts: 851
  • Karma: +41/-4
  • Semi-Newbie.
    • View Profile
    • EarthQuake
Re: LOD system
« Reply #32 on: December 10, 2016, 09:06:33 PM »
What if instead of each grass object running the script you have the player run the script against a known # of grass objects & it changes them that way?  You'd only have one thread running then.  Would be a little more complex to setup though.

argoon

  • Sr. Member
  • ****
  • Posts: 267
  • Karma: +21/-80
  • Doom Newbie
    • View Profile
Re: LOD system
« Reply #33 on: December 10, 2016, 10:03:24 PM »
What if instead of each grass object running the script you have the player run the script against a known # of grass objects & it changes them that way?  You'd only have one thread running then.  Would be a little more complex to setup though.

Yes that is a nice idea!! I could just "tag" the grass objects and make the player detect them at run time, in my head the code wouldn't need to be very different, i would just run the loop on the player script instead of on every grass object, but i could be thinking wrong, need to experiment and see. Now that i think about it, that is how BielBdeLuna made his frob highlight script that he generously gave us!

Btw i assume this will not solve the flickering problem but i hope i'm mistaken.
« Last Edit: December 10, 2016, 10:04:55 PM by argoon »

The Happy Friar

  • Happy Happy Joy Joy
  • Administrator
  • Hero Member
  • *****
  • Posts: 851
  • Karma: +41/-4
  • Semi-Newbie.
    • View Profile
    • EarthQuake
Re: LOD system
« Reply #34 on: December 11, 2016, 12:41:47 PM »
If you're getting flickering in stock D3 but I can load  & change between random entities (even ones not cached) w/o flicker, it's got to be a CPU/threading thing or something in the engine changed that broke that ability.

Also try to do the grass in groups.  So instead of a single model it's 10 grass models.  Would cut down on what to check for.

argoon

  • Sr. Member
  • ****
  • Posts: 267
  • Karma: +21/-80
  • Doom Newbie
    • View Profile
Re: LOD system
« Reply #35 on: December 11, 2016, 05:05:59 PM »
If you're getting flickering in stock D3 but I can load  & change between random entities (even ones not cached) w/o flicker, it's got to be a CPU/threading thing or something in the engine changed that broke that ability.

Also try to do the grass in groups.  So instead of a single model it's 10 grass models.  Would cut down on what to check for.

Thanks i will if the suggestion about running the code on the player don't pan out, btw so i assume you tested my code and it worked?

The Happy Friar

  • Happy Happy Joy Joy
  • Administrator
  • Hero Member
  • *****
  • Posts: 851
  • Karma: +41/-4
  • Semi-Newbie.
    • View Profile
    • EarthQuake
Re: LOD system
« Reply #36 on: December 11, 2016, 07:02:06 PM »
haven't had time to test, I was basing it on my previous experiments with loading random entities.