I currently have two shaders, one with a graying effect and one with a burning effect

How can I mix these two effects to make this icon both gray and burn

Based on the information available online, https://github.com/godotengine/godot-proposals/issues/7870
it seems that I need to use BackBufferCopy to complete the function of the next pass

Alternatively, I can achieve the goal by writing multiple shaders in one shader file

  1. use BackBufferCopy
  2. use a big shader file
  3. Is there any other better and more universal method?

Which method do you recommend me to use to achieve this goal

  • xyz replied to this.
  • vmjcv As I said - it depends. If you have relatively small number of computationally inexpensive effects - it's a good way to handle it. Your described situation would fit this criteria. So try implementing it like that. If some performance bottlenecks appear (unlikely), you can then split mutually exclusive effects into several separate shaders and swap the shader as needed.

    vmjcv You can do it in a single shader. Set rgb from the gray shader calculation and set alpha from the burn shader calculation.

      xyz
      Yes, but actually I have many effects that I want to mix together.

      Is it the best option to write all the shaders in one shader file?

      • xyz replied to this.

        vmjcv It depends. Best to describe your exact situation.

        For example, I also have a distorting Effect

        1. I hope this icon can achieve both graying and distortion effects simultaneously

        2. I hope this icon can have both a graying effect and a burning effect simultaneously

        Of course, there are many more effects, in other words, I should need a feasible solution for next_pass

        • xyz replied to this.

          vmjcv You still haven't described to full extent what exactly is your goal here. If you only need to combine pairs of shaders that are applied to a single object, you can almost always do it by "mixing" inside a single shader code. Both combinations you've described are doable like that.

          i only need to combine pairs of shaders that are applied to a single object

          I want to know if putting all the effects in one shader file is a suitable solution if I have many effect implementations.
          Is there a better solution?

          • xyz replied to this.

            vmjcv As I said, describe exactly what you aim to achieve if you want more specific advice. If you have many shaders to combine, putting them all into one source is not the best approach. But putting each pair into one source is fine. Using passes may also be fine but certain effects may be easier to achieve by mixing in the single source shader.

            @xyz Thank you very much for your suggestion, so I should try using the method of the single source shader.

            Because there are many unrelated elements between the specific case and this question, I will try to provide you with a simple description in the first few replies.

            The specific case is:
            I have a card,

            1. Use a gray shader to represent its charging status (each card will automatically release skills when fully charged),
            2. Use outline shaders to indicate whether I am selecting this card or not,
            3. By burning the shader to indicate that the card is being destroyed,
            4. By distorting the shader to indicate that the card is undergoing changes,
            5. By highlight shaders to indicate that the card is being upgraded
            6. There are also some other effects,

            When I tested every shader, it is ok,
            I now hope to make these shaders work together, but I cannot set multiple shaders for one card, so I have raised this question

            I can write all shaders into one shader to achieve my goal, but whether this is a good solution and whether there is a more suitable solution is the core of my question.

            • xyz replied to this.

              vmjcv You can put all those effects in the same shader and then control visibility/prominence of each effect (or animate it) via shader uniforms.

                xyz
                Yes, that's exactly what I'm doing.

                But I'm not very professional with shaders, so I want to know if this is the best way to combine multiple shader effects?

                • xyz replied to this.

                  vmjcv As I said - it depends. If you have relatively small number of computationally inexpensive effects - it's a good way to handle it. Your described situation would fit this criteria. So try implementing it like that. If some performance bottlenecks appear (unlikely), you can then split mutually exclusive effects into several separate shaders and swap the shader as needed.

                    xyz Thank you very much for your detailed reply