Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Standard Double Sided Shaders

Discussion in 'Assets and Asset Store' started by username_unity_of_my, Jul 29, 2015.

  1. username_unity_of_my

    username_unity_of_my

    Joined:
    Feb 24, 2015
    Posts:
    330
    Hello


    I released double sided standard shaders package on AssetStore.
    They are used same like Unity standard and standard(SpecularSetup) shaders.
    They require shader model 3.0 or higher.
    They feature mesh triangles drawn on both sides with accurate lighting in single draw call.

    You can see use in this video.


    Also you can try web player HERE .

    Link to asset store HERE .

    Instructions:
    - choose mesh
    - create material and apply StandardDoubleSided or StandardSpecularDoubleSided shader on it.
    - carry on like usual Standard or Standard (Specular Setup) shader.

    Thank you.
     
    Last edited: Oct 27, 2016
    kenshin likes this.
  2. mholub

    mholub

    Joined:
    Oct 3, 2012
    Posts:
    123
    Thank you! %) I already bought and used it in my project. Works perfectly.
    Wanted to write it by myself (need to turn culling off and flip the normals for back side), but you saved me few hours of work.
     
  3. PROTOFACTOR_Inc

    PROTOFACTOR_Inc

    Joined:
    Nov 15, 2009
    Posts:
    4,029
    Edit: didn't see in the description that you have it as well for the specular set up. However in the video I just noticed the metallic set one.
    sorry for being to quick to post...
     
  4. username_unity_of_my

    username_unity_of_my

    Joined:
    Feb 24, 2015
    Posts:
    330
    You are right. Thank you.

    Yes, there are both variants. I use standard(specular setup) more often in my projects than the other one, so its more important to me.
     
  5. username_unity_of_my

    username_unity_of_my

    Joined:
    Feb 24, 2015
    Posts:
    330
    I just wanna say that I added additional double sided shaders to the pack:

    mobile diffuse,
    mobile bumped,
    mobile bumped specular
    mobile bumped specular 1 directional light
    legacy decal,
    legacy diffuse,
    legacy bumped specular,
    legacy parallax diffuse,
    legacy parallax specular
    legacy cutout diffuse
    legacy cutout bumped specular
    also two face texture shaders that draws two textures, one on each face .
    two face diffuse
    two face bumped

    All in single draw call / pass.

    Another web player: LINK

    If someone needs another kind, feel free to suggest.
     
    Last edited: Oct 27, 2016
  6. kenshin

    kenshin

    Joined:
    Apr 21, 2010
    Posts:
    936
    Very interesting, great idea!
     
  7. TorbenDK

    TorbenDK

    Joined:
    Jun 28, 2016
    Posts:
    24
    Hi.

    This looks like just what I need!

    But I need to know if this works with the Realtime GI?

    You see, our CAD-software does not care about what side of a triangle is the front. It renders everything as doublesided, so when I export for use in Unity it's pretty much hit-n-miss if a tri is facing the wrong way. (Yes out CAD-software sucks)

    I tried to do the "Cull Off" on the standard shader and that is definitly not enough to satisfy the "Enlighten" thing-a-magicky
     
  8. username_unity_of_my

    username_unity_of_my

    Joined:
    Feb 24, 2015
    Posts:
    330
    Yes, it works with GI - same like standard shader.
     
  9. TorbenDK

    TorbenDK

    Joined:
    Jun 28, 2016
    Posts:
    24
    Hi again. At least with my setup it doesn't. Deferred, Specular workflow. Backside renders with what seems like no GI; much darker. Also the reflection in probes is black. Also Ambient occlusion using G-buffer stopped working. Any clues? 5.4.0f3.
     
  10. username_unity_of_my

    username_unity_of_my

    Joined:
    Feb 24, 2015
    Posts:
    330
    As far as ambient occlusion goes - it needs doublesidedness implemented in the .AO process I think.
    I remember using 'AmbientObscurance' from standard assets and it worked - though 'AmbientOcclusion' does not work.
    I'll check the other.
     
    Last edited: Sep 4, 2016
  11. username_unity_of_my

    username_unity_of_my

    Joined:
    Feb 24, 2015
    Posts:
    330
    I just checked - and all works fine. All the scenes in the package are realtime GI. ( Do the package scenes work on your end )
    Did you used maybe double sided standard shaders from before 5.4 on 5.4 - if you did then it they dont work - they changed standard shader a little for 5.4.
     
  12. TorbenDK

    TorbenDK

    Joined:
    Jun 28, 2016
    Posts:
    24
    I don't see any GI solution used in the demoscenes?

    Anyways. I tried adding Precomputed realtime GI, and made the lot static for lightmap, and well, something didn't work. Materials unresponsive to GI. Also looks like direct light travel through to the backside on some carpets with normals at least.

    I just purchased your package today from asset store, so I think it matches my Unity version?

    Thanks for the support on this :)
     
  13. Diomede

    Diomede

    Joined:
    Mar 10, 2015
    Posts:
    31
    Hi,

    I Have tried to compile the scene "scene" contained in package example on I-Pad Air , but the player crashes at startup (On android devices works well). The only error that I can see is the following.

    Compilation failed:

    program_source:4:10: error: unknown type name 'FragmentCommonData'
    constant FragmentCommonData _xlat_mtl_const1 = {float3(0.0, 0.0, 0.0), float3(0.0, 0.0, 0.0), 0.0, 0.0, float3(0.0, 0.0, 0.0), float3(0.0, 0.0, 0.0), float3(0.0, 0.0, 0.0), 0.0};
    program_source:72:20: error: assigning to 'float3' (aka 'vector_float3') from incompatible type 'half3' (aka 'vector_half3')
    s_14.normalWorld = tmpvar_8;


    Any ideas ?
    Thanks.
     
    kenshin likes this.
  14. username_unity_of_my

    username_unity_of_my

    Joined:
    Feb 24, 2015
    Posts:
    330
    Hello!
    Can you tell me what graphics API are you using. IOS has problems building my shaders with metal. So if you are building for IOS can you please use OpenGL.
     
  15. Diomede

    Diomede

    Joined:
    Mar 10, 2015
    Posts:
    31
    Hi,
    Thanks for reply!.
    The problem is the graphics API, by switching to OpenGL shader works fine.
     
  16. kenshin

    kenshin

    Joined:
    Apr 21, 2010
    Posts:
    936
    Are you planning to update the package to work with metal?
     
  17. username_unity_of_my

    username_unity_of_my

    Joined:
    Feb 24, 2015
    Posts:
    330
    Hmmm...
    From unity blog:
    'When you create a new shader file (.shader) in Unity or edit existing one, we launch a “shader importer”. Just like for any other changed asset. That shader importer does some parsing, and then compiles the whole shader into all platform backends we support.'
    I'll have to see if compilation from shaderlab to metal will be fixed/improved by unity.
    I worked in HLSL a lot, I am not really experienced in metal.
    I'll keep an eye for solution other than switching to other API.
     
  18. kenshin

    kenshin

    Joined:
    Apr 21, 2010
    Posts:
    936
    Ok, great. Thanks!
     
  19. barrydineen

    barrydineen

    Joined:
    Jan 5, 2016
    Posts:
    9
    Just upgraded to 5.5 and it broke. Snarf snarf!!
     
  20. bufothejig

    bufothejig

    Joined:
    Nov 24, 2013
    Posts:
    13
    Love these shaders but 5.5 broke them for me as well. The code giving problems is :
    UnityLight mainLight = MainLight (normal);

    UnityLight light = AdditiveLight (normalWS, IN_LIGHTDIR_FWDADD(i), LIGHT_ATTENUATION(i));

    I am looking for a fix online but if anyone has ideas let me know. Gonna dig through the 5.5 release notes and see what changed.
     
  21. barrydineen

    barrydineen

    Joined:
    Jan 5, 2016
    Posts:
    9
    The MainLight function from UnityStandardCore.cginc took a parameter before which has now been removed:

    5.4.3 - UnityLight MainLight (half3 normalWorld)
    5.5 - UnityLight MainLight ()

    Likewise AdditiveLight() previously took three parameters and now only takes two.

    As for how to fix it - this is my first excursion into Shader code so I have no idea.
     
  22. barrydineen

    barrydineen

    Joined:
    Jan 5, 2016
    Posts:
    9
    Ok so i kind of got it working:

    - removed the parameter from all the MainLight() calls
    - removed the first parameter from all the AdditiveLight() calls
    - replaced oneminusroughness with smoothness everywhere
    - removed the parameter from all the DummyLight() calls

    I seems to work but I have no idea how much functionality I have just butchered!
     
  23. username_unity_of_my

    username_unity_of_my

    Joined:
    Feb 24, 2015
    Posts:
    330
    I submited DS shaders for version 5.5 and I done exaclty as you did.
     
  24. bufothejig

    bufothejig

    Joined:
    Nov 24, 2013
    Posts:
    13
    The fix worked for me as well. Thanks for the quick response!

    Love your shaders!
     
  25. barrydineen

    barrydineen

    Joined:
    Jan 5, 2016
    Posts:
    9
    Likewise I love these shaders - use them for all my single-sided vegetation.

    And if you decide some day to add translucency then this will be my all time favorite asset!
     
  26. username_unity_of_my

    username_unity_of_my

    Joined:
    Feb 24, 2015
    Posts:
    330
    Thank you guys!
     
  27. yakosan

    yakosan

    Joined:
    Jan 17, 2017
    Posts:
    2
    Hi Mario, I get 4 errors :

    Assets/_DoubleSidedShaders/Script/CameraScript.cs(104,24): error CS0117: `Cursor' does not contain a definition for `visible'
    Assets/_DoubleSidedShaders/Script/CameraScript.cs(105,24): error CS0117: `Cursor' does not contain a definition for `lockState'
    Assets/_DoubleSidedShaders/Script/CameraScript.cs(109,20): error CS0117: `Cursor' does not contain a definition for `visible'
    Assets/_DoubleSidedShaders/Script/CameraScript.cs(110,20): error CS0117: `Cursor' does not contain a definition for `lockState'

    any advice?

    Thank you

    Unity 5.6.0b3
    Mac OSX 10.11.6
     
  28. yakosan

    yakosan

    Joined:
    Jan 17, 2017
    Posts:
    2
    and :) is there a way to develop something for Text Mesh objects and Font Material?
     
  29. username_unity_of_my

    username_unity_of_my

    Joined:
    Feb 24, 2015
    Posts:
    330
    Hello!

    As I can see in your post, its Unity 5.6 beta. If there are errors in next version of Unity I'll update when its out of beta.
    Its not double sided shader related error, its one of the testing scenes cursor lock method.
    Hmmm, now I was looking through unity documentation of new Unity 5.6b and the Cursor is not changed since 5.5
    Unity 5.6b Cursor: https://docs.unity3d.com/560/Documentation/ScriptReference/Cursor.html
    Unity 5.5 Cursor: https://docs.unity3d.com/ScriptReference/Cursor.html
    We'll see when 5.6 is out of beta.
    As for fixing your current problem, you just delete/comment those lines.
     
  30. ValtechVR

    ValtechVR

    Joined:
    Feb 2, 2017
    Posts:
    2
    hello,

    First good job for the great package. Sadly, seems like I'm having shader compilation error in StandardDSCoreForward.cginc (line 137 & 138). I'm using unity 5.5.1f1 on windows

    invalid ps_2_0 input semantic 'VFACE'
    Compiling Fragment program with DIRECTIONAL
    Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING SHADER_API_DESKTOP UNITY_COLORSPACE_GAMMA (d3d9)

    semantic 'VFACE' unsupported on ps_4_0_level_9_1
    Compiling Fragment program with DIRECTIONAL
    Platform defines: UNITY_NO_SCREENSPACE_SHADOWS UNITY_ENABLE_REFLECTION_BUFFERS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING SHADER_API_MOBILE SHADER_API_DESKTOP UNITY_COLORSPACE_GAMMA (d3d11_9x)

    invalid ps_2_0 input semantic 'VFACE'
    Compiling Fragment program with POINT
    Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING SHADER_API_DESKTOP UNITY_COLORSPACE_GAMMA (d3d9)

    semantic 'VFACE' unsupported on ps_4_0_level_9_1
    Compiling Fragment program with DIRECTIONAL
    Platform defines: UNITY_NO_SCREENSPACE_SHADOWS UNITY_ENABLE_REFLECTION_BUFFERS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING SHADER_API_MOBILE SHADER_API_DESKTOP UNITY_COLORSPACE_GAMMA (d3d11_9x)

    That been said, visualy, seems like its working, but I get error also in Unity Cloud which make the build fail.

    Thank you in advance for any help you can provide me.

    Mykel
     
  31. username_unity_of_my

    username_unity_of_my

    Joined:
    Feb 24, 2015
    Posts:
    330
    You can ignore those messages.
    invalid ps_2_0 input semantic 'VFACE' gives warning that shader model 2.0 ( DirectX9) does not supports VFACE sematic - it is implemented since ps_3_0 ( shader model 3)
    semantic 'VFACE' unsupported on ps_4_0_level_9_1 also gives same warning on shader model 2.0 ( DirectX11 - feature level of DirectX9 shader model 2)
    It is stated in the description that this shaders require shader model 3.0 or higher.
    As for Unity Cloud build faild, try to disable building for shader model 2.
     
  32. ValtechVR

    ValtechVR

    Joined:
    Feb 2, 2017
    Posts:
    2

    Mmmm that interesting, thank you for the reply, regarding unity cloud, do you know by any chance how I could achieve that?
     
  33. username_unity_of_my

    username_unity_of_my

    Joined:
    Feb 24, 2015
    Posts:
    330
    Im sorry, I haven't worked with Unity Cloud. I just ignore messages :/
    Try messing with:
    - click on shader
    - click on 'compile and show code' - little arrow next to the text.
    - try disabling compile platforms you dont use.
     
  34. Steva

    Steva

    Joined:
    Sep 9, 2010
    Posts:
    60
    Hi,

    i'm having a problem with the StandardDoubleSided shader not rendering correctly on a laptop with a GTS 250m (dx 10.1). This is what i see:

    sds_error.png

    This is what is should be seeing:

    sds_ok.PNG

    Any help as to what might cause this problem is much appreciated.

    Edit: the problem appears only with deferred rendering
     
    Last edited: Feb 17, 2017
  35. username_unity_of_my

    username_unity_of_my

    Joined:
    Feb 24, 2015
    Posts:
    330
    Hello, can you contact me on email so we can disscuss more on this?
     
  36. Steva

    Steva

    Joined:
    Sep 9, 2010
    Posts:
    60
    I've sent an email to the contact on your site
     
  37. Weblox

    Weblox

    Joined:
    Apr 11, 2016
    Posts:
    277
    Hi, I am getting an error .

    Shader error in 'DoubleSided/Standard/StandardSpecularDoubleSided': failed to open source file: 'StandardDSCoreForward.cginc' at line 88 (on d3d11)

    Compiling Vertex program with DIRECTIONAL SHADOWS_SCREEN _EMISSION _NORMALMAP _DETAIL_MULX2
    Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING SHADER_API_DESKTOP

    Any help is much appreciated. Thanks in advance
     
  38. username_unity_of_my

    username_unity_of_my

    Joined:
    Feb 24, 2015
    Posts:
    330
    Hello, can you please contact me on email.
     
  39. kenshin

    kenshin

    Joined:
    Apr 21, 2010
    Posts:
    936
    Hi,
    in unity 5.6 the shader doesn't work.
    Please, can you fix it?
    Thanks in advance,
    Kenshin
     
  40. username_unity_of_my

    username_unity_of_my

    Joined:
    Feb 24, 2015
    Posts:
    330
    I'll update shaders after Unity 5.6 goes out of beta. Its still 5.5.2 when you download Unity as latest.
     
    Last edited: Mar 29, 2017
  41. kenshin

    kenshin

    Joined:
    Apr 21, 2010
    Posts:
    936
    Ok.

    If I am not wrong 5.6 will released next week; currently is really stable.
     
  42. kenshin

    kenshin

    Joined:
    Apr 21, 2010
    Posts:
    936
  43. username_unity_of_my

    username_unity_of_my

    Joined:
    Feb 24, 2015
    Posts:
    330
    kenshin likes this.
  44. kenshin

    kenshin

    Joined:
    Apr 21, 2010
    Posts:
    936
    Thanks a lot!!!
     
    username_unity_of_my likes this.
  45. Jick87

    Jick87

    Joined:
    Oct 21, 2015
    Posts:
    124
    Hello.

    We just purchased this asset today.

    It seems to work for the most part, but we were noticing one issue while using the newer Post Processing Stack. It seems any effects used from that appear on top of any materials set to use the double-sided shader. They only appear on the back faces (which would normally be invisible with the unmodified standard shader). The front faces look fine. Only if you view from the back faces can you see the post processing effects showing on top. One good effect to highlight it is Ambient Occlusion.

    We're not sure where the issue lies specifically, so we figured we would ask to see if you had any ideas.

    EDIT: Just tried with the demo scene included with this asset and I can see the issue there as well, so I guess it's not an issue with just my particular scene. You can find the quick start guide for the Post Processing Stack here if you want to see for yourself.

    Thanks!
     
    Last edited: Apr 10, 2017
  46. username_unity_of_my

    username_unity_of_my

    Joined:
    Feb 24, 2015
    Posts:
    330
    If any of the post processing effect are using its own depth pass and do not use vface semantic for double sidedness then depth of backface would not be written and it would be ignored. Does that happen in forward of deferred - maybe, if you are using deferred path pp effect will use depth from gbuffer which will have correct depth on backfaces.
     
  47. Jick87

    Jick87

    Joined:
    Oct 21, 2015
    Posts:
    124
    We are currently using forward rendering because it was needed for our project. Is there any way to make it work in forward?

    Thanks!
     
  48. username_unity_of_my

    username_unity_of_my

    Joined:
    Feb 24, 2015
    Posts:
    330
    In that case you need to implement doublesidedness in pp effect depth pass manually :/

    EDIT: In case of writing depth, you just need to add cull none line to depth pass - no need for lighting and vface semantic.
     
    Last edited: Apr 12, 2017
  49. ProjectBarBar

    ProjectBarBar

    Joined:
    Jan 28, 2017
    Posts:
    7
    Hi, I am developing android and ios application by Unity3D.
    I purchased your asset to make a texture be a 'double-sided with alpha'.
    Finally "DoubleSided/Legacy Shaders/Cutout/Bumped Specular" has been selected.

    With Android there is no problem, however there is a problem when
    building application in ios.

    In Unity Editor of OSX(Macbook air) there is no issue. See the attached picture.
    The light is good and double-sided alpha is also working.

    The issue is the screenshot of application played in IPAD Mini Retina 2.
    The picture has shader of "DoubleSided/Legacy Shaders/Cutout/Bumped Specular"
    is too dark to see the content of itself.

    It is weired that difference of shading between Unity Editor of OSX
    and application of iOS.

    There are some pictures you can check out.
    If you have any solution, plz reply to me.

    Thanks.
     

    Attached Files:

  50. jStinson

    jStinson

    Joined:
    May 9, 2017
    Posts:
    21
    Thanks for the shaders, they've been working well for our project, but we're getting some strange behavior after upgrading to Unity 5.6.1. The shader will compile with an error and render the default purple intermittently. One of our engineers has been looking into the issue and we can get it working (sans attenuated light unfortunately) by commenting out the following:

    Code (CSharp):
    1. // UnityLight light = AdditiveLight( IN_LIGHTDIR_FWDADD(i), LIGHT_ATTENUATION(i)); from  line 129 of StandardDSCoreForward.cginc and replacing it with UnityLight list = MainLight();
    Do you have any plans to update the shaders for 5.6.1?

    Thanks!