1 registered members (TipmyPip),
18,449
guests, and 6
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
"Fog cubes" and depth sorting!
#65171
02/28/06 02:08
02/28/06 02:08
|
Joined: Aug 2002
Posts: 681 Massachusetts, USA
Ichiro
OP
User
|
OP
User
Joined: Aug 2002
Posts: 681
Massachusetts, USA
|
Howdy. I have an enormous, semi-transparent, hollowed-out cube that I use to tint the sky a particular color. This works well, but I notice that it appears in front of other transparent objects (presumably due to depth sorting -- the cube follows the player around as he moves, so the center is right at the camera's coordinates). Is there an easy way to force the object to be drawn first, so that everything else appears over it?
Note: There are, of course, a number of other ways to handle this tinting; I'll eventually just paint over the skycube to tint it. But I thought I'd ask re: the depth sorting, since I'm just prototyping things.
Thanks!
|
|
|
Re: "Fog cubes" and depth sorting!
[Re: Ichiro]
#65172
02/28/06 02:45
02/28/06 02:45
|
Joined: Oct 2003
Posts: 4,131
Matt_Aufderheide
Expert
|
Expert
Joined: Oct 2003
Posts: 4,131
|
I assume you have this cube placed at the camera position..
Then this sorting problem is natural, because transparent polygons are sorted by entitity position, not the Z-buffer. So think about this, if its x,y,z position is at the camera position, its always closest to the camera, and will generally be drawn on top of other transparent entities, not behind as you want.
Setting aside the fact that it's not the best idea to use a transparent cube in this way, as I'm sure you know, there is no easy way to solve this sorting problem . To do so you would need to render it in a DLL, using the 'render_sky' event. This way you could ensure that it's drawn before all other entities..(of course then I think it would be drawn before the skybox too, so you have another, worse problem).
So basically, this isnt going to work. if you want to tint your sky box, there is a much better to way.. do it with a very simple pixel shader. That way you could change it's tint at runtime to simulate changing time of day, weather, etc.
|
|
|
Re: "Fog cubes" and depth sorting!
[Re: Ichiro]
#65174
02/28/06 07:21
02/28/06 07:21
|
Joined: Feb 2006
Posts: 28 Australia
Blood
Newbie
|
Newbie
Joined: Feb 2006
Posts: 28
Australia
|
Maybe would work if you set its "layer" lower than other entities.
In the manual...
Elements with higher layer value will be placed over elements with lower layer value. Elements with the same layer value are sorted due to the z buffer
entity shotgun_onscreen { type = <shotgun.mdl>; layer = 2; // display above view entities with layer 1 flags = visible;// visible on screen from the start view = CAMERA; // same camera parameters as the default view albedo = 50; // gouraud shading from sun position x = 100; // place 100 quants ahead of the view y = -50; // 50 to the right z = 0; // and center vertically }
Another you could try would just be a flat transparent sprite infront of camera and use layers. Goodluck
( It is better to conceal one's knowledge than to reveal one's ignorance. )
|
|
|
Re: "Fog cubes" and depth sorting!
[Re: Matt_Aufderheide]
#65178
03/01/06 15:42
03/01/06 15:42
|
Joined: Jun 2005
Posts: 656
Grafton
User
|
User
Joined: Jun 2005
Posts: 656
|
Or, a variation of Doug's idea(?), move the origin of the cube to the center of the far side that will be in front of the camera in MED. Then assuming the cube is say 20000 per side, the cube should be kept 10000 quants in front of the camera so the camera is still in the center of the cube and the cubes origin is always 10000 quants in front of the camera. (like this;) Code:
action tint_cube { while(me) { vec_set(temp, vector(10000,0,0)); // create offset with temp vec_rotate (temp, camera.pan); //pan temp same as cameras pan vec_add (temp, camera.x); // add cameras position to offset vec_set (my.x, temp.x); // put me there wait(1); } }
Last edited by Josiah; 03/01/06 15:44.
Not two, not one.
|
|
|
Re: "Fog cubes" and depth sorting!
[Re: Grafton]
#65179
03/02/06 03:37
03/02/06 03:37
|
Joined: Sep 2003
Posts: 4,959 US
Grimber
Expert
|
Expert
Joined: Sep 2003
Posts: 4,959
US
|
tint the sky try using a totaly semi transparent solid color ( like white set to 50%) for your skybox texture ( be sure its flagged SKY when you apply it to the skybox) now set your background colors (bg_color. ) to set a sky color tint ( remeber to adjust sunlight color also to help properly reflect the overall level lighitng color) Edited: any sky texture you use over the background ( like domes ) you then want transparent or overlay areas in the image to allow the BG_color to com through some shots I did of just the above thing. forground Im using a model with the same 50% white transparent image as the box model skin. a skybox set with the same 50% white texture flagged with sky applied to the walls and cieling of this holow cube ( floor of cube is the floor textured block you see)  for the sort issue I've found it you just don't combine a semi-transparent and full opaque in the same skin image then things seem to work ok then.
Last edited by Grimber; 03/02/06 03:40.
|
|
|
Re: "Fog cubes" and depth sorting!
[Re: Grimber]
#65180
03/02/06 04:01
03/02/06 04:01
|
Joined: Sep 2003
Posts: 4,959 US
Grimber
Expert
|
Expert
Joined: Sep 2003
Posts: 4,959
US
|
I did anotehr example test for the semi transparent sort stuff. with the new changes in MED. group parts of the model that will have OPAQUE skin. group triangles of the model that need an transparent skin. then apply differnt skin texture to each group  I duplicated the cube in the model itself, deleted teh faces where the 2 cubes meet. set each cube as a differnt group. one gave the 50% transparent white skin, other half gave is some bad wood texture I had ( differnt image formats btw. 32 bit tga and 24 bit bmp) ill play around with anotehr example If I can find a nice car model, give its windows seperate grouing and apply a transpeent image
|
|
|
|