Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shaderlab support renderState switch #2225

Open
zhuxudong opened this issue Jul 16, 2024 · 2 comments
Open

Shaderlab support renderState switch #2225

zhuxudong opened this issue Jul 16, 2024 · 2 comments
Assignees
Labels
Rendering Rendering related functions shader Shader related functions
Milestone

Comments

@zhuxudong
Copy link
Member

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];
@Sway007 Sway007 added this to the Backlog milestone Jul 16, 2024
@Sway007
Copy link
Member

Sway007 commented Jul 16, 2024

review in next milestone

@Sway007
Copy link
Member

Sway007 commented Aug 12, 2024

"Macro" way is a more general solution. User can use diffirent directives like UsePass, Tags besides RenderState declaration.

Solution:
move preprocessor parsing to before struct parse stage.

@zhuxudong zhuxudong modified the milestones: Backlog, 1.4 Aug 26, 2024
@zhuxudong zhuxudong added Rendering Rendering related functions shader Shader related functions labels Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Rendering Rendering related functions shader Shader related functions
Projects
None yet
Development

No branches or pull requests

2 participants