Phantom107 Forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Phantom107 Forum

Phantom107's Forum. Discuss about games, GML, 3d, game design here. Enjoy your stay ;)
 
HomeSearchLatest imagesRegisterLog in

 

 Important Speed & Graphics Discovery

Go down 
2 posters
AuthorMessage
Phantom107
Admin
Phantom107


Posts : 206
Join date : 2008-01-03
Location : The Netherlands

Important Speed & Graphics Discovery Empty
PostSubject: Important Speed & Graphics Discovery   Important Speed & Graphics Discovery Icon_minitimeFri 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! Very Happy
Back to top Go down
https://phantom107.actieforum.com
slayer64
Heavy Poster
slayer64


Posts : 143
Join date : 2008-01-05

Important Speed & Graphics Discovery Empty
PostSubject: Re: Important Speed & Graphics Discovery   Important Speed & Graphics Discovery Icon_minitimeFri 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?
Back to top Go down
Phantom107
Admin
Phantom107


Posts : 206
Join date : 2008-01-03
Location : The Netherlands

Important Speed & Graphics Discovery Empty
PostSubject: Re: Important Speed & Graphics Discovery   Important Speed & Graphics Discovery Icon_minitimeFri 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 (!)
Back to top Go down
https://phantom107.actieforum.com
Sponsored content





Important Speed & Graphics Discovery Empty
PostSubject: Re: Important Speed & Graphics Discovery   Important Speed & Graphics Discovery Icon_minitime

Back to top Go down
 
Important Speed & Graphics Discovery
Back to top 
Page 1 of 1
 Similar topics
-
» vintage speed 3 x 2
» Speed Techniques

Permissions in this forum:You cannot reply to topics in this forum
Phantom107 Forum :: Techniques-
Jump to: