Giter VIP home page Giter VIP logo

urp-screenspacecavity's Introduction

URP-ScreenSpaceCavity

How to preview

Tested with Unity version - 2020.3 URP version - 10.7

Configurable parameters

  • Type:
    • Curvature - highlights only the edges of objects.
    • Cavity - highlights the edges with the Ambient Occlusion effect.
    • Both - well, it's understandable ๐Ÿคทโ€โ™‚๏ธ.
  • Curvature:
    • Scale - effect width.
    • Ridge - effect ntensivity for ridge (white).
    • Valley - effect ntensivity for valley (black).
  • Cavity:
    • Distance - distance of effect from edge.
    • Attenuation - fading out the effect relative to the camera (relevant for nearby objects).
    • Ridge - effect ntensivity for ridge (white).
    • Valley - effect ntensivity for valley (black).
    • Samples - number of passes to calculate the effect.

Shader setup

Here is an example of parts of the code for the shader to work with Cavity:

#if defined (_SCREEN_SPACE_CAVITY)
  #include "CavityInput.hlsl"
#endif
#pragma multi_compile_fragment _ _SCREEN_SPACE_CAVITY
#pragma multi_compile _ _CAVITY_DEBUG
#if defined (_SCREEN_SPACE_CAVITY)
  if (_CavityEnabled)
  {
    float2 normalizedUV = GetNormalizedScreenSpaceUV(input.positionCS);
    half cavity = SampleCavity(normalizedUV);
    #ifdef _CAVITY_DEBUG
      albedo.rgb = cavity * 2.0;
    #else
      bakedGI *= cavity * 4.0;
      lightColor *= cavity * 4.0;
    #endif
  }
#endif

The main thing is to get the cavity value and use it to apply the color:

#include "CavityInput.hlsl"
float2 normalizedUV = GetNormalizedScreenSpaceUV(input.positionCS);
half cavity = SampleCavity(normalizedUV);
color *= cavity * 4.0;

Attention! A custom shader must have passes for normals and depths.

Notes

Good to everyone!:v:

urp-screenspacecavity's People

Contributors

malyawka 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.