Advertisement

Another way to create 3d icons for item?

Started by November 10, 2019 09:40 AM
6 comments, last by Kryzon 5 years ago

Hi.

I am looking for a better way to create 2D / 3D icons for items from 3D models.  For example, I have about 120 items in the game.  

Now I am creating icons for items as follows:

1)I create a simple script inside the game that will sequentially make a screen shot from the camera and change the item. All this is done on a green background.

2)I put all these screenshots in Photoshop.  And for each subject I delete the background, center it on the grid, crop it.  

3)I put it into the game.  And when building inventory slots with items, I still have to align and scale them because each item has the different size. And I must select all these parameters for each subject manually.  It takes too much time.  

Does anyone have any ideas how to do this faster?  Maybe there is software to create something like that?

Thx.

Sorry for my English.

All of these steps can be easily done from a script.  If your game engine doesn't come with a robust set of 2D image manipulation tools, use a different scripting environment.  It'd take maybe ten to thirty minutes or so to write such a script in Python using PIL/Pillow.

Advertisement
8 minutes ago, a light breeze said:

It'd take maybe ten to thirty minutes or so to write such a script in Python using PIL/Pillow.

Python can help me with resizing, overlay effects. Can python solve the background removal problem?  Or do automatically center the object without a background? I did not go deep into PIL capabilities.

Background removal is easy, and it's even easier if you render each object twice, once with a white background and once with a black background.  If you have the same pixel color in both images, then the pixel is totally opaque.  If you have one black pixel and one white pixel, then the pixel is totally transparent.  If it's neither of these, then the pixel is partially transparent.  Take one pixel value and subtract the other to get the level of transparency, subtract the level of transparency from 255 to get the alpha value, and divide the darker pixel color by the alpha to get the rgb.  (There is probably a faster way using PIL.ImageChops, but it's not immediately clear to me what it is, and performance isn't really critical here.)

Centering is even easier.  Use image.crop(image.getbbox()) to get the cropped image, then use PIL.ImageOps.pad to resize and center.

This is not a Writing topic. Moving to an appropriate forum.

-- Tom Sloper -- sloperama.com

19 hours ago, a light breeze said:

.

Initially, I took your option with skepticism.  But now it seems less attractive.  I obviously won’t make a script in 15-30 minutes.  I think I will have to spend quite a lot of time learning python / PIL, but this will probably help in the future to organize work with images.  Thank you.

Advertisement
On 11/10/2019 at 4:37 AM, a light breeze said:

Take one pixel value and subtract the other to get the level of transparency,

@a light breeze Oh I get it, you have...

(white*(alpha-1.0) + channel*alpha) - (black*(alpha-1.0) + channel*alpha)

Knowing that white = w = 1.0, black = b = 0.0, alpha = a and channel = c, this expands to:

(w.a - w + c.a) - (b.a - b + c.a) = (1.a - 1 + c.a) - (0.a - 0 + c.a) = a - 1

So subtracting, say, the red channel of the black pixel from the red channel of the white pixel, you end up with x = ALPHA - 1.0. Then ALPHA = 1.0 - x

Pretty clever!

PS: You could also try creating an RGBA framebuffer for semi-transparent rendering?

This topic is closed to new replies.

Advertisement