You can find the code snippet in my gists , and there is a complete shader.



Unity has an option to set native size on the UI element so it will be positioned perfectly. But if you dive into making a more tricky shaders that work with masks and detail textures which don't match the size of the main texture, you'll find yourself wanting that crisp prescission for them too while avoiding to adjust tiling and offset.

To get there my shader comes with a script that feeds the center of the object in screen space to the mesh for shader to sample a texture with center...

I figured this one out a while back, but wasn't sure if the complexity worth the effort. It may be more optimal to just create a mesh with sub-meshes and apply a different materials to them - not good for performance, but an optimal solution for character models, which also happen not to have tiling in most cases, so regular texture atlasing is a viable solution for performance optimization. Plus, on modern PCs, and I think also Playstation 4, Xbox One there are texture arrays, which could be used instead of my texture atlasing method. But I still decided to exp...

Microdetail is not visible in the first image of this article. But What micro detail does, is keeping the magic ON when you inspect surface up close:

I used my Playtime Painter to combine a bunch of maps into one.

Using detaI maps is relatively performance friendly addition, texture sampling is the one taking up the most time. By packaging up to 4 masks into RGBA texture you reduce that up to 4 times. Also it's a good way to overcome the texture limit. Sure, in some cases you may want to have different tiling and/or offset for different masks, and also different c...

I like cool glossy lighting. It makes virtual environment look real. But what really breaks immersion is when light illuminates object that sits on the other side of the wall from given light. That is why you'll see "Light Range" property for light sources in Unity and Unreal. Property which doesn't make too much sense physically since photons from even the tiniest candle may still affect surface far away. You would tune those to be constrained within the single room and never cast light onto objects outside of it. Range property is also there for performance re...

 Originally, the Color Bleed effect was noticed in photography. As you take a photo of something colorful, with high brightness, the color in photo may get a bit washed - closer to white. This effect wasn't too unwanted, and sometimes even simulated in 3D rendering software to make images more photo-realistic. I added the effect to each of the Shaders of my Playtime Painter Asset (optional, can be toggled ON/OFF globally). Basically it's just a simple operation of:

    float3 mix = col.gbr + col.brg;
    col.rgb += mix * mix*bleedStrength;...

Damage shaders uses texcoord2 coordinates which usually contains UVs for Baked Light. Which means no segment of the texture will not be repeated twice on a mesh. Mesh on the screenshot was created in ProBuilder - now a free editor extension for Unity.  

The example, included with Playtime Painter, has scripts for playtime destruction. When using World Space brush, all painting is done with Render Textures - so no texture uploading to GPU, just a regular rendering - very fast. Also the size of the brush will be in world space, which means a perfectly spherica...


Recipe

Simulating Bevel effect in Shader requires additional normal vectors for each vertex:

1. Smooth normal - calculated as if all vertices were shared between triangles.

2. Sharp normal - calculated normally, since all triangles are made of unique vertices.

3. 2 Normal vectors, one for each of triangle lines attached to the vertex.

4. Also one float3 is needed to package edge detection data. 

Vertex count and triangle count remains the same. Transforming the mesh is a matter of selecting a correct mesh profile. In Profile image to the right you can see 3 Line...

Please reload

Geeky:
GitHub icon
unity-Connet-Logo.png
Discord icon
Social:
Facebook icon
unnamed.png
Instagram icon