Giter VIP home page Giter VIP logo

unity-scratch-effect-demo's Introduction

Unity Scratch Effect Demo

Scratch Effect Demo in unity

How to remove dust/fog from an object in Unity with swipe?

  • Objective­:

    • The Main objective of this Code sample is to create a dust/fog removing effect using Unity. Using, Texture Masking shader, Mask Construction Shader, Render Texture, Camera Masking Script and masking camera, you can create your own effect. Read on to know how and download the source code. It’s free!!
  • Texture Masking Shader:

    • This shader gives an effect of a layer of dust on the screen. We only need to add dust texture and render texture (as Mask)in material shader.

  • How to use Shader­: Assets/ScratchEffect/Masked.shader

    • Start by creating a sprite in Hierarchy panel.
    • Add dust image (as Sprite) in this Sprite
    • Add new Material in this sprite and select Texture Masking Shader.
    • In this material, set Dust Texture as Main Texture and Mask as Render Texture.
    • For Render Texture, create a Render texture in project Panel and Select this render texture in this material.
  • Mask Construction Shader: Assets/ScratchEffect/MaskConstruction.shader This shader gives a wiping off dust effect each time the user swipes the screen. To make it happen, we also need to add an eraser image and set it’s colour too.

    • In Project Panel Create an empty material
    • Select Shader as “MaskConstruction”
    • Select Main Color and Select Erase image.
  • Masking camera­:

    Masking Camera shows dust on screen as Mask.

    How to Use Masking Camera? In Hierarchy panel create a camera.

    • In this Camera component as Clear Flag Select ”Don’t clear”
    • Create a layer and name it as “Mask ” and set camera Culling mask select as “Mask”.
    • Set Projection to “Orthographic”.
    • and its size “5”
    • add “Camera Masking ” script on this camera object

    • Drag dust object (Sprite) to get the dust effect on Screen.
    • Drag Eraser Material to wipe off the aforementioned sprite and create the effect.

unity-scratch-effect-demo's People

Contributors

khanhuitse05 avatar

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.