Search Unity

lightmapped/specular shader - Paid

Discussion in 'Scripting' started by kondrup, Mar 11, 2011.

  1. kondrup

    kondrup

    Joined:
    Apr 23, 2009
    Posts:
    205
    Hi,

    I recently posted my problem in the 'shaderlab-section' and I was adviced to post it in here as well.
    I have made a video showing my problem - hope it's clear what's going on.

    http://coindrop.dk/shadervideo/shader.html

    Here's a short descibtion of the issue we are having.

    We just recently converted to unity 3.2 - and discovered that all our lightmapped/specular materials did not have any specular highlight - we have tried changing the specular shader by downloading the build in shaders but it seems like the legacy shaders are locked somehow?

    I see 2 solutions.

    1. If it is possible to search through all materials somehow and check if the material is using legacy/lightmapped/specular shader and then change the shader to another one.

    2. Unlocking the legacy/lightmapped/specular shader somehow and making it WORK again, like in the good old days :)

    We have at least 10.000 materials using this lightmapped/specular shader, so converting them manually is not an option

    We are willing to pay at least 100$ for a solution that works.

    any advice?
     
  2. Frank Oz

    Frank Oz

    Joined:
    Oct 13, 2010
    Posts:
    1,560
    $100 eh, bugger wish one of my previous suggestions had worked. That would have covered PlayMaker for me hehe.

    Actually watching your video. I'm beginning to side with those who say its a bug, cause that shouldn't to my knowledge, be happening. (the whole not being able to replace those with edited ones). You should report it, that ain't right IMO.
     
  3. kondrup

    kondrup

    Joined:
    Apr 23, 2009
    Posts:
    205
    200$ - anybody? Getting kinda desperate here.

    I cannot understand why this error/bug has slipped through - since the lightmapped shaders are some of the most important shaders?
    Also you can create much better lightmaps using Vray (for interior for example), so I don't understand why the lightmapped shaders should suddenly be hidden away in the legacy category. I guess they have their reasons.

    EDIT: I have posted the job at getafreelancer, so for now the 200$ are on hold :)
     
    Last edited: Mar 17, 2011
  4. Dover8

    Dover8

    Joined:
    Aug 20, 2010
    Posts:
    94
    You can change the shader of any game object at runtime, so it would just be a case of having this run through all gameobjects you wanted to check at start up/loading.


    Code (csharp):
    1.  
    2. var oldShader : Shader = Shader.Find("Legacy Shaders/Lightmapped/Specular");
    3. var newShader : Shader = Shader.Find("test");
    4.  
    5. for(var go:GameObject in /*where-ever you need to check*/)
    6.         ChangeShader(go.transform);
    7.  
    8. private function ChangeShader(t:Transform){
    9.     if(t.renderer != null  t.renderer.materials.length > 0){
    10.         for(var m:Material in t.renderer.materials){
    11.             if(m.shader == oldShader){
    12.                 m.shader = newShader;
    13.             }
    14.         }
    15.     }
    16. }
    17.  

    Edit: Just been testing this and the comparison doesn't even seem to work anymore on the Legacy shaders, changed the code to compare their string representations

    Code (csharp):
    1.  
    2.             if(m.shader.ToString() == oldShader.ToString()){
    3.  
     
    Last edited: Mar 18, 2011
  5. bigmisterb

    bigmisterb

    Joined:
    Nov 6, 2010
    Posts:
    4,221
    Stick Dover8's example in a OnDrawGizmos() function on a test object, and let it work for a few frames and it will fix everything in your scene at edit time.
     
  6. kondrup

    kondrup

    Joined:
    Apr 23, 2009
    Posts:
    205
    Hi, I am not sure I understand it correctly but wouldn't this require the assets to be present in a scene?
    Our asset are located in folders and are built to asset bundles.
     
  7. multivac

    multivac

    Joined:
    Oct 27, 2009
    Posts:
    133
    hmm, just to exhaust the easier options, try to remove the fallback from the specular shader. It should display spec, but seems to fall back to diffuse one.
     
  8. kondrup

    kondrup

    Joined:
    Apr 23, 2009
    Posts:
    205
    Maybe there is a work around but I did not find it.. well anyway I just received the script from our freelancer and it seems to work.

    - if someone is interested in this script we could maybe put it on asset store for a very reasonable price - maybe 5-10$ (we paid 100$)
    - I will have to ask my boss about it, since he was the one paying ;)
     
  9. Dover8

    Dover8

    Joined:
    Aug 20, 2010
    Posts:
    94
    We load everything in to our game at runtime from asset bundles, the code I have written above is now in use to remove lightmaps from our assets if the user is playing at a higher graphics setting (which includes real time lights).
     
  10. kondrup

    kondrup

    Joined:
    Apr 23, 2009
    Posts:
    205
    @Dover8 - Ahhh alright. Could be useful if we made the project for Iphone. - thanks
     
  11. Schlumpfsack

    Schlumpfsack

    Joined:
    May 30, 2010
    Posts:
    608
    wouldn't that be reselling?
     
  12. Dover8

    Dover8

    Joined:
    Aug 20, 2010
    Posts:
    94
    This is exactly what my code does
     
  13. kondrup

    kondrup

    Joined:
    Apr 23, 2009
    Posts:
    205
    Yeah, but we needed it to be done not runtime :)
     
  14. Dover8

    Dover8

    Joined:
    Aug 20, 2010
    Posts:
    94
    Ah right, well I could make it into an editor script I am sure, but if you have a solution now I won't bother.
     
  15. kondrup

    kondrup

    Joined:
    Apr 23, 2009
    Posts:
    205
    @dover8 - Yeah the script worked nicely, so you don't have to work overtime to help us, but thanks a lot for all the advice.
    - We have talked about just giving the script away for free, since we have enjoyed this forum and all the helpful advice/shaders/scripts and not to mention all the people in here - now it's pay back time :)