How do I create a dynamic forcefield shader?

Hey!

I built a shader in Unity and want to port it to UE4. Now, I don’t really know how I shall do this. Maybe someone of you can help me, maybe show me how to rebuild it via material system and Blueprint. The shader shall interact with projectiles. I can’t do it by decals because they don’t work on translucent surfaces, therefore I tried to modify my materials using blueprints. I found some tutorial version of interactive materials in the content examples but that’s way too difficult for me yet.

Here is a video how it looks like:

Dynamic forcefield shader

It’s not my video but the shader works in the same way, mine is just a modified version of this one.

Could you send me all your Unity files (textures and shader) and send it to me (contact@roelbartstra.com), with subject [UNREAL 4 SHADER REQUEST]. I might be able to make it tomorrow night or the day after.

I would be interested in seeing how you made this effect also. Roel if you could post a postmortem that would be nice :slight_smile:

That would be great, I will send it to you. (Here you have to use your scalar parameters ;)) I never learned how to use them or rather how they can be changed…so please add some information what I have to do, to integrate it into the project.

Here is your complete shader copied into the material editor. I hope I didn’t make any mistakes, I could not compare it with Unity. A lot of your code does not make sense, so you should probably clean it up a little. But at least it should copy your Unity results.

Things you need to do:
-Attach the material instance to the mesh, not the material. Only material instances can be changed dynamically ingame.
-Check the sRGB settings for your texture in Unity and put it the same in Unreal.
-Create Blueprint or C++ script that feeds the material instance the proper values.

Good luck!

][1]
[Download][2]

Create Blueprint or C++ script that feeds the material instance the proper values.

How can I do that, I took a look at the examples form epic, but couldn’t figure how to give the values to the material.
I look into the material and I really don’t have a clue what I have to do now. That it just appears when it gets hit or to be translucent (without changing the blend mode)

Inside a material instance you can see all the parameters you created in a material. You can adjust these values right inside the material instance viewer, or adjust them from code.

Everything you need is in this other answer:

Okay, I understand the most things now, but I still don’t know what I shall do to make it translucent and the hit point + surrounding area stronger than the rest.

In the material properties it says “blend mode”, you can make it translucent in there. You can pass a hit point through a Vector Parameter, and checking the distance between that and the current pixel. But maybe you should try and make a simpler shader first, to get used to how unreal works. Follow some tutorials.

Good luck!

I never got the shader to work, so I had to start over…

Nicely done, any info on how you acheived it?

I have a website on which I post some of the materials I make, maybe I will post this one too, once it’s completly finished.

summarized:

  1. create a material for the base sphere
  2. create a material that spawns an effect on the hit location
  3. if the base sphere gets hit, spawn another sphere with the same transform as child of the base sphere and put the material on it you made in 2).
  4. Destroy the spawned spheres after the animation is finished.

Hey thanks for the info. What is your website, I would love to check it out.
On #3, you spawn the same sphere model overtop the base sphere with a new texture. How do you get the second material to expand from that spot?

[Link to the website][1]

If you replace the “Center” with a vector parameter that holds the hit location on the sphere the effect will be centered on this point.