Counter-Strike 2

Counter-Strike 2

Not enough ratings
How to make 3D holo stickers (CONCEPT)
By Meson
The concept of creating 3D holos. Perhaps it can be used in the future
   
Award
Favorite
Favorited
Unfavorite
Warning!
The method shown below is just a concept and is hardly applicable for sticker creation, as it contains many drawbacks. My goal is to show this method and maybe get some feedback and ideas on how it can be applied or made usable.
Some theory
Some time ago, one guy discovered a way to create holo stickers with a unique effect. Part of the pattern on them moved in a certain direction when the sticker was tilted. Later these stickers were added to the game as “lenticular”.


But what does lenticular mean? In fact, the creators of CS are very much concerned with the realism of the game and would not add anything that could not exist in the real world. So they decided to create a legend that such stickers are made by lenticular printing. Print made by this method can look like a 3D image in the real world or play some animation when tilting the object on which this image printed.


How does lenticular printing work?
A specially shaped sheet of transparent plastic is applied to a specially printed image. Each bump on this sheet is a miniature lens that shows part of the image only at a certain angle. Each part of the image shown at a certain angle is part of one frame of animation. Thus, looking at the lenticular print from different angles we see different images.


It doesn't look much like what is called “lenticular” in CS, but it could theoretically be realized with true lenticular printing too.
Goal
So, my goal is to create a lenticular print effect in Counster Strike using the tools available when creating a holo sticker.
Some theory about holos
The holo stickers have four textures, two of which have no meaning for us: the main sticker texture and the scratch intensity map, and two textures we need: the holo effect map (holomask) and the texture displayed on the holo effect areas.

How holomask works.
Any image can be divided into 3 channels, in photoshop these channels look like this:


They mean how red, green or blue a pixel is. So, we just divide an RGB image into its three components.

The red color on this mask indicates the intensity of the holo effect. The whiter the color of the pixel when you select a channel, the more intensive the effect will be. (For now we will leave this channel just white)

The green color means the offset on the x-axis. The lighter the pixel, the more the rightmost value of the texture will appear in the holo effect.

Blue color means the y-axis offset. The lighter the pixel, the more extreme lower value of the texture will be displayed on the holo effect.

Since we want the 3D model to rotate horizontally the blue color will be just a smooth gradient from 0 to 255 (0 - black, 255 - completely white), so vertically we will have the texture unchanged.
Implementation
There will only be a "sharp" gradient on the green channel, each step of which will show only a certain section of pixels horizontally, thus simulating the effect of lenticular printing.


As a result of my experiments I stopped at the number of 32 gradient steps, so the 3D image turns out to be quite distinguishable, but at the same time not much blurred into an incomprehensible mass.

My python algorithm for gradient generation:
from PIL import Image import math width = 1024 height = 1024 # number of gradient steps image_final_width = 32 pixel_width = width / image_final_width final = Image.new('RGB', (width, height)) for x in range(width): for y in range(height): x_shraped = math.floor(x / pixel_width) * pixel_width value = math.floor(x_shraped * 256 / width) final.putpixel((x, y), (value, value, value)) final.save("gradient.png")

Next, I need to create a holo texture from animation of the 3D model rotation, so that when viewed from different angles, different frames of the animation are shown. To do this, I wrote this python code:
from PIL import Image import math # size of each frame of the animation image width = 512 height = 512 # number of gradient steps image_final_width = 32 # number of animation frames size = 32 texture_size = image_final_width * size final = Image.new('RGB', (texture_size, height)) gifFrames = [] # In the folder I have the animation divided into separate frames each of which is numbered starting from 1 path = "frames_skull/frame" for i in range(size): gifFrames.append(Image.open(path + str(i + 1) + '.png')) for ind in range(size): rgb_im = gifFrames[ind].convert('RGB') for x in range(image_final_width): for y in range(height): scaled_x = math.floor(x * width / image_final_width) pixel = rgb_im.getpixel((scaled_x, y)) final.putpixel(((x * size + i), y), pixel) final.save("texture.png")

I took this gif (source[www.artpie.co.uk]) as an example


The result of the code's work with this gif is this texture:


Also I decided to add on the red channel of the holo map black lines at the junctions of gradient steps, it removes the holo effect at the junctions. The problem is that because of the principle of how holos in CS works, in places at the junctions formes false displays of those parts of the texture, which I did not want to be displayed there, which led to the appearance of phantom lines between vertical pixels. It doesn't actually get rid of them, it just makes them indistinguishable due to optical illusion.

Final holo map:
Result
As a result, we have, uh... this...


And although when viewing the sticker it turns out quite bad even now you can see some 3D effect. I was about to get upset, but it turned out that viewing the sticker on the skin and on the weapon looks different. Here is how it looks on the weapon:


Wow! It even works somehow. This is what real lenticular stickers should look like in CS2.

So why does it look like this when viewing an unapplied sticker?
The thing is that the image change effect works due to the fact that when you rotate the sticker, the texture changes its position a little bit, just like if we lighten or darken the green channel on the sticker's mask a little bit. And in sticker view mode this effect doesn't work linearly, it seems to work faster on the upper parts than on the lower parts and because of that the sticker floats diagonally. In sticker view on weapons it works much straighter, but still with its own problems, so the effect can be seen only at a certain angle.


Here's a rotating cube to show how much this effect warps its display when tilted:


Overall it looks like a rotating cube, but it's better to use more complex objects so the distortion is less noticeable.

Also the sticker has to be applied on a perfectly flat surface, if you apply the sticker not on a perfectly flat surfaceit starts to distort:


Summary
To summarize, it was a fun idea, but unfortunately I didn't manage to achieve something that could be applied to sticker creation. It would be interesting to read if you have any ideas on how to use this method, even though it's not perfect, or ideas to improve the method. It would be cool if Valve added support for real lenticular stickers so that you could load animations as spritesheets and they would play when you tilt the sticker.

Thanks for reading, bye!
2 Comments
shakk_oo Oct 6, 2024 @ 9:39am 
+rep
shakk_oo Oct 6, 2024 @ 9:39am 
free baby oil for you