|
|
Goombert
 Joined: Jan 2013
Posts: 2,991
|
 |
Reply #1 Posted on: July 04, 2014, 07:06:03 AM |
|
|
|
Is that a combined texture there frog? Is the fence a separate model? Let me explain why this is happening first.
The triangles drawing the fence are being drawn before the other ones, because they must be declared first in the model, so what is happening is when they draw their texture is interpolating with whatever is behind them which at the time they are drawn in the background color. There are several things you could do, move all the vertices for the fence to the end of the model, but the interpolation issue will still occur if the fence triangles begin to overlap each other and then you'll see the terrain through parts of the fence.
Another easy solution is to turn of zwriting, and no I don't mean disable the depth buffer entirely, I mean just disable writing to it for this one model. d3d_set_zwriteenable(false); Do that before drawing the model, and then turn it back on afterwards. This is how I solved it in Project Mario's trees, Dailly specifically added this function in 8.1 at my request, which was really awesome at the time despite the fact I don't like where Studio is going.
There are other solutions that involve screwing with the sampler or something, I'm not sure, you'd have to investigate but I know there are alternatives, but I believe they may involve depth sorting and may be slow. This artifact is actually pretty common even in a lot of today's games.
|
|
|
FroggestSpirit
 Joined: Mar 2013
Posts: 79
|
 |
Reply #2 Posted on: July 04, 2014, 12:33:20 PM |
|
|
thanks a lot  i'll try out the zbuffering. and yeah, the fence is its own model currently, so it should be easy to do
|
|
|
Josh @ Dreamland
Prince of all Goldfish
 Joined: Feb 2008
Posts: 2,950
|
 |
Reply #3 Posted on: July 04, 2014, 02:53:39 PM |
|
|
|
Drawing the fence last is really your best course of action. Enabling zwrite for it won't really be an issue, then. Frequently, people queue up semitransparent polygons for draw last, and then sort by distance from camera. That's pretty costly, but fortunately, I don't suspect you'll have a lot of transparent objects that overlap.
Let me add: that function is underpowered. And I remember using it in GM6, Robert, so if it was missing from Studio, it was probably accidentally elided. It was underpowered, then, too. You need to be able to set the z-buffer write and read operators. You should be able to say, "write to the z buffer when depth is less [or equal]", or "read from the z buffer and draw when greater [or equal]", which would cause objects to only be drawn when there's a face occluding them. This is useful for when you want to draw a shadow of a player when that player is behind a rock. Instead, our fearless leader only lets you enable or disable a less-than test on z-write.
|
|
|
FroggestSpirit
 Joined: Mar 2013
Posts: 79
|
 |
Reply #4 Posted on: July 04, 2014, 03:19:21 PM |
|
|
I've updated my model format, so sorting the faces that have transparency should be easy. Right now, each part of the level with a different texture has it's own model, and own properties (draw both sides, collision, lighting, etc) so adding a flag for transparency to sort it will be simple. On the other hand, games like Banjo Kazooie have parts with 2 faces on the ground where there are 2 different textures. this allows blending them, like grass into dirt. is there a way I can do vertex coloring with alpha colors? This would also make water easier to do. (would they also need to be sorted in draw order?) 
|
|
|
TheExDeus
 Joined: Apr 2008
Posts: 1,860
|
 |
Reply #5 Posted on: July 04, 2014, 03:20:41 PM |
|
|
|
Josh, that function was added in GM8.1.139. I don't remember having it in GM6. I also think there was a function added to actually change the z-buffer operator.
edit: draw_set_alpha()? If you create models by adding your own vertices (draw_vertex(...)), then just use the one with color.
|
|
|
FroggestSpirit
 Joined: Mar 2013
Posts: 79
|
 |
Reply #6 Posted on: July 04, 2014, 05:13:25 PM |
|
|
|
I forgot that there's a parameter for model_color_add_vertex() (or whatever it's called) to set transparency from 0 to 1.
|
|
|
Goombert
 Joined: Jan 2013
Posts: 2,991
|
 |
Reply #7 Posted on: July 04, 2014, 08:08:28 PM |
|
|
Yes, Josh Harri is right, zwriteenable was not gm6, it was added to 8.1 at my request, I pm'd Dailly on the GMC. Now I hadn't actually thought of what Josh said, but I already snuck in a function a while ago that does that. http://enigma-dev.org/docs/Wiki/D3d_set_depth_operatorThese are the constants, they are mapped the same for GL1 and GL3 and DX9. enum { rs_never, // Always False D3DCMP_NEVER GL_NEVER rs_less, // source Z < depth Z D3DCMP_LESS GL_LESS rs_equal, // source Z = depth Z D3DCMP_EQUAL GL_EQUAL rs_lequal, // source Z <= depth Z D3DCMP_LESSEQUAL GL_LEQUAL rs_greater, // source Z > depth Z D3DCMP_GREATER GL_GREATER rs_notequal, // source Z != depth Z D3DCMP_NOTEQUAL GL_NOTEQUAL rs_gequal, // source Z >= depth Z D3DCMP_GREATEREQUAL GL_GEQUAL rs_always // Always True D3DCMP_ALWAYS GL_ALWAYS };
|
|
|
|