igerx.blogg.se

Unity shader free
Unity shader free







unity shader free

Add the following code to the top of the fragment shader. We will sample pixels from the depth buffer in a X shape, roughly centred around the current pixel being rendered. Some edge detection algorithms work with grayscale images because we are operating on computer rendered images and not photographs, we have better alternatives in the depth and normals buffers. If the values are very different, we will draw an edge. To generate outlines, we will sample adjacent pixels and compare their values. As well, our effect will be automatically compatible with other post-process effects in the stack, like the Bloom shown below. There is also a function named alphaBlend defined we will use it later for blending our outlines with the on-screen image.īy integrating our shader with the post-processing stack, we gain access to powerful built-in anti-aliasing solutions. As well, some functionality, such as texture sampling, is now handled by macros.Ĭurrently, the Outline file contains a simple fragment shader (named Frag) that samples the image on-screen and returns it without modification. Although the shader code itself is the same, it is encapsulated in HLSLPROGRAM blocks, instead of CGPROGRAM. Shaders written for Unity's post-processing stack have a few differences compared to standard image effects. Open the Outline shader in your preferred code editor.

unity shader free

For the "finished" screenshots in this tutorial, and for best results, anti-aliasing is set to Subpixel Morphological Anti-aliasing (SMAA) at High quality. It can useful to keep anti-aliasing disabled when developing screen space shaders, as it allows you to see the end product of the shader without any further modification applied. Note that by default Anti-aliasing in the layer is set to No Anti-aliasing. This will contain data that we will use to configure our outline effect. Assigned to the Profile field of the volume is a post-process profile, OutlinePostProfile.

unity shader free

These components allow us to make use of the post-processing stack. If you select the Main Camera, you will note that already attached to it are the Post Process Layer and Post Process Volume components.









Unity shader free