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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Include Shaders in build?

Discussion in 'Editor & General Support' started by ZO5KmUG6R, Nov 23, 2014.

  1. ZO5KmUG6R

    ZO5KmUG6R

    Joined:
    Jul 15, 2010
    Posts:
    490
    Hi! My game uses a custom-built framework that doesn't use the asset system whatsoever except for scripts. Now that I have stated this the next thing is obvious:

    It loads models at runtime.

    When it loads models at runtime it also parses a. shaders file. A fully-customizable file that allows the materials within a model to use any shader with any customization parameters needed. Bumpmaps, cubemaps, specular, even animation (by setting tiling parameters).

    Now here's the question : The current way to add shaders to the build is creating a quad in the menu with a material that has the shader I need, which gets annoying to do and limits the shaders file capability to only a few shaders. So is there anyway to specify what shaders to include in the build ? I've tried putting the shaders into the resources folder from the builtin shaders but that resulted in very weird shadows and I did not like that method at all anyways.

    Thank you, aaro4130.
     
    tigerleapgorge likes this.
  2. JFo

    JFo

    Joined:
    Dec 9, 2007
    Posts:
    217
    Edit > Project Settings > Graphics
     
  3. ZO5KmUG6R

    ZO5KmUG6R

    Joined:
    Jul 15, 2010
    Posts:
    490
    I literally said out loud
    "WOW! As if... Omg" :p

    Thank you for that. I can't believe I didn't know about it!!
     
    tigerleapgorge likes this.
  4. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,347
    Adding the Standard (specular setup) shader causes Unity to crash on building (sharedassets0.assets) the executable here .
     
    tigerleapgorge and SimRuJ like this.
  5. fg34

    fg34

    Joined:
    Aug 31, 2015
    Posts:
    6
    Try removing support for Dx9 in the project settings.
     
    tigerleapgorge likes this.
  6. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    Its not intended to have the standard shader linked there.
    Unity does include all variants of the shaders linked there and that is way to much for the standard shader.
    You should use a or multiple ShaderVariantCollection to make sure that all shader variants you whant to use are included.
    https://docs.unity3d.com/ScriptReference/ShaderVariantCollection.html
     
  7. aibolith

    aibolith

    Joined:
    Apr 9, 2017
    Posts:
    9
    Can someone explain step-by-step how to include some of the standard Unity shaders into Assets so that they appear in the build? I use Shader.Find() and it works perfecty in Editor, but in the build all the shaders set this way are gone. I need to download sources of older versions of Unity and take shaders from there?
     
  8. imphenzia

    imphenzia

    Joined:
    Jun 28, 2011
    Posts:
    413
    You can probably put all the shaders you want in a folder named exactly "Resources" anywhere in your project and they will be included in the build and Shader.Find() should work.
     
    jhocking-bundlar and SimRuJ like this.
  9. dyenaldinesh

    dyenaldinesh

    Joined:
    Nov 25, 2017
    Posts:
    2
    Thank man it reallyy worked
     
  10. dyenaldinesh

    dyenaldinesh

    Joined:
    Nov 25, 2017
    Posts:
    2
    Thanks..it worked
     
  11. SimRuJ

    SimRuJ

    Joined:
    Apr 7, 2016
    Posts:
    247
    Thanks!

    E.g. "Hidden/Internal-Colored" doesn't show up in
    ... but you can download the shaders here (click on the "Downloads" dropdown of the version you want and pick "built in shaders") and copy the ".shader" file from the arch into the "Resources" folder, then they can indeed be accessed with "Shader.Find()".

    This is still happening in 2017.3.1f1 but fortunately you don't have to add the "Standard" shader, at least in my app it's accessible without actually assigning a material with the shader to an invisible GameObject (to make Unity export it in a build).