Git Product home page Git Product logo

dynamicdecals's Introduction

Dynamic Decals by Llockham-Industries

Unity Forums | Getting Started | Masking | Pooling | Printers | Modifiers | Positioners | Optimizing Build Times | Custom Decal Types

This solution was developed by Llockham-Industries and originally sold in the Unity Asset Store. Dynamic Decals was deprecated when the new Unity render pipeline was launched, but the original author gave their permission to open source the project as it still works for Unity's Built-in Render Pipeline.

Dynamic Decals

Description

Dynamic Decals is the decal solution built from the ground up to be fast, easy to use and flexible. Perfect for bullet holes, blood effects, projected UI elements and just about anything else you can think of!

No more fiddling with quads to avoid z-fighting, or re-projecting / recalculating decal meshes every time you want to move a decal. Just drop a projection renderer onto an empty gameObject and setup your projection. You can save it as a prefab and spawn it like any other gameObject, as well as move, rotate and scale it at run-time without issue. It's that easy.

On top of this, Llockham-Industries has built a fast fully featured and flexible pooling system, a layered masking system and some "Printers" & "Positioners" to help users with no programming experience use the system.

New Version 2.0 Features

  • GPU instancing with per-instance properties and atlassing.
  • Animated projections.
  • Additive & Multiplicative projections.
  • Masking via Unity layers.

Key Features

  • Print and manipulate decals at run-time.
  • Project decals onto skinned meshes.
  • Overlap and order decals.
  • Clean, simple editor integration.
  • Run-time Printers & Positioners.
  • Omni-directional Projections.
  • Mobile & VR support
  • Support for Deferred & Forward rendering paths & all shader models.
  • Full source code included.
  • Zero setup required.

dynamicdecals's People

Contributors

ericfreeman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dynamicdecals's Issues

Decal doesn't render in Build

I just happened to notice that decals do not render in build but they render in editor. What would be possible cause?

Custom Shader issue

Hi. I am using a custom shader with flipbook logic. Attaching the shader code. Takes sort of sprite sheet of multiple frames and plays it in a sequence according to values of columns, rows and speed. It works fine if I apply it to a cube directly. When I create a decal from it, it actually renders but the whole sprite sheet is being rendered instead of per frame. I verified shader properties on runtime but those properties don't seem to make an effect.

Shader Code

Shader "Projection/Decal/LiveSpray"
{
    Properties
    {
        _Color("Albedo", Color) = (1,1,1,1)
        _MainTex("Albedo Map", 2D) = "white" {}

        _Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
        _NormalCutoff("Normal Cutoff", Range(0.0, 1.0)) = 0.5

        _TilingOffset("Tiling / Offset", Vector) = (1, 1, 0, 0)

        _MaskBase("Mask Base", Range(0.0, 1.0)) = 0.0
        _MaskLayers("Layers", Color) = (0.5, 0.5, 0.5, 0.5)

        _FlipbookRows("Rows", Int) = 1
        _FlipbookColumns("Columns", Int) = 8
        _Speed("Animation Speed", Float) = 10.0
    }

        // 2.5
            SubShader
        {
            Tags{ "Queue" = "AlphaTest+1" "DisableBatching" = "True" "IgnoreProjector" = "True" }
            ZWrite Off ZTest Always Cull Back

            Pass
            {
                Name "FORWARD"
                Tags{ "LightMode" = "ForwardBase" }

                Blend SrcAlpha OneMinusSrcAlpha

                CGPROGRAM
                #pragma target 2.5
                #pragma multi_compile_instancing
                #pragma multi_compile_fwdbase
                #pragma multi_compile_fog
                #pragma glsl

                #pragma multi_compile _PrecisionDepthNormals _CustomDepthNormals
                #pragma multi_compile _ _AlphaTest
                #pragma multi_compile ___ _Omni

                #include "../../Cginc/ForwardPasses.cginc"

                #pragma vertex vertProjection
                #pragma fragment fragUnlit
                ENDCG
            }

            // Add a new pass for the Flipbook animation
            Pass
            {
                Name "Flipbook"
                Stencil
                {
                    Ref 1
                    Comp always
                    Pass replace
                }

                Tags { "Queue" = "Transparent" }

                CGPROGRAM
                #pragma vertex vert
                #pragma fragment frag
                #include "UnityCG.cginc"

                struct appdata_t
                {
                    float4 vertex : POSITION;
                    float2 texcoord : TEXCOORD0;
                };

                struct v2f
                {
                    float2 texcoord : TEXCOORD0;
                    float4 vertex : SV_POSITION;
                };

                sampler2D _MainTex;
                float4 _MainTex_ST;
                float4 _Color;
                float _Cutoff;
                int _FlipbookRows;
                int _FlipbookColumns;
                float _Speed;

                v2f vert(appdata_t v)
                {
                    v2f o;
                    o.vertex = UnityObjectToClipPos(v.vertex);

                    // Calculate UV coordinates for the flipbook with Y inversion
                    float frameWidth = 1.0 / _FlipbookColumns;
                    float frameHeight = 1.0 / _FlipbookRows;
                    float time = _Time.y * _Speed;
                    int frameIndex = (int)floor(time) % (_FlipbookRows * _FlipbookColumns);
                    int rowIndex = frameIndex / _FlipbookColumns;
                    int colIndex = frameIndex % _FlipbookColumns;

                    o.texcoord = v.texcoord;
                    o.texcoord.x = (v.texcoord.x * frameWidth) + (frameWidth * colIndex);
                    o.texcoord.y = (v.texcoord.y * frameHeight) + (frameHeight * rowIndex);

                    return o;
                }

                fixed4 frag(v2f i) : SV_Target
                {
                    fixed4 col = tex2D(_MainTex, i.texcoord) * _Color;
                    clip(col.a - _Cutoff); // Use alpha cutoff
                    return col;
                }
                ENDCG
            }
        }

            Fallback Off
}

This is what it looks when directly applied on a cube.
https://github.com/EricFreeman/DynamicDecals/assets/33382155/cab3169a-8065-4131-b809-0fcff2d3e259

This is what it looks like when rendered through decal even though those flipbook parameters are being set on runtime.
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.