Unity Community


Results 1 to 9 of 9

  1. Location
    Turkey
    Posts
    1,925

    True Image Effects for Unity Free

    These assets help you to do true post processing effects in unity free.
    Mostly you will face problems and it wont work the same in every computer.
    Those of you with OSX will have the most trouble.
    And, the resulting frame rates will be frustrating.
    But here it is, use on your own risk.

    DOWNLOAD FROM MY BLOG
    Last edited by Aubergine; 11-22-2011 at 01:42 PM.


  2. Location
    Germany
    Posts
    453
    First though was: Cool, sounds really great. And it's for Unity Free
    I opened it and saw: A Demo Scene, 3 Folders called _Media, _Scrips and _Shaders, one .cs-File named ImageFx.cs and a readme.txt.

    In the _Media folder are:
    - a forest_sky.mat
    - 6 jpgs named forest_sky_XX.jpg (XY = back, bottom, front, etc).

    In the _Scripts folder is:
    a .cs-File called ImageFxBase.cs.

    In the _Shaders folder are:
    - two Shaders named BloomSimple.shader and EdgeDetect.shader.

    The readme.txt says the following:
    BE PREPARED FOR VEEERY LOW FRAMES PER SECOND.

    HOW TO USE:
    First of all, you must change LAYER 31 to "CameraQuad"
    Then add the ImageFx script to your main camera and add an effect to the scripts
    appropriate spot from the _Shaders folder.
    Thats it.

    HOW IT WORKS:
    We build a QUAD on screen right infront of our main rendering camera, occupying all there
    view frustum space.

    During runtime, we first render our scene except our quad with the very same camera,
    save the scene into a texture and paste this texture to our quad,
    then render the scene again but ONLY the quad is visible this time with the applied shader.
    And the shader just does what it is supposed to do, and we get our final result.

    BEWARE that the shader will also effect all GUI stuff as well.

    INCLUDED EFFECTS:
    BloomSimple - this is a simple effect that fakes bloom.
    EdgeDetect - This is a conversion of Unity PRO included edge detect.(properties are hard coded into this one)

    HOW CAN YOU ADD YOUR OWN EFFECTS:
    Image effects are mostly pixel shaders, so find any reasonable shader on the internet,
    duplicate one of the included shaders in this pack, and change the frag function to reflect
    your shader.

    Or, you can buy my IMAGE EFFECTS PACK FOR UNITY PRO
    http://u3d.as/content/aubergine/aube...rocess-effects

    and copy paste the frag parts from those and make them work with unity free.
    Still there is no guarantee that all of the effects will work though.
    So, the RISK is all yours. And i wont give any support for it.

    WHAT YOU CAN NOT DO:
    Although there are ways to fake it as well, any effect that requires a depth image is not doable.
    I.E. Depth of field effect.

    After applying the effect;
    You cant resize your screen,
    You cant resize your camera rect,
    You cant change anything camera view related stuff.

    If you do, you must rewrite the ImageFxBase script to continuously change vertex positions
    of the quad every loop.
    But you dont want to do that, this already works on very low FPS.

    Support:
    There is none, the pack is free. It may or may not work for all machines, so you are all alone.
    I really wish there would be more image effects in the package here. The thread-title says "True Image Effects for Unity Free". Thats right, but there are only two inside the project. And not everybody have the knowlenghe to build their own shaders...


    Edit:
    Oh and a friendly tip: Next time please bring many informations as possible into your postings, when you release something. Like you've do here: http://forum.unity3d.com/threads/941...-in-Assetstore .. Because not everyone has the time or desire to download things blind.. ^^
    Last edited by Mauri; 11-15-2011 at 06:46 PM.


  3. Location
    Turkey
    Posts
    1,925
    I released it for free for a reason. i also have a paid package in the assetstore as your link shows and if i include those shaders in this free package, then i think i wont be able to sell the other one.

    But, you are right. I will show here some new shaders and teach how to add new ones on your own if i find some time.
    Last edited by Aubergine; 11-15-2011 at 11:34 PM.


  4. Location
    Athens, Greece
    Posts
    1,060
    Hi,
    Aubergine, thanks a lot for releasing the workflow you found for free. I really appreciate it and I find your shaders very educative. Have you considered writing some paid tutorials on how to make a shader ?

    Mauri :

    I really wish there would be more image effects in the package here. The thread-title says "True Image Effects for Unity Free". That's right, but there are only two inside the project. And not everybody have the knowledge to build their own shaders.
    If you take the time to learn how to build a shader, even the simplest one, perhaps you will appreciate more Abergine's gesture ( giving these for free ). I also believe that this workflow is probably more valuable to people who want to learn how to make shaders, than to people who wish to use them.

    Oh and a friendly tip: Next time please bring many informations as possible into your postings, when you release something. Like you've do here: http://forum.unity3d.com/threads/941...-in-Assetstore .. Because not everyone has the time or desire to download things blind.. ^^
    I believe that anyone who releases things for free cannot be expected to put extra time to advertise it properly. It is indeed a good practice though.
    Last edited by Ippokratis; 01-12-2013 at 12:59 AM.
    Colored Shadows
    Batching Tools
    : Batch draw calls easily.
    Toon Shader Mobile: Good for mobile, fast and beautiful.
    Toon Shader Desktop: Good for desktops, more advanced.
    Thyella : A small game prototype on Kongregate


  5. Location
    Turkey
    Posts
    1,925
    Thanks for kind words Ippokratis. Unfortunately i am not the teacher type and i cant make any tutorials in commercial quality. And after all, there are so many quality tutorials for free all over the internet anyways.


  6. Location
    Turkey
    Posts
    1,925
    So, here is one simple tutorial about how to add a new shader to this pack.

    1. First things first, we make a clean new project in unity, and import everything in the package to this clean new project(for the sake of simplicity)

    2. As it is a zip file, imported assets will be messed up and needs your attention. As we are going to use the supplied demo scene for testing, we need to fix missing script in MainCamera, the skybox materials textures and the skybox material in the RenderSettings itself. (You know how to do those right?)

    3. as its all setup now, lets search the internet for a cool (but a simple one for the sake of this tutorial) shader. After alittle searching, we decide Nvidia Shader Library is the best place to find this kind of stuff.

    4.We scroll down the pages of shader library, what we are looking for is a (post effect (for now)) then we see the Post Negative in the middle of the page. It says Directx10 stuff, but we dont care, we are only interested in the math part of the fragment shader here.

    5. So we decide to convert this shader to unity and to this package, we download either of HLSL or CGFX file supplied (we can also look at the whitepaper to understand whats going on but who needs a document while theres the source code anyways)

    6. I downloaded the CGFX file, opened it with 7-zip (Which is also free by coincidence) and see theres a folder "CgFX", i clicked on it twice and see "post_negative.cgfx" file and "include" dir. Just looked at the include dir and saw a "Quad.cgh" file, and decided we dont need it(what quad file can do is already provided in unity and this pack) so we go back and open the "post_negative.cgfx" file.

    We see the below mambo jambo:

    Code:  
    1. /*********************************************************************NVMH3****
    2. *******************************************************************************
    3. $Revision: #3 $
    4.  
    5. Copyright NVIDIA Corporation 2008
    6. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED
    7. *AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS
    8. OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY
    9. AND FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS
    10. BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES
    11. WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS,
    12. BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY
    13. LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
    14. NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
    15.  
    16. % Create a negative image of the underlying scene.
    17. % Un-inverted alpha is preserved.
    18.  
    19. keywords: image_processing color_conversion
    20.  
    21.  
    22.  
    23. To learn more about shading, shaders, and to bounce ideas off other shader
    24.     authors and users, visit the NVIDIA Shader Library Forums at:
    25.  
    26.     http://developer.nvidia.com/forums/
    27.  
    28. *******************************************************************************
    29. ******************************************************************************/
    30.  
    31. /*****************************************************************/
    32. /*** HOST APPLICATION IDENTIFIERS ********************************/
    33. /*** Potentially predefined by varying host environments *********/
    34. /*****************************************************************/
    35.  
    36. // #define _XSI_        /* predefined when running in XSI */
    37.  
    38. #ifndef FXCOMPOSER_VERSION  /* for very old versions */
    39. #define FXCOMPOSER_VERSION 180
    40. #endif /* FXCOMPOSER_VERSION */
    41.  
    42. // #define FLIP_TEXTURE_Y   /* Different in OpenGL & DirectX */
    43.  
    44. /*****************************************************************/
    45. /*** EFFECT-SPECIFIC CODE BEGINS HERE ****************************/
    46. /*****************************************************************/
    47.  
    48. //
    49. // #define this macro to permit reading of COLLADA-FX
    50. //   shared-surface render targets
    51. //
    52. // #define SHARED_BG_IMAGE
    53.  
    54. #include "include/Quad.cgh"
    55.  
    56. float Script : STANDARDSGLOBAL <
    57.     string UIWidget = "none";
    58.     string ScriptClass = "scene";
    59.     string ScriptOrder = "postprocess";
    60.     string ScriptOutput = "color";
    61.     string Script = "Technique=Main;";
    62. > = 0.8;
    63.  
    64. // color and depth used for full-screen clears
    65.  
    66. float4 gClearColor <
    67.     string UIWidget = "Color";
    68.     string UIName = "Background";
    69. > = {0,0,0,0};
    70.  
    71. float gClearDepth <string UIWidget = "none";> = 1.0;
    72.  
    73. ///////////////////////////////////////////////////////////
    74. /////////////////////////////////////// Textures //////////
    75. ///////////////////////////////////////////////////////////
    76.  
    77. DECLARE_QUAD_TEX(gSceneTexture,gSceneSampler,"A8R8G8B8")
    78. DECLARE_QUAD_DEPTH_BUFFER(DepthBuffer,"D24S8")
    79.  
    80. //////////////////////////////////////////////////////
    81. /////////////////////////////////// pixel shader /////
    82. //////////////////////////////////////////////////////
    83.  
    84. QUAD_REAL4 negativePS(QuadVertexOutput IN,
    85.     uniform sampler2D SceneSampler) : COLOR
    86. {  
    87.     QUAD_REAL4 texCol = tex2D(SceneSampler, IN.UV);
    88.     return float4((float3(1,1,1)-texCol.xyz),texCol.w); // protect alpha
    89. }  
    90.  
    91. ///////////////////////////////////////
    92. /// TECHNIQUES ////////////////////////
    93. ///////////////////////////////////////
    94.  
    95. technique Main < string Script =
    96. #ifndef SHARED_BG_IMAGE
    97.     "RenderColorTarget0=gSceneTexture;"
    98.     "RenderDepthStencilTarget=DepthBuffer;"
    99.     "ClearSetColor=gClearColor;"
    100.     "ClearSetDepth=gClearDepth;"
    101.     "Clear=Color;"
    102.     "Clear=Depth;"
    103.     "ScriptExternal=Color;" // calls all "previous" techniques & materials
    104.     "Pass=PostP0;";
    105. #else /* defined(SHARED_BG_IMAGE)  - no nead to create one, COLLADA has done it for us  */
    106.     "ClearSetColor=gClearColor;"
    107.     "ClearSetDepth=gClearDepth;"
    108.     "Clear=Color;"
    109.     "Clear=Depth;"
    110.     "Pass=PostP0;";
    111. #endif /* SHARED_BG_IMAGE */
    112. > {
    113.     pass PostP0 < string Script =
    114.     "RenderColorTarget0=;"
    115.     "RenderDepthStencilTarget=;"
    116.     "Draw=Buffer;";
    117.     > {
    118.     VertexProgram = compile vp40 ScreenQuadVS2(QuadTexelOffsets);
    119.         DepthTestEnable = false;
    120.         DepthMask = false;
    121.         BlendEnable = false;
    122.         CullFaceEnable = false;
    123.         DepthFunc = LEqual;
    124.     FragmentProgram = compile fp40 negativePS(gSceneSampler);
    125.     }
    126. }
    127.  
    128. //////////////////////////////////////////////
    129. /////////////////////////////////////// eof //
    130. //////////////////////////////////////////////

    Too much junk.

    7. We just look over the file, see so many fancy stuff, but we are confident unity can do most of these by itself and remember we are here only to look at the Pixel Shader maths.

    Here it is (in the middle of the file):
    Code:  
    1. //////////////////////////////////////////////////////
    2. /////////////////////////////////// pixel shader /////
    3. //////////////////////////////////////////////////////
    4.  
    5. QUAD_REAL4 negativePS(QuadVertexOutput IN,
    6.     uniform sampler2D SceneSampler) : COLOR
    7. {  
    8.     QUAD_REAL4 texCol = tex2D(SceneSampler, IN.UV);
    9.     return float4((float3(1,1,1)-texCol.xyz),texCol.w); // protect alpha
    10. }

    Again to much mambo jambo.
    The main maths is:
    QUAD_REAL4 texCol = tex2D(SceneSampler, IN.UV);
    return float4((float3(1,1,1)-texCol.xyz),texCol.w); // protect alpha
    8. So, we look at the maths, its so simple, it takes the current pixel color from sampler (texCol) and calculates the inverse of the color, and returns this new color on the current pixel while protecting original alpha. "Meh!, so is this what shaders are all about??" we say. Then we answer back as "Yeah i guess so."

    9. After our schizofrenia fades away, we go back to our unity, there are 2 shaders already provided, "BloomSimple" and "EdgeDetect". (Now bloomsimple is a very simple thing that only does pixel fragment and edgedetect also provides a vertex fragment sample.)
    So, we remember post negative shader is only made of a pixel fragment, we decide our starting point should be "BloomSimple", so we duplicate it and name the new copy as "Negative" and obviously open it. We look at the very first line:
    Shader "Hidden/Aubergine/UnityFree/BloomSimple" {
    Aaand, we need to give here a unique name, so we change "BloomSimple" to "Negative"

    10. We scroll down to pixelshader part of our duplicated shader and delete everything in there and start typing in the Nvidia shaders code there with care to do necessary conversions as follows:
    Our Changes:
    half4 frag (v2f i) : COLOR {
    half4 texCol = tex2D(_MainTex, i.uv);
    return half4((half3(1,1,1)-texCol.xyz),texCol.w); // protect alpha
    }
    And here is our final shader:
    Code:  
    1. Shader "Hidden/Aubergine/UnityFree/Negative" {
    2.     Properties {
    3.         _MainTex ("Base (RGB)", 2D) = "white" {}
    4.     }
    5.     SubShader {
    6.         Pass {
    7.             ZTest Always Cull Off ZWrite Off Lighting Off Fog { Mode off }
    8.             CGPROGRAM
    9.                 #pragma vertex vert
    10.                 #pragma fragment frag
    11.                 #include "UnityCG.cginc"
    12.                
    13.                 struct v2f {
    14.                     float4 pos : SV_POSITION;
    15.                     half2 uv : TEXCOORD0;
    16.                 };
    17.  
    18.                 uniform sampler2D _MainTex;
    19.  
    20.                 v2f vert(appdata_img v) {
    21.                     v2f o;
    22.                     o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
    23.                     o.uv = MultiplyUV( UNITY_MATRIX_TEXTURE0, v.texcoord );
    24.                     return o;
    25.                 }
    26.  
    27.                 half4 frag (v2f i) : COLOR {
    28.                     half4 texCol = tex2D(_MainTex, i.uv);
    29.                     return half4((half3(1,1,1)-texCol.xyz),texCol.w); // protect alpha
    30.                 }
    31.             ENDCG
    32.         }
    33.     }
    34. }

    Thats all folks.
    Last edited by Aubergine; 11-22-2011 at 04:10 AM.


  7. Location
    Athens, Greece
    Posts
    1,060
    Hi,
    Thanks a lot for the code and the explanations,
    -Ippokratis
    Colored Shadows
    Batching Tools
    : Batch draw calls easily.
    Toon Shader Mobile: Good for mobile, fast and beautiful.
    Toon Shader Desktop: Good for desktops, more advanced.
    Thyella : A small game prototype on Kongregate


  8. Location
    Turkey
    Posts
    1,925
    No problem, hope it helps to someone.


  9. Location
    Germany
    Posts
    453
    @Ippokratis
    Don't get me wrong. Of course i appreciate it

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •