MixedRealityToolkit-Unity icon indicating copy to clipboard operation
MixedRealityToolkit-Unity copied to clipboard

Switch shader on runtime: Compile directive in cginclude file appears to be ignored

Open Holo-Fiedel opened this issue 9 years ago • 2 comments

When switching between the HoloToolkit shaders on runtime, for some shaders the materials "lose" their color, i.e. they are rendered in white, the default. This apparently happens when using a shader that has the shader feature _USECOLOR_ON. (e.g. BlinnPhongConfigurable.shader)

Neither does material.SetFloat("_UseColor", 1); help, nor adjusting the shader to have the feature enabled by default.

So I commented out the according compile directives in the .cginc files:

//#if _USECOLOR_ON
float4 _Color;
//#endif

[...]

//#if _USECOLOR_ON
     c *= _Color;
//#endif

which helped me achieve what I wanted.

Still, there appears to be a problem when trying to access the _USECOLOR_ON keyword

Holo-Fiedel avatar Mar 14 '17 14:03 Holo-Fiedel

@dbastienMS, any idea about this?

StephenHodgson avatar Apr 19 '17 03:04 StephenHodgson

shader_feature doesn't compile all paths, just the used ones. you can swap it out for multi_compile to get the behavior you want. Ideally though you'd be using the fast configurable shader and not the earlier ones. We need to blow them all away and move the samples over to fc. Fast configurable is much lower per-pixel ALU ops for the same quality level.

dbastienMS avatar Apr 19 '17 04:04 dbastienMS