With cordite in the air, splintered steel, shell casings and powder burns, there’s only one explanation...
Discuss & improve the game engine.

Moderators: sparcdr, torhu, Tequila

new cool stuff ! func_static far clipping !

Postby Joe Kari » Sat Jan 10, 2009 11:58 pm

Hi, I'm currently working on far clipping !

This is a really cool stuff, this will allow us to have brushs that are magically turn invisible when the camera is far away... ideal for example for grass effect (do you remember my experimental duel map ?). For instance, it works only for func_static, you have to add a key to this entity in radiant, named "farclip", the value is the distance in game unit where the whole func_static will be clipped. Your func_static needs an origin brush (this is what is used for the distance to camera).

If this is not too difficult, I plan adding this feature to misc_model too ;)
Very interesting for tiny model that can't be well hintbrushed (for example all models in the big house of alamo, that are VISible from many place because this house has too many window... This could boost FPS ;)
User avatar
Joe Kari
SG Team
 
Posts: 879
Joined: Sun Sep 16, 2007 8:44 pm
Location: France



Postby DeUgli » Sun Jan 11, 2009 6:58 am

Wow, Joe. You are really productive and creative. Like your blog too. Keep up the good work!
Irgendeiner wartet immer.
User avatar
DeUgli
Smokin' Amigo!
 
Posts: 280
Joined: Sat Nov 05, 2005 12:29 am
Location: Seattle WA, USA



Postby ReD NeCKersoN » Sun Jan 11, 2009 7:11 am

DeUgli wrote:Wow, Joe. You are really productive and creative. Like your blog too. Keep up the good work!

I'll second that. :wink:
Image
User avatar
ReD NeCKersoN
SG Team
 
Posts: 3245
Joined: Wed Mar 27, 2002 6:22 am
Location: VA, USA



Postby Joe Kari » Mon Jan 12, 2009 12:07 am

Got it to work ! 8)

It all works with func_static. It was a hard work cause we have got a bug with func_static that have an origine brush: it was fooling the physical engine for the whole group. Unfortunately, my far-clipping needs absolutely an origin brush since it is the point where distance to camera are calculated. So I have rewritten from scratch all the func_static code for Smokin' Guns, adding the new far-clip feature. I have commited it. It's only in the mod-part of the code.

You can far-clip models too, just link your misc_model to a func_static that have far-clipping (unselect all -> select your misc_model -> select one brush of your func_static -> hit Ctrl-K -> the model is now a part of the func_static). Only one little annoying things: your func_static need at least one brush, it looks like Q3 engine don't like entity that are empty and don't load the map.

Good tips is to link many models that stand close each other to the same func_static, so they will be calculated only once.

The entity key is "farclip", the value is in game unit. Small limitation: your value is rounded to a multiplier of 100 (because it is coded with 8bits in the network code).

I will update Alamo tomorrow, with far-clipped md3 I hope I will gain some FPS (I will post result ;) ).



I hope you enjoy this new feature ! Just imagine the new possibility of clipping ! Especially with grass !
User avatar
Joe Kari
SG Team
 
Posts: 879
Joined: Sun Sep 16, 2007 8:44 pm
Location: France



Postby EvilFutsin » Mon Jan 12, 2009 12:32 am

I think you may have just given poor mappers like me a new hero to champion! :D Way to go, Joe-dude! Rawk that codin' mappin' goodness. 8)
Image
"I Gotta Believe!"
User avatar
EvilFutsin
SG Team
 
Posts: 382
Joined: Wed Apr 09, 2003 12:33 pm
Location: Portland, OR



Postby Breli » Mon Jan 12, 2009 12:49 am

very, very cool! is there any way I can test that with models in my maps? Sorry for these dumb question but an ol' guy like me can barely keep up to speed here ...
SG name: =SG= BRELI

Harmonica: Did you bring a horse?
Gunmen: Looks like we are short on one horse!
Harmonica: No. You brought two too many.
User avatar
Breli
SG Team
 
Posts: 906
Joined: Mon Jul 18, 2005 10:08 am
Location: Germany



Postby Joe Kari » Mon Jan 12, 2009 10:59 pm

Now it is possible to set the "form" of the clipping ;)
The syntax has a little changed, now you have to set the key "farclip" to a string like "form + one or two value".
For example setting it to the value "sphere 256" will clip the func_static if you are farther than 256 game unit from its origin. Sphere is the former behaviour. Just imagine a sphere of 256 unit radius, if you are outside of it, your func_static is clipped.
If you prefer a cubic clipping, just put the value "cube 256".
You can also have cylinder, for example "cylinder_z 256 192" specify a cylinder along the z-axis, that have a radius of 256 and a height of 192. "cylinder_x" and "cylinder_y" exist too.

One of the more interesting is "cone_z". That's the perfect form for grass. I invented it because while I was testing with usual sphere form, that was not very fine because if your player (or a spectator) fly over the scene, all grass was disappearing. However, even with a high cylinder form, I was able to see the "trick". I wanted something that does less clipping while I go higher. Now with "cone_z 256", if you are at the same level than the func_static origin, you got the clip at 256 game unit away from it, but for every unit of distance along the z-axis you have got with its origin you have got one unit of radius more before clipping. The clipping frontier looks like this: \_/

Others forms are box_*, ellipse_*, square_infinite_*, circle_infinite_* and pyramid_* ('*' means 'x', 'y' or 'z').

The distance is now rounded to the closest multiplier of 64, to better fit the gridsize of your map.

Well I hope I don't confuse you too much, I realize that I should probably write a full tutorial about that :D

very, very cool! is there any way I can test that with models in my maps? Sorry for these dumb question but an ol' guy like me can barely keep up to speed here ...

BTW you need the last qvm for that ;)
I still have some work to put on this, for instance my func_static don't register to the PVS tab -_-' so wait two or three days before testing it!
User avatar
Joe Kari
SG Team
 
Posts: 879
Joined: Sun Sep 16, 2007 8:44 pm
Location: France



Postby Joe Kari » Tue Jan 13, 2009 1:13 pm

Wow I was wrong, they links to the PVS tab, it's just that the whole func_static is or is not visible, it doesn't work per brush/model like I was guessing. I can't change this this except if I rewrite a bunch of code (both in SG and in q3map2), a thing I don't want to do lol :D
So it will work this way.
User avatar
Joe Kari
SG Team
 
Posts: 879
Joined: Sun Sep 16, 2007 8:44 pm
Location: France



Postby Joe Kari » Thu Jan 15, 2009 2:19 pm

I have added some cvar to controle the effect:
- "cg_farclip to turn" on/off far clipping, default: 1 (on)
- "cg_farclipValue" to scale it up, default: 1, value lesser than 1 are ignored to prevent potential cheat... If you saw some clipping and don't like that too much (but don't want to disable it because your computer isn't enough powerfull) you can set it to 1.5 or 2

And a new cool stuff:
- "cg_farclipZoomValue" for the sharp's zoom mode, default: 3 (can't be lesser than 1 too)... So when you zoom in with the scope, the far-clipping occurs 3 times farther, this is a good thing ;)
(oh and the day I found where r_subdivide is calculated, I will change its value when zooming, cause curves are not really nice-looking with a scope... but it looks like it is coded in the engine, so I will wait for the ioQ3 backport before doing anything on that).


BTW I'm currently modeling new md3 for Alamo, so I strongly suggest everyone to never turn far-clipping off :lol:

EDIT: those variable's name are now in camelCase.
Last edited by Joe Kari on Fri Feb 06, 2009 1:33 pm, edited 1 time in total.
User avatar
Joe Kari
SG Team
 
Posts: 879
Joined: Sun Sep 16, 2007 8:44 pm
Location: France



Postby Joe Kari » Sat Jan 17, 2009 7:12 pm

I have finished upgrading Alamo using some far clipping.

I gain around 4~5 FPS almost everywhere.
The worst spot of Alamo has 44 FPS on my computer with far-clipping off, 49 FPS with far-clipping on. There are few area where I gain 15 FPS.

I was expecting slightly better result, but this is still very usefull, especially because now, I can replace all low poly stuff in the house by fine hi-poly md3 without any additionnal cost (I have already design a 800 poly chair that does it well).

