Search Unity

I need an Iridescence shader

Discussion in 'Shaders' started by strongbox3d, Apr 5, 2017.

  1. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    860
    Hello guys,

    I need an Iridescence shader for my game. Does anyone can make one? I will pay for it.

    Regards,
    Carlos
     
  2. jvo3dc

    jvo3dc

    Joined:
    Oct 11, 2013
    Posts:
    1,520
    The simple way would be to have a lookup texture for the Fresnel to do that. That would work on static surfaces. For something like a soap bubble it's a bit more complex though.

    Then you can manually create a lookup texture or actually generate one which is a bit more tricky:
    https://en.wikipedia.org/wiki/Thin-film_interference

    My opinion is still that Unity should offer this out of the box in the standard shader. The simple option to have a lookup texture for Fresnel allows for better approximations for things like metals and adds the option for the average artist to add iridescence.

    This also means that the Unity lighting system should actually respect the values in the g-buffer. Whether or not you want to create a PBR base, you should leave this part up to the shader. The shader should output the amount of diffuse and reflection in a PBR way and the lighting calculations should follow this as is. (Currently Unity also adds reflections to surfaces that output 0 reflection/specular in the g-buffer.)
     
  3. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    860
    I need this shader for fish, so it most be able to perform in dynamic objects that have animations. I don't have any knowledge about shaders, so I am offering to pay for someone to make the shader.

    Regards,
    Carlos
     
  4. AbandonedCart

    AbandonedCart

    Joined:
    Mar 4, 2014
    Posts:
    72
    I stumbled across https://assetstore.unity.com/packages/vfx/shaders/iridescence-thin-film-42944 while searching for something similar, but I am not affiliated with the author and have not tested it.
    I have a character that has the "blue black" hair that appears relatively blue in light and almost pitch black out of it. I was looking for a shader to create that effect. This one appeared to be a bit more focused on appearing metallic.
     
  5. Subliminum

    Subliminum

    Joined:
    Nov 9, 2017
    Posts:
    97
    Give this one a whirl.


    Code (CSharp):
    1. Shader "Toon/Iridescent" {
    2.     Properties{
    3.         _Color("Main Color", Color) = (0.5,0.5,0.5,1)
    4.        
    5.         _MainTex("Base (RGB)", 2D) = "white" {}
    6.  
    7.     _Noise("Noise (RGB)", 2D) = "white" {} // noise texture
    8.     _Ramp("Toon Ramp (RGB)", 2D) = "gray" {}
    9.     _IrTex("Iridescence Ramp (RGB)", 2D) = "white" {} // color ramp
    10.     _IrColor("Ir Color", Color) = (0.5,0.5,0.5,1)// extra iridescence tinting
    11.     _Offset ("Iridescence Ramp Offset", Range (0, 1)) = 1 // offset of the color ramp
    12.     _Brightness ("Iridescence Opacity", Range (0, 1)) = 1 // opacity of iridescence
    13.     _WorldScale ("Noise Worldscale", Range (.002, 5)) = 1 // noise scale
    14.     [Toggle(LM)] _LM("Use Lightmap UVS?", Float) = 0 // use lightmap uvs instead of normal ones
    15.  
    16.  
    17.     }
    18.  
    19.         SubShader{
    20.         Tags{ "RenderType" = "Opaque" }
    21.         LOD 200
    22.  
    23.         CGPROGRAM
    24. #pragma surface surf ToonRamp
    25. #pragma shader_feature LM
    26.         sampler2D _Ramp;
    27.  
    28.     // custom lighting function that uses a texture ramp based
    29.     // on angle between light direction and normal
    30. #pragma lighting ToonRamp exclude_path:prepass
    31.     inline half4 LightingToonRamp(SurfaceOutput s, half3 lightDir, half atten)
    32.     {
    33. #ifndef USING_DIRECTIONAL_LIGHT
    34.         lightDir = normalize(lightDir);
    35. #endif
    36.  
    37.         half d = dot(s.Normal, lightDir)*0.5 + 0.5;
    38.         half3 ramp = tex2D(_Ramp, float2(d,d)).rgb;
    39.  
    40.         half4 c;
    41.         c.rgb = s.Albedo * _LightColor0.rgb * ramp * (atten * 2);
    42.         c.a = 0;
    43.         return c;
    44.     }
    45.  
    46.  
    47.     sampler2D _MainTex;
    48.     sampler2D _Noise; // noise
    49.     sampler2D _IrTex; // color ramp
    50.     float4 _Color;
    51.     float4 _IrColor; // extra tinting
    52.     float _Offset; // color ramp offset
    53.     float _Brightness; // Iridescence opacity
    54.     float _WorldScale; // noise scale
    55.  
    56.     struct Input {
    57.         float2 uv_MainTex : TEXCOORD0;
    58.         float2 uv2_Noise : TEXCOORD1; // lightmap uvs
    59.         float3 viewDir; // view direction
    60.     };
    61.  
    62.     void surf(Input IN, inout SurfaceOutput o) {
    63.  
    64.         half f = 1 -dot(o.Normal, IN.viewDir) + _Offset; // fresnel
    65.         half4 n = tex2D(_Noise, IN.uv_MainTex * _WorldScale); // noise based on the first uv set
    66. #if LM
    67.         n = tex2D(_Noise, IN.uv2_Noise * _WorldScale); // noise based on the lightmap uv set
    68. #endif
    69.  
    70.         half4 c = tex2D(_MainTex, IN.uv_MainTex ) * _Color;
    71.  
    72.        
    73.         half3 i = tex2D(_IrTex, float2(f,f)+ n).rgb * _IrColor; // iridescence effect
    74.        
    75.         o.Albedo = (c.rgb) + ((i * n) * _Brightness); // multiplied by original texture, with an opacity float
    76.        
    77.         o.Alpha = c.a;
    78.     }
    79.     ENDCG
    80.  
    81.     }
    82.  
    83.         Fallback "Diffuse"
    84. }
    Try it out with the color ramp.
    This shader is from https://twitter.com/minionsart and i believe their is a patreon page if you wish to donate.
     

    Attached Files:

    PrimalCoder likes this.
  6. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    860
    Thank you LoungeKatt and Subliminum,

    Both reply are very helpful! I will check that shader from Subliminum and the asset store one. I appreciate very much your help in this matter. I will let you know how it goes.

    Regards,
    Carlos
     
    StevenGerrard and Subliminum like this.
  7. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,493
  8. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    860
    Subliminum, I checked the shader Toon/Iridescent, but as the title says it the shader doesn't have any specular, and other properties, so it is not practical for a realistic graphics game. The one in the assets store look very good indeed, I think I will go with that for my game.

    neoshaman, that tutorial is very interesting, but I am working in all aspects of my game and don't have time to learn about shaders really. Thank you for the link, it was very interesting read.

    Regards,
    Carlos
     
  9. Subliminum

    Subliminum

    Joined:
    Nov 9, 2017
    Posts:
    97
    Yea if you want to save a few bucks just put the code relating to iridescence into unitys standard shader which has specular and detail maps etc. I cannot recommend learning shaders enough if you end up with the spare time. Good luck with the project!
     
  10. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    860
    I would love to learn shader programming but I am in a tight deadline with the Xbox One folks so I really can't at least for this game, but you can be sure I will as soon as I have a down time. I think it is one of the most important knowledge to have if you want to create a nice looking and fast fps game. Anyways thank you for your input, very appreciated.

    Regards,
    Carlos
     
  11. Seyed_Morteza_Kamaly

    Seyed_Morteza_Kamaly

    Joined:
    Nov 18, 2015
    Posts:
    80
  12. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    860
    Seyed_Morteza_Kamaly,

    I appreciate very much you offering a shader for free. The problem that the shader I am looking for most have specular, smoothness, and the other properties of the standard Unity shader. To be more clear I need this shader to create realistic fish skin, like Tuna, Jacks, Barracudas, etc... This type of fish's skin are Iridescent. But your offer is very nice.

    Regards,
    Carlos
     
  13. Seyed_Morteza_Kamaly

    Seyed_Morteza_Kamaly

    Joined:
    Nov 18, 2015
    Posts:
    80
    Hi Dear Friend I added Surface Shader to my repository
    some new properties
    BumpMap
    BumpPower
    Metallic
    Glossiness
    Hue
    Saturation
    Brightness
    Contrast
     
  14. Seyed_Morteza_Kamaly

    Seyed_Morteza_Kamaly

    Joined:
    Nov 18, 2015
    Posts:
    80
  15. chelnok

    chelnok

    Joined:
    Jul 2, 2012
    Posts:
    680
    @Seyed_Morteza_Kamaly Thanks for sharing, looks really nice. Any change to add license, that allows us to use it in our games?
     
  16. Seyed_Morteza_Kamaly

    Seyed_Morteza_Kamaly

    Joined:
    Nov 18, 2015
    Posts:
    80
    I'll do it...It's free to use
     
    Adam-Bailey and chelnok like this.
  17. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,769
  18. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    860
    IredescenceShader.jpg @Seyed_Morteza_Kamaly,

    Thank you so much!! This is perfect brother, exactly what I was looking for! I tested last night and it works perfectly. I appreciate it very much, thanks a bunch!

    Regards,
    Carlos
     
    Last edited: May 6, 2018
  19. Seyed_Morteza_Kamaly

    Seyed_Morteza_Kamaly

    Joined:
    Nov 18, 2015
    Posts:
    80
    It was my pleasure to help you.
     
    Last edited: May 7, 2018
  20. Seyed_Morteza_Kamaly

    Seyed_Morteza_Kamaly

    Joined:
    Nov 18, 2015
    Posts:
    80
    I Added Anisotropic Iridescence

     
    Adam-Bailey, chelnok and neoshaman like this.
  21. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    860
    Wow! this is super cool brother!! Great work! You remind me of when there were a lot of people in these forums helping each other instead of selling everything in the asset store. Now a days pretty much everything has to be bought and there are more people selling assets than creating games. Any way...

    Great job and thanks again brother.

    Regards,
    Carlos
     
    neoshaman likes this.
  22. Seyed_Morteza_Kamaly

    Seyed_Morteza_Kamaly

    Joined:
    Nov 18, 2015
    Posts:
    80
    Currently I'm working on Iridescent bubble :)





     
    Last edited: May 8, 2018
    StevenGerrard and Adam-Bailey like this.
  23. Seyed_Morteza_Kamaly

    Seyed_Morteza_Kamaly

    Joined:
    Nov 18, 2015
    Posts:
    80
    Last edited: May 10, 2018
    PrimalCoder, RyanJVR, steego and 8 others like this.
  24. tomasdgarcia

    tomasdgarcia

    Joined:
    Nov 2, 2014
    Posts:
    2
  25. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,267
    I just noticed this thread. Thank you very much for providing these shaders. I found good use for the soap bubbles here:



    Now people keep asking me to provide a GitHub repo for the bubble instantiation and wrapping around an enemy. Is it okay to integrate your shader into my repo if I create one, credits of course to you for the bubbles. I see it's MIT licensed, but since it's all based on your work, I'd like to ask you nontheless.
     
  26. Seyed_Morteza_Kamaly

    Seyed_Morteza_Kamaly

    Joined:
    Nov 18, 2015
    Posts:
    80
    Nice Job!
    I'm so glad it helped you
    it's free to use you can share with anyone
    thank you for using my shader
     
    Rowlan likes this.
  27. dannyr83

    dannyr83

    Joined:
    Jul 14, 2021
    Posts:
    10
  28. Seyed_Morteza_Kamaly

    Seyed_Morteza_Kamaly

    Joined:
    Nov 18, 2015
    Posts:
    80
    Hi Danny unfortunately Patreon closed my page because I'm an Iranian developer and I lost my funds and access to my page.
     
  29. april_4_short

    april_4_short

    Joined:
    Jul 19, 2021
    Posts:
    489
    Sorry to hear! A great pity. Now I know why the screenshots aren't visible, too. All the best to you!

    Would you mind if @Rowlan re-shared your wonderful shaders and tech and whatever they have of this direction?

    If Rowlan still has the stuff, and the time to share, it... obviously, too.
     
  30. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,267
    That's tough to hear. One of the reasons I don't like Patreon. Do you have a donation account other than Patreon?

    I do, but Seyed's GitHub page is still here:

    https://github.com/smkplus/Iridescence
     
  31. freakmindtoo

    freakmindtoo

    Joined:
    Oct 26, 2021
    Posts:
    1
    God bless you dude