Phantom107 Admin
Posts : 206 Join date : 2008-01-03 Location : The Netherlands
| Subject: Important Speed & Graphics Discovery Fri Jan 11, 2008 8:04 pm | |
| I was working on my FPS Engine and I figured it was time for some vegetation. I decided to add trees to make the level design and geometry more interesting. I use a transparent billboard of a tree for the texture. I created a variable that I was going to use for the model index. I executed this piece of code to very professionally create the big tree model used for the map: - Code:
-
model_trees = d3d_model_create(); with (o_Tree) { d3d_model_wall(o_Controller.model_trees,x-4,y,0,x+4,y,20,1,1); d3d_model_wall(o_Controller.model_trees,x+4,y,0,x-4,y,20,1,1); d3d_model_wall(o_Controller.model_trees,x,y-4,0,x,y+4,20,1,1); d3d_model_wall(o_Controller.model_trees,x,y+4,0,x,y-4,20,1,1); } Now the strangest thing happened: When I executed d3d_model_draw(...) to draw the trees on the map, it was lagging the game to death. What the fuck!? I have models using d3d_model_wall(...) all over the place and it that caused no lag at all!! After a lot of speed tests I figured it was the texture! Appearantly d3d_model_wall(...) hates using a transparent texture! Very strange indeed... The solution I found is actually very simple. Instead of using d3d_model_wall(...) for creating the model that uses a transparent texture, I create it with the d3d_model_primitive(...) and d3d_model_vertex_texture(...) functions. The lag was gone! It even looked prettier because somehow it solved depth issues too! I hope this helps. It certainly did in my engine! | |
|
slayer64 Heavy Poster
Posts : 143 Join date : 2008-01-05
| Subject: Re: Important Speed & Graphics Discovery Fri Jan 11, 2008 8:35 pm | |
| so you had a transparent tree and it looked right? you didn't just see whatever was behind it. i know when i make things in 3d and give them an alpha using draw_set_alpha() they sometimes show what is behind them or what is behind a wall behind them. i correct this by setting their depth to -100.
so where did you set the alpha value? in the model? or where you drew the model? | |
|
Phantom107 Admin
Posts : 206 Join date : 2008-01-03 Location : The Netherlands
| Subject: Re: Important Speed & Graphics Discovery Fri Jan 11, 2008 9:17 pm | |
| No, you see, this has nothing to do with alpha. I know what you problem is though, since it happened to me in the past quite often. Your problem is depth. The depth determines the order in which things are drawn after each other. You need to make sure that either the more distance from the object to the camera the greater it's depth should be, or just manually control what gets drawn first (very advanced, use with care). If the depth is correct, you won't get those strange alpha blending problems anymore and draw_set_alpha(...) works perfectly.
Alpha != Transparency (!) | |
|
Sponsored content
| Subject: Re: Important Speed & Graphics Discovery | |
| |
|