Search Unity

IndieEffects: Bringing (almost) AAA quality Post-Process FX to Unity Indie

Discussion in 'Assets and Asset Store' started by FuzzyQuills, Sep 2, 2013.

  1. Cyrien5100

    Cyrien5100

    Joined:
    Oct 17, 2012
    Posts:
    145
    Your package is awesome :)
    But DoF doesn't work with me (Null Reference Exeption) :(
    You think it would be possible to deacrease the resolution of the rendertexture (for example with the bloom effect) ? Because effects have a very big impact on the performance at full screen (drops from 90 to 30).
    And it would be great too if it works on linear space :)
     
  2. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    @Cyrien5100: THe "NullReferenceException" means that the _Depth Extension may not be added to your camera. if you are using C#, then that is probably something Berenger forgot to add. (He offered to do, and does, ports for me whenever i ask him to, and it is usually after every main release)

    The linear space thing can't be fixed as of yet, as the function that draws an effect on the screen is done using a quad in front of the camera. (this is why the screen goes dark!) And even though scaling the tex down would boost performance, another thihg you can try is dropping your drawcalls: by having under 500, it should run at a solid 30 or 60fps. And if you have an Intel HD 3000, I have this, and try to optimize around this card, meaning that more powerful ones should run this smoothly! Would also be great to have it working in linear space, as the lighting is more PBR-like!

    I am hopefully going to be able to bring out a new version soon, so i will try an algorithm that takes zero seconds to scale down the tex, then do the apply opeation faster.

    EDIT: I just realised, did you try and use a C# scrpit with a JS one? this definitely won't work. try double-checking this before you confirm that DoF won't work for you!
     
    Last edited: May 15, 2014
  3. Cyrien5100

    Cyrien5100

    Joined:
    Oct 17, 2012
    Posts:
    145
    It's strange, i tested DOF with another scene, and it works well...
    And about the framerate, i have a GTX 570 and my scene only have 250 drawcalls. It seems that the texture.apply, which uses the CPU, have a big impact. The complexity of the scene drops less the framerate than the resolution.
    However, you did a very good job :)
     
  4. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    @Cyrien5100: Actually, texture.apply is done by first gathering the tex data in CPU, then it uploads to GPU, a very slow process by milliseconds...
    And try playing at 640 X 480 and see what happens. good to see that DoF works in another scene. in that case, try looking for conflicts.

    And thanks sir!
     
  5. Cyrien5100

    Cyrien5100

    Joined:
    Oct 17, 2012
    Posts:
    145
  6. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Well, I could, but the prob with blender is that it uses GLSL, of which i know next to nothing. Maybe this one uses something I understand, I could also have a look at the shader and attempt to write a CG version. (I did tell a lie with the GLSL part: I do know some of the syntax!)

    EDIT: Unbelieveably, that is the SIMPLEST conde i have ever seen! Depending on how this turns out, you have glory for a week for coming up with this! :D

    I have a spare period at school, so i could attempt a quick-and-dirty port when that rolls around... :)
     
    Last edited: May 19, 2014
  7. Cyrien5100

    Cyrien5100

    Joined:
    Oct 17, 2012
    Posts:
    145
    I learned a little of cg programmation, and tried a port of the ssao shader i sent... and it didn't worked. So i tried to port the Unity Pro's SSAO shader (which is very simple), and it works, but not very well (many artifacts) :
    $1400437556-ssao-test.jpg
    $1400437784-ssao-test2.jpg
    However, the Unity Pro's SSAO is very crap, and is a very basic implementation. Another implementation (like the one i sent) would have far better results.
    Here is the shader (using FXLab because i really dont know how to sample the depth texture with Indie Effects:mrgreen:) :
    Code (csharp):
    1. Shader "FXLab/PostProcessing/SSAO2" {
    2.     Properties {
    3.         _FXDepthTexture ("Depth Texture (FXDepthTexture)", 2D) = "" {}
    4. //      _FXWorldNormalTexture ("WorldNormal Texture (FXWorldNormalTexture)",2D) = "" {}
    5.         _SampleRange ("Sample Range", Range(0, 10)) = 3
    6.         _Area ("Area", Range(0, 20)) = 8
    7.         _Falloff ("Falloff", Float) = 0.87
    8.         _Strength ("Strength", Range(0, 10)) = 1
    9.         _Bias ("Bias", Range(0, 1)) = 0.0
    10.         _NoiseTex ("Noise Texture", 2D) = "gray" {}
    11.         _NoiseScale ("NoiseScale",Range (0,10)) = 3
    12.         _Near ("Min Z",Float) = 0.1
    13.         _Far ("Max Z",Float) = 1000
    14.     }
    15.     SubShader {
    16.         //Blend One Zero
    17.         Blend Zero SrcColor
    18.         Tags { "Queue"="Overlay" "IgnoreProjector"="True" "RenderType"="Opaque"}
    19.         Lighting Off
    20.         Cull Off
    21.         Fog { Mode Off }
    22.         ZWrite Off
    23.                        
    24.         Pass {
    25.             CGPROGRAM
    26.  
    27.             #pragma vertex vert
    28.             #pragma fragment frag
    29.             #pragma target 3.0
    30.             #pragma glsl
    31.            
    32.             #include "UnityCG.cginc"
    33.            
    34.             #define FORCE_TEX2DLOD
    35.             #include "../FXLab.cginc"
    36.            
    37.             float _SampleRange;
    38.             float _Area;
    39.             float _Falloff;
    40.             float _Strength;
    41.             float _NoiseScale;
    42.             float _Bias;
    43.             sampler2D _NoiseTex;
    44.             float _Near;
    45.             float _Far;
    46.  
    47.             struct appdata {
    48.                 float4 vertex : POSITION;
    49.                 float4 texcoord : TEXCOORD0;
    50.             };
    51.  
    52.             struct v2f {
    53.                 float4 pos : SV_POSITION;
    54.                 float2 uv : TEXCOORD0;
    55.                 float2 uvr : TEXCOORD1;
    56.             };
    57.                                    
    58.             v2f vert (appdata v) {
    59.                 v2f o;
    60.                 o.pos = mul( UNITY_MATRIX_MVP, v.vertex );
    61.                 o.uv = v.texcoord.xy;
    62.                 o.uvr = v.texcoord.xy * _NoiseScale;
    63.                 return o;
    64.             }
    65.            
    66.            
    67.             fixed3 calculateNormal(float depth, float2 texcoords)
    68.             {
    69.                 depth *= _ProjectionParams.z;
    70.  
    71.                 float2 offset1 = float2(0.0,_FXDepthTexture_TexelSize.y);
    72.                 float2 offset2 = float2(_FXDepthTexture_TexelSize.x,0.0);
    73.  
    74.                 float depth1 = sampleFloat(_FXDepthTexture, texcoords + offset1) * _ProjectionParams.z;
    75.                 float depth2 = sampleFloat(_FXDepthTexture, texcoords + offset2) * _ProjectionParams.z;
    76.  
    77.                 float3 p1 = float3(offset1, depth1 - depth);
    78.                 float3 p2 = float3(offset2, depth2 - depth);
    79.  
    80.                 float3 normal = cross(p1, p2);
    81.                 normal.z = -normal.z;
    82.  
    83.                 return normalize(normal);
    84.             }
    85.            
    86.                    
    87.         float4 frag (v2f o) : COLOR
    88.         {
    89.         const float3 RAND_SAMPLES[26] = {
    90.         float3(0.2196607,0.9032637,0.2254677),
    91.         float3(0.05916681,0.2201506,-0.1430302),
    92.         float3(-0.4152246,0.1320857,0.7036734),
    93.         float3(-0.3790807,0.1454145,0.100605),
    94.         float3(0.3149606,-0.1294581,0.7044517),
    95.         float3(-0.1108412,0.2162839,0.1336278),
    96.         float3(0.658012,-0.4395972,-0.2919373),
    97.         float3(0.5377914,0.3112189,0.426864),
    98.         float3(-0.2752537,0.07625949,-0.1273409),
    99.         float3(-0.1915639,-0.4973421,-0.3129629),
    100.         float3(-0.2634767,0.5277923,-0.1107446),
    101.         float3(0.8242752,0.02434147,0.06049098),
    102.         float3(0.06262707,-0.2128643,-0.03671562),
    103.         float3(-0.1795662,-0.3543862,0.07924347),
    104.         float3(0.06039629,0.24629,0.4501176),
    105.         float3(-0.7786345,-0.3814852,-0.2391262),
    106.         float3(0.2792919,0.2487278,-0.05185341),
    107.         float3(0.1841383,0.1696993,-0.8936281),
    108.         float3(-0.3479781,0.4725766,-0.719685),
    109.         float3(-0.1365018,-0.2513416,0.470937),
    110.         float3(0.1280388,-0.563242,0.3419276),
    111.         float3(-0.4800232,-0.1899473,0.2398808),
    112.         float3(0.6389147,0.1191014,-0.5271206),
    113.         float3(0.1932822,-0.3692099,-0.6060588),
    114.         float3(-0.3465451,-0.1654651,-0.6746758),
    115.         float3(0.2448421,-0.1610962,0.1289366),
    116.         };
    117.         float4 _Params = float4(_SampleRange,_Near,_Falloff,_Strength); // x=radius, y=minz, z=attenuation power, w=SSAO power
    118.                
    119.         // read random normal from noise texture
    120.         half3 randN = tex2D (_NoiseTex, o.uvr).xyz * 2.0 - 1.0;    
    121.    
    122.         // read scene depth/normal
    123.         float4 depthnormal = tex2D(_FXWorldNormalTexture, o.uv);
    124.         float depth = sampleFloat(_FXDepthTexture, o.uv);
    125.         float3 viewNorm = calculateNormal(depth, o.uv);
    126.         depth *= _ProjectionParams.z;
    127.         float scale = _Params.x / depth;
    128.    
    129.         // accumulated occlusion factor
    130.         float occ = 0.0;
    131.         for (int s = 0; s < 26; ++s) // We use 26 samples because we need an accurate occ factor with this shader
    132.         {
    133.         // Reflect sample direction around a random vector
    134.         half3 randomDir = reflect(RAND_SAMPLES[s], randN);
    135.        
    136.         // Make it point to the upper hemisphere
    137.         half flip = (dot(viewNorm,randomDir)<0) ? 1.0 : -1.0;
    138.         randomDir *= -flip;
    139.         // Add a bit of normal to reduce self shadowing
    140.         randomDir += viewNorm * 0.4;
    141.        
    142.         float2 offset = randomDir.xy * scale;
    143.         float sD = depth - (randomDir.z * _Params.x);
    144.  
    145.         // Sample depth at offset location
    146. //        float4 sampleND = tex2D (_FXDepthTexture, o.uv + offset);
    147.         float sampleD = sampleFloat(_FXDepthTexture, o.uv + offset);
    148.         float3 sampleN = calculateNormal(sampleD, o.uv + offset);
    149. //      DecodeDepthNormal (sampleND, sampleD, sampleN);
    150.         sampleD *= _ProjectionParams.z;
    151.         float zd = saturate(sD-sampleD);
    152.         if (zd > _Params.y&zd < _Far) {
    153.             // This sample occludes, contribute to occlusion
    154.             occ += pow(1-zd,_Params.z); // sc2
    155.             //occ += 1.0-saturate(pow(1.0 - zd, 11.0) + zd); // nullsq
    156.             //occ += 1.0/(1.0+zd*zd*10); // iq
    157.         }        
    158.         }
    159.         occ /= 26; // Number of samples        
    160.         fixed3 color = saturate(1-occ);
    161.         color = pow (color, _Params.w);  
    162.         return (depth > _Far) ? 1f : fixed4(color, 1); 
    163.         }
    164.             ENDCG
    165.         }
    166.         }
    167.        
    168.     Fallback off
    169.     CustomEditor "FXMaterialEditor"
    170. }
    So three solutions :
    - Find a way to avoid these artifacts (dont know how)
    - Try another implementation
    - Blur the result (dont know how and it would be very expensive)

    PS : I did a little test and I found a way to got Indie Effects works in Linear Space ! In the shaders, simply add :
    Code (csharp):
    1. sqrt(result) // Cheaper method
    2. OR
    3. pow(result, 1.0 / 2.2) // Most accurate methods because it takes the gamma at 2.2 instead of 2.0
     
    Last edited: May 19, 2014
  8. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    REALLY?! AWESOME!!!

    Finally, the fx should work with linear space! Honestly, I need to go back through this thread, grab everyone's suggestions, and bang it all together!

    And BTW, that shader port is FAR better than my previous attempt, and a bit of noise won't hurt, will it... I could blur the result too, it actually isn't expensive at all!

    And to sample the depth in IndieEffects, just make a new sampler2D called Depth or something like that, then in the script, import the _Depth class, then use a SetTexture command to set the "depth" var in the shader to DepthTex. (DepthTex is the static depth texture variable in the _Depth extension)
     
    Last edited: May 20, 2014
  9. Cyrien5100

    Cyrien5100

    Joined:
    Oct 17, 2012
    Posts:
    145
    What i mean by sampling Depth Buffer is how to return a value from 0 to 1.
    In FXLab, i use a function named SampleFloat :

    I tried tex2D but it doesn't work at all :
    $SSAO test3.jpg
    Code (csharp):
    1. Shader "Custom/SSAO2" {
    2.     Properties {
    3.         _DepthTexture ("Depth Texture", 2D) = "white" {}
    4.         _MainTex ("Base (RGB)", 2D) = "white" {}
    5.         _SampleRange ("Sample Range", Range(0, 10)) = 3
    6.         _Falloff ("Falloff", Float) = 0.87
    7.         _Strength ("Strength", Range(0, 10)) = 1
    8.         _NoiseTex ("Noise Texture", 2D) = "gray" {}
    9.         _NoiseScale ("NoiseScale",Range (0,10)) = 3
    10.         _Near ("Min Z",Float) = 0.1
    11.         _Far ("Max Z",Float) = 1000
    12.     }
    13.     SubShader {
    14.         //Blend One Zero
    15.         Blend Zero SrcColor
    16.         Tags { "Queue"="Overlay" "IgnoreProjector"="True" "RenderType"="Opaque"}
    17.         Lighting Off
    18.         Cull Off
    19.         Fog { Mode Off }
    20.         ZWrite Off
    21.                        
    22.         Pass {
    23.             CGPROGRAM
    24.  
    25.             #pragma vertex vert
    26.             #pragma fragment frag
    27.             #pragma target 3.0
    28.             #pragma glsl
    29.            
    30.             #include "UnityCG.cginc"
    31.            
    32.             #define FORCE_TEX2DLOD
    33.            
    34.             float _SampleRange;
    35.             float _Falloff;
    36.             float _Strength;
    37.             float _NoiseScale;
    38.             sampler2D _NoiseTex;
    39.             float _Near;
    40.             float _Far;
    41.             sampler2D _DepthTexture;
    42.             sampler2D _MainTex;
    43.  
    44.             struct appdata {
    45.                 float4 vertex : POSITION;
    46.                 float4 texcoord : TEXCOORD0;
    47.             };
    48.  
    49.             struct v2f {
    50.                 float4 pos : SV_POSITION;
    51.                 float2 uv : TEXCOORD0;
    52.                 float2 uvr : TEXCOORD1;
    53.             };
    54.                                    
    55.             v2f vert (appdata v) {
    56.                 v2f o;
    57.                 o.pos = mul( UNITY_MATRIX_MVP, v.vertex );
    58.                 o.uv = v.texcoord.xy;
    59.                 o.uvr = v.texcoord.xy * _NoiseScale;
    60.                 return o;
    61.             }
    62.            
    63.            
    64.             fixed3 calculateNormal(float depth, float2 texcoords)
    65.             {
    66.                 depth *= _ProjectionParams.z;
    67.  
    68.                 float2 offset1 = float2(0.0,0.001);
    69.                 float2 offset2 = float2(0.001,0.0);
    70.  
    71.                 float depth1 = tex2D(_DepthTexture, texcoords + offset1) * _ProjectionParams.z;
    72.                 float depth2 = tex2D(_DepthTexture, texcoords + offset2) * _ProjectionParams.z;
    73.  
    74.                 float3 p1 = float3(offset1, depth1 - depth);
    75.                 float3 p2 = float3(offset2, depth2 - depth);
    76.  
    77.                 float3 normal = cross(p1, p2);
    78.                 normal.z = -normal.z;
    79.  
    80.                 return normalize(normal);
    81.             }
    82.            
    83.                    
    84.         float4 frag (v2f o) : COLOR
    85.         {
    86.         const float3 RAND_SAMPLES[26] = {
    87.         float3(0.2196607,0.9032637,0.2254677),
    88.         float3(0.05916681,0.2201506,-0.1430302),
    89.         float3(-0.4152246,0.1320857,0.7036734),
    90.         float3(-0.3790807,0.1454145,0.100605),
    91.         float3(0.3149606,-0.1294581,0.7044517),
    92.         float3(-0.1108412,0.2162839,0.1336278),
    93.         float3(0.658012,-0.4395972,-0.2919373),
    94.         float3(0.5377914,0.3112189,0.426864),
    95.         float3(-0.2752537,0.07625949,-0.1273409),
    96.         float3(-0.1915639,-0.4973421,-0.3129629),
    97.         float3(-0.2634767,0.5277923,-0.1107446),
    98.         float3(0.8242752,0.02434147,0.06049098),
    99.         float3(0.06262707,-0.2128643,-0.03671562),
    100.         float3(-0.1795662,-0.3543862,0.07924347),
    101.         float3(0.06039629,0.24629,0.4501176),
    102.         float3(-0.7786345,-0.3814852,-0.2391262),
    103.         float3(0.2792919,0.2487278,-0.05185341),
    104.         float3(0.1841383,0.1696993,-0.8936281),
    105.         float3(-0.3479781,0.4725766,-0.719685),
    106.         float3(-0.1365018,-0.2513416,0.470937),
    107.         float3(0.1280388,-0.563242,0.3419276),
    108.         float3(-0.4800232,-0.1899473,0.2398808),
    109.         float3(0.6389147,0.1191014,-0.5271206),
    110.         float3(0.1932822,-0.3692099,-0.6060588),
    111.         float3(-0.3465451,-0.1654651,-0.6746758),
    112.         float3(0.2448421,-0.1610962,0.1289366),
    113.         };
    114.         float4 _Params = float4(_SampleRange,_Near,_Falloff,_Strength); // x=radius, y=minz, z=attenuation power, w=SSAO power
    115.                
    116.         // read random normal from noise texture
    117.         half3 randN = tex2D(_NoiseTex, o.uvr).xyz * 2.0 - 1.0;    
    118.    
    119.         // read scene depth/normal
    120.         float depth = tex2D(_DepthTexture, o.uv);
    121.         float3 viewNorm = calculateNormal(depth, o.uv);
    122.         depth *= _ProjectionParams.z;
    123.         float scale = _Params.x / depth;
    124.    
    125.         // accumulated occlusion factor
    126.         float occ = 0.0;
    127.         for (int s = 0; s < 26; ++s)
    128.         {
    129.         // Reflect sample direction around a random vector
    130.         half3 randomDir = reflect(RAND_SAMPLES[s], randN);
    131.        
    132.         // Make it point to the upper hemisphere
    133.         half flip = (dot(viewNorm,randomDir)<0) ? 1.0 : -1.0;
    134.         randomDir *= -flip;
    135.         // Add a bit of normal to reduce self shadowing
    136.         randomDir += viewNorm * 0.4;
    137.        
    138.         float2 offset = randomDir.xy * scale;
    139.         float sD = depth - (randomDir.z * _Params.x);
    140.  
    141.         // Sample depth at offset location
    142. //        float4 sampleND = tex2D (_DepthTexture, o.uv + offset);
    143.         float sampleD = tex2D(_DepthTexture, o.uv + offset);
    144.         float3 sampleN = calculateNormal(sampleD, o.uv + offset);
    145. //      DecodeDepthNormal (sampleND, sampleD, sampleN);
    146.         sampleD *= _ProjectionParams.z;
    147.         float zd = saturate(sD-sampleD);
    148.         if (zd > _Params.y&zd < _Far) {
    149.             // This sample occludes, contribute to occlusion
    150.             occ += pow(1-zd,_Params.z); // sc2
    151.             //occ += 1.0-saturate(pow(1.0 - zd, 11.0) + zd); // nullsq
    152.             //occ += 1.0/(1.0+zd*zd*10); // iq
    153.         }        
    154.         }
    155.         occ /= 26;         
    156. //      fixed3 color = saturate(1-occ);
    157. //      color = pow (color, _Params.w);
    158.         float4 Output;
    159.         Output.rgb = saturate((1-occ)*_Params.w);
    160.         return (depth > _Far) ? 1f : tex2D(_MainTex, o.uv) * Output;   
    161.         }
    162.             ENDCG
    163.         }
    164.         }
    165.        
    166.     Fallback off
    167.     CustomEditor "FXMaterialEditor"
    168. }
    And i need this to achieve a good SSAO. But for me it's better to try another implementation of SSAO (like the one i sent) because Unity Pro's SSAO is VERY VERY basic and has many artifacts.
    And i have several suggestions :
    - A rework of the API would be good (we don't need Motion blur in the main script^^), with more functions that we can use in shaders (like a .cginc API ?).
    - I think (but it's a supposition, not necessarily true) the Depth buffer has something wrong because with FXLab, the shader works but when i use Indie Effects, it doesn't look like SSAO at all.

    PS : Maybe i'll try to implement this SSAO : http://www.altdevblogaday.com/2012/10/12/angle-based-ssao/
    It's not based on comparing depth but on calculate angle to contribute to occlusion factor.
    It's an approach close to HBAO but not exactly the same and it's used in UE4's Elemental demo.
    The good thing is it only needs Depth Texture and we can have very correct result without blur.
    The problem is i dont know if i have enough knowledge on shaders to port it. I'll try but if someone (FuzzyQuills:mrgreen: ?) more experienced with shaders can implement it, honor on him :D !).

    EDIT : I found a way to filter artifacts i have with FXLab but it sometimes creates "holes" in SSAO.
    I did another try with Indie Effects but it doesn't works too :( Is your Depth buffer is linear ?
     
    Last edited: May 20, 2014
  10. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    @Cyrien5100: try using the _Depth_Corrected shader instead. This one is specifically designed for SSAO, and to assign it, go to the _Depth extension, then change the shader to _Depth_Corrected.

    EDIT: Ok, NONE of your shaders do anything on my end... :/ What's up with that? Try giving me your script as i tried writing my own, only to find the shader won't work! and BTW, I can port shaders a little bit! Only GLSL sometimes needs tweaking...
     
    Last edited: May 21, 2014
  11. Cyrien5100

    Cyrien5100

    Joined:
    Oct 17, 2012
    Posts:
    145
    Here is the script of SSAO (with IndieEffects), but it doesn't works (giving the image i sent) :
    Code (csharp):
    1. using UnityEngine;
    2.  
    3. [RequireComponent (typeof(IndieEffects))]
    4. [AddComponentMenu ("Indie Effects/SSAO 2")]
    5. public class SSAO2 : MonoBehaviour
    6. {
    7.     public Texture2D mainTex;
    8.     public Texture2D depthTex;
    9.     public Texture2D randTex;
    10.    
    11.     private Material materialAO;
    12.     public Shader shaderAO;
    13.    
    14.     public float strength = 1f;
    15.     public float falloff = 0.01f;
    16.     public float noiseScale = 1.0f;
    17.     public float sampleRange = 1.0f;
    18.     public float zNear = 0.3f;
    19.     public float zFar = 50.0f;
    20.    
    21.     private void Start ()
    22.     {
    23.         materialAO = new Material(shaderAO);
    24.     }
    25.    
    26.     private void Update ()
    27.     {
    28.         mainTex = IndieEffects.renderTexture;
    29.         depthTex = _Depth.DepthTex;
    30.         materialAO.SetTexture("_MainTex", mainTex);
    31.         materialAO.SetTexture("_DepthTexture", depthTex);
    32.         materialAO.SetTexture("_NoiseTex", randTex);
    33.         materialAO.SetFloat("_SampleRange", sampleRange);
    34.         materialAO.SetFloat("_Falloff", falloff);
    35.         materialAO.SetFloat("_Strength", strength);
    36.         materialAO.SetFloat("_NoiseScale", noiseScale);
    37.         materialAO.SetFloat("_Near", zNear);
    38.         materialAO.SetFloat("_Far", zFar);
    39.        
    40.     }
    41.    
    42.     private void OnPostRender ()
    43.     {
    44.         IndieEffects.FullScreenQuadPass(materialAO,0);
    45.         materialAO.SetTexture("_MainTex", mainTex);
    46.         IndieEffects.FullScreenQuadPass(materialAO, 1);
    47.     }
    48. }
    It's strange because in FXLab, the effect works (with artifacts). In the IndieEffect version, i just replaced FXLab's SampleFloat function with tex2D and changed the name of Depth Texture. Even with _DepthCorrected shader, it doesn't works :/
    EDIT : After searching and looking for SSAO's implementations (there is many of them), i found that we need a Linear Depth Buffer (not an exponential) with values from 0 to 1. So i little tweaked the _DepthCorrected shader to have a correct depth texture :
    Code (csharp):
    1. Shader "IndieEffects/DepthTexture_Corrected" {
    2. SubShader {
    3. Tags {"RenderType" = "Fog" "Queue"="Transparent"}
    4.  
    5. Pass {
    6.     Fog { Mode Off }
    7.     Lighting Off
    8.     Cull off
    9.  
    10.     CGPROGRAM
    11.     #pragma target 3.0
    12.     #pragma vertex vert
    13.     #pragma fragment frag
    14.     #include "UnityCG.cginc"
    15.  
    16.     struct v2f {
    17.         float4 pos : POSITION;
    18.         float2 depth : TEXCOORD0;
    19.     };
    20.  
    21.     v2f vert( appdata_base v ) {
    22.     v2f o;
    23.     o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
    24.     UNITY_TRANSFER_DEPTH(o.depth);
    25.     return o;
    26.     }
    27.  
    28.     float4 frag(v2f i) : COLOR {
    29.         float o = EncodeFloatRGBA(Linear01Depth(i.depth.x / i.depth.y));
    30.         return o;
    31.     }
    32.  
    33.     ENDCG
    34.     }
    35. }
    36. }
     
    Last edited: May 21, 2014
  12. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    @Cyrien5100: Thx buddy, your contributions are proving the best so far. will test the depth tex now.

    BTW, I am not that good at C#, so this might turn out messy... :/ At least i have some knowledge though!

    EDIT: I just looked at your script an i am proud of you! You used FullScreenQuadPass, which makes you the first to use it!
     
    Last edited: May 22, 2014
  13. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Another question: did the linear buffer work? I tried it and it didn't work for me...
     
  14. Cyrien5100

    Cyrien5100

    Joined:
    Oct 17, 2012
    Posts:
    145
    The code i sent to you is wrong^^
    Try this :
    Code (csharp):
    1. Shader "IndieEffects/DepthTexture_Corrected" {
    2. SubShader {
    3. Tags {"RenderType" = "Fog" "Queue"="Transparent"}
    4.  
    5. Pass {
    6.     Fog { Mode Off }
    7.     Lighting Off
    8.     Cull off
    9.  
    10.     CGPROGRAM
    11.     #pragma target 3.0
    12.     #pragma vertex vert
    13.     #pragma fragment frag
    14.     #include "UnityCG.cginc"
    15.  
    16.     struct v2f {
    17.         float4 pos : POSITION;
    18.         float2 depth : TEXCOORD0;
    19.     };
    20.  
    21.     v2f vert( appdata_base v ) {
    22.     v2f o;
    23.     o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
    24.     UNITY_TRANSFER_DEPTH(o.depth);
    25.    
    26.     return o;
    27.     }
    28.  
    29.     float4 frag(v2f i) : COLOR {
    30.  
    31.     //This is the calculation from wikipedia. Simple but!...
    32.     //farClip = 50
    33.     //nearClip = 0.5
    34. //        float a = (50 + 0.5) / ( 50 - 0.3);
    35. //        float b = -2 * 50 * 0.3 / (50-0.3);
    36. //        float z = i.depth.x;
    37. //  
    38. //        float4 d = a + b/z;
    39.  
    40. //        I think your depth texture looks better!
    41. //        Only in the ssao shader it looks wrong
    42. //        float4 d = i.depth.x;
    43. ////        float a = DECODE_EYEDEPTH(i)
    44. //  
    45. //        float4 c;
    46. //        c.r = d;
    47. //        c.g = d;
    48. //        c.b = d;
    49. //        c.a = d;
    50. //
    51. //        return c;
    52. //      float o = Linear01Depth(i.depth.x);
    53. //      UNITY_OUTPUT_DEPTH(i.depth);
    54. //      DECODE_EYEDEPTH(i);
    55.         return Linear01Depth(i.depth.x / i.depth.y);
    56.     }
    57.  
    58.     ENDCG
    59.     }
    60. }
    61. }}
    I'm currently trying to implement this method : http://www.gamedev.net/topic/556187-the-best-ssao-ive-seen/
    It's the Bunell Disk Method, and it gives very good results : https://www.youtube.com/watch?v=uCiXUnvIqs0
    In the video, there is no blur and no jittering so it should works in one pass.
    The problem i have for now is how to reconstruct view space position using the depth buffer.
    Also, i saw that Depth buffer with readPixels is only an 8 bit Depth buffer, so values are from 0 to 255.
    So if i (or anyone) successfully implement ssao effect, a too far clip plane would be prohibed.

    However, i had an idea to have a more precise depth buffer but i'm not sure :
    i found a function named EncodeFloatRGBA which encode a float (0 to 1 range so perfect for depth buffer) in an RGBA texture (vector4). The idea is : to keep the float value precise, we "cut" it in 4 parts, put each in xyzw of the 32 bit texture (8 bit per channel) so and after, by using DecodeFloatRGBA, decode the encoded value stored in low precision buffer and recover the original precise value.
    By doing that, i think it's possible to have a more precise depth buffer (because readpixels only works for 8 bit per channel), but i have no idea of how to implement that correctly. It would create a "strange" depth buffer which we decode in the right shader.

    I hope i wasn't too long in explanations and for now, i dont give good results^^
     
  15. Cyrien5100

    Cyrien5100

    Joined:
    Oct 17, 2012
    Posts:
    145
    Finally, i got something working. Not very well, but working :D
    It needs some tweaks, and has some limitations because the Depth buffer is only 8 bit (so very low precision).
    I modified the Depth Shader too, and now Depth and Normals are in the same texture.
    It's strange but my previous attempt worked in FXLab but not in IndieEffect but now, it's in the reverse order XD.
    To have GOOD result, far clip range can't exceeds 10. To have ACCEPTABLE results, 25 can work. But dont exceeds 50 becuase after, the effect gets crrapy and doesn't looks like SSAO.
    It have some bug too with skybox and a little artifact at the bottom of the screen, but it looks pretty good in Sponza Scene :D
    There is some halo but it's FAR better than what i did previously.
    Here is some pictures :

    No SSAO :
    $WSSAO1.jpg

    SSAO :
    $WSSAO2.jpg

    No SSAO (With textures)
    $WSSAO3.jpg

    SSAO (With textures) :
    $WSSAO4.jpg

    AO Only :
    $WSSAO5.jpg

    Say what you think about :)

    PS : I did some tests and it doesn't works in Linear Space and with DirectX 11.
    I have an idea for Linear Space but not for DX11
     
    Last edited: May 24, 2014
  16. 0tacun

    0tacun

    Joined:
    Jun 23, 2013
    Posts:
    245
    Looks good, was the hint I gave you helpfull?
     
  17. Cyrien5100

    Cyrien5100

    Joined:
    Oct 17, 2012
    Posts:
    145
    Yep it was really helpful (i found the same code in another site xD).
    Now i'm trying to optimize this and increase the max far clip range (50 is not usable).
    PS : Do you have any idea on how i can have a 16 bit Depth buffer ? Becuase currently, i only have a 8 bit * 2 so the precision is very low (0-512 range).
    And to increase the view distance without sacryfing quality of ssao i need a more precise depth buffer :/
     
  18. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    So you're saying: this won't work in DX11? And that is sick SSAO!\

    And... code please? it's too epic just to look at! And BTW, I haven't got around to trying the depth tex yet... May do it today if i get time. and I am not sure how to get a 16-bit tex in Unity yet! ;)
     
    Last edited: May 26, 2014
  19. deadlycrow

    deadlycrow

    Joined:
    Feb 10, 2014
    Posts:
    166
    that is very nice, but how can i put this on my camera? what textures i need to put on it? ._. iam confused (iam noob sorry xD)
     
    Last edited: May 26, 2014
  20. Cyrien5100

    Cyrien5100

    Joined:
    Oct 17, 2012
    Posts:
    145
    I can't give the code because i'm using a customizated version of the framework but i can send you the package in PM if you want to improve it.
    It's not ready at all yet and i'm not satisfated with the results i have currently.
    But i can send little webplayer to see the effect in action :) : https://dl.dropboxusercontent.com/s/w9oaujevoyuwp4e/SSAO_Webplayer.html

    The effect is not implemented in IndieEffect for now xD


    PS : When i'll finish this, maybe i'll try to implement SSGI, Screen Space Shadow and others effects.
     
  21. NinjaRubberBand

    NinjaRubberBand

    Joined:
    Feb 22, 2013
    Posts:
    243
    Can i use this for commercial use? this is just what i need. :)
     
  22. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    @DeadlyCrow: Well, Although this release is partially broken in places, it is as simple as going to the classes folder, (or the C# classes folder if you need C#) and drag-and-drop the effect you want onto the camera. it should auto-add the components it needs for you. (there was a problem with the C# classes not auto-adding components, but i am hopefully able to fix this in a future release, which is hopefully coming soon!)

    EDIT: If you want the SSAO, then unfortunately, as Cyrien stated, it's not finished yet.

    @NinjaRubberBand: Feel free to use this pack for anything: it's not only free, but open-source, so feel free to modify any part of it to suit your needs! One example could be to strip out everything but the base script, or write a custom base that may be project-specific. One of my big projects does this, so if you want examples, i can give them!

    BTW, nice nickname ;)

    @Cyrien5100: I can take a modded class, but that could also be the reason why none of your scripts run on my end... and yes, your version of the base script would be great! :)
     
    Last edited: May 27, 2014
  23. 0tacun

    0tacun

    Joined:
    Jun 23, 2013
    Posts:
    245
    @Cyrien5100: Unfortunally I currently don't have a solution for a bigger depth texture... Anyways I don't think it isn't necessary to increase the far range where SSAO applies. Often you will get artifacts, sometimes it is better to occlude nearer geometric and exclude objects which are far away.

    http://forum.unity3d.com/threads/83543-SSAO-with-depth-cutoff-parameter

    Maybe it could be possible to use two different far clip ranges for the two cameras. By the way, I would also be curious to see the package!
    Keep up the good work.

    @FuzzyQuills: I agree with Cyrien that the API could need a rework, maybe you have something in your mind? What I would like to see is some individually access to each camera, meaning droping the static texture approach. I could post an example if you like.
     
  24. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    @0tacun: we could do that... only your scripts pops up all these annoying warnings about implicit downcasts. (i do know where the problem is, but still...)

    What i was thinking was having a texture index for each camera, where the effects only grab the texture form the part of the array that camera controls. that way, the same individuality is achieved, but it also means that the API won't change much. (I intend to keep it easy for the n00b group's sake. ;))

    and go ahead and post an example, I would like to see how you would set this out. :)
     
  25. Cyrien5100

    Cyrien5100

    Joined:
    Oct 17, 2012
    Posts:
    145
    New webplayer : https://dl.dropboxusercontent.com/s/efsnnoeet9ikby3/SSAO_WebPlayerLabo.html
    Tell me how much FPS you have and you configuration please :) .

    Change Log :
    - Far clip increased to ~5000
    - Black halo are removed
    - Better looking SSAO
    - Problem with skyboxes solved

    There is only 2 things i have to do now, optimize the shader and make it to work for particles, trees and grass.

    If you have any comment, suggestion or tip, say it to me ;)

    Screenshots :

    $SSAO With.jpg

    $SSAO Without.jpg

    $SSAO AO.jpg
     
    Last edited: May 28, 2014
  26. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    I couldn't really see it, but that scene... it's epic! did you make that?
     
  27. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    @Cyrien5100: Really nice. That is the best AO I have seen in free. Did not notice a performance drop with the effect active. Nice:D

    @FuzzyQuills: It is a Unity team made scene. You can get it on the Asset Store for free. It is used in tutorials. It is really nice. Even more beautiful physically based:D.
     
    Last edited: May 29, 2014
  28. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Hi, Long time no see! ;)

    And I guess it's no big surprise it was made by UT.
     
  29. Cyrien5100

    Cyrien5100

    Joined:
    Oct 17, 2012
    Posts:
    145
    I'm very close to release !!!
    I'm happy to announce new changes :
    - I improved the look of SSAO again
    - Added a "Self Occlusion" parameter
    - Some optimizations
    I think in some cases my SSAO implementation is better than Unity Pro implementation, because it's not noisy at all !
    After one week of working on it, i have at last successfully implemented a good looking SSAO !
    I'll create others effects and my goal is to bring Unity Free to Next-gen !
    SSAO is only a first step :)

    Here is a video of what i have now (low FPS is because of recording), watch it in HD:
    [video=youtube_share;GNF6zlETs28]http://youtu.be/GNF6zlETs28

    Here is a standalone with possibility of changing SSAO Quality : https://mega.co.nz/#!7EYjADCK!WnM0NPgnzBIkdgzUljkSqybsHUAluUxzF1duuK9ATiA
     
  30. Eric2241

    Eric2241

    Joined:
    Dec 2, 2012
    Posts:
    642
    Nice work, I got around 36fps with the new webplayer. Will the effect be free?
     
  31. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    So are you going to help integrate this with my fx pack? If you could send me the base script, i can incorporate the changes for you if you like. I am currently working on the multi-cam support for 0tacun's sake, and will happily incorporate any changes you made as well.
     
  32. 0tacun

    0tacun

    Joined:
    Jun 23, 2013
    Posts:
    245
    @FuzzyQuills: Sorry for the late reply, working on a custom shader.
    Hmm I don't know of any implicit downcast problems, but I'm using a moddified version of your framework, maybe some scripts I supported weren't correctly transfered to your package. Also have you added camera motion blur, which I provided, to your package?

    Anyways, what I have to disagree with the texture array approach is that I think everything should stay almost object orientated.

    I am currently using something like this:

    Base.js:
    Code (csharp):
    1.  
    2. var thisCamera : Camera;
    3. var renderTexture : Texture2D;
    4.  
    5. static function  FullscreenQuad( renderMat : Material ) { ... }
    6. ...
    7. function OnPostRender() {
    8.     ...
    9.  
    10.     //capture main texture
    11.     renderTexture.Resize(thisCamera.pixelWidth, thisCamera.pixelHeight, TextureFormat.RGB24, false);
    12.     renderTexture.ReadPixels(thisCamera.pixelRect, 0, 0);
    13.     renderTexture.Apply();
    14.  
    15.     ...
    16. }
    17.  
    And then in every effect for example:
    Bloom.js:
    Code (csharp):
    1.  
    2. var BaseScript : Base;
    3. private var bloomMat : Material;
    4. var  bloomShader : Shader;
    5.  
    6. @range (0,5)
    7. var radius : float;
    8. @range(0,2)
    9. var amount : float;
    10.  
    11. function Start () {
    12.     IndieEffects = transform.GetComponent("BaseScript");
    13.     bloomMat = new Material(bloomShader);
    14. }
    15.  
    16. function OnPostRender () {
    17.     bloomMat.SetTexture("_MainTex", BaseScript.renderTexture);
    18.     bloomMat.SetTexture("_BlurTex", BaseScript.renderTexture);
    19.     bloomMat.SetFloat("_Radius", radius);
    20.     bloomMat.SetFloat("_Amount", amount);
    21.     FullScreenQuad(bloomMat);
    22. }
    23.  
    This is an example of my approuch. It is also extended with the depth scripts etc. . The advantage is that all script objects/ materials/ textures/ shaders, are all asigned to the camera in use, so it is not so confusing.
     
  33. NeonTanto

    NeonTanto

    Joined:
    Jun 19, 2013
    Posts:
    156
    @Cyrien5100, nice work! But i don't understand how you did it with small redusing of fps... Can you tell me how you did it? =)
    And you dont use normals? I think you may store depth into r and g channel (almost 65500 position in two 8 bit value), and x and y of normals in b and a channel (we know that the axis Z is positive and that normal length equal 1 that why we can restore Z from X and Y):
    Code (csharp):
    1.  
    2. //store depth from 0..FAR_CLIP to r and g
    3. texture.r = frac(depth);
    4. texture.g = floor(depth)/256;
    5.  
    6. //restore depth
    7. depth = texture.r + texture.g * 256;
    8.  
    9. //store normal to b and a
    10. texture.b = normal.x
    11. texture.a = normal.y
    12. //restore normal from b and a
    13. normal.x = texture.b;
    14. normal.y = texture.a;
    15. normal.z = sqrt(1 - texture.b * texture.b - texture.a * texture.a);
    16.  
    I use this method for another target, but I think you may use this idea.

    P.S. Please forgive me for my bad English.
     
    Last edited: May 30, 2014
  34. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    OK, Since my laptop is in front of me, (not typing this from it though!) I will integrate it right away!

    EDIT: So far...
    • the renderTexture variable has been renamed to RT, to avoid the RenderTexture class being mixed with it.
    • the base script is now object-dependant.
    • There is now a Texture Latency slider which allows you to drop frames from being grabbed, making things that much faster.
    • to use IndieEffects in scripting, you derive from a variable called fxRes (this is a local variable, and can actually be named anything you like, so long as you have something to get resources from :)) where you GetComponent in start() to assign IndieEffects as the resource, then simply write fxRes.RT or something like that
    • I have been considering integrating depth texture generation in the base script, and at the same time, integrate normals with the depth, making this ultra-portable and much faster. (normals are stored in rgb chanels while depth is stored in alpha channel.)
    • I may plan to add texture downscaling in the future, but at the moment, the only way to do that is to resize the camera rect... :?
    • The C# classes will have C# put to their name, and will be in a different listing, to avoid conflicting IDs.
    There you go. what's in store for you next release.

    EDIT2: I have found an odd problem: for some reason, the depth isn't stored in the alpha channel... :(
    EDIT3: found the prob, it was being re-encoded as RGB24 when resizing... :rolleyes:
     
    Last edited: May 30, 2014
  35. Cyrien5100

    Cyrien5100

    Joined:
    Oct 17, 2012
    Posts:
    145
    @mf_andreich
    Yes, i encode both depth and normals into one texture. I'm using the built-in function EncodeDepthNormal which encode normals in r g and depth in b w
    and i decode them using DecodeDepthNormal. It allows me to have 2 textures packed in one, so only one grabpass is needed. The depth buffer is 16 bit so i have a good precision :)
    After, to increase FPS, i did a "size factor" parameter, which resize the RT at the wanted size.

    @FuzzyQuills
    My SSAO effect only use the FullScreenQuad of IndieEffects. It does his own RT.
    So i will post the package when i finished a little demo :)
    A tip : to downscale the texture, i'm using camera rect ;)
    I think store normals in RGB and depth in alpha channel is not a good idea :
    depth will be only 8 bit so not very precise. I think use my method (EncodeDepthNormal and DecodeDepthNormal) is better because z normal is correctly reconstructed (stereographic reconstruction) and depth is 16 bit (more effect can use it with a bigger far clip). ;)

    I hope Unity 5 will allow rendertexture (a limited rendertexture is enough), because performances of all Unity free effect packages are not that good :?

    EDIT : Here is the package. I removed all the effects and keep only things needed for ssao.
    Link : https://mega.co.nz/#!iJICRCiK!Yroj00f_Ti0zmGXrn3lOOZmaXY-JPdnF-X7Ne-xgAN4
     
    Last edited: May 30, 2014
  36. NeonTanto

    NeonTanto

    Joined:
    Jun 19, 2013
    Posts:
    156
    @Cyrien5100, to increase performance try create Texture2d with power of two sides. And fill only inside part with correct uv coords on render quad. That may reduce lag for Apply() method.
    EDIT: broken link
     
    Last edited: May 30, 2014
  37. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    @Cyrien5100: Well, i do use camera rect too, but sometimes, it doesn't come out right... :?

    BTW, do you use a mac? My script window said "inconsistent line endings.' no problem though, just curious! :)

    EDIT: How do you get the depth in your texture? My DoF broke on it... :(
     
    Last edited: May 31, 2014
  38. Cyrien5100

    Cyrien5100

    Joined:
    Oct 17, 2012
    Posts:
    145
    @FuzzyQuills
    No, i don't have a mac^^
    It's normal that your DoF broke on it, my _NormalsDepth shader packs both normals and depth and encode them into RGBA.
    So you have to decode them in your shaders by using DecodeDepthNormal().
    It's faster to have only one texture for depth and normals because it avoids one apply (so it saves many performances).
     
  39. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Yes, I know this, I assumed it when I looked at it. Well, I tried this, but for some reason, i either get really weird reverse color effects or it only blurs the sky.

    So how do i sample it properly? I also got the problem of the depth appearing to be rendering in bars!
     
  40. 0tacun

    0tacun

    Joined:
    Jun 23, 2013
    Posts:
    245
    @FuzzyQuills: Texture Latency sounds interessting, could you explain what you are going to do? Meanwhile I try to port the other outline shader provided by Unity.

    @mf_andreich: But couldn't then such a texture having to much information and reducing performance of ReadPixels()? I just don't know, have you tried something?
     
  41. Cyrien5100

    Cyrien5100

    Joined:
    Oct 17, 2012
    Posts:
    145
    @FuzzyQuills
    Look in the SSAO shader, the function readDepthNormal() gives the good depth. If it doesn't works, try to use Linear01Depth(depth) on the depth value.
     
  42. Cyrien5100

    Cyrien5100

    Joined:
    Oct 17, 2012
    Posts:
    145
    Trying to implement SSGI...
    No SSGI :
    $No SSGI.jpg

    SSGI (Look at the corner):
    $SSGI.jpg

    But too many artifacts to be right.
     
  43. doncsoo

    doncsoo

    Joined:
    Jun 14, 2013
    Posts:
    3
    Hey! These effects looks awesome but I have a big problem. When I apply these any of these effects to the Camera ,in Play Mode it goes too bright. How can I fix this? $Vignette problem.jpg
     
  44. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    @Cyrien5100: Thanks, I will give Linear01Depth a shot. And SSGI... How are you trying this?

    EDIT: I got the same result: blurred skybox, but nothing else... :(

    EDIT2: now look what happens...
    $Weird DOF glitch.png
    What am i doing so wrong for this to happen?!

    @doncsoo: Do you have linear space enabled? this can break the effects. I was planning on using Cyrien5100's fix, but in 4.5, they removed linear space... :(

    It also looks like you may have enabled negative colors as well as vignetting, try removing one of these two and see if it fixes the problem! :)
     
    Last edited: Jun 2, 2014
  45. Cyrien5100

    Cyrien5100

    Joined:
    Oct 17, 2012
    Posts:
    145
    @FuzzyQuills : It's strange, 0tacun tried the ssao shader and it worked well for him. Here is what i think can resolve the problem :
    - Try to test it on another hardware, maybe your graphic card doesn't generate a good depth texture (i'm using the default unity depthnormal generation).
    - Check the if the normaldepth shader is the correct one (doesn't work with your depth_corrected shader ) and remove linear01depth if you tried it (because in the normaldepth shader, depth texture is already encoded as a lineardepth).
    - If you use a custom version of IndieEffects Base, check if the texture is an ARGB32 texture.

    About SSGI, it's based on the same method as the ssao shader (Bunell Disk), but the calculation is not the same : it doesn't calculate occlusion but calculate transfered radiance. You can find something about that here : http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter14.html (The last part)
    The problem is that it's not physically accurate : there is some bounces in shadows, where it should not have.
     
  46. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Um, that's the DoF effect. the SSAO works fine, although I have noticed sometimes that the SSAO seems to wrap around the screen and leak out on the other side. (this I have noticed with blurring effects too, so it's most likely a limit of Unity Free)
     
  47. Cyrien5100

    Cyrien5100

    Joined:
    Oct 17, 2012
    Posts:
    145
    Oh sry i have misunderstood ^^
    About your DoF, i think it's because your old depth buffer was exponential but mine is linear.
    I think it's why your just have the sky blurred.
     
  48. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    It's more likely because my depth buffer used a 0-1 range, whereas yours seems to have "segments" in the depth buffer when viewed. (this is because the depth of field lerp needs to have 0-1 value)
     
  49. mlhornbo

    mlhornbo

    Joined:
    May 17, 2014
    Posts:
    24
    When I layer several of these effects in Unity and then later decide to remove one of them, like, for example, DOF or God Rays, the game engine after that renders nothing but blank white unless the unwanted effect is turned on again. Why would it do this, and is there a good fix?

    Otherwise, amazing work FuzzyQuills! This set of effects is really awesome... but it'd be better if I could get them to work reliably.
     
    Last edited: Jun 4, 2014
  50. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    You will have to show me your project layout sir for me to help you. And the god rays shader is technically obsolete, as I have ideas for a new one that looks better. All this tells me is that you have added a C# version of an effect and tried to mix it with JS scripts. (not gonna work...)

    to remedy this, go to the classes asset folder and manually drag the classes to your camera. (The next release will hopefully split the classes by name, making this not so confusing) ;)