Toribash
Original Post
Invisible Texture Prevention
While perusing a the ban list (for no apparent reason) I noticed staff have to manually ban people for invisible textures. My idea is probably stupid and not plausible. Here it is though. I don't know if its even possible either.

Anyway, I would like to suggest some kind of line of code in the shop that analyzes textures when uploading textures with an alpha channel (.png) must not contain less than X percentage of blank pixels or the system automatically blocks it. Something that tailors itself to the size of the texture as well.

Here's an example using no less than 70% of the area of the texture and 30% blank allowed.

  • 16384 pixels in a 128 texture square means 11468.8 pixels must be filled with a color.
  • 45875.2 pixels on a 256 texture must be filled.
  • 183500.8 pixels on a 512 texture must be filled.
I just thought it would be useful for the staff because it's kind of a fire-and-forget solution to invisible textures.
Buy me food and tell me I'm cute.
Yeah, that's my main thing. I don't know if hampa or anyone currently on the staffing team has the time to create some kind of monitoring system like this. Also, no idea if they would have an extra server or whatever to manage this functionality.
Buy me food and tell me I'm cute.
Originally Posted by Fee View Post
The next step however, is unfortunately to perform a complete search, pixel-by-pixel. I cannot think of another way to do it. I guess if users who choose to use PNGs for texture upload with a RGB + alpha colour type were okay with longer wait times then this solution might be acceptable.

<?php
    function has_Transparency($imageData){
         //Get the width and height of the image for looping
         $w =imagesx($imageData);
         $h = imagesy($imageData);

         //Define an acceptable level of transparency
         $cutOff = ($w * $h) * 0.7;
         $transparentCounter = 0;

         //Iterate through pixels and amend transparency counter.
         //Break loop if cut off point (70% is reached). 
         for($i = 0; $i < $w; $i++){
            for($j = 0; $j < $h; j++){
                $rgba = imagecolorat($imgData, $i, $j);
                if(($rgba & 0x7F000000) >> 24) $transparentCounter++;
                if($transparentCounter == $cutOff) return true; 
            }
        }
        return false; 
    }
?>
That should work (I haven't tested it), although it is not going to be particularly efficient. There is probably a more intelligent way to search for transparency, but I'm starting to think that'll be beyond the effort of just having users report misuse and dealing with it then.

Checking every pixel would not be that slow, 512x512 textures have only 262144 pixels, which is pretty small for a computer to check, it would take at worst a few milliseconds.
Originally Posted by dengue View Post
nice one man,
I recommend a list to deal with that and make it scan every neighbour pixel.
with this you would not be so messed with sequential overhead.

I know sequential loops are a bit of overhead as the complexity grows as a power of loops count.

with lists you would do the same as the bucket fill of computer graphics libs,
make sure to use graphics processor.

Most servers don't have GPUs though, sequential accesses are the fastest BTW, checking every pixel wouldn't be that slow, it would take a few milliseconds at worst.