lichlichi

Hello! Thank you for visiting my post. I ask for help in solving one not a big problem.
I use Spine and Todd River's Shader - Pixel Lit. ( https://github.com/traggett/UnitySpriteShaders ), since i do not just need to drop the shadow, but also receive shadow (which Spine / Skeleton can not boast).
I ran into the following problem:

My object is created in realtime, and i cant configure it through the inspector in advance. In fact, I can not even copy my object in prefab, since its mesh is created at runtime.
So i need to change the parameters using the code. I rummaged through the script for the editor (SpriteShaderGUI) and took a couple of functions from there.
As a result, my configuration code looks like this:
SetBlendMode(material, eBlendMode.StandardAlpha);
material.SetTexture("_BumpMap", GameObject.Find("TestObject").GetComponent<Res>().normalMap);
material.SetFloat("_ShadowAlphaCutoff", 0.635f);
material.SetFloat("_Cutoff", 0.6f);
material.SetFloat("_ZWrite", 1.0f);
SetMaterialKeywords(material);
As a result, everything is perfect in the editor. The shader is configured and i can safely work, but in the standalone build for Windows the parameters seem to be not applied and the object itself becomes very dark.

Perhaps this is due to the fact that I do not include the Pixel Lit shader in Graphics-> Always Included Shaders, but I throw it in ShaderVariants, since if i throw it in Always Included Shaders, then I get this madness:

Who faced the similar problem? Maybe I'm somehow not correctly changing the parameters of the shader?
lichlichi
Posts: 4

Pharan

Have you tried opening this issue on the github repo too?
User avatar
Pharan

Pharan
Posts: 5015

lichlichi

Pharan wrote:Have you tried opening this issue on the github repo too?
I just know (read different posts) that this forum often use this shader, so I did not write to the git at first)
Created there, thanks for the advice.
lichlichi
Posts: 4

ara

Maybe you should set the Shader's Property [Fixed Normals] to true. That works for me if the spine object becomes dark when created
User avatar
ara
Posts: 9

Pharan

This discussion was continued here: https://github.com/traggett/UnitySpriteShaders/issues/16

The recommendation is to just have an actual prepared Material asset in your project since you can more or less predict what you want out of the shader. Then at runtime, just use it as a template and make copies of that Material, which can have the shader keywords you want, but with property values you can set.

Then Unity can limit compiling the shader variants to the ones you actually use rather than preparing every permutation (this being an uber-shader of sorts, is inevitably A LOT, or more specifically 3,440,640 variants).
User avatar
Pharan

Pharan
Posts: 5015


Return to Unity