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. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

Forcing shader with includes to be included in build

Discussion in 'Shaders' started by jvo3dc, Jul 31, 2018.

  1. jvo3dc

    jvo3dc

    Joined:
    Oct 11, 2013
    Posts:
    1,520
    What is the best way to do this? The includes are in a subfolder "Include" relative to the shader itself. I've placed the shader and folder Include in a folder named Resources, but that doesn't help. Linking the shader from the scene has the same result:
    WARNING: Shader Unsupported: 'VMF Forward/ ' - Pass 'FORWARD' has no vertex shader
    WARNING: Shader Unsupported: 'VMF Forward/ ' - All passes removed
    WARNING: Shader Unsupported: 'VMF Forward/ ' - Pass 'FORWARD' has no vertex shader
    WARNING: Shader Unsupported: 'VMF Forward/ ' - All passes removed
    WARNING: Shader Unsupported: 'VMF Forward/ ' - Pass 'FORWARD' has no vertex shader
    WARNING: Shader Unsupported: 'VMF Forward/ ' - All passes removed
    ERROR: Shader Shader is not supported on this GPU (none of subshaders/fallbacks are suitable)WARNING: Shader Unsupported: 'VMF Forward/ ' - Setting to default shader.


    It seems that either way the shader itself is included, but can't be compiled because the actual content is in the includes. Everything works fine in the editor of course.

    I'm doing the exact same thing with another shader, which does work in the build. So it might actually be related to the naming with a space or something else.

    Edit: It doesn't seem to be the space as name. I just get a whole lot of these messages:
    Shader error in 'VMF Deferred/Blend': failed to open source file: 'Include/VMFShadow.cginc' at line 160 (on d3d11)

    Which seems to be some sort of file locking issue, because the files all do exist. So, going to restart Unity.
     
    Last edited: Jul 31, 2018
  2. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,836
    Wild guess: do you use a case-sensitive file system?
     
  3. Invertex

    Invertex

    Joined:
    Nov 7, 2013
    Posts:
    1,495
    What version of Unity are you on?
    Don't put them in a Resources directory path.
    Try right clicking only the shaders, not the CGINC files, and Reimport.
    Try closing Unity, and delete your ProjectRoot\Library\ShaderCache folder.
     
  4. jvo3dc

    jvo3dc

    Joined:
    Oct 11, 2013
    Posts:
    1,520
    Well, Windows/NTFS, as far as I know it's stored case-sensitive, but retrieved case-insensitive. I've checked and the casing is exactly how it is used in the include statement. (Kind of used to that as a programmer.)
    5.6.3f1. I'll try a reimport and clearing the shader cache.

    Edit: Ok, that doesn't do it. One thing I didn't mention before, is that the objects are being loaded from asset bundles. Both in the editor and the Windows build. Same files, asset bundles built for Windows. The objects are loaded just fine, but shown pink with the missing vertex shader warning in the output log in the build.

    I'm going to look whether the material fails directly or after I change it for a mouse over. Ok, only after the mouse over, so the asset bundles don't seem related. Then my next guess is that I should remove this line:
    Code (csharp):
    1. if (shader == null) shader = Shader.Find("VMF Forward/ ");
    It might be that this is actually returning the shader that is coming with the asset bundle that is just loaded.

    Edit 2: Ok, that's not it, the problem is that "Include" is not understood as relative folder, so changing it to "./Include" helps.

    Edit 3: That does remove the errors that the includes can't be read, but the result is still the same in the build.
     
    Last edited: Aug 1, 2018
  5. jvo3dc

    jvo3dc

    Joined:
    Oct 11, 2013
    Posts:
    1,520
    I've been able to work around the issue. Instead of using Shader.Find or linking the shader in the scene, I'm reusing the shader that comes with the asset bundle.
    Code (csharp):
    1.  
    2. Material newMaterial = new Material(oldMaterial.shader);
    3. newMaterial.CopyPropertiesFromMaterial(oldMaterial);
    4. // Adjust new
    5.  
    I still find it surprising that the other ways don't work. All I can think of is that the shader includes are simply not included into the build when using resources or linking in the scene. (But they are included in asset bundles.)