FroggestSpirit
|
|
Posted on: July 03, 2014, 11:35:52 pm |
|
|
Joined: Mar 2013
Posts: 79
|
I've noticed this after porting bobomb battlefield into my game for testing, but the textures with transparencey get an outline with the color of the background color (aqua in the picture) This is present in ogl 1 and 3, I haven't tested in anything else. This is fixed if i turn off texture interpolation, but is there another way? Also, is there a way to draw the vertices with alpha coloring? this way a texture can be faded or partially transparent (maybe for ice or something)
|
|
|
Logged
|
This isn't easy to say, but…
|
|
|
Goombert
|
|
Reply #1 Posted on: July 04, 2014, 02:06:03 am |
|
|
Location: Cappuccino, CA Joined: Jan 2013
Posts: 2993
|
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.
|
|
|
Logged
|
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.
|
|
|
FroggestSpirit
|
|
Reply #2 Posted on: July 04, 2014, 07:33:20 am |
|
|
Joined: Mar 2013
Posts: 79
|
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
|
|
|
Logged
|
This isn't easy to say, but…
|
|
|
Josh @ Dreamland
|
|
Reply #3 Posted on: July 04, 2014, 09:53:39 am |
|
|
Prince of all Goldfish
Location: Pittsburgh, PA, USA Joined: Feb 2008
Posts: 2950
|
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.
|
|
|
Logged
|
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble "I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
|
|
|
FroggestSpirit
|
|
Reply #4 Posted on: July 04, 2014, 10:19:21 am |
|
|
Joined: Mar 2013
Posts: 79
|
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?)
|
|
|
Logged
|
This isn't easy to say, but…
|
|
|
|
FroggestSpirit
|
|
Reply #6 Posted on: July 04, 2014, 12:13:25 pm |
|
|
Joined: Mar 2013
Posts: 79
|
I forgot that there's a parameter for model_color_add_vertex() (or whatever it's called) to set transparency from 0 to 1.
|
|
|
Logged
|
This isn't easy to say, but…
|
|
|
Goombert
|
|
Reply #7 Posted on: July 04, 2014, 03:08:28 pm |
|
|
Location: Cappuccino, CA Joined: Jan 2013
Posts: 2993
|
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 };
|
|
|
Logged
|
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.
|
|
|
|