I will make a tutorial soon...
User avatar
Joe Kari
SG Team
 
Posts: 879
Joined: Sun Sep 16, 2007 8:44 pm
Location: France



Postby Tequila » Tue Jan 20, 2009 8:14 pm

Hey Joe, when you'll think you have done with farclip, can you tell us what do you want to see in the system settings UI to permit tuning it ?
8)
User avatar
Tequila
SG Team
 
Posts: 1100
Joined: Thu Nov 15, 2007 11:33 pm
Location: Montpellier, France



Postby Joe Kari » Tue Jan 20, 2009 10:32 pm

Something like :
far-clipping: disable / standard / farther / farthest

* disable set cg_farclip to 0
* standard set all to default value (set cg_farclip to 1, set cg_farclipValue to 1, set cg_farclipZoomValue to 3)
* farther set cg_farclip to 1, set cg_farclipValue to 1.5 and set cg_farclipZoomValue to 4.5
* farthest set cg_farclip to 1, set cg_farclipValue to 2 and set cg_farclipZoomValue to 6

EDIT: those variable's name are now in camelCase.
Last edited by Joe Kari on Fri Feb 06, 2009 1:32 pm, edited 1 time in total.
User avatar
Joe Kari
SG Team
 
Posts: 879
Joined: Sun Sep 16, 2007 8:44 pm
Location: France



Postby mugenmidget » Wed Jan 21, 2009 1:04 am

This is VERY cool, thanks a bunch! I hope all of the maps get retrofitted so my poor PC can run this game smoother.

:lol:
My gosh, that's too cheap!
User avatar
mugenmidget
Drifter
 
Posts: 15
Joined: Wed Jan 14, 2009 11:44 am



Postby Joe Kari » Mon Feb 09, 2009 6:23 pm

I can easily modify my farclipping code to introduce conditionnal func_static that are rendered only depending on a cvar that represent the level of detail the user want.

Something like cg_mapLevelOfDetail could be the name of this cvar.

For example, my church in Alamo look a little to simple, blocky... I want to add more geometric detail on it (maybe some sculpture, etc), but owner of old computer are already complaining about their FPS in Alamo.

With this new feature, we will be able to upgrade geometric detail to a more decent level, regarding of today's game, but owner of old computer will be still able to play.


Some idea of how to map this:
You design a rough object in brushwork, it is solid (that will be that object that will be used by the physical engine). You make it func_static and set a key "level_of_detail" to "max 0".
You make a fine md3 that have more or less the same shape than your brushwork, non-solid and that does not cast shadow, with high polycount, you move it at the same place, you make it a func_static and set the key "level_of_detail" to "min 1".

So if the user choose a level of detail over 1, only the md3 will be displayed, if he choose a level of detail of 0, only the brushwork is displayed.



Do you like the idea ?
User avatar
Joe Kari
SG Team
 
Posts: 879
Joined: Sun Sep 16, 2007 8:44 pm
Location: France



Postby Joe Kari » Tue Feb 10, 2009 6:44 pm

Done on revision 135.

Finally the entity's key is simply: "lod". Possible value are "[min|max] [0|1|2|3]".
Cvar name to controle your level of detail is: cg_mapLOD, default value 2, should be between 0 and 3.
You can modify cg_mapLOD without a vid_restart.

Take care that using it like I explain in the previous post use 2 entity instead of 1, so use it when it can really change things, for example if your mapobject is visible almost everywhere, and you can't use far-clipping for various reason...
Can be used for grass effect to limit permanently the number of them.

You can use "farclip" and "lod" in conjunction in the same entity.

Let's say that:
- level 0 is for "low" level of detail, filtering for old computer
- level 1 is for "medium"
- level 2 is for "high", filtering for fast computer
- level 3 is for "very high", eventually if you plan to add some detail to your map for video scene only ;)
User avatar
Joe Kari
SG Team
 
Posts: 879
Joined: Sun Sep 16, 2007 8:44 pm
Location: France



Next

Return to Code

Show Sidebar
Show Sidebar

User Control Panel

cron