Shadows from Standard "Fade" texture created via C# script

I’m going to explain my problem using screenshots.

During runtime I create a RenderTexture that is shown using the Standard shader set up to use rendering mode “fade”. In the editor it looks fine, casting a shadow and being transparent:

However when I Build & Run a standalone exe file it is no longer transparent:

BUT if I add a Quad with a Material made inside the editor (using the standard shader and rendering mode “fade”:

Now all of a sudden when I Build & Run a standalone exe the RenderTexture appears correctly (casts a shadow and is transparent):

I haven’t changed any code at all between taking these screenshots, the only difference is that I add that green quad in the editor. Somehow this affects how Unity is building the standalone exe.

How can I make the Standard shader work correctly without having to use a Standard shader in the scene that is created inside the Unity Editor? (I need to create all my textures and materials via script during runtime.)

Bump…

I just noticed that this is also true if I want to make the Standard shader emissive.

myMeshRenderer.material.SetColor("_EmissionColor", new Color(1f, 1f, 1f));
myMeshRenderer.material.EnableKeyword("_EMISSION");

(The material is created from new Material(Shader.Find(“Standard”)) and then configured correctly to use the rendering mode “fade”.)

In the Unity Editor the texture gets a white overlay. If I Build & Run a standalone exe the texture does not.

HOWEVER if I also add emission to the green dummy quad via the Unity Editor and then Build & Run a standalone exe THEN the texture appears like it should.

What magic is this? What is the Unity Editor doing to make these things work all of a sudden?

Note that the GameObject I work with in the Unity Editor has nothing to do with the material that is created via code yet somehow simply because it is there in the scene it somehow affect the stuff I create in C# and enables alpha (original topic of the thread) and emission to work correctly.

Bump

Pump

We can bump if we want to
We can age your threads behind
Cause your threads don’t bump
And if they don’t bump
Well they’re no threads of mine

Bump

Bamp

Materials with the standard shader don’t have all the features compiled in if you create them in code. You have to specifically enable the features.

Here is the page in the manual that shows you what to do:

“2. You must make sure Unity includes your required shader variants in the build”

I guess what I want to do is impossible then, it’s just a strange limitation with the Unity Engine.

Thanks a lot for replying Jaimi!

For me I spent a lot of time and finally find out that it’s because my Standalone app uses default Graphics Quality: Fastest, but in Editor the default graphics quality seems to be Fantastic, which causes some texture behavior differences. Edit->Project Settings->Quality->Choose “Fastest” and then change “Texture Quality” from “Half Res” to “Full Res” and everything in Standalone build goes the same with Editor.

can you please share your project files @ShadyGuy