• Welcome to PiBoSo Official Forum. Please login or sign up.
 
March 29, 2024, 10:54:22 AM

News:

World Racing Series beta14 available! :)


What is the correct method for transparency for GPB track?

Started by h106frp, April 22, 2017, 03:16:32 PM

Previous topic - Next topic

h106frp

I have not been happy with the result from using CK_TREE for 'cut out' type textures when the source image is just a texture with alpha for the transparent areas.

In the track notes it explains that CK_ is color key, so should I be defining some sort of chroma-key rather than just having a transparent image texture?

Thank you

TFC

I have no idea about chroma-key, but I can quickly explain how I've managed to get 2d trees to work with little to no alpha bleeding and no need for the CK prefix.

First off, make sure the alpha mask is perfectly cut out, and turn up the contrast so the only values that exist are 0 black and 255 white.

Then use something along the lines of 'Flaming Pear' plugin, for Gimp I use this one http://gimpchat.com/viewtopic.php?f=9&t=3153&start=0

Then I export as a DDS image, compression set to 'BC3 DTX5' and 'Generate MipMaps' set to ON.

Next I 'Import Image as Plane' in Blender, making sure to tick the 'Use Alpha' box.

First thing I do is copy the plain and flip it 180* so it's double sided, then join those together. Then I do the same with the 2nd image (if I'm using 2 for my 2d trees, you can do it with one just duplicate the joined faces and rotate 90*). Once you have the layout or setup you want for the tree, select everything and join it together so it's one object.

I now have my 2d tree.. But the most important step is to duplicate it, leave it occupying the same space as the master and join the 2 together (so it's 2 trees in the same spot).

One tree comes out at 16 tri's which is more than acceptable, and it works really nicely. Sorry if this isn't the answer you wanted, but I've spent over a year battling with this problem and only through trial and error was I able to get the process down to a point I was happy with the results ;)

This image below uses this method. There is no 'CK' prefix used and no bleeding issues, no sorting issues etc.. Perfect.


h106frp

They look like better trees

I am suffering with Z sorting and I think the step missing might be

'First off, make sure the alpha mask is perfectly cut out, and turn up the contrast so the only values that exist are 0 black and 255 white. '

Can you explain this step a bit more.

Thanks

TFC

April 22, 2017, 06:08:22 PM #3 Last Edit: April 22, 2017, 06:20:58 PM by TheFatController
I only use Gimp but I can explain that process.

Take your tree with alpha channel, assuming you've already cut it out or downloaded a pre cut one.

Right click on the trees layer and 'Add Layer Mask', then choose 'Layers Alpha Channel'. What this does is converts your alpha into a visible image. You'll notice some of the edges are antialiased and if this is done badly, it will bleed nothingness (normally white) around the edges giving a halo.

Click the black and white layer to enable mask editing and you should see it becomes highlighted, then adjust brightness and contrast, wacking the contrast up to maximum, this will convert the antialiased mask into a clear cut 2 colour black and white mask. You can right click the alpha mask and choose 'show layer mask' to see what you're doing, but the results will be transferred into your main image anyway.

The importance of the 'Flaming Pear' type plugin is to make sure all edges of the tree overlap into the transparent areas before being masked. When texture quality is lowered in game and the edges of the texture are blurred, without making sure there is enough coverage under the mask can result in the halo effect.

Z-sorting or z-buffer issues are unrelated though. It's just the graphics cards inability to distinguish which tree needs drawing first. I don't know much more than that but I know programs like Blender, SketchUp and other 3d platforms suffer so I don't think it's a simple fix. If using CK works then definitely do it, but I found using my method doesn't require it.

h106frp

Thanks, following your guide I can see that one issue is that the tree mask was slightly 'grey' hence the translucent tree effect.

Should be stickied  :)

Hawk

Quote from: h106frp on April 22, 2017, 06:41:43 PM
Thanks, following your guide I can see that one issue is that the tree mask was slightly 'grey' hence the translucent tree effect.

Should be stickied  :)

+1

Well done guys, an issue we have on a lot of tracks can now be sorted by the sound of it. Thanks!  ;D 8)

Hawk.

TFC

Glad to help, but I wouldn't fancy the job of fixing a bunch of tracks! God knows how bad some of the tree textures are, the worse the problem the harder it is to fix. The tree textures I use were bigger than 2k before being scaled down so the quality is perfect.

Once I've finished the track I'm working on I'll be releasing a tree pack to the MXB Asset thread, since nobody has so far taken up the role of running one over here they will remain over there for now. I guess I could just copy and paste the post content into a thread over here but.. well.. I didn't want to :P

If an admin wants to sticky this, I'll gladly write out a proper tutorial with pictures. Someone just let me know :)

Hawk

@TheFatController: You mentioned creating Mipmaps..... As far as I know GPB doesn't support them, does MXB?

Hawk.

TFC

I have no idea if GPB or MXB support mipmaps.. I would have thought from an optimisation point of view they should be supported, but if not I don't think using the option affects anything negatively.

It might be the winning formula though, I can do tests some time to see if not generating them offers the same result, but I'm not in a rush :)