[Solved] Flash shader for grenade +

==============================================
I bring my apologies once again, but the script from Stierlitz with a frustum, while you can not use it for commercial purposes - until it is in the affirmative - CC BY 3.0 license…
It seems there is a small code, but it’s better to beware, and to find solutions based on standard Python API help
==============================================


Hi everyone.
Who has a flash shader, with a timer and color adjustment? Which can be used for the effect of flash (shock) grenades and/or the effect as in Mirror’s Edge © (if you change the color from white to yellow or blue, or…).

For example, in the old Counter Strike 1.6 © shader has already been used for these needs :eyebrowlift:
I will be very grateful if you share with me.

p.s. maybe someone else will need this shader in the future :yes:


Solved example

https://youtu.be/iT4k_IlbdjA

Thanks for the help:

  • Thatimster - shader example
  • Stierlitz - script with “Frustum”
    I just created a thread, modeled a little, and the logic created (simple)

This should be in the Game Engine Support and Discussion, I believe. Try to move your thread over to there.

How to do this, I did not find such a function? Or delete thread?

The admin will do the moving.

Mirrors edge has a different effect to that of a flash, perhaps you should choose one?

At the beginning of any level in the Mirror’s Edge © appears a light blue flash. If there was a universal shader - to change the color and the degree of the initial shading, and the time of shading.
But of course the priority is simply a light effect - like in Counter Strike 1.6 © a flash grenade, with a shading timer. But if in such a shader there is a color adjustment and a shading timer, you can recreate the effect like in Mirror’s Edge ©, maybe without a light zone inside, but I’m completely satisfied with this.
Of course without a grenade position script and a grenadedirect parameter, the flash will work even if the player turns away.

Here is some of this effect, touch the red wire - Flash with fog is not suitable for multiplayer.

You have 3 options.
1: Add a plane with an object color animation that fades out to a seperate scene, add this scene as an overlay when there is a flash.
2: spawn a plane infront of the camera with a similar animation as mentioned above
3: use a 2d filter, here is a quick demo I made. Use the “myprop” variable (on the cube) to change the amount:
.blend:
flash example.blend (84.6 KB)
glsl:

uniform sampler2D bgl_RenderedTexture;uniform float myprop;
void main(void){
    //r,g,b,alpha
    vec4 amount = vec4(myprop, myprop, myprop,1.0);
    gl_FragColor = texture2D(bgl_RenderedTexture, gl_TexCoord[0].st) +amount;
}

Ok man.
About the first two options I knew - not suitable for me personally, with the sherder everything is easier (If you have a shader).
The third option with a shader is much better.
This effect can be used at the beginning of the game (If automate shading) - from a white screen to normal shading, and at the end - from a normal to a white screen. It’s cool in my opinion. The appearance of a game level immediately, not very professionally - for amateurs, as I am now :yes:
Ок? :eek:
How to automate what is done with the up and down arrows? Well, color - how to insert the color setting?
If such a question is solved (and maybe with a transparent circle zone in the center) - there will be an effect like in Mirror’s Edge ©. And one more step to flash grenades.Need shading timer and color adjustment.
One more question:
Is it possible to write a self-shutdown in the shader? This automates the creation of the game - it starts the shader under certain conditions, and it works, it self-shutdown at the end. Because the running sheder always takes away the FPS - I have already conducted the test. Game logic is good, but the automation of creating a game is even better, and the brain will have less problems :yes:. Self-shutdown is good for using a temporary shader - after work, the shader automatically turns itself off - a good idea for everyone (If this is possible).

The answer to all of your questions is: Properties.
You might want to delve into BGE more until you get then hang of them.
But basically the float ‘myprop’ game property controls how much of the effect is in place (check the logic). This means you can directly determine how much of the effect there is.

You can shut down a shader by disabling the filter pass number associated with the filter.

Hi man again.
I looked at the “properties”, and found a solution with a timer, I now have a starting/end flash (looks good), and a flash on the sensor.
Maybe you would have solved this question differently.
But with the color settings, I have not yet found a solution.
Can you tell me how to add color settings, please? And to solve the problem with turning away from the grenade.
And one more question - the “timer” property always works, does this not reduce the system’s performance?

Thanks!

flash_grenade_TMP_01.blend

Hi everyone.
That’s done almost completely … but not solved with turning away and/or when the grenade is behind the barrier (changing the grenade_direct game property to 0), so that the flash does not turn on.
Can anyone know how to solve such a problem?

Thanks!

p.s.the sound of an explosion from a real grenade.

Here I made a turn away from the grenade (sensor radar), but it would be better script - I see a grenade - blind, I do not see - does not blind.

Hi everyone.


© Darkwing Duck from Disney :slight_smile: Do you know this man?

Flash grenade is ready. Who is interested, here is the link -!!!
A little python script, and everything works.
Special thanks to Stierlitz from Blenader Ukraine, for the script with “Frustum”

Thanks!

Someone help me add color settings to this shader, and I’ll give you an interesting solution (example) - a good idea for future games.

uniform sampler2D bgl_RenderedTexture;uniform float myprop;
void main(void){
//r,g,b,alpha
vec4 amount = vec4(myprop, myprop, myprop,1.0);
gl_FragColor = texture2D(bgl_RenderedTexture, gl_TexCoord[0].st) +amount;
}

Blend file - https://blenderartists.org/forum/attachment.php?attachmentid=476177&d=148953431

Make a Vid.

If “Vid”, it’s “video” - I already added at the beginning of the Thread.
If you want an example video with color settings? - After an example of color adjustment.

A video, thx. :slight_smile: