Hello, although I already have a (very) little experience in game development, I’m realtively new to shaders. I read a couple of things on the web and tried to adapt the solution found here. I created a blink_sprite.fp file with the following code:
I do blinking by calling the go.set function: go.set(SPRITE, “blink_effect_trigger”, vmath.vector4(1))
This solution works perfectly when I test the game but I can’t see the sprite in the IDE editor: it’s invisible. If I reset the sprite’s material to the default one, the sprite re-appears.
Thank you for your reply. I really don’t know anything about the shading language, I just made a mix of different solutions found on wht web. BTW, I tried your code but still continue having invisible sprites in the editor.
I’ll try this solution. Apart this, I would like to undestand if it’s a bug, it’s me that I0m wrong using shaders or a limit or a dìifferent behaviour of the editor
@britzl I’m sorry, I already said in a previous msg that I tried the solution from @Dragosha but it didn’t work, at least on my environment, as you can see from the attached pic.
Apart from that, I’ll explain what I have to do. While playing the game, I need to set the sprite to a plain white colour with a simple flag, which I would like to use to simulate damage received by the sprite itself. However, I would also like to see the sprite correctly in the editor when I use it. Assuming that the solution works (and as I have already told you, it does not work for me), seeing the sprite completely white in the editor does not help me. For example, I use two similar sprites, one for a classic green slime and one red for a lava slime: if they are not rendered in the editor with their original colours, at first glance I don’t know which is which.
@MasterMind Your suggestion was helpful. By following that guide and using a preprocessor directive, I have now solved the problem. I hope that anyone will then provide an explanation as to why the solution proposed by @britzl does not work on my system.
I copied and pasted the script from the sprite.fp file because when I used the directive for only the central part of my code, I couldn’t get the desired effect. Unfortunately, I admit my total ignorance in the use of shaders and I don’t really know what the code does or how it works.
Ok, then you need to tell us a bit about your environment. Windows, Linux or macOS? Are your drivers up to date?
In my screenshot I set the blink_effect_trigger.r value to 1.0 to prove that the editor renders using the material (ie renders white). If I set the value to 0.0 it renders in the original color.
Please try the attached project and confirm if it works or not.
I can confirm that your project DOES work. So I decided to copy all your shader code instead of the one I used, and magically, it worked in my project too!!!
I was literally stunned because I can’t understand why. The only thing I can think of is that the first version of the code I used was missing this line: “#version 140”.