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

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,869
    Huh? I don't remember seeing any syntax errors in my scripts... :D

    If you got the github version, by the looks of it, merging a couple of changes has messed up parts of the script. (Where else would a ">>=" symbol come from?! :eek: )

    Nonetheless, just post the entire script here and let me fix it up for you! :)
     
  2. clevermango

    clevermango

    Joined:
    Jan 7, 2015
    Posts:
    32
    Ahh yes, good point I did grab the github version as the Network I'm on atm wont allow a connection to other sources (don't ask..;) )

    Here the script. Much appreciated, Many thanks!

    #pragma strict
    /*
    ----------Indie Effects Base----------
    This is the base for all other image effects to occur. Includes depth texture generation
    */

    @script RequireComponent(Camera);
    @script AddComponentMenu("Indie Effects/IndieEffectsBase")

    //base effects
    @script HideInInspector var RT : Texture2D;
    var textureSize : int;
    var capture : boolean;
    var DepthShader : Shader;
    var DNBuffer : Texture2D;
    var DNRequire : boolean;
    var DepthCam : GameObject;
    @Range(0,0.04)
    var latency : float;

    var useOldVersion : boolean; //enable old rendering method
    var myCamera : Camera; //cache camera and transform component for
    private var myTransform : Transform; //performance

    static function FullScreenQuad(renderMat : Material) {
    GL.PushMatrix();
    for (var i = 0; i < renderMat.passCount; ++i) {
    renderMat.SetPass(i);
    GL.LoadOrtho();
    GL.Begin(GL.QUADS); // Quad
    GL.Color(Color(1,1,1,1));
    GL.MultiTexCoord(0,Vector3(0,0,0));
    GL.Vertex3(0,0,0);
    GL.MultiTexCoord(0,Vector3(0,1,0));
    GL.Vertex3(0,1,0);
    GL.MultiTexCoord(0,Vector3(1,1,0));
    GL.Vertex3(1,1,0);
    GL.MultiTexCoord(0,Vector3(1,0,0));
    GL.Vertex3(1,0,0);
    GL.End();
    }
    GL.PopMatrix();
    }

    static function FullScreenQuadPass(renderMat : Material, pass : int){
    GL.PushMatrix();
    for (var i = 0; i < pass; ++i) {
    renderMat.SetPass(i);
    GL.LoadOrtho();
    GL.Begin(GL.QUADS); // Quad
    GL.Color(Color(1,1,1,1));
    GL.MultiTexCoord(0,Vector3(0,0,0));
    GL.Vertex3(0,0,0);
    GL.MultiTexCoord(0,Vector3(0,1,0));
    GL.Vertex3(0,1,0);
    GL.MultiTexCoord(0,Vector3(1,1,0));
    GL.Vertex3(1,1,0);
    GL.MultiTexCoord(0,Vector3(1,0,0));
    GL.Vertex3(1,0,0);
    GL.End();
    }
    GL.PopMatrix();
    }

    static function screenGrab ( rt : Texture2D, camRect : Rect ) {
    var asp = Camera.current.pixelWidth/Camera.current.pixelHeight;
    var dom = new GameObject("capture", Camera);
    dom.camera.aspect = asp;
    dom.camera.pixelRect = camRect;
    dom.transform.position = Camera.current.transform.position;
    dom.transform.rotation = Camera.current.transform.rotation;
    dom.camera.Render();
    rt.ReadPixels(camRect, 0, 0);
    rt.Apply();
    Destroy(dom);
    return rt;
    }

    var prevRect : Rect;
    var asp : float;
    var dom : GameObject;
    function OnPreRender () {
    if( !useOldVersion ){

    asp = camera.pixelWidth/camera.pixelHeight;
    if (!DepthCam){
    DepthCam = new GameObject("DepthCamera",Camera);
    DepthCam.camera.CopyFrom(camera);
    DepthCam.camera.depth = camera.depth-2;
    }
    if (!dom){
    dom = new GameObject("capture", Camera);
    dom.camera.CopyFrom(camera);
    dom.camera.depth = camera.depth-3;
    }
    if (capture && DNRequire) {
    DepthCam.transform.position = camera.transform.position;
    DepthCam.transform.rotation = camera.transform.rotation;
    DepthCam.camera.SetReplacementShader(DepthShader, "RenderType");
    DepthCam.camera.aspect = asp;
    DepthCam.camera.pixelRect = Rect(0,0,textureSize,textureSize);
    DepthCam.camera.Render();
    DNBuffer.ReadPixels(Rect(0,0,textureSize,textureSize), 0, 0);
    DNBuffer.Apply();
    }
    if (capture) {
    dom.transform.position = camera.transform.position;
    dom.transform.rotation = camera.transform.rotation;
    dom.camera.aspect = asp;
    dom.camera.pixelRect = Rect(0,0,textureSize,textureSize);
    dom.camera.Render();
    RT.ReadPixels(Rect(camera.pixelRect.x,camera.pixelRect.y,textureSize,textureSize), 0, 0);
    RT.Apply();
    }

    } else {
    if( DNRequire ) {
    //for old rendering method
    if (!DepthCam){
    DepthCam = new GameObject("DepthCamera",Camera);
    DepthCam.camera.CopyFrom(myCamera);
    DepthCam.camera.depth = myCamera.depth-2;
    }

    DepthCam.transform.position = myTransform.position;
    DepthCam.transform.rotation = myTransform.rotation;
    DepthCam.camera.SetReplacementShader(DepthShader, "RenderType");
    DepthCam.camera.aspect = myCamera.aspect;
    DepthCam.camera.pixelRect = myCamera.pixelRect;
    DepthCam.camera.Render();
    DNBuffer.Resize(myCamera.pixelWidth, myCamera.pixelHeight, TextureFormat.RGB24, false);
    DNBuffer.ReadPixels(myCamera.pixelRect, 0, 0);
    DNBuffer.Apply();

    }

    }
    }

    function OnPostRender() {
    if( useOldVersion ) {
    RT.Resize(myCamera.pixelWidth, myCamera.pixelHeight, TextureFormat.RGB24, false);
    RT.ReadPixels(myCamera.pixelRect, 0, 0);

    RT.Apply();
    }
    }

    function Start () {
    int viewportMinSize = System.Convert.ToInt32(Mathf.Min (myCamera.pixelHeight,myCamera.pixelWidth));
    if(textureSize>viewportMinSize)
    {
    //Debug.Log("Texture size "+ viewportMinSize);
    // Get nearest lower log 2
    // http://graphics.stanford.edu/~seander/bithacks.html#IntegerLogObvious
    int r = 0;
    while ((viewportMinSize >>=1) != 0)
    {
    r++;
    }
    viewportMinSize= 1<<r;
    //Debug.Log("Texture size "+ viewportMinSize);
    textureSize = viewportMinSize;
    }
    else{
    Debug.Log("Viewport min size"+ viewportMinSize + " Texture size "+textureSize);

    }
    myTransform = transform;
    myCamera = GetComponent(Camera);



    if( !useOldVersion ){

    capture = true;
    RT = new Texture2D(textureSize, textureSize, TextureFormat.RGB24, false);
    RT.wrapMode = TextureWrapMode.Clamp;
    DNBuffer = new Texture2D(textureSize, textureSize, TextureFormat.ARGB32, false);
    DNBuffer.wrapMode = TextureWrapMode.Clamp;
    while(true) {
    capture = true;
    yield WaitForSeconds(latency);
    }

    } else {
    //old approuch
    //possible for splitscreen too
    RT = new Texture2D(myCamera.pixelWidth, myCamera.pixelHeight, TextureFormat.RGB24, false);
    //RT.wrapMode = TextureWrapMode.Clamp;
    DNBuffer = new Texture2D(myCamera.pixelWidth, myCamera.pixelHeight, TextureFormat.ARGB32, false);

    }
    }
     
  3. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,869
    Code (csharp):
    1.  
    2. #pragma strict
    3. /*
    4. ----------Indie Effects Base----------
    5. This is the base for all other image effects to occur. Includes depth texture generation
    6. */
    7.  
    8. @script RequireComponent(Camera);
    9. @script AddComponentMenu("Indie Effects/IndieEffectsBase")
    10.  
    11. //base effects
    12. @script HideInInspector var RT : Texture2D;
    13. var textureSize : int;
    14. var capture : boolean;
    15. var DepthShader : Shader;
    16. var DNBuffer : Texture2D;
    17. var DNRequire : boolean;
    18. var DepthCam : GameObject;
    19. @Range(0,0.04)
    20. var latency : float;
    21.  
    22. var useOldVersion : boolean; //enable old rendering method
    23. var myCamera : Camera; //cache camera and transform component for
    24. private var myTransform : Transform; //performance
    25.  
    26. static function FullScreenQuad(renderMat : Material) {
    27. GL.PushMatrix();
    28. for (var i = 0; i < renderMat.passCount; ++i) {
    29. renderMat.SetPass(i);
    30. GL.LoadOrtho();
    31. GL.Begin(GL.QUADS); // Quad
    32. GL.Color(Color(1,1,1,1));
    33. GL.MultiTexCoord(0,Vector3(0,0,0));
    34. GL.Vertex3(0,0,0);
    35. GL.MultiTexCoord(0,Vector3(0,1,0));
    36. GL.Vertex3(0,1,0);
    37. GL.MultiTexCoord(0,Vector3(1,1,0));
    38. GL.Vertex3(1,1,0);
    39. GL.MultiTexCoord(0,Vector3(1,0,0));
    40. GL.Vertex3(1,0,0);
    41. GL.End();
    42. }
    43. GL.PopMatrix();
    44. }
    45.  
    46. static function FullScreenQuadPass(renderMat : Material, pass : int){
    47. GL.PushMatrix();
    48. for (var i = 0; i < pass; ++i) {
    49. renderMat.SetPass(i);
    50. GL.LoadOrtho();
    51. GL.Begin(GL.QUADS); // Quad
    52. GL.Color(Color(1,1,1,1));
    53. GL.MultiTexCoord(0,Vector3(0,0,0));
    54. GL.Vertex3(0,0,0);
    55. GL.MultiTexCoord(0,Vector3(0,1,0));
    56. GL.Vertex3(0,1,0);
    57. GL.MultiTexCoord(0,Vector3(1,1,0));
    58. GL.Vertex3(1,1,0);
    59. GL.MultiTexCoord(0,Vector3(1,0,0));
    60. GL.Vertex3(1,0,0);
    61. GL.End();
    62. }
    63. GL.PopMatrix();
    64. }
    65.  
    66. static function screenGrab ( rt : Texture2D, camRect : Rect ) {
    67. var asp = Camera.current.pixelWidth/Camera.current.pixelHeight;
    68. var dom = new GameObject("capture", Camera);
    69. dom.camera.aspect = asp;
    70. dom.camera.pixelRect = camRect;
    71. dom.transform.position = Camera.current.transform.position;
    72. dom.transform.rotation = Camera.current.transform.rotation;
    73. dom.camera.Render();
    74. rt.ReadPixels(camRect, 0, 0);
    75. rt.Apply();
    76. Destroy(dom);
    77. return rt;
    78. }
    79.  
    80. var prevRect : Rect;
    81. var asp : float;
    82. var dom : GameObject;
    83. function OnPreRender () {
    84. if( !useOldVersion ){
    85.  
    86. asp = camera.pixelWidth/camera.pixelHeight;
    87. if (!DepthCam){
    88. DepthCam = new GameObject("DepthCamera",Camera);
    89. DepthCam.camera.CopyFrom(camera);
    90. DepthCam.camera.depth = camera.depth-2;
    91. }
    92. if (!dom){
    93. dom = new GameObject("capture", Camera);
    94. dom.camera.CopyFrom(camera);
    95. dom.camera.depth = camera.depth-3;
    96. }
    97. if (capture && DNRequire) {
    98. DepthCam.transform.position = camera.transform.position;
    99. DepthCam.transform.rotation = camera.transform.rotation;
    100. DepthCam.camera.SetReplacementShader(DepthShader, "RenderType");
    101. DepthCam.camera.aspect = asp;
    102. DepthCam.camera.pixelRect = Rect(0,0,textureSize,textureSize);
    103. DepthCam.camera.Render();
    104. DNBuffer.ReadPixels(Rect(0,0,textureSize,textureSize), 0, 0);
    105. DNBuffer.Apply();
    106. }
    107. if (capture) {
    108. dom.transform.position = camera.transform.position;
    109. dom.transform.rotation = camera.transform.rotation;
    110. dom.camera.aspect = asp;
    111. dom.camera.pixelRect = Rect(0,0,textureSize,textureSize);
    112. dom.camera.Render();
    113. RT.ReadPixels(Rect(camera.pixelRect.x,camera.pixelRect.y,textureSize,textureSize), 0, 0);
    114. RT.Apply();
    115. }
    116.  
    117. } else {
    118. if( DNRequire ) {
    119. //for old rendering method
    120. if (!DepthCam){
    121. DepthCam = new GameObject("DepthCamera",Camera);
    122. DepthCam.camera.CopyFrom(myCamera);
    123. DepthCam.camera.depth = myCamera.depth-2;
    124. }
    125.  
    126. DepthCam.transform.position = myTransform.position;
    127. DepthCam.transform.rotation = myTransform.rotation;
    128. DepthCam.camera.SetReplacementShader(DepthShader, "RenderType");
    129. DepthCam.camera.aspect = myCamera.aspect;
    130. DepthCam.camera.pixelRect = myCamera.pixelRect;
    131. DepthCam.camera.Render();
    132. DNBuffer.Resize(myCamera.pixelWidth, myCamera.pixelHeight, TextureFormat.RGB24, false);
    133. DNBuffer.ReadPixels(myCamera.pixelRect, 0, 0);
    134. DNBuffer.Apply();
    135.  
    136. }
    137.  
    138. }
    139. }
    140.  
    141. function OnPostRender() {
    142. if( useOldVersion ) {
    143. RT.Resize(myCamera.pixelWidth, myCamera.pixelHeight, TextureFormat.RGB24, false);
    144. RT.ReadPixels(myCamera.pixelRect, 0, 0);
    145.  
    146. RT.Apply();
    147. }
    148. }
    149.  
    150. function Start () {
    151. int viewportMinSize = System.Convert.ToInt32(Mathf.Min (myCamera.pixelHeight,myCamera.pixelWidth));
    152. if(textureSize>viewportMinSize)
    153. {
    154. //Debug.Log("Texture size "+ viewportMinSize);
    155. // Get nearest lower log 2
    156. // http://graphics.stanford.edu/~seander/bithacks.html#IntegerLogObvious
    157. int r = 0;
    158. while ((viewportMinSize >=1) != 0)
    159. {
    160. r++;
    161. }
    162. viewportMinSize= 1<<r;
    163. //Debug.Log("Texture size "+ viewportMinSize);
    164. textureSize = viewportMinSize;
    165. }
    166. else{
    167. Debug.Log("Viewport min size"+ viewportMinSize + " Texture size "+textureSize);
    168.  
    169. }
    170. myTransform = transform;
    171. myCamera = GetComponent(Camera);
    172.  
    173.  
    174.  
    175. if( !useOldVersion ){
    176.  
    177. capture = true;
    178. RT = new Texture2D(textureSize, textureSize, TextureFormat.RGB24, false);
    179. RT.wrapMode = TextureWrapMode.Clamp;
    180. DNBuffer = new Texture2D(textureSize, textureSize, TextureFormat.ARGB32, false);
    181. DNBuffer.wrapMode = TextureWrapMode.Clamp;
    182. while(true) {
    183. capture = true;
    184. yield WaitForSeconds(latency);
    185. }
    186.  
    187. } else {
    188. //old approuch
    189. //possible for splitscreen too
    190. RT = new Texture2D(myCamera.pixelWidth, myCamera.pixelHeight, TextureFormat.RGB24, false);
    191. //RT.wrapMode = TextureWrapMode.Clamp;
    192. DNBuffer = new Texture2D(myCamera.pixelWidth, myCamera.pixelHeight, TextureFormat.ARGB32, false);
    193.  
    194. }
    195. }
    Try this. it appears someone putting in a new feature might have accidentally typed two ">" signs instead of one in the associated section... Anyway! :D Let me know if it works for you! :)
     
  4. Eric2241

    Eric2241

    Joined:
    Dec 2, 2012
    Posts:
    642
    What's the new version?
     
  5. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,869
    The one you quoted, buddy! :)

    If you're talking of 3.0 though... it's finally coming! but it isn't ready yet... :D
     
    Eric2241 likes this.
  6. Eric2241

    Eric2241

    Joined:
    Dec 2, 2012
    Posts:
    642
    Yay! Message me when it does so I can update the repo!
     
  7. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,869
    Another note about 3.0: You might have to wipe the repo first... :D

    On the other hand however, if there are any extra shaders in there, post them here in a .zip, and I will include them! :)
     
    Eric2241 likes this.
  8. Eric2241

    Eric2241

    Joined:
    Dec 2, 2012
    Posts:
    642
    Ok cool!
     
  9. Eric2241

    Eric2241

    Joined:
    Dec 2, 2012
    Posts:
    642
    So they aren't really organized but here they are!
     

    Attached Files:

  10. ariusdb222

    ariusdb222

    Joined:
    Jan 25, 2015
    Posts:
    88
    hello
    This is awesome pro effects in indie... but screen goes black or white when trying to use any script added to main camera. any suggestions??:(
     
  11. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,869
    Make sure texture size is set to your screen height, as that being un-set (default ended up 0 for some reason...) causes this issue.

    The next release (and something in the repo atm, I think... :D) is designed to use a different approach for downscaling the render-target, and won't have this issue, just to let you know! :)
     
  12. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,869
    @Eric2241: Thank you! I will ask though: why is there a grass shader in there? :D
     
    Eric2241 likes this.
  13. ariusdb222

    ariusdb222

    Joined:
    Jan 25, 2015
    Posts:
    88
    Ok, seems like that was the issue. Thanks a lot mate!!:D
     
  14. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,869
    You're welcome! :)
     
  15. Eric2241

    Eric2241

    Joined:
    Dec 2, 2012
    Posts:
    642
    I have no clue! It will be nice and clean when 3.0 comes out!
     
  16. Kikispoke

    Kikispoke

    Joined:
    Aug 12, 2013
    Posts:
    2
    hi, i tried using the effects but i keep getting the error trying to read pixels out of bounds (this is happening with all the fx that i tried so far)
     
  17. DRRosen3

    DRRosen3

    Joined:
    Jan 30, 2014
    Posts:
    643
    Trying to use SSAO and getting 3 errors...

    1.
    Material doesn't have a texture property '_DepthNormalTex'
    UnityEngine.Material:.ctor(Shader)
    SSAO_C5100:Start() (at Assets/IndieEffects/Classes/SSAO_C5100.js:28)

    2.
    Material doesn't have a texture property '_noiseTex'
    UnityEngine.Material:.ctor(Shader)
    SSAO_C5100:Start() (at Assets/IndieEffects/Classes/SSAO_C5100.js:28)

    3.
    Material doesn't have a float or range property '_sampleRad'
    UnityEngine.Material:.ctor(Shader)
    SSAO_C5100:Start() (at Assets/IndieEffects/Classes/SSAO_C5100.js:28)

    AND the entire screen is pink.
     
  18. icecreamtruck14

    icecreamtruck14

    Joined:
    Feb 14, 2015
    Posts:
    2
     
  19. icecreamtruck14

    icecreamtruck14

    Joined:
    Feb 14, 2015
    Posts:
    2
    why i keep getting "trying to read pixels out of bounds"?
     
  20. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,869
    @icecreamtruck14, KiKiSpoke: you probably have the texture size at 0. put it at something like your screen height, or 256

    @DRRosen3: If you're using D3D11 mode, switch to DX9, as of now, the shader has no support for DX11 renderer... :D
     
  21. Kikispoke

    Kikispoke

    Joined:
    Aug 12, 2013
    Posts:
    2
     
  22. Souk21

    Souk21

    Joined:
    Dec 28, 2014
    Posts:
    14
    Code (JavaScript):
    1.  
    2. #pragma strict
    3. /*
    4. ----------Indie Effects Base----------
    5. This is the base for all other image effects to occur. Includes depth texture generation
    6. */
    7. @script RequireComponent(Camera);
    8. @script AddComponentMenu("Indie Effects/IndieEffectsBase")
    9. //base effects
    10. @script HideInInspector var RT : Texture2D;
    11. var textureSize : int;
    12. var capture : boolean;
    13. var DepthShader : Shader;
    14. var DNBuffer : Texture2D;
    15. var DNRequire : boolean;
    16. var DepthCam : GameObject;
    17. @Range(0,0.04)
    18. var latency : float;
    19. var useOldVersion : boolean; //enable old rendering method
    20. var myCamera : Camera; //cache camera and transform component for
    21. private var myTransform : Transform; //performance
    22. static function FullScreenQuad(renderMat : Material) {
    23. GL.PushMatrix();
    24. for (var i = 0; i < renderMat.passCount; ++i) {
    25. renderMat.SetPass(i);
    26. GL.LoadOrtho();
    27. GL.Begin(GL.QUADS); // Quad
    28. GL.Color(Color(1,1,1,1));
    29. GL.MultiTexCoord(0,Vector3(0,0,0));
    30. GL.Vertex3(0,0,0);
    31. GL.MultiTexCoord(0,Vector3(0,1,0));
    32. GL.Vertex3(0,1,0);
    33. GL.MultiTexCoord(0,Vector3(1,1,0));
    34. GL.Vertex3(1,1,0);
    35. GL.MultiTexCoord(0,Vector3(1,0,0));
    36. GL.Vertex3(1,0,0);
    37. GL.End();
    38. }
    39. GL.PopMatrix();
    40. }
    41. static function FullScreenQuadPass(renderMat : Material, pass : int){
    42. GL.PushMatrix();
    43. for (var i = 0; i < pass; ++i) {
    44. renderMat.SetPass(i);
    45. GL.LoadOrtho();
    46. GL.Begin(GL.QUADS); // Quad
    47. GL.Color(Color(1,1,1,1));
    48. GL.MultiTexCoord(0,Vector3(0,0,0));
    49. GL.Vertex3(0,0,0);
    50. GL.MultiTexCoord(0,Vector3(0,1,0));
    51. GL.Vertex3(0,1,0);
    52. GL.MultiTexCoord(0,Vector3(1,1,0));
    53. GL.Vertex3(1,1,0);
    54. GL.MultiTexCoord(0,Vector3(1,0,0));
    55. GL.Vertex3(1,0,0);
    56. GL.End();
    57. }
    58. GL.PopMatrix();
    59. }
    60. static function screenGrab ( rt : Texture2D, camRect : Rect ) {
    61. var asp = Camera.current.pixelWidth/Camera.current.pixelHeight;
    62. var dom = new GameObject("capture", Camera);
    63. dom.camera.aspect = asp;
    64. dom.camera.pixelRect = camRect;
    65. dom.transform.position = Camera.current.transform.position;
    66. dom.transform.rotation = Camera.current.transform.rotation;
    67. dom.camera.Render();
    68. rt.ReadPixels(camRect, 0, 0);
    69. rt.Apply();
    70. Destroy(dom);
    71. return rt;
    72. }
    73. var prevRect : Rect;
    74. var asp : float;
    75. var dom : GameObject;
    76. function OnPreRender () {
    77. if( !useOldVersion ){
    78. asp = camera.pixelWidth/camera.pixelHeight;
    79. if (!DepthCam){
    80. DepthCam = new GameObject("DepthCamera",Camera);
    81. DepthCam.camera.CopyFrom(camera);
    82. DepthCam.camera.depth = camera.depth-2;
    83. }
    84. if (!dom){
    85. dom = new GameObject("capture", Camera);
    86. dom.camera.CopyFrom(camera);
    87. dom.camera.depth = camera.depth-3;
    88. }
    89. if (capture && DNRequire) {
    90. DepthCam.transform.position = camera.transform.position;
    91. DepthCam.transform.rotation = camera.transform.rotation;
    92. DepthCam.camera.SetReplacementShader(DepthShader, "RenderType");
    93. DepthCam.camera.aspect = asp;
    94. DepthCam.camera.pixelRect = Rect(0,0,textureSize,textureSize);
    95. DepthCam.camera.Render();
    96. DNBuffer.ReadPixels(Rect(0,0,textureSize,textureSize), 0, 0);
    97. DNBuffer.Apply();
    98. }
    99. if (capture) {
    100. dom.transform.position = camera.transform.position;
    101. dom.transform.rotation = camera.transform.rotation;
    102. dom.camera.aspect = asp;
    103. dom.camera.pixelRect = Rect(0,0,textureSize,textureSize);
    104. dom.camera.Render();
    105. RT.ReadPixels(Rect(camera.pixelRect.x,camera.pixelRect.y,textureSize,textureSize), 0, 0);
    106. RT.Apply();
    107. }
    108. } else {
    109. if( DNRequire ) {
    110. //for old rendering method
    111. if (!DepthCam){
    112. DepthCam = new GameObject("DepthCamera",Camera);
    113. DepthCam.camera.CopyFrom(myCamera);
    114. DepthCam.camera.depth = myCamera.depth-2;
    115. }
    116. DepthCam.transform.position = myTransform.position;
    117. DepthCam.transform.rotation = myTransform.rotation;
    118. DepthCam.camera.SetReplacementShader(DepthShader, "RenderType");
    119. DepthCam.camera.aspect = myCamera.aspect;
    120. DepthCam.camera.pixelRect = myCamera.pixelRect;
    121. DepthCam.camera.Render();
    122. DNBuffer.Resize(myCamera.pixelWidth, myCamera.pixelHeight, TextureFormat.RGB24, false);
    123. DNBuffer.ReadPixels(myCamera.pixelRect, 0, 0);
    124. DNBuffer.Apply();
    125. }
    126. }
    127. }
    128. function OnPostRender() {
    129. if( useOldVersion ) {
    130. RT.Resize(myCamera.pixelWidth, myCamera.pixelHeight, TextureFormat.RGB24, false);
    131. RT.ReadPixels(myCamera.pixelRect, 0, 0);
    132. RT.Apply();
    133. }
    134. }
    135. function Start () {
    136. var viewportMinSize = System.Convert.ToInt32(Mathf.Min (myCamera.pixelHeight,myCamera.pixelWidth));
    137. if(textureSize>viewportMinSize)
    138. {
    139. //Debug.Log("Texture size "+ viewportMinSize);
    140. // Get nearest lower log 2
    141. // http://graphics.stanford.edu/~seander/bithacks.html#IntegerLogObvious
    142. var r = 0;
    143. while ((viewportMinSize >=1) != 0)
    144. {
    145. r++;
    146. }
    147. viewportMinSize= 1<<r;
    148. //Debug.Log("Texture size "+ viewportMinSize);
    149. textureSize = viewportMinSize;
    150. }
    151. else{
    152. Debug.Log("Viewport min size"+ viewportMinSize + " Texture size "+textureSize);
    153. }
    154. myTransform = transform;
    155. myCamera = GetComponent(Camera);
    156. if( !useOldVersion ){
    157. capture = true;
    158. RT = new Texture2D(textureSize, textureSize, TextureFormat.RGB24, false);
    159. RT.wrapMode = TextureWrapMode.Clamp;
    160. DNBuffer = new Texture2D(textureSize, textureSize, TextureFormat.ARGB32, false);
    161. DNBuffer.wrapMode = TextureWrapMode.Clamp;
    162. while(true) {
    163. capture = true;
    164. yield WaitForSeconds(latency);
    165. }
    166. } else {
    167. //old approuch
    168. //possible for splitscreen too
    169. RT = new Texture2D(myCamera.pixelWidth, myCamera.pixelHeight, TextureFormat.RGB24, false);
    170. //RT.wrapMode = TextureWrapMode.Clamp;
    171. DNBuffer = new Texture2D(myCamera.pixelWidth, myCamera.pixelHeight, TextureFormat.ARGB32, false);
    172. }
    173. }
    New version of IndieEffectsBase.js (neither the one on github and the one posted few comments earlier work) ;)

    I heard about v3? do you know when it'll be available?
     
  23. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,869
    Not sure... I definitely have it underway, but due to school being back, I haven't had much time to work on it.

    As a result, can't give an ETA yet... :D
     
  24. Souk21

    Souk21

    Joined:
    Dec 28, 2014
    Posts:
    14
    What would be nice would be the ability to apply the effect on a certain region of the screen only.
    I tried to use it with multiple camera, but the effect always covers the all screen.
     
  25. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,869
    @Souk21: I am guessing this is for a 2D underwater effect, yes? If not, please state what you want this for.

    If you mean to use it for split screen, that's doable, but it requires a bit of tweaking with the current version (next release will have it built in!)

    EDIT: Actually, if you're using "useOldVersion," that might interfere with what you're trying to achieve.
     
  26. OMGWare

    OMGWare

    Joined:
    Mar 4, 2014
    Posts:
    24
    Thank you for this amazing contribution!
    I just grabbed the latest source without compiler errors, but unfortunately have some issues (I'm using DX9, textureSize is equal to Screen.height all the time, have only one Main Camera, and both the JS scripts and C# scripts have the same bahaviors).
    For starters any effect looks like it only makes the screen really blurry if I have the useOldVersion unchecked, but when I check it some effects seem to work as intended (I guess...).
    But the main problem for me is SSAO, it just doesn't produce any effect at all, do you guys have any guess what is it? :)
     
  27. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,869
    Um... Have no idea. is there an error log?

    Also, if you have grabbed the gitHub version, you need to assign the right shader to the right script. The SSAO uses SSAO_C5100.shader as the fx shader.

    Also, make sure "DNRequire" is ticked for depth and normals based fx, in this case, SSAO.
     
  28. OMGWare

    OMGWare

    Joined:
    Mar 4, 2014
    Posts:
    24
    Sounds like the main problem was the DNRequire not checked, thanks!
    The issue about the "Use Old Version" remains, if it's unchecked every effect causes a blurry screen with a strong aliasing effect.
    Anyway the only SSAO shaders seem to be in the DNBased folder: 0tacunSSAO.shader and Bunell Disk SSAO.shader.
    The former gives pink screen, and the latter seems to work but only adds fairly hard outlines to the geometry, is it supposed to work this way?

    Here are some example images:

    No SSAO: http://i.imgur.com/Bvg2pJU.png
    SSAO default: http://i.imgur.com/Esngk8S.png
    SSAO "Use Old Version": http://i.imgur.com/eusDutm.png
     
  29. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,869
    The former's actually broken... :D It was more a test shader back when SSAO wasn't even in this pack.

    And just play around with the settings in the shader script, as it is possible to sample the SSAO at a larger radius. (Might require more samples to look good though, as this shader doesn't use a blur pass! :) ) Also, I recommend that you adjust the intensity of the SSAO to match your scene, as the default settings do tend to look like a sharp outline... :D
     
  30. OMGWare

    OMGWare

    Joined:
    Mar 4, 2014
    Posts:
    24
    Thanks for your time, it all clears up now :)
     
  31. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,869
    You're welcome! :)
     
  32. TinkerTyler

    TinkerTyler

    Joined:
    Apr 29, 2014
    Posts:
    1
    I got 76 folders, but i'm not sure what's going on.
     
  33. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    5,857
    renderrrrrtextures! :)
     
    Baldinoboy, shkar-noori and hopeful like this.
  34. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,339
    I know. It is too good. Guess Fuzzy is going to have to make image effects the easy way now;).
     
  35. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,869
    Supposing everyone heard of Unity 5... I may have to revamp the texture system!

    I will still support older releases, but for those with Unity 5 free, you get a rendertexture boost!

    @mgear, baldinoboy: Yes, that is correct! Finally, a way of doing custom shadow maps... :D

    Also, did you see what unity did to the shadows?! THEY LOOK INSANE!

    @WanderingHermit: 76 folders?! o_O
    Ok... :D What you do is pull out the IndieEffects folder from that mess, then put that folder into your unity project. (Yea, have to wipe and re-build the repo once 3.0's out, so it's tidier...) Oh, this presumes you got the release from the GitHub repo
     
    Baldinoboy likes this.
  36. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    5,857
    @FuzzyQuills whats your next community project ? :)

    For example, free community collection of unity5 pbr materials would be pretty amazing to play with, if there isnt any.
    Also now with rendertextures could start looking for some nice water shaders to port into unity, other effects too..
     
  37. TheGraficalOne

    TheGraficalOne

    Joined:
    Feb 14, 2014
    Posts:
    50
    @FuzzyQuills Thank you guys So Much the time you all invested to give us Unity free users free Post Processing effects on 4x and 3x!:)

    I 'm excited about Unity 5, but I'm perfectly content, for now, using Unity 4.6 with your Effects package and Lux PBR Shaders. Atleast with my current projects anyway.

    So what are you going to work on now?
     
  38. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,869
    Not sure yet... I still plan on finishing IndieEffects 3.0, and at least one game (Whether the game's Unity 5 or 4.6, I don't care! :D) before I start another community project of any kind. But still, nice idea! :) Might as well attempt to port CryEngine water at some point... ;)

    @TheGraficalOne: You're welcome! I am still planning on finishing IndieEffects 3.0, although 3.0 is probably the last release I will make, due to Unity 5's arrival...

    If you read one of my previous posts though, you might know this already, but I do plan on extending the texture system so that a Unity 5 user benefits from standard renderTextures! That way, upgrading to Unity 5 with my pack in tow shouldn't be much of a problem, and the performance boost is well worth it. ;)

    As for what I'm going to work on... most likely what I said above, along with tidying the pack's files (they're a bit of a mess atm... :D) but I also plan to either port an existing project to Unity 5 or make a small game to showcase it's features! :)

    EDIT: Also, a question for you; with Lux chewing up a bit of GPU resources, along with my pack, what performance numbers do you get? :)
     
    Baldinoboy likes this.
  39. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,339
    You better.;) Need some one to do testing you know where I am.
     
    Eric2241 likes this.
  40. TheGraficalOne

    TheGraficalOne

    Joined:
    Feb 14, 2014
    Posts:
    50
    Well I have two projects ATM. One is 2D and mostly sprites with a few 3d elements thrown in. The other is a fully 3d FPS. I don't recall what my stats were on the 2d game, it's been a while since I worked on that one.

    The FPS game on the other hand is going threw an exhaustively, extensive asset overhaul so I can't say currently. But I do remember what the stats were.

    It was a simple scene consisting of a terrain littered with trees, a simple enemy a stand in gun and most of the materials were Lux. With such effects as bloom, fisheye and any other non-depth based effect my frame rate ranges from 80 to 70 fps. With a depth based effect however it's 55 fps or less normally.

    I don't know if it matters, but I rarely ever test my games in full screen, so I don't know if the frame rate would've dropped dramatically if I did:)
     
  41. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,869
    @TheGraficalOne: Well, not saying this would be the case on your PC, but increasing res probably would drop the framerate.

    And the reason the depth based fx have a lower FPS... two textures! ;)

    @Baldinoboy: Maybe! I just tried Water4 on my PC... AWESOMENESS!
     
    Baldinoboy and Eric2241 like this.
  42. AlphaGarg8447

    AlphaGarg8447

    Joined:
    Jul 28, 2013
    Posts:
    18
    A setup tutorial would be good. BTW which version are these effects for? Unity 5 or 4.x? It all used to work fine for me before, but now nothing seems to work.
     
  43. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,339
    These effects are for the free version of Unity 4. Unity 5 gave free users the all the pro abilities so you do not need this anymore. Unless you are using Unity 4 that is.
     
    Eric2241 likes this.
  44. khos85

    khos85

    Joined:
    Jul 21, 2013
    Posts:
    541
    Hi, I came across this interesting thread, imported and added the scripts to my camera but see error when playing:

    Trying to read pixels out of bounds
    UnityEngine.Texture2D:ReadPixels(Rect, Int32, Int32)
    IndieEffects:OnPreRender() (at Assets/IndieEffects/Classes/IndieEffects.js:97)

    I looked at the manual and thread history but could only one other person getting this, could you advise what I am doing wrong?
    upload_2015-6-3_22-44-45.png

    Many thanks
     
  45. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,339
    What I did was set the texture size value to the height of my play screen height.

    This is for Unity 4.x free though. Most likely your are using Unity 5 and in that case it would be better to use the normal image effects. This is an amazing tool but it was for free users before Unity gave us everything in 5.
     
    Eric2241 likes this.
  46. khos85

    khos85

    Joined:
    Jul 21, 2013
    Posts:
    541
    Thanks I got it working with the sample scene, performance takes a hit with these scripts in my big scene, I'm still on V4.6 as I have lots upgrade issues :) I guess I'll have to try the po effects to see if the performance is better. Nice to see these though!
     
  47. Frostbite23

    Frostbite23

    Joined:
    Mar 8, 2013
    Posts:
    430
    @khos85 yeah, you missed the chance though of experiencing this asset. now with the release of unity 5 this is no longer needed.


    This is kind of sad, after with the release of unity 5 including many pro features into this "Personal Edition". This thread has helped hundreds of people using unity indie, its just sad to now see it die quietly because now unity 5 supports everything in the free version of unity now. Of course we all know that change was gonna happen, its supposed to change.

    Think of it like the flow of a river or your blood. If you stop the flow of a river or your blood, it stagnates, clogs, and eventually you die.

    Or in a game, if you don't change and just stay, your gonna get your face blown off the next time you wait for 2 minutes on a COD match camping in a corner.
     
    Eric2241 likes this.
  48. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,869
    Well, although indieEffects 3.0 may never come to light (I hope it does someday though, I am very busy and haven't had time to do so) I do still support this, so anyway... This is a common issue, and the fix is to set that number to 256, 512, etc. rather than 1.

    EDIT: Looks like Baldinoboy beat me to it! :D
     
    Eric2241 likes this.
  49. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,869
    Well.... I did have plans on porting this over to Unity 5 so that people can use the fx in this pack in Unity 5, with added performance benefits. :)
     
    chelnok, Eric2241 and Baldinoboy like this.
  50. Frostbite23

    Frostbite23

    Joined:
    Mar 8, 2013
    Posts:
    430
    By the way, fuzzy, can you start a conversation with me? because for some reason unity won't let me.
     
unityunity