Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

noob question

Discussion in 'Shaders' started by Unclet, May 10, 2007.

  1. Unclet

    Unclet

    Joined:
    Apr 12, 2007
    Posts:
    92
    I am trying to get a light baked texture to work with a detail texture overlay -- no such animal in the standard assets, but I found something that seems perfect on the Wiki :

    Code (csharp):
    1.  
    2. Shader "Baked Lighting/Detail Texture" {
    3. Properties {
    4.     _MainTex ("Base (RGB)", 2D) = "white" {}
    5.     _Detail ("Detail (RGB)", 2D) = "gray" {}
    6. }
    7.  
    8. Category {
    9.     // Bind per-vertex color for use
    10.     BindChannels {
    11.         Bind "Color", color
    12.         Bind "Vertex", vertex
    13.         Bind "TexCoord", texcoord
    14.     }
    15.    
    16.     // Two texture cards: main and detail texture
    17.     SubShader {
    18.         Pass {
    19.             SetTexture [_MainTex] { Combine texture * primary }
    20.             SetTexture [_Detail] { Combine previous * texture DOUBLE, previous }
    21.         }
    22.     }
    23.    
    24.     // Single texture cards: only main texture
    25.     SubShader {
    26.         Pass {
    27.             SetTexture [_MainTex] { Combine texture * primary }
    28.         }
    29.     }
    30. }
    31.  
    32. }
    Except it doesn't work when I try to build a shader using this code. The shader appears as "Default" in the shader list and no params are exposed. Hmm. So I tried to build some of the other shaders on the Wiki, some work, some, same problem. Is this because I only have an indie license? Or am I doing something wrong?

    I doubled checked that no funky characters were getting into pasted source, and that I used the correct extension, etc. Beyond that I'm stumped!

    Tia,

    -- Bo
     
  2. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    What errors are printed into the Unity console? (at the bottom of the screen, clicking on the red icon opens the full console)
     
  3. Unclet

    Unclet

    Joined:
    Apr 12, 2007
    Posts:
    92
    none, but when I try to run it with the boogered up shader attached to something, I get the red X without an error message(!)
     

    Attached Files:

  4. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    Ok, how are you creating the shader?

    It should go like this:
    1. Assets -> Create -> Shader
    2. Double click the created shader file in Project view (by default it's named "New Shader")
    3. Paste the text, save. There should be no errors at this point.
    4. Now in some of your materials, you select the shader from the popup.
     
  5. Unclet

    Unclet

    Joined:
    Apr 12, 2007
    Posts:
    92
    That's exactly how I am doing it. It just doesn't work! Shader comes up "Default" in the list, parameters are not exposed, and it doesn't work. :(

    Thanks for your help...
     
  6. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    Can you send the project folder with this problematic shader via Report Bug.app?
     
  7. Unclet

    Unclet

    Joined:
    Apr 12, 2007
    Posts:
    92
    Sure thing...
     
  8. Unclet

    Unclet

    Joined:
    Apr 12, 2007
    Posts:
    92
    ... sending now -- I stripped out most of the extraneous material from the project folder, but verified that the problem still persists in the stripped down version.

    Thanks...
     
  9. Unclet

    Unclet

    Joined:
    Apr 12, 2007
    Posts:
    92
    Just to follow up, in case others run into the same snafu:

    Problem turned out to be extraneous invisible characters that snuck into the code when copying and pasting from the web browser to my editor. Turning on "show invisibles" and doing a regex to hunt down the little nasties solved everything.

    Thanks Aras.