{"id":4224,"date":"2016-03-23T19:02:49","date_gmt":"2016-03-23T16:02:49","guid":{"rendered":"http:\/\/unitycoder.com\/blog\/?p=4224"},"modified":"2016-03-23T19:08:07","modified_gmt":"2016-03-23T16:08:07","slug":"volumetric-image-effect-shader","status":"publish","type":"post","link":"https:\/\/unitycoder.com\/blog\/2016\/03\/23\/volumetric-image-effect-shader\/","title":{"rendered":"Volumetric Image Effect Shader"},"content":{"rendered":"<p>&nbsp;<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"4226\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2016\/03\/23\/volumetric-image-effect-shader\/volumetric_effect_unity_1\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2016\/03\/volumetric_effect_unity_1.jpg?fit=679%2C558&amp;ssl=1\" data-orig-size=\"679,558\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"volumetric_effect_unity_1\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2016\/03\/volumetric_effect_unity_1.jpg?fit=679%2C558&amp;ssl=1\" class=\"alignnone size-full wp-image-4226\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2016\/03\/volumetric_effect_unity_1.jpg?resize=679%2C558\" alt=\"volumetric_effect_unity_1\" width=\"679\" height=\"558\" srcset=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2016\/03\/volumetric_effect_unity_1.jpg?w=679&amp;ssl=1 679w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2016\/03\/volumetric_effect_unity_1.jpg?resize=300%2C247&amp;ssl=1 300w\" sizes=\"auto, (max-width: 679px) 100vw, 679px\" \/><\/p>\n<p>Converted this old godrays shader ( <a href=\"http:\/\/unitycoder.com\/blog\/2012\/10\/02\/fake-godrays-shader\/\" target=\"_blank\">http:\/\/unitycoder.com\/blog\/2012\/10\/02\/fake-godrays-shader\/<\/a> ) into image effect &#8211; interesting results! (see video below)<\/p>\n<p>&nbsp;<\/p>\n<p><span class=\"embed-youtube\" style=\"text-align:center; display: block;\"><iframe loading=\"lazy\" class=\"youtube-player\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/ZagpSl0xxvg?version=3&#038;rel=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;fs=1&#038;hl=en-US&#038;autohide=2&#038;wmode=transparent\" allowfullscreen=\"true\" style=\"border:0;\" sandbox=\"allow-scripts allow-same-origin allow-popups allow-presentation allow-popups-to-escape-sandbox\"><\/iframe><\/span><\/p>\n<p>&nbsp;<\/p>\n<p>Source codes below (Attach script to main camera)<\/p>\n<style>.gist table { margin-bottom: 0; }<\/style>\n<div style=\"tab-size: 8\" id=\"gist33173105\" class=\"gist\">\n<div class=\"gist-file\" translate=\"no\" data-color-mode=\"light\" data-light-theme=\"light\">\n<div class=\"gist-data\">\n<div class=\"js-gist-file-update-container js-task-list-container\">\n<div id=\"file-volumetricimageeffect-cs\" class=\"file my-2\">\n<div itemprop=\"text\"\n      class=\"Box-body p-0 blob-wrapper data type-c  \"\n      style=\"overflow: auto\" tabindex=\"0\" role=\"region\"\n      aria-label=\"VolumetricImageEffect.cs content, created by unitycoder on 03:36PM on March 23, 2016.\"\n    ><\/p>\n<div class=\"js-check-hidden-unicode js-blob-code-container blob-code-content\">\n<p>  <template class=\"js-file-alert-template\"><\/p>\n<div data-view-component=\"true\" class=\"flash flash-warn flash-full d-flex flex-items-center\">\n  <svg aria-hidden=\"true\" data-component=\"Octicon\" height=\"16\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" data-view-component=\"true\" class=\"octicon octicon-alert\">\n    <path d=\"M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z\"><\/path>\n<\/svg><br \/>\n    <span><br \/>\n      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.<br \/>\n      <a class=\"Link--inTextBlock\" href=\"https:\/\/github.co\/hiddenchars\" target=\"_blank\">Learn more about bidirectional Unicode characters<\/a><br \/>\n    <\/span><\/p>\n<div data-view-component=\"true\" class=\"flash-action\">        <a href=\"{{ revealButtonHref }}\" data-view-component=\"true\" class=\"btn-sm btn\">    Show hidden characters<br \/>\n<\/a>\n<\/div>\n<\/div>\n<p><\/template><br \/>\n<template class=\"js-line-alert-template\"><br \/>\n  <span aria-label=\"This line has hidden Unicode characters\" data-view-component=\"true\" class=\"line-alert tooltipped tooltipped-e\"><br \/>\n    <svg aria-hidden=\"true\" data-component=\"Octicon\" height=\"16\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" data-view-component=\"true\" class=\"octicon octicon-alert\">\n    <path d=\"M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z\"><\/path>\n<\/svg><br \/>\n<\/span><\/template><\/p>\n<table data-hpc class=\"highlight tab-size js-file-line-container\" data-tab-size=\"4\" data-paste-markdown-skip data-tagsearch-path=\"VolumetricImageEffect.cs\">\n<tr>\n<td id=\"file-volumetricimageeffect-cs-L1\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"1\"><\/td>\n<td id=\"file-volumetricimageeffect-cs-LC1\" class=\"blob-code blob-code-inner js-file-line\">using UnityEngine;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetricimageeffect-cs-L2\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"2\"><\/td>\n<td id=\"file-volumetricimageeffect-cs-LC2\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetricimageeffect-cs-L3\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"3\"><\/td>\n<td id=\"file-volumetricimageeffect-cs-LC3\" class=\"blob-code blob-code-inner js-file-line\">[ExecuteInEditMode]<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetricimageeffect-cs-L4\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"4\"><\/td>\n<td id=\"file-volumetricimageeffect-cs-LC4\" class=\"blob-code blob-code-inner js-file-line\">public class VolumetricImageEffect : MonoBehaviour<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetricimageeffect-cs-L5\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"5\"><\/td>\n<td id=\"file-volumetricimageeffect-cs-LC5\" class=\"blob-code blob-code-inner js-file-line\">{<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetricimageeffect-cs-L6\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"6\"><\/td>\n<td id=\"file-volumetricimageeffect-cs-LC6\" class=\"blob-code blob-code-inner js-file-line\">    public float exposure=0.6f;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetricimageeffect-cs-L7\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"7\"><\/td>\n<td id=\"file-volumetricimageeffect-cs-LC7\" class=\"blob-code blob-code-inner js-file-line\">    public float decay = 0.95f;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetricimageeffect-cs-L8\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"8\"><\/td>\n<td id=\"file-volumetricimageeffect-cs-LC8\" class=\"blob-code blob-code-inner js-file-line\">    public float density = 0.96f;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetricimageeffect-cs-L9\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"9\"><\/td>\n<td id=\"file-volumetricimageeffect-cs-LC9\" class=\"blob-code blob-code-inner js-file-line\">    public float weight = 0.4f;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetricimageeffect-cs-L10\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"10\"><\/td>\n<td id=\"file-volumetricimageeffect-cs-LC10\" class=\"blob-code blob-code-inner js-file-line\">    public float clamp = 1f;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetricimageeffect-cs-L11\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"11\"><\/td>\n<td id=\"file-volumetricimageeffect-cs-LC11\" class=\"blob-code blob-code-inner js-file-line\">    public int samples = 16;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetricimageeffect-cs-L12\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"12\"><\/td>\n<td id=\"file-volumetricimageeffect-cs-LC12\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetricimageeffect-cs-L13\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"13\"><\/td>\n<td id=\"file-volumetricimageeffect-cs-LC13\" class=\"blob-code blob-code-inner js-file-line\">    private Material material;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetricimageeffect-cs-L14\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"14\"><\/td>\n<td id=\"file-volumetricimageeffect-cs-LC14\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetricimageeffect-cs-L15\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"15\"><\/td>\n<td id=\"file-volumetricimageeffect-cs-LC15\" class=\"blob-code blob-code-inner js-file-line\">    \/\/ Creates a private material used to the effect<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetricimageeffect-cs-L16\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"16\"><\/td>\n<td id=\"file-volumetricimageeffect-cs-LC16\" class=\"blob-code blob-code-inner js-file-line\">    void Awake()<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetricimageeffect-cs-L17\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"17\"><\/td>\n<td id=\"file-volumetricimageeffect-cs-LC17\" class=\"blob-code blob-code-inner js-file-line\">    {<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetricimageeffect-cs-L18\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"18\"><\/td>\n<td id=\"file-volumetricimageeffect-cs-LC18\" class=\"blob-code blob-code-inner js-file-line\">        material = new Material(Shader.Find(&quot;Hidden\/VolumetricLightApproximation&quot;));<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetricimageeffect-cs-L19\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"19\"><\/td>\n<td id=\"file-volumetricimageeffect-cs-LC19\" class=\"blob-code blob-code-inner js-file-line\">    }<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetricimageeffect-cs-L20\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"20\"><\/td>\n<td id=\"file-volumetricimageeffect-cs-LC20\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetricimageeffect-cs-L21\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"21\"><\/td>\n<td id=\"file-volumetricimageeffect-cs-LC21\" class=\"blob-code blob-code-inner js-file-line\">    \/\/ Postprocess the image<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetricimageeffect-cs-L22\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"22\"><\/td>\n<td id=\"file-volumetricimageeffect-cs-LC22\" class=\"blob-code blob-code-inner js-file-line\">    void OnRenderImage(RenderTexture source, RenderTexture destination)<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetricimageeffect-cs-L23\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"23\"><\/td>\n<td id=\"file-volumetricimageeffect-cs-LC23\" class=\"blob-code blob-code-inner js-file-line\">    {<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetricimageeffect-cs-L24\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"24\"><\/td>\n<td id=\"file-volumetricimageeffect-cs-LC24\" class=\"blob-code blob-code-inner js-file-line\">        if (material == null)<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetricimageeffect-cs-L25\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"25\"><\/td>\n<td id=\"file-volumetricimageeffect-cs-LC25\" class=\"blob-code blob-code-inner js-file-line\">        {<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetricimageeffect-cs-L26\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"26\"><\/td>\n<td id=\"file-volumetricimageeffect-cs-LC26\" class=\"blob-code blob-code-inner js-file-line\">            material = new Material(Shader.Find(&quot;Hidden\/VolumetricLightApproximation&quot;));<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetricimageeffect-cs-L27\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"27\"><\/td>\n<td id=\"file-volumetricimageeffect-cs-LC27\" class=\"blob-code blob-code-inner js-file-line\">        }<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetricimageeffect-cs-L28\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"28\"><\/td>\n<td id=\"file-volumetricimageeffect-cs-LC28\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetricimageeffect-cs-L29\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"29\"><\/td>\n<td id=\"file-volumetricimageeffect-cs-LC29\" class=\"blob-code blob-code-inner js-file-line\">         material.SetFloat(&quot;fExposure&quot;, exposure);<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetricimageeffect-cs-L30\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"30\"><\/td>\n<td id=\"file-volumetricimageeffect-cs-LC30\" class=\"blob-code blob-code-inner js-file-line\">        material.SetFloat(&quot;fDecay&quot;, density);<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetricimageeffect-cs-L31\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"31\"><\/td>\n<td id=\"file-volumetricimageeffect-cs-LC31\" class=\"blob-code blob-code-inner js-file-line\">        material.SetFloat(&quot;fDensity&quot;, density);<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetricimageeffect-cs-L32\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"32\"><\/td>\n<td id=\"file-volumetricimageeffect-cs-LC32\" class=\"blob-code blob-code-inner js-file-line\">        material.SetFloat(&quot;fWeight&quot;, weight);<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetricimageeffect-cs-L33\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"33\"><\/td>\n<td id=\"file-volumetricimageeffect-cs-LC33\" class=\"blob-code blob-code-inner js-file-line\">        material.SetFloat(&quot;fClamp&quot;, clamp);<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetricimageeffect-cs-L34\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"34\"><\/td>\n<td id=\"file-volumetricimageeffect-cs-LC34\" class=\"blob-code blob-code-inner js-file-line\">        material.SetInt(&quot;fSamples&quot;, samples);<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetricimageeffect-cs-L35\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"35\"><\/td>\n<td id=\"file-volumetricimageeffect-cs-LC35\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetricimageeffect-cs-L36\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"36\"><\/td>\n<td id=\"file-volumetricimageeffect-cs-LC36\" class=\"blob-code blob-code-inner js-file-line\">        Graphics.Blit(source, destination, material);<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetricimageeffect-cs-L37\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"37\"><\/td>\n<td id=\"file-volumetricimageeffect-cs-LC37\" class=\"blob-code blob-code-inner js-file-line\">    }<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetricimageeffect-cs-L38\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"38\"><\/td>\n<td id=\"file-volumetricimageeffect-cs-LC38\" class=\"blob-code blob-code-inner js-file-line\">}<\/td>\n<\/tr>\n<\/table>\n<\/div><\/div>\n<\/p><\/div>\n<\/div><\/div>\n<div class=\"gist-meta\">\n        <a href=\"https:\/\/gist.github.com\/unitycoder\/399da67db426f20c04f3\/raw\/9f5f189952cf22c38734dff8f3d511796df979f4\/VolumetricImageEffect.cs\" style=\"float:right\" class=\"Link--inTextBlock\">view raw<\/a><br \/>\n        <a href=\"https:\/\/gist.github.com\/unitycoder\/399da67db426f20c04f3#file-volumetricimageeffect-cs\" class=\"Link--inTextBlock\"><br \/>\n          VolumetricImageEffect.cs<br \/>\n        <\/a><br \/>\n        hosted with &#10084; by <a class=\"Link--inTextBlock\" href=\"https:\/\/github.com\">GitHub<\/a>\n      <\/div>\n<\/p><\/div>\n<div class=\"gist-file\" translate=\"no\" data-color-mode=\"light\" data-light-theme=\"light\">\n<div class=\"gist-data\">\n<div class=\"js-gist-file-update-container js-task-list-container\">\n<div id=\"file-volumetriclightapproximation-shader\" class=\"file my-2\">\n<div itemprop=\"text\"\n      class=\"Box-body p-0 blob-wrapper data type-shaderlab  \"\n      style=\"overflow: auto\" tabindex=\"0\" role=\"region\"\n      aria-label=\"VolumetricLightApproximation.shader content, created by unitycoder on 03:36PM on March 23, 2016.\"\n    ><\/p>\n<div class=\"js-check-hidden-unicode js-blob-code-container blob-code-content\">\n<p>  <template class=\"js-file-alert-template\"><\/p>\n<div data-view-component=\"true\" class=\"flash flash-warn flash-full d-flex flex-items-center\">\n  <svg aria-hidden=\"true\" data-component=\"Octicon\" height=\"16\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" data-view-component=\"true\" class=\"octicon octicon-alert\">\n    <path d=\"M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z\"><\/path>\n<\/svg><br \/>\n    <span><br \/>\n      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.<br \/>\n      <a class=\"Link--inTextBlock\" href=\"https:\/\/github.co\/hiddenchars\" target=\"_blank\">Learn more about bidirectional Unicode characters<\/a><br \/>\n    <\/span><\/p>\n<div data-view-component=\"true\" class=\"flash-action\">        <a href=\"{{ revealButtonHref }}\" data-view-component=\"true\" class=\"btn-sm btn\">    Show hidden characters<br \/>\n<\/a>\n<\/div>\n<\/div>\n<p><\/template><br \/>\n<template class=\"js-line-alert-template\"><br \/>\n  <span aria-label=\"This line has hidden Unicode characters\" data-view-component=\"true\" class=\"line-alert tooltipped tooltipped-e\"><br \/>\n    <svg aria-hidden=\"true\" data-component=\"Octicon\" height=\"16\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" data-view-component=\"true\" class=\"octicon octicon-alert\">\n    <path d=\"M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z\"><\/path>\n<\/svg><br \/>\n<\/span><\/template><\/p>\n<table data-hpc class=\"highlight tab-size js-file-line-container\" data-tab-size=\"4\" data-paste-markdown-skip data-tagsearch-path=\"VolumetricLightApproximation.shader\">\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L1\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"1\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC1\" class=\"blob-code blob-code-inner js-file-line\">\/\/ original source: http:\/\/demo.bkcore.com\/threejs\/webgl_tron_godrays.html<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L2\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"2\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC2\" class=\"blob-code blob-code-inner js-file-line\">\/\/ converted to surface shader : http:\/\/unitycoder.com\/blog\/2012\/10\/02\/fake-godrays-shader\/<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L3\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"3\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC3\" class=\"blob-code blob-code-inner js-file-line\">\/\/ converted to image effect : <\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L4\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"4\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC4\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L5\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"5\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC5\" class=\"blob-code blob-code-inner js-file-line\">Shader &quot;Hidden\/VolumetricLightApproximation&quot;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L6\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"6\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC6\" class=\"blob-code blob-code-inner js-file-line\">{<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L7\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"7\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC7\" class=\"blob-code blob-code-inner js-file-line\">    Properties<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L8\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"8\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC8\" class=\"blob-code blob-code-inner js-file-line\">\t{<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L9\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"9\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC9\" class=\"blob-code blob-code-inner js-file-line\">        _MainTex (&quot;Texture&quot;, 2D) = &quot;white&quot; {<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L10\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"10\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC10\" class=\"blob-code blob-code-inner js-file-line\">            }<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L11\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"11\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC11\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L12\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"12\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC12\" class=\"blob-code blob-code-inner js-file-line\">        fExposure (&quot;fExposure&quot;, Float) = 0.6<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L13\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"13\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC13\" class=\"blob-code blob-code-inner js-file-line\">        fDecay (&quot;fDecay&quot;, Float) = 0.93<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L14\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"14\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC14\" class=\"blob-code blob-code-inner js-file-line\">        fDensity (&quot;fDensity&quot;, Float) = 0.96<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L15\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"15\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC15\" class=\"blob-code blob-code-inner js-file-line\">        fWeight (&quot;fWeight&quot;, Float) = 0.4<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L16\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"16\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC16\" class=\"blob-code blob-code-inner js-file-line\">        fClamp (&quot;fClamp&quot;, Float) = 1.0<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L17\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"17\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC17\" class=\"blob-code blob-code-inner js-file-line\">        fSamples (&quot;fSamples&quot;, Int) = 32<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L18\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"18\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC18\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L19\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"19\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC19\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L20\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"20\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC20\" class=\"blob-code blob-code-inner js-file-line\">\t}<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L21\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"21\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC21\" class=\"blob-code blob-code-inner js-file-line\">\tSubShader<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L22\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"22\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC22\" class=\"blob-code blob-code-inner js-file-line\">\t{<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L23\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"23\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC23\" class=\"blob-code blob-code-inner js-file-line\">        \/\/ No culling or depth<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L24\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"24\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC24\" class=\"blob-code blob-code-inner js-file-line\">\t\tCull Off ZWrite Off ZTest Always<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L25\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"25\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC25\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L26\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"26\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC26\" class=\"blob-code blob-code-inner js-file-line\">\t\tBlend SrcAlpha OneMinusSrcAlpha \/\/ Traditional transparency<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L27\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"27\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC27\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L28\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"28\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC28\" class=\"blob-code blob-code-inner js-file-line\">\t\tPass<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L29\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"29\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC29\" class=\"blob-code blob-code-inner js-file-line\">\t\t{<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L30\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"30\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC30\" class=\"blob-code blob-code-inner js-file-line\">            CGPROGRAM<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L31\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"31\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC31\" class=\"blob-code blob-code-inner js-file-line\">\t\t\t#pragma vertex vert<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L32\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"32\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC32\" class=\"blob-code blob-code-inner js-file-line\">\t\t\t#pragma fragment frag<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L33\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"33\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC33\" class=\"blob-code blob-code-inner js-file-line\">\t\t\t<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L34\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"34\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC34\" class=\"blob-code blob-code-inner js-file-line\">\t\t\t#include &quot;UnityCG.cginc&quot;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L35\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"35\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC35\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L36\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"36\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC36\" class=\"blob-code blob-code-inner js-file-line\">\t\t\tstruct appdata<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L37\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"37\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC37\" class=\"blob-code blob-code-inner js-file-line\">\t\t\t{<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L38\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"38\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC38\" class=\"blob-code blob-code-inner js-file-line\">                float4 vertex : POSITION;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L39\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"39\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC39\" class=\"blob-code blob-code-inner js-file-line\">                float2 uv : TEXCOORD0;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L40\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"40\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC40\" class=\"blob-code blob-code-inner js-file-line\">            };<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L41\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"41\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC41\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L42\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"42\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC42\" class=\"blob-code blob-code-inner js-file-line\">            struct v2f<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L43\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"43\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC43\" class=\"blob-code blob-code-inner js-file-line\">\t\t\t{<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L44\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"44\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC44\" class=\"blob-code blob-code-inner js-file-line\">                float2 uv : TEXCOORD0;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L45\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"45\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC45\" class=\"blob-code blob-code-inner js-file-line\">                float4 vertex : SV_POSITION;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L46\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"46\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC46\" class=\"blob-code blob-code-inner js-file-line\">            };<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L47\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"47\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC47\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L48\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"48\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC48\" class=\"blob-code blob-code-inner js-file-line\">            v2f vert (appdata v)<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L49\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"49\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC49\" class=\"blob-code blob-code-inner js-file-line\">\t\t\t{<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L50\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"50\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC50\" class=\"blob-code blob-code-inner js-file-line\">                v2f o;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L51\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"51\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC51\" class=\"blob-code blob-code-inner js-file-line\">                o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L52\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"52\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC52\" class=\"blob-code blob-code-inner js-file-line\">                o.uv = v.uv;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L53\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"53\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC53\" class=\"blob-code blob-code-inner js-file-line\">                return o;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L54\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"54\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC54\" class=\"blob-code blob-code-inner js-file-line\">            }<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L55\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"55\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC55\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L56\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"56\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC56\" class=\"blob-code blob-code-inner js-file-line\">\t\t\tsampler2D _MainTex;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L57\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"57\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC57\" class=\"blob-code blob-code-inner js-file-line\">            float fX,fY,fExposure,fDecay,fDensity,fWeight,fClamp;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L58\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"58\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC58\" class=\"blob-code blob-code-inner js-file-line\">\t\t\tint fSamples;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L59\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"59\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC59\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L60\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"60\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC60\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L61\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"61\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC61\" class=\"blob-code blob-code-inner js-file-line\">            fixed4 frag (v2f i) : SV_Target<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L62\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"62\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC62\" class=\"blob-code blob-code-inner js-file-line\">\t\t\t{<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L63\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"63\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC63\" class=\"blob-code blob-code-inner js-file-line\">                float2 vUv = i.uv;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L64\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"64\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC64\" class=\"blob-code blob-code-inner js-file-line\">\t\t\t\tfloat2 deltaTextCoord = float2(vUv &#8211; float2(0.5,0.5));<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L65\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"65\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC65\" class=\"blob-code blob-code-inner js-file-line\">\t\t\t\tdeltaTextCoord *= 1.0 \/  float(fSamples) * fDensity;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L66\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"66\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC66\" class=\"blob-code blob-code-inner js-file-line\">\t\t\t\tfloat2 coord = vUv;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L67\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"67\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC67\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L68\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"68\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC68\" class=\"blob-code blob-code-inner js-file-line\">                float illuminationDecay = 1.0;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L69\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"69\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC69\" class=\"blob-code blob-code-inner js-file-line\">                float4 FragColor = float4(0,0,0,0);<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L70\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"70\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC70\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L71\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"71\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC71\" class=\"blob-code blob-code-inner js-file-line\">                for(int i=0; i &lt; fSamples ; i++)<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L72\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"72\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC72\" class=\"blob-code blob-code-inner js-file-line\">\t\t\t\t{<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L73\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"73\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC73\" class=\"blob-code blob-code-inner js-file-line\">                    coord -= deltaTextCoord;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L74\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"74\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC74\" class=\"blob-code blob-code-inner js-file-line\">                    float4 texel = tex2D(_MainTex, coord);<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L75\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"75\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC75\" class=\"blob-code blob-code-inner js-file-line\">                    texel *= illuminationDecay * fWeight;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L76\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"76\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC76\" class=\"blob-code blob-code-inner js-file-line\">                    FragColor += texel;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L77\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"77\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC77\" class=\"blob-code blob-code-inner js-file-line\">                    illuminationDecay *= fDecay;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L78\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"78\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC78\" class=\"blob-code blob-code-inner js-file-line\">                }<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L79\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"79\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC79\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L80\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"80\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC80\" class=\"blob-code blob-code-inner js-file-line\">\t\t\t\tFragColor *= fExposure;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L81\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"81\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC81\" class=\"blob-code blob-code-inner js-file-line\">                FragColor = clamp(FragColor, 0.0, fClamp);<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L82\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"82\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC82\" class=\"blob-code blob-code-inner js-file-line\">                float4 c = FragColor;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L83\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"83\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC83\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L84\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"84\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC84\" class=\"blob-code blob-code-inner js-file-line\">\t\t\t\treturn c;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L85\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"85\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC85\" class=\"blob-code blob-code-inner js-file-line\">            }<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L86\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"86\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC86\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L87\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"87\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC87\" class=\"blob-code blob-code-inner js-file-line\">\t\t\tENDCG<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L88\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"88\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC88\" class=\"blob-code blob-code-inner js-file-line\">\t\t}<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L89\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"89\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC89\" class=\"blob-code blob-code-inner js-file-line\">\t}<\/td>\n<\/tr>\n<tr>\n<td id=\"file-volumetriclightapproximation-shader-L90\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"90\"><\/td>\n<td id=\"file-volumetriclightapproximation-shader-LC90\" class=\"blob-code blob-code-inner js-file-line\">}<\/td>\n<\/tr>\n<\/table>\n<\/div><\/div>\n<\/p><\/div>\n<\/div><\/div>\n<div class=\"gist-meta\">\n        <a href=\"https:\/\/gist.github.com\/unitycoder\/399da67db426f20c04f3\/raw\/9f5f189952cf22c38734dff8f3d511796df979f4\/VolumetricLightApproximation.shader\" style=\"float:right\" class=\"Link--inTextBlock\">view raw<\/a><br \/>\n        <a href=\"https:\/\/gist.github.com\/unitycoder\/399da67db426f20c04f3#file-volumetriclightapproximation-shader\" class=\"Link--inTextBlock\"><br \/>\n          VolumetricLightApproximation.shader<br \/>\n        <\/a><br \/>\n        hosted with &#10084; by <a class=\"Link--inTextBlock\" href=\"https:\/\/github.com\">GitHub<\/a>\n      <\/div>\n<\/p><\/div>\n<\/div>\n<p>Scene has just few spotlights, particles, and 3d objects..<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"4227\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2016\/03\/23\/volumetric-image-effect-shader\/volumetric_scene\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2016\/03\/volumetric_scene.jpg?fit=372%2C465&amp;ssl=1\" data-orig-size=\"372,465\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"volumetric_scene\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2016\/03\/volumetric_scene.jpg?fit=372%2C465&amp;ssl=1\" class=\"alignnone size-full wp-image-4227\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2016\/03\/volumetric_scene.jpg?resize=372%2C465\" alt=\"volumetric_scene\" width=\"372\" height=\"465\" srcset=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2016\/03\/volumetric_scene.jpg?w=372&amp;ssl=1 372w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2016\/03\/volumetric_scene.jpg?resize=240%2C300&amp;ssl=1 240w\" sizes=\"auto, (max-width: 372px) 100vw, 372px\" \/><\/p>\n<p>&#8212;<\/p>\n<p><strong>References:<\/strong><\/p>\n<p>Image effects tutorial &#8211; <a href=\"http:\/\/www.alanzucconi.com\/2015\/07\/08\/screen-shaders-and-postprocessing-effects-in-unity3d\/\" target=\"_blank\">http:\/\/www.alanzucconi.com\/2015\/07\/08\/screen-shaders-and-postprocessing-effects-in-unity3d\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Converted this old godrays shader ( http:\/\/unitycoder.com\/blog\/2012\/10\/02\/fake-godrays-shader\/ ) into image effect &#8211; interesting results! (see video below) &nbsp; &nbsp; Source codes below (Attach script to main camera) This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":4226,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[13,3],"tags":[160,50,867,866,52,14,865],"class_list":["post-4224","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-shaders","category-unity3d","tag-blur","tag-effect","tag-godray","tag-image-effect","tag-light","tag-shader","tag-volumetric"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2016\/03\/volumetric_effect_unity_1.jpg?fit=679%2C558&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/p1KTaT-168","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/4224","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/comments?post=4224"}],"version-history":[{"count":3,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/4224\/revisions"}],"predecessor-version":[{"id":4230,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/4224\/revisions\/4230"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media\/4226"}],"wp:attachment":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media?parent=4224"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/categories?post=4224"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/tags?post=4224"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}