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

    Frostbite23

    Joined:
    Mar 8, 2013
    Posts:
    458
    did you assign the shaders to the image effects? like BCS shader to the BCS image effect slot and plus i don't think fuzzy quills has did this but it BCS, Filmic Tonemap, and Refraction use the new indie effects, and i don't know if fuzzy released it yet but if he hasn't stick with the V1
     
  2. Frostbite23

    Frostbite23

    Joined:
    Mar 8, 2013
    Posts:
    458
    I had never heard of "desactivate Anti Aliasing", do you mean Deactivate?
     
  3. Frostbite23

    Frostbite23

    Joined:
    Mar 8, 2013
    Posts:
    458
    and yes i think the resizes on my image effects ardent nessasry but i know that for each pass the script has to read the screen pixels but that causes a performance decrease.
     
  4. Cyrien5100

    Cyrien5100

    Joined:
    Oct 17, 2012
    Posts:
    145
    Yes deactivate^^ sorry for the mistake.
     
  5. Frostbite23

    Frostbite23

    Joined:
    Mar 8, 2013
    Posts:
    458
    hmm not sure about that, right now Im doing cubic lens distortion but in the meantime could you maybe send me some websites or papers about this? or could this be done just inside of unity?
     
  6. Cyrien5100

    Cyrien5100

    Joined:
    Oct 17, 2012
    Posts:
    145
    It's just an option in the graphics settings :
    AA.PNG
     
  7. Frostbite23

    Frostbite23

    Joined:
    Mar 8, 2013
    Posts:
    458
    ah yes, yeah i always disable AA.
     
  8. Frostbite23

    Frostbite23

    Joined:
    Mar 8, 2013
    Posts:
    458
  9. LegendWill

    LegendWill

    Joined:
    Jun 20, 2014
    Posts:
    9
    In the Pro version of Unity image effects motionblur, there is a string called blurAmount, what would that be in this package?
     
  10. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    @LegendWill: there is a variable called "_Accumulation" or something like that. Just look in the shader, it's not hard to find. (unless you know next to nothing about shaders... :D)

    @Frostbite23: That is CRAAAZY! :D Nice lens distortion!

    and BTW, the new IndieEffects should be called "the one in testing!"
     
  11. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    @Gogin: I can quickly whip up a scene for you if you like, as today, I have the whole day to myself! ;)
     
  12. 0tacun

    0tacun

    Joined:
    Jun 23, 2013
    Posts:
    245
    Nice going in this thread!

    Unfortunatly I deleted my game and started again programming it on a super nintendo:



    Just kidding :D I quickly converted a pixel post fx from here to contribute something: http://developer.download.nvidia.com/shaderlibrary/webpages/shader_library.html


    Code (JavaScript):
    1. #pragma strict
    2.  
    3. //@script RequireComponent (IndieEffects)
    4. @script AddComponentMenu ("Indie Effects/Tiles Effect")
    5.  
    6. @HideInInspector
    7. var IndieEffects : IndieEffects;
    8.  
    9.  
    10. var edgeColor : Color;
    11. var numTiles : float = 8.0;
    12. var threshhold : float = 1.0;
    13.  
    14. @HideInInspector
    15. var blurMat : Material;
    16. var tilesShader : Shader;
    17.  
    18. function Start () {
    19.  
    20.     IndieEffects = transform.GetComponent("IndieEffects");
    21.     blurMat = new Material(tilesShader);
    22. }
    23.  
    24. function Update () {
    25. }
    26.  
    27. function OnPostRender () {
    28.     blurMat.SetTexture("_MainTex", IndieEffects.renderTexture);
    29.     blurMat.SetColor("_EdgeColor", edgeColor);
    30.     blurMat.SetFloat("_NumTiles", numTiles);
    31.     blurMat.SetFloat("_Threshhold", threshhold);
    32.     FullScreenQuad(blurMat);
    33. }

    Code (JavaScript):
    1.  
    2. /*********************************************************************NVMH3****
    3. *******************************************************************************
    4. $Revision: #4 $
    5.  
    6. Copyright NVIDIA Corporation 2008
    7. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED
    8. *AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS
    9. OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY
    10. AND FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS
    11. BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES
    12. WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS,
    13. BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY
    14. LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
    15. NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
    16.  
    17. % Degrade image into a set of mock "3D-looking" tiles
    18.  
    19.  
    20.  
    21. To learn more about shading, shaders, and to bounce ideas off other shader
    22.   authors and users, visit the NVIDIA Shader Library Forums at:
    23.  
    24.   http://developer.nvidia.com/forums/
    25.  
    26. Shader "Custom/Tiles Effect" {
    27. Properties {
    28.     _MainTex ("Base (RGB)", 2D) = "white" {}
    29.     _EdgeColor ("EdgeColor", Color) = (0.5,0.5,0.5,1)
    30.     _NumTiles ("Number of Tiles", float) = 8.0
    31.     _Threshhold ("Threshhold", float) = 1.0
    32. }
    33.  
    34. SubShader {
    35.     Pass {
    36.         ZTest Always Cull Off ZWrite Off
    37.         Fog { Mode off }
    38.         //Blend DstColor SrcColor
    39.  
    40. CGPROGRAM
    41. #pragma vertex vert
    42. #pragma fragment frag
    43. #pragma fragmentoption ARB_precision_hint_fastest
    44. #include "UnityCG.cginc"
    45.  
    46. sampler2D _MainTex;
    47. half4  _EdgeColor;
    48. float4 _MainTex_TexelSize;
    49. float _NumTiles;
    50. float _Threshhold;
    51.  
    52. struct v2f {
    53.     float4 pos : POSITION;
    54.     float2 UV : TEXCOORD0;
    55. };
    56.  
    57. v2f vert( appdata_img v )
    58. {
    59.     v2f o;
    60.     o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
    61.     float2 uv = MultiplyUV( UNITY_MATRIX_TEXTURE0, v.texcoord );
    62.     o.UV = uv;
    63.     return o;
    64. }
    65.  
    66.  
    67. half4 frag (v2f IN) : COLOR
    68. {
    69.     half4 original = tex2D(_MainTex, IN.UV);
    70.  
    71.     half size = 1.0/_NumTiles;
    72.     half2 Pbase = IN.UV - fmod(IN.UV,size.xx);
    73.     half2 PCenter = Pbase + (size/2.0).xx;
    74.     half2 st = (IN.UV - Pbase)/size;
    75.     half4 c1 = (half4)0;
    76.     half4 c2 = (half4)0;
    77.     half4 invOff = (1-_EdgeColor);
    78.     if (st.x > st.y) { c1 = invOff; }
    79.     half threshholdB =  1.0 - _Threshhold;
    80.     if (st.x > threshholdB) { c2 = c1; }
    81.     if (st.y > threshholdB) { c2 = c1; }
    82.     half4 cBottom = c2;
    83.     c1 = (half4)0;
    84.     c2 = (half4)0;
    85.     if (st.x > st.y) { c1 = invOff; }
    86.     if (st.x < _Threshhold) { c2 = c1; }
    87.     if (st.y < _Threshhold) { c2 = c1; }
    88.     half4 cTop = c2;
    89.     //half4 tileColor = tex2D(SceneSampler,PCenter);
    90.     half4 tileColor = tex2D(_MainTex,PCenter);
    91.     half4 result = tileColor + cTop - cBottom;
    92.     return result;
    93.  
    94. }
    95. ENDCG
    96.     }
    97. }
    98.  
    99. Fallback off
    100.  
    101. }
     

    Attached Files:

  13. Frostbite23

    Frostbite23

    Joined:
    Mar 8, 2013
    Posts:
    458
    nice work otcaun, you can see how easy it was to port image effects
     
  14. Frostbite23

    Frostbite23

    Joined:
    Mar 8, 2013
    Posts:
    458
    is anyone using my indie bloom? i would like to see what results they got.
     
  15. Frostbite23

    Frostbite23

    Joined:
    Mar 8, 2013
    Posts:
    458
  16. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    @Frostbite23: just a question: is your filmic tonemap adaptive, or not?
     
  17. Frostbite23

    Frostbite23

    Joined:
    Mar 8, 2013
    Posts:
    458
    adaptive? you mean it has adaption?

    if so, you are totally wrong. Tonemaps don't have adaption, however some techniques do. this one does not. and adaption is totally different from tonemaping. Adaption is like going from dark to bright, like your pupils dilating in the dark.
     
  18. Frostbite23

    Frostbite23

    Joined:
    Mar 8, 2013
    Posts:
    458
    I think i may have the hang of godrays, I'm still stuck on the masking.
     
  19. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Pass me the shader, and I will have a shot at god rays masking.

    @0tacun: Impressive! I also have a question for you: how would I go about rendering a camera, then capturing the screen, aspect and all, at power-of-two size? I tried GL.Viewport, but all it would do was capture the bottom-left corner... :(
     
  20. Frostbite23

    Frostbite23

    Joined:
    Mar 8, 2013
    Posts:
    458
  21. Frostbite23

    Frostbite23

    Joined:
    Mar 8, 2013
    Posts:
    458
    and to increase performance on any image effect your using, open the image effect script and at the top usually it would say this
    Code (JavaScript):
    1. @script RequireComponent (IndieEffects)
    2. @script AddComponentMenu ("Indie Effects/<ImageEffectName>")
    Remove that code and wala, a performance increase. This will increase fps by around 5fps.
     
  22. Eric2241

    Eric2241

    Joined:
    Dec 2, 2012
    Posts:
    642
  23. LegendWill

    LegendWill

    Joined:
    Jun 20, 2014
    Posts:
    9
    I do know next nothing about shaders... Please help. It's not Threshold, _Amount, _Accumulation, or _FrameAccumulation
     
  24. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    That is truly beautiful. Can not wait to try it.
     
  25. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Sorry about that LegendWill. hopefully, I will be able to officially release 2.0 today, as nearly everything is done.

    And Frosty, I need that code there so that the C# scripts don't get mixed up, so please don't. sure, increase performace as you like, but to avoid weird bugs, just leave them there! ;)

    Baldinoboy, it will be released soon. I am still working on radial blur, of which there are still a couple of issues with the brightness and the way it's rendered. I am also working on making all the textures power-of-two, to speed up the rendering pipeline.
     
  26. Frostbite23

    Frostbite23

    Joined:
    Mar 8, 2013
    Posts:
    458
    wait are you switching to C# Fuzzy?
     
  27. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    WTF... No! :D

    Every time I bring out a new release, Berenger ports the scripts to C# for me so that users like Seth McCumber can use it with his C# scripts, since JS and C# don't mix very well.

    If i tried to switch to c#...
     
    Last edited: Apr 5, 2017
  28. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    You guys, I tell of some good news: I was able to compress the textures by power-of-two size, and got a performance increase from 25ms to 10.8! it even drops under the latter number at times too!
     
    Eric2241 likes this.
  29. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    Awesome job. That will help. I was not trying to pressure you before. Take your time. IndieEffects get better with time:D.
     
  30. LegendWill

    LegendWill

    Joined:
    Jun 20, 2014
    Posts:
    9
    When you do release version 2.0, then can you tell me which string it is? lol
     
  31. Seth-McCumber

    Seth-McCumber

    Joined:
    May 26, 2013
    Posts:
    141
    :D, Im a guy
     
    Eric2241 likes this.
  32. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    @Seth McCumber: OOPS! Sorry about that! :D Normally, Seth is a girl's name, that's all!

    @LegendWill: sure, the next release will feature a new motion blur shader, and since it appears your game needs one that can be turned off via the shader, I can easily add this for you! :)
     
    Last edited: Jun 27, 2014
  33. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    UPDATE: After getting the performance Increase, the motion blur broke... But don't worry, I got an idea for a newer motion blur that doesn't require depth textures, or alpha-blending, so bye-bye N64 Motion blur!

    And I am still trying to fix 0tacun's motion blur, but the sky still wriggles around like a moron! :D
     
  34. Frostbite23

    Frostbite23

    Joined:
    Mar 8, 2013
    Posts:
    458
    Fuzzy do you mind sending me a quick package of the new indie effects? i want to make sure none of my effects break.
     
  35. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Sure! Check your PM. a new mail should come in soon! :)

    EDIT: sent! :D
     
    Last edited: Jun 27, 2014
  36. LegendWill

    LegendWill

    Joined:
    Jun 20, 2014
    Posts:
    9

    Awesome!! :)
     
  37. Alpha128

    Alpha128

    Joined:
    Feb 23, 2013
    Posts:
    1
    I love your shaders FuzzyQuills, can you point me to a package with the latest versions? Some shaders break with 4.5
     
    Eric2241 likes this.
  38. LegendWill

    LegendWill

    Joined:
    Jun 20, 2014
    Posts:
    9
    Oh wait, not turned off, just the ability to change the amount of blurriness
     
  39. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    @Alpha128: I am actually going to release this new one coming very soon, and it is guaranteed to work in 4.5 since I am using it right now to produce the new IndieEffects.

    @LegendWill: either way... I will have something :D
     
  40. Eric2241

    Eric2241

    Joined:
    Dec 2, 2012
    Posts:
    642
    Porting question: I"m trying to port the grayscale effect into indie effects, and so does anyone know if you have to write a new shader or can I just use the same shader with the ported script ?
     
  41. Eric2241

    Eric2241

    Joined:
    Dec 2, 2012
    Posts:
    642
    Here is what I have, the shader is the default grayscale shader; currently it displays a red screen, since its default color is red.
    EDIT: It now displays a gray screen, good news?
    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. public class GrayScale : MonoBehaviour {
    6.     public Texture textureRamp;
    7.     public float rampOffset = 0;
    8.     public Texture2D tex;
    9.     private Material Mat;
    10.     public Shader matShader;
    11.  
    12.     // Use this for initialization
    13.     public void Start () {
    14.    
    15.        Mat = new Material(matShader);
    16.        tex = new Texture2D (Screen.width, Screen.height, TextureFormat.RGB24, false);
    17.     }
    18.  
    19.     public void Update () {
    20.         //Mat.SetTexture("_RampTex", textureRamp);
    21.        // Mat.SetFloat("_RampOffset", rampOffset);
    22.         Mat.SetTexture("_MainTex", IndieEffects.renderTexture);
    23.  
    24.     }
    25.     public void OnPostRender () {
    26.  
    27.  
    28.         IndieEffects.FullScreenQuad(Mat);
    29.     }
    30. }
    31.  
    32.  
    Shader Code
    Code (csharp):
    1.  
    2. //UpgradeNOTE: replaced 'samplerRECT' with 'sampler2D'
    3. //UpgradeNOTE: replaced 'texRECT' with 'tex2D'
    4.  
    5. Shader"Hidden/GrayscaleEffect" {
    6. Properties {
    7. _MainTex ("Base (RGB)", 2D) = "red" {}
    8. _RampTex ("Base (RGB)", 2D) = "grayscaleRamp" {}
    9. }
    10.  
    11. SubShader {
    12. Pass {
    13. ZTestAlwaysCullOffZWriteOff
    14. Fog { Modeoff }
    15.  
    16. CGPROGRAM
    17. #pragmavertexvert_img
    18. #pragmafragmentfrag
    19. #pragmafragmentoptionARB_precision_hint_fastest
    20. #include "UnityCG.cginc"
    21.  
    22. uniformsampler2D_MainTex;
    23. uniformsampler2D_RampTex;
    24. uniformfloat_RampOffset;
    25.  
    26. float4frag (v2f_imgi) : COLOR
    27. {
    28. float4original = tex2D(_MainTex, i.uv);
    29. floatgrayscale = Luminance(original.rgb);
    30. float2remap = float2 (grayscale + _RampOffset, .5);
    31. float4output = tex2D(_RampTex, remap);
    32. output.a = original.a;
    33.  
    34. returnoutput;
    35. }
    36. ENDCG
    37.  
    38. }
    39. }
    40.  
    41. Fallback"Diffuse"
    42.  
    43. }
    44.  
     
    Last edited: Jun 29, 2014
  42. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    your shader is missing spaces in the code, this might make it do weird things, and it probably didn't compile. also make sure you're using the C# indieEffects class and not the JS one, as this will fail! :O
     
    Eric2241 likes this.
  43. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    and BTW, that shader is overcomplex! ;)

    try this one:
    Code (csharp):
    1. shader "IndieEffects/Grayscale" {
    2. Properties {
    3. _MainTex("Texture", 2D) = "white" {}
    4. }
    5.  
    6. Subshader{
    7. pass{
    8. CGPROGRAM
    9. #pragma vertex vert_img
    10. #pragma fragment frag
    11. #include "UnityCG.cginc"
    12. struct v2f {
    13. float4 pos : POSITION;
    14. float2 uv : TEXCOORD0;
    15. }
    16.  
    17. sampler2D _MainTex
    18. half4 frag (v2f i) : COLOR {
    19. half4 col = half4 (Luminance(tex2D(_MainTex, i.uv).rgb), 1);
    20. return col;
    21. }
    22. ENDCG
    23. }
    24. }
    25. }
    There. since I typed this out of my head, there might be errors. just let me know and I will fix them! :)
     
  44. Eric2241

    Eric2241

    Joined:
    Dec 2, 2012
    Posts:
    642
    Thank you so much! :)
     
  45. Eric2241

    Eric2241

    Joined:
    Dec 2, 2012
    Posts:
    642
    Whoops, did not use the c# one! I just needed to use the C# version of indie effects so I'll optimize it and try to get the ramp to work!
     
  46. Eric2241

    Eric2241

    Joined:
    Dec 2, 2012
    Posts:
    642
    Updated Gray Scale code and shader code:
    C# version: Use the C# version of indie effects
    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4. [ExecuteInEditMode]
    5. public class GrayScale : MonoBehaviour {
    6.      //public Texture textureRamp; not implemented yet
    7.     //public float rampOffset = 0; not implemented yet
    8.     private Material Mat;
    9.     public Shader matShader;
    10.  
    11.     // Gives on average 2 fps better
    12.     public void Awake () {
    13.  
    14.         Mat = new Material(matShader);
    15.  
    16.     }
    17.  
    18.     public void Update () {
    19.         //Mat.SetTexture("_RampTex", textureRamp);
    20.        // Mat.SetFloat("_RampOffset", rampOffset);
    21.         Mat.SetTexture("_MainTex", IndieEffects.renderTexture);
    22.    
    23.     }
    24.     public void OnPostRender () {
    25.    
    26.         IndieEffects.FullScreenQuad(Mat);
    27.     }
    28. }
    29.  
    30.  
    JS version: Use the JS version of indie effects

    Code (csharp):
    1.  
    2. #pragma strict
    3.  
    4.  
    5. private var Mat : Material;
    6. var matShader : Shader;
    7.  
    8. function Awake () {
    9.     Mat = new Material(matShader);
    10.    
    11. }
    12.  
    13. function Update () {
    14.    
    15.     Mat.SetTexture("_MainTex", IndieEffects.renderTexture);
    16. }
    17.  
    18. function OnPostRender () {
    19.    
    20.      IndieEffects.FullScreenQuad(Mat);
    21. }
    22.  
    Shader Code: Simplified

    Code (csharp):
    1.  
    2. // Upgrade NOTE: replaced 'samplerRECT' with 'sampler2D'
    3. // Upgrade NOTE: replaced 'texRECT' with 'tex2D'
    4.  
    5. Shader "IndieEffects/Gray Scale Effect" {
    6. Properties {
    7.     _MainTex ("Base (RGB)", 2D) = "red" {}
    8.     _RampTex ("Base (RGB)", 2D) = "grayscaleRamp" {}
    9. }
    10.  
    11. SubShader {
    12.     Pass {
    13.         ZTest Always Cull Off ZWrite Off
    14.         Fog { Mode off }
    15.                
    16. CGPROGRAM
    17. #pragma vertex vert_img
    18. #pragma fragment frag
    19. #pragma fragmentoption ARB_precision_hint_fastest
    20. #include "UnityCG.cginc"
    21.  
    22. uniform sampler2D _MainTex;
    23. uniform sampler2D _RampTex;
    24. uniform float _RampOffset;
    25.  
    26. float4 frag (v2f_img i) : COLOR
    27. {
    28.     float4 original = tex2D(_MainTex, i.uv);
    29.     float grayscale = Luminance(original.rgb);
    30.    
    31.    
    32.    
    33.     return grayscale;
    34. }
    35. ENDCG
    36.  
    37.     }
    38. }
    39.  
    40. Fallback off
    41.  
    42. }
    43.  
     
    Last edited: Jun 30, 2014
  47. Eric2241

    Eric2241

    Joined:
    Dec 2, 2012
    Posts:
    642
    Here's my somewhat optimized version of the BCS originally made by @Frostbite23
    Code (csharp):
    1.  
    2. #pragma strict
    3. //@script ExecuteInEditMode
    4. //@script AddComponentMenu ("Indie Effects/BrightnessSaturationContrast")
    5.  
    6. private var Mat : Material;
    7. var matShader : Shader;
    8. @range(0,10)
    9. var Brightness : double = 1;
    10. @range(0,10)
    11. var Contrast : double = 1;
    12. @range(0,10)
    13. var Saturation : double = 1;
    14.  
    15.  
    16. function Awake () {
    17.     Mat = new Material(matShader);
    18. }
    19.  
    20.  
    21. function Update () {
    22.  
    23.     Mat.SetFloat("_SaturationAmount", Saturation);
    24.     Mat.SetFloat("_BrightnessAmount", Brightness);
    25.     Mat.SetFloat("_ContrastAmount", Contrast);
    26.     Mat.SetTexture("_MainTex", IndieEffects.renderTexture);
    27. }
    28.  
    29. function OnPostRender () {
    30.  
    31.     IndieEffects.FullScreenQuad(Mat);
    32. }
    33.  
     
    Last edited: Jun 30, 2014
  48. Frostbite23

    Frostbite23

    Joined:
    Mar 8, 2013
    Posts:
    458
    NOOOOO!!! Don't add the
    Code (JavaScript):
    1. @script ExecuteInEditMode
    2. @script AddComponentMenu ("Indie Effects/BrightnessSaturationContrast")
    3.  
    I have already optimized it, do not add that for some reason most users have reported performance issues with those specific lines, do not add them. And I already optimized the BCS why optimize it again?
     
  49. Frostbite23

    Frostbite23

    Joined:
    Mar 8, 2013
    Posts:
    458
    I don't know if i posted the new code but here it is
    Code (JavaScript):
    1. #pragma strict
    2.  
    3. import IndieEffects;
    4. var fxRes : IndieEffects;
    5. private var Mat : Material;
    6. var matShader : Shader;
    7. @range(0,2)
    8. var Brightness : float = 1;
    9. @range(0,2)
    10. var Contrast : float = 1;
    11. @range(0,2)
    12. var Saturation : float = 1;
    13. function Start () {
    14.     Mat = new Material(matShader);
    15.     Mat.SetFloat("_SaturationAmount", Saturation);
    16.     Mat.SetFloat("_BrightnessAmount", Brightness);
    17.     Mat.SetFloat("_ContrastAmount", Contrast);
    18. }
    19.  
    20. function OnPostRender () {
    21.     Mat.SetTexture("_MainTex", fxRes.RT);
    22.     FullScreenQuad(Mat);
    23. }
    Changes
    - Removed @script lines
    - Moved the Sautration, Brightness, Contrast to the start function so they ardent set every frame.
     
  50. Eric2241

    Eric2241

    Joined:
    Dec 2, 2012
    Posts:
    642
    Oh, whoops did not see the optimized code, anyways thanks for the effects its really nice!

    Side note:
    This happened while trying to implement the texture ramp to the gray scale effect.
     
    Last edited: Jun 30, 2014