engine icon indicating copy to clipboard operation
engine copied to clipboard

Shaderlab support renderState switch

Open zhuxudong opened this issue 7 months ago • 2 comments

Is your feature request related to a problem? Please describe. I want change isTransparent in shaderlab by one macro or one variable.

Describe the solution you'd like by macro:

            #ifdef MATERIAL_IS_TRANSPARENT
                BlendState {
                  Enabled = true;
                  SourceColorBlendFactor = BlendFactor.SourceAlpha;
                  DestinationColorBlendFactor = BlendFactor.OneMinusSourceAlpha;
                  SourceAlphaBlendFactor = BlendFactor.One;
                  DestinationAlphaBlendFactor = BlendFactor.OneMinusSourceAlpha;
                }
                DepthState {
                  WriteEnabled = false;
                }
                RenderQueueType = RenderQueueType.Transparent;
              #else
                BlendState {
                  Enabled = false;
                  SourceColorBlendFactor = BlendFactor.SourceAlpha;
                  DestinationColorBlendFactor = BlendFactor.OneMinusSourceAlpha;
                  SourceAlphaBlendFactor = BlendFactor.One;
                  DestinationAlphaBlendFactor = BlendFactor.OneMinusSourceAlpha;
                }
                DepthState {
                  WriteEnabled = true;
                }
                RenderQueueType = RenderQueueType.Opaque;
              #endif

or by variable:

               BlendState {
                  Enabled = [isTransparent? false: true];
                  SourceColorBlendFactor = BlendFactor.SourceAlpha;
                  DestinationColorBlendFactor = BlendFactor.OneMinusSourceAlpha;
                  SourceAlphaBlendFactor = BlendFactor.One;
                  DestinationAlphaBlendFactor = BlendFactor.OneMinusSourceAlpha;
                }
                DepthState {
                  WriteEnabled =[isTransparent? false: true];
                }
                RenderQueueType =[isTransparent? Transparent: Opaque];

zhuxudong avatar Jul 16 '24 08:07 zhuxudong