Search Unity

Marmoset Skyshop - Image-Based Lighting Tools [RELEASED]

Discussion in 'Assets and Asset Store' started by monkeyscience, May 31, 2013.

Thread Status:
Not open for further replies.
  1. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Monkeyscience,

    I am wondering why it takes so long to compile skyshop shaders? if I change something in the shader file or include file it usually takes very long time to even start compiling the shader, and then when it does, it takes long time to compile too.

    I thought it could be some kind of dependency isssue and Unity trying to figure out which shader needs to be compiled, but I tried to delete all other skyshop shaders except one and it still takes way too long.

    I know you have mentioned somewhere that releasing skyshop shaders with precompiled versions to reduce compile time for us, so I was wondering some more information regarding to this. When you develop shaders for Skyshop do you also have this long delay between tweaking something in the shader and waiting for it to compile inside Unity? How do you get around this?

    thanks.
     
  2. monkeyscience

    monkeyscience

    Joined:
    Dec 13, 2011
    Posts:
    705
    This is also probably true. Unity renders direct lights in additional passes, so its entirely possible the shader won't have any overhead if there are no direct lights present or hitting the materials in question.
     
  3. monkeyscience

    monkeyscience

    Joined:
    Dec 13, 2011
    Posts:
    705
    Yes and it is the worst >_<. You can get around it by moving shaders you aren't working on out of the Assets/ folder. If you are importing Skyshop into a project, the first thing you should do is uncheck shaders you don't want, Terrain/ directory, Mobile/ directory, etc.

    Unity builds all permutations of every shader (lightmaps, no lightmaps, shadows, no shadows, etc) for every platform and every rendering path at import-time. This times the 40+ shaders in Skyshop, times 2 for gamma and linear space = a ridiculous amount of shader code to churn through.

    Unity shader wizards tell me they have made leaps and bounds in improving compile times, caching shaders that haven't changed, etc. All due out in Unity 4.3.
     
  4. OH NO

    OH NO

    Joined:
    Oct 16, 2013
    Posts:
    14
    Hi MonkeyScience, its a real charm to work with Skyshop. 1 question tho..do you you know when you can release ur next planned update or can you tell me how to implement the BPCEM into the occlusion bumped specular shader ( which almost covers all my needs in a shader) ?

    Any news of the UBER shading for the next Unity Version ?

    Monkey you doing just an amazing work. BLESS THE MONKEY !! :D

    have a good weekend
     
  5. Charkes

    Charkes

    Joined:
    Apr 17, 2013
    Posts:
    228
    Maybe you already now this but It works also with DX9 with : MyCubemap.SmoothEdges(SizeOfEdges);

    http://docs.unity3d.com/Documentation/ScriptReference/Cubemap.SmoothEdges.html

    Works well for me but maybe it will erase your generated mips, not sure.
     
  6. tripknotix

    tripknotix

    Joined:
    Apr 21, 2011
    Posts:
    744
    So whats the best way to speed this process up currently other than waiting for unity 4.3, Overclocking/more cores, is it even multi-threaded shader compiling? or is it a hard drive bottleneck where a faster ssd needs to be involved? =X
     
  7. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Removing shaders outside Asset folder etc didn't help much for me. Instead, what I did was I made shader to compile only either to the linear or gamma space depends on what my project setting is. And then only compile to the platform you are working on. This made compile process much faster. I guess when you are done with the modifying the shader, then just put the options back.

    I too, am waiting for 4.3 release. There are many interesting features that I am waiting for. One of them is Uber shader. Should have applied for beta. :)
     
  8. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    909
    i have look for terrain shader on mobile on last log he say works for no terrain model and i no see normal map is apply
     
  9. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    MonkeyScience

    I have issue with skydome with my builds.

    It doesn't matter if I do webplayer build or pc stand alone build, the sky rotation is messed up.
    It looks like setting the skymatrix is somehow messed up, because all the shaders also trying to use the messed up sky rotation.

    I have no idea what can possibly cause this, because it works fine inside Unity Editor. (both in scene and game window)

    $SSR15.jpg

    Edit : I have just tried commenting out part of the sky shader that takes skymatrix and it works fine in builds so skymatrix is definitely the cause. I have never touched that part of the code so I am not sure what it could be. I will say this again, it works fine inside Editor.
     
    Last edited: Nov 12, 2013
  10. monkeyscience

    monkeyscience

    Joined:
    Dec 13, 2011
    Posts:
    705
    Couple of things I can think of:
    - Does calling Sky.ApplySkyTransform() manually fix it? This should get called from Sky.Update every frame but in Unity 4.1+ it is predicated on:
    Code (csharp):
    1. if( transform.hasChanged )  ApplySkyTransform();
    - Is your sky object active in the hierarchy at runtime? If not the matrix setting code might not be run (the Unity editor would still have stale matrix data bound to the shader).
    Code (csharp):
    1.  
    2. public void ApplySkyTransform() {
    3.         #if UNITY_3_5
    4.             if( this.enabled  this.gameObject.active ) {
    5.         #else
    6.             if( this.enabled  this.gameObject.activeInHierarchy ) {
    7.         #endif
    8.                 skyMatrix.SetTRS(Vector3.zero,transform.rotation,Vector3.one);     
    9.                 Shader.SetGlobalMatrix("SkyMatrix", skyMatrix);
    10.             }
    11.         }
    12.  
    - Do you have anything else that might be binding data to a shader uniform named "SkyMatrix"? Maybe something is overwriting the shader global.
     
  11. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    909
    any info about terrain shader please it's very interessing
     
  12. wensk

    wensk

    Joined:
    Aug 9, 2012
    Posts:
    24
    Hi, Monkeyscience, I am wondering how to render color map in 3dsmax 2013? I know your tutorial talked about make color map with ddo in photohop, but how to get it with vray render? It's seems not diffuse map or complete map. Because the color map without any light information. thank you !
     
    Last edited: Nov 12, 2013
  13. Knil

    Knil

    Joined:
    Nov 13, 2013
    Posts:
    66
    Skyshop is throwing some warnings with Unity 4.3 and having some memory leaking issues causing crashing.
     
  14. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    I will check but yes I am using the latest version of Unity. Strange thing is they work fine in Editor , (game running) Just doesn't work in builds. Is there any specific build setting I need to be aware of when I use SkyShop?

    Edit : Ok, I have made break through after countless building of the scene. Basically, I am setting few of my own Matrices from within OnRenderImage function. Obviously, the matrix names are not the same as SkyMatrix. It was not as simple as that. FOR SOME REASON, when you do this inside OnRenderImage function it some how corrupts the SkyMatrix. I have no idea why and how it can ever even touch SkyMatrix at all. Because first of all the names are totally different and it seems to work if I move my own matrices setting code into Update instead. And error ONLY occurs in builds not inside Unity. My wild guess is that for some reason if you set global Matrix in OnRenderImage function it overrides the previous matrix placement reserved by the SkyMatrix setting. I think this could potentially be Unity bug, or some kind of Unity behaviour that is not documented at all. Very strange!
     
    Last edited: Nov 13, 2013
  15. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    829
    Sorry if I have missed any developments over the past month.

    Around the time of the initial release of Skyshop, there was a question from multiple users, asking about potential support of multiple cubemap sets distributed through environment probes. That would have allowed us to have quite precise contextual image-based lighting that stays correct as you travel through multiple different rooms or varied outdoor scenery.

    What I'm talking about is support of multiple HDR cubemaps being distributed from certain points (probes) to any surrounding object using Marmoset shaders, in a manner similar to how omnidirectional lights illuminate stuff around them; with distributed reflections fading between multiple cubemaps as an object travels from one area of influence to another.

    Case in point: CryENGINE implementation of reflections:
    http://docs.cryengine.com/display/SDKDOC2/Environment+Probes

    There, you essentially drop some probes around the level, set up their area of influence (hard mode: box projection with XYZ influence area instead of a spherical projection with a radius), press Bake and voila, there are HDR cubemaps generated and you've got some beautiful contextually correct lighting.

    Marmoset folks mentioned they were looking into the possibility of something like that long time ago. Were there any developments on the matter since, or the product is still best used for homogenous environments and object showcases using only one cubemap?
     
  16. kurylo3d

    kurylo3d

    Joined:
    Nov 7, 2009
    Posts:
    1,123

    I would also like to know this.
     
  17. monkeyscience

    monkeyscience

    Joined:
    Dec 13, 2011
    Posts:
    705
    I am working towards box projection and multiple cubemaps (per object instead of per material) for the next release. There are a few hairy problems left to solve that I may not get to this time around:
    - HDR cubemap rendering (aaalmost got it!)
    - Unity Free cubemap rendering (existing solutions are quite hacky)
    - Spatial interpolation (figuring out which cube to bind when)
     
  18. kurylo3d

    kurylo3d

    Joined:
    Nov 7, 2009
    Posts:
    1,123
    Very exciting!
     
  19. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,467
    Will I still have the use HDR Light Studio? If not you just saved me a TON of scratch... will skin shaders be also a part of the next release? (I finally downloaded 4.3)
     
  20. someunityguy

    someunityguy

    Joined:
    Jun 28, 2011
    Posts:
    35
    Curious if this offers the same workflow as toolbag 2.0
    or are they radically different ?
     
  21. monkeyscience

    monkeyscience

    Joined:
    Dec 13, 2011
    Posts:
    705
    I am not sure what you are asking. Could you please elaborate or send screenshots?
     
  22. monkeyscience

    monkeyscience

    Joined:
    Dec 13, 2011
    Posts:
    705
    This falls into the category of content creation and I am by no means an environment artist or 3dsmax expert :p.

    The color map is nothing precise, just a layer of large-scale noise and variance you can paint into your terrain to keep things from looking too tiled or uniform green/brown/gray in the distance. Hand-painting it would be totally acceptable; you can even render photoshop clouds into it and hide tiling pretty well.
     
  23. monkeyscience

    monkeyscience

    Joined:
    Dec 13, 2011
    Posts:
    705
    Maybe shader vars have to be set again if you are invoking your own draw calls for render to texture type stuff. Try calling ApplySkyTransform() in various places and see if it helps.
     
  24. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    829
    Incredible news, glad to hear it's being worked on and can't wait. :)
     
  25. monkeyscience

    monkeyscience

    Joined:
    Dec 13, 2011
    Posts:
    705
    The tech in Skyshop is somewhere between Toolbag 1.0 and 2.0. Things like fresnel falloff behave more like Toolbag 1 and some of the new PBR features like metalness, specular dimming diffuse intensity, and anisotropic shaders are not in Skyshop. Otherwise responses from diffuse, specular and gloss maps are going to look very similar to both Toolbag 1 and 2.

    Once TB2 ships, I am going to focus on how best to bring the rest of our cool new tech to Unity :).
     
  26. stevesan

    stevesan

    Joined:
    Aug 14, 2011
    Posts:
    65
    Running into what seems like a bug: I like having Sky objects that I tune for certain environments, and I want to use them in other scenes. However, whenever I create a prefab out of a Sky object, it seems to get corrupted or something and never works. Any idea on this? Cheers!
     
  27. dzodzu

    dzodzu

    Joined:
    Nov 25, 2012
    Posts:
    46
    Yup, same here, making a prefab from sky object just doesn't work correctly.
    It breaks the sky object.. so bye bye your sky setup..
     
    Last edited: Nov 14, 2013
  28. dzodzu

    dzodzu

    Joined:
    Nov 25, 2012
    Posts:
    46
    Last edited: Nov 14, 2013
  29. patricr_ms

    patricr_ms

    Joined:
    Jul 8, 2013
    Posts:
    1
    Sorry if this is answered somewhere else... I'm working on mobile shaders with D3D11_9x as the min spec. This means I can't use texCUBElod and must use texCUBEbias. However, there is a pretty big quality drop:

    $bias_vs_lod.jpg

    From what I can see there are two problems:
    1. Mip selection (and thus gloss selection) is viewing angle-dependent.
    2. No filtering between mip levels.
    Is there any way to make these less offensive? Ideally I'd like to be able to eliminate both problems.

    Thanks!

    Jesse
     
  30. PureSpider

    PureSpider

    Joined:
    Oct 25, 2013
    Posts:
    3
    How would I go on and combine the custom shader Zombiegons is using in his "Concrete Building Exterior" pack (https://www.assetstore.unity3d.com/#/content/2088) with skyshop's shaders?
    I have been trying to do it the entire day to no avail.
     
  31. toby29

    toby29

    Joined:
    Sep 8, 2012
    Posts:
    15
    Hi can anybody help me with regards to the update of unity 4.3? I'm pretty sure it has broken the marmoset grass shader. You can see the differences in the pictures below, the 1st is from 4.2 and second from 4.3. (Ignore the trees they are not set of properly)
    If anybody can be of any help it would be greatly appreciated $Marmo_001Capture.JPG $Marmo_002Capture.JPG
     
  32. stuckon3d

    stuckon3d

    Joined:
    Nov 9, 2013
    Posts:
    7
    is there a way to tile the specular map with a different value than the diffuse. Right now now both my specular and normal tiles are locked to the diffuse value. and the offset dials are not working at all. Is this broken. I'm using unit4.2 and the shader is marmoset/bumped specular.

    thank you
     
  33. toby29

    toby29

    Joined:
    Sep 8, 2012
    Posts:
    15
    After looking at the terrain trees they also seem to have been effected by the update
     
  34. CodWag

    CodWag

    Joined:
    Nov 15, 2013
    Posts:
    1
    Hi, I'm trying to get marmoset to work with movieTexture and alpha, but without success so far.
    Since movieTexture doesn't come with alpha I'm using the method of having a movieTexture with double height (diffuse on top, alpha on bottom).
    The problem is I can't find the right place (or places?) to manipulate the alpha.
    I've tried duplicating the "Transparent/Marmoset Diffuse IBL" and adding a new define and manipulating stuff in the input,direct and surf files, but nothing changes (except an occational hotpink when I've done something wrong)

    Before trying to make this new shader, I started with this shader and script (taken from some thread here) and they worked perfectly in a project without marmoset, but only render black in one with it. If someone spots something in them that could solve it as well, that'd be great, I don't need fancy rendering for the objects using this :)
    Code (csharp):
    1. Shader "Transparent/SplitAlpha"
    2. {
    3.     Properties
    4.     {
    5.         _MainTex ("Base (RGB)", 2D) = "white" {}
    6.         _Mask ("Culling Mask", 2D) = "white" {}
    7.         _Cutoff ("Cutoff", Range (0,1)) = .5
    8.     }
    9.    
    10.     SubShader
    11.     {
    12.         Tags
    13.         {
    14.             "Queue"="AlphaTest"
    15.             "IgnoreProjector"="True"
    16.             "RenderType"="TransparentCutout"
    17.         }
    18.        
    19.         Pass
    20.         {
    21.             CGPROGRAM
    22. // Upgrade NOTE: excluded shader from OpenGL ES 2.0 because it does not contain a surface program or both vertex and fragment programs.
    23. #pragma exclude_renderers gles
    24. // Upgrade NOTE: excluded shader from OpenGL ES 2.0 because it does not contain a surface program or both vertex and fragment programs.
    25. //#pragma exclude_renderers gles
    26.             #pragma fragment frag
    27.             #include "UnityCG.cginc"
    28.            
    29.             sampler2D _MainTex;
    30.             sampler2D _Mask;
    31.            
    32.             struct v2f
    33.             {
    34.                 float4 pos : POSITION;
    35.                 float4 uv : TEXCOORD0;
    36.                 float4 uv2 : TEXCOORD1;
    37.             };
    38.            
    39.             half4 frag (v2f i) : COLOR
    40.             {
    41.                 half4 color = tex2D(_MainTex, i.uv.xy);
    42.                 half4 color2 = tex2D(_Mask, i.uv2.xy);
    43.            
    44.                 return half4(color.r, color.g, color.b, 0);
    45.             }
    46.             ENDCG
    47.         }
    48.     }
    49.    
    50.     Fallback "Transparent/Diffuse"
    51. }
    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class AlphaMoviePlayer : MonoBehaviour
    5. {
    6.     private MovieTexture mask;
    7.  
    8.     void Awake ()
    9.     {
    10.         mask = (MovieTexture)renderer.material.GetTexture("_Mask");
    11.         mask.loop = true;
    12.     }
    13.    
    14.     void OnEnable ()
    15.     {
    16.         mask.Stop();
    17.         mask.Play();
    18.     }
    19. }
    //CodWag
     
  35. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,467
    Hey Monkeyscience... Is there a way to enable shadows for the transparent shaders for all lights in the scene? I fixed the flickering in the shader, but shadows are the only thing missing...
     
  36. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    909
    $5jRiQ.jpg
    terrain shader
     
  37. Sargonius

    Sargonius

    Joined:
    Nov 18, 2013
    Posts:
    15
    Hello!
    Is there a solution for using Skyshop with alpha-channel reflection?
     
  38. Spartan_Boy

    Spartan_Boy

    Joined:
    Jul 8, 2012
    Posts:
    38
    Hey Monkeyscience, just bought your package this afternoon and it is tremendous, i guess we ran into some issues displayed in this whole thread but overall very stable with our scenes. For those interested Marmoset 1.04+Unity+Vuforia AR 2.6 is a total winner, we still have things to tweak here and there but this is just gorgeous rendering, can't wait to test the lightmapping and cubemaps on specific targets. Really awesome package. Keep up the good work!
    [...]
    Couldn't help getting my hands on skyshop+beast tonight, is the lightmapping txt in the doc the only ressource in the package ? If so do you intend to put a small tut on weighting ibl with beast lightmapper?
    THX, getting back there.
     
    Last edited: Nov 18, 2013
  39. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462

    Very Cool, Skyshop is just getting more and more Awesome. It really deserves the Tech Innovation award once again.

    Cheers.
     
  40. maart

    maart

    Joined:
    Aug 3, 2010
    Posts:
    82
    Hi Monkey,

    is there allready a way to do tiling in skyshop? I really need it
     
  41. monkeyscience

    monkeyscience

    Joined:
    Dec 13, 2011
    Posts:
    705
    Interesting, I'll take a look at this.
     
  42. monkeyscience

    monkeyscience

    Joined:
    Dec 13, 2011
    Posts:
    705
    Yeah, texCubeBias kinda sucks :-(. As far as I can tell there's not much you can do with just one bias value to set an exact mip level.

    texCubeGrad lets you specify the dx and dy geometry gradients that control view-angle dependence. No idea if d3d11_9x has any support for it or if Unity exposes it. http://msdn.microsoft.com/en-us/library/windows/desktop/bb509689(v=vs.85).aspx

    Trilinear filtering filters between mip levels but might not be working on cubemaps, which would be a Unity bug/short-coming. Might be a good thing to bug-report actually :).

    As a work-around, my suggestion would be to bake a specular cube without a mipmap chain. You can bake a couple of them with different gloss levels and use them as custom spec cubes per material. Its not as nice as having per-texel gloss but probably better than cubeBias.
     
  43. monkeyscience

    monkeyscience

    Joined:
    Dec 13, 2011
    Posts:
    705
    No unfortunately this is expected behavior. All the textures tile based on the diffuse map settings. Unity's texture tiling happens in the vertex shader and there are not enough vertex interpolants to get the tiled UVs over to the fragment shader.

    I've seen other third-party shaders get around this with their own tiling vars and applying the tiling math in the fragment shader instead. Haven't gotten around to doing this to ours yet though.
     
  44. monkeyscience

    monkeyscience

    Joined:
    Dec 13, 2011
    Posts:
    705
    See the above post. You can tile but the diffuse, specular, and normalmaps all tile based on the tiling/offset settings of the diffuse map.
     
  45. monkeyscience

    monkeyscience

    Joined:
    Dec 13, 2011
    Posts:
    705
    Yeah, it sounds like the terrain and vegetation shaders are broken since 4.3 :(. I'll take a look at it asap.
     
  46. Autarkis

    Autarkis

    Joined:
    Oct 10, 2011
    Posts:
    318
    Is it possible to use a regular lightmap into one of the occlusion shaders so I can get detailed lighting ( lights with .ies profiles inside of studio max.) instead of just ambient occlusion?
    The docs state that it just masks off ambient lighting/spec in the alpha of the occlusion map.
    Any clue as to what I could achieve what I am looking for?

    Thanks MonkeyScience ( and anyone who might help me finding out that answer!)
     
  47. monkeyscience

    monkeyscience

    Joined:
    Dec 13, 2011
    Posts:
    705
    If I understand correctly, you want to take a lightmap baked in max (lit with or without .ies lights) and use them in Unity. Currently there are no Marmoset shaders that let you do this. Using Occlusion shaders won't really work. Lightmaps have to be added to the lighting results, but occlusion, being basically a shadow, has to mask lighting.

    I would recommend using Beast to bake lighting in Unity if you have Pro, and using a light-gel texture on Unity spotlights to mimic the effect of .ies. It won't be a volumetric shadow like true ies would cast, but will get you close. Lightmaps are big blurry pixelated things anyway, all the subtlety of .ies will be lost in a game-ready bake.

    For those who don't know what .ies profiles are, they are this, and they are awesome! :)
     
  48. Autarkis

    Autarkis

    Joined:
    Oct 10, 2011
    Posts:
    318
    Thanks MS, I really appreciate the time that you took to reply. Is there any plans in the future to create a marmoset shader that would let users import their own lightmaps? It would be really useful for the portion of us that are doing some real time arch viz with Unity + Skyshop :)
     
  49. monkeyscience

    monkeyscience

    Joined:
    Dec 13, 2011
    Posts:
    705
    Yea that would be pretty cool and relatively straight-forward. Right now every new shader type I create adds to the headache of shader management and compile times. Once I clean up the base platform a bit (uuuuber shaders!) I can add this as well.
     
  50. Autarkis

    Autarkis

    Joined:
    Oct 10, 2011
    Posts:
    318
    Thanks for keeping it in my mind for a future upgrade of skyshop. You guys are great!

    And another question,
    Im running my scene in deferred rendering to get dynamic shadows, every single object that has a skyshop object shader applied to it refuses to catch/receive shadows. I checked the shader codes, and they are the latest version ( and have the fullforwardshadows line in their shader files. At a complete loss of what to do.
    Did anyone run into an issue with skyshop and unity 4.2 ( can't upgrade to 4.3 yet - maybe the error would go away with an upgrade?)
     
    Last edited: Nov 20, 2013
Thread Status:
Not open for further replies.