I was wondering if anyone could contribute to helping me understand the process of tackling yet another shader effect as I crawl my way into accessing more complex features of Unreal. Previously, I had posted something about a completely dynamic system for pulling a particular area of an object's local coordinates and translating that into UV space for shader manipulating, but it proved to be too difficult for the time being. Now, I'm attempting to dumb that down a bit and start from square one.
Basically, I have a trigger area around a wall, that when it is touched, I would like to effect very specific UV coordinates of a specific material that is currently on the wall. By this I mean, I want to trigger a shader effect that will effect only a specific area of the material, rather than the whole wall. I do not wish to cheat this with a texture or do this with a decal due to some shader limitations on decals and the surfaces they're on. So basically, I'm looking for some guidance on what the Kismet and Material Editor framework might look like for a system in which the player touches a trigger box, and sets off a masking or specularity adjustment effect on a particular area of the shader. This would include figuring out how to manually hardcode parameters into a material to designate which UV coordinates I'm looking to manipulate.
I will continue to toy with the process myself, but any remotely professional input would mean the world to me. Thanks again, all --you're always a huge help.
Extract the red component of the UV coordinate node.
Subtract a certain value, which leaves only part of the values positive.
Those coordinates will be white in the mask at the end.
Multiply the values for higher contrast.
Clamp stuff to [0,1].
Your mask is ready sir.
You can factor in the green channel for more control, and add a sine or frac
function if you want to make a rectangular “island” in the middle of the UV space.
Thanks for the guidelines there Zoltran, that's helpful and I just needed the slight push.
Luiz, based on my experimentation, I couldn't seem to place a decal on an object and have the material distort the other material that was behind it, similar to how most basic water materials work. If this IS possible, this may be the direction I want to go again. As I mentioned some time ago, I'm basically trying to cheat the effect where a rock falls into water and a ripple effect on only occurs in that specific area of impact. I'm temporarily stepped away from handling this dynamically and am just looking for very well-controlled, hard-coded methods of doing for now.
Also, I seemed to have a problem simulating depth with normal and parallax mapping on the decals, but that could've been just me.
Seth, that's a pretty good idea that I hadn't considered. I'll take a look into the feasibility of that method based on some other things I'm trying to do.
Try piping your texture into the distortion plug on the material, that’s exactly what that does, distorts whatever is behind it. It’s not dirt cheap, but likely cheaper than any complex UV manipulation that you carry around in the shader all the time
Yeah, that works in most situations, particularly for static meshes that I have assigned distortion materials, etc. However, I’m not seeing the same effects with decals --I’m not sure if they’re set up to operate that way. Correct me if I’m wrong.
Davidmlally: Could you show us exactly what you want to achieve? Like a concept drawing
or a screenshot of a typical place where the effect would appear, and images of the
effect itself. So we are on the same page.
Sure. Ideally, I wanted to create dynamic reactions from physics based interactions throughout a level. Because the dynamic generation proved to be a bit difficult, I'm now attempting to hard-code an example using trigger boxes to read collision of a specifically assigned area, rather than trying to record points of collision where I wasn't sure where to begin with. Below are two basic example of this type of effect. Rigid body is thrown, it collides or at least intersects with another mesh or volume, and at that point of collision/intersection, the material on the receiving object is effected, as well as particles being emitted from that point on that object.
This could be seen on say, a bullet hitting a wall or a rock being thrown at a wall:
I’m not ruling decals out as an option, I just need to be sure they can distort the objects they are applied to and also simulate depth with normal maps, a bump offset, or something else.
Putting this kind of stuff (variable effect location and number) into a shader is
not very elegant or easy to use so I think you should try working with decals
for now.
The hole in the wall thing is pretty straightforward as you’ll see. The result is
as expected…
…assuming the decal is not rotated. There was a bug in the engine right until
the end of 2008, which screwed up the bump offset direction in rotated
decals. So don’t rotate them.
You can make hole repetition less apparent by using several variations.
Decals on transparent and opaque surfaces:
The decal shader uses the SceneTextureSample node to get information
about the underlying surface. The UV input comes from the ScreenPosition
node.
Same thing cheaper:
This wave is produced by a plane floating just above the transparent surface.
If your water is a flat surface then you can exploit that and spawn a simple
mesh. This method is less expensive than generating lots of decals on the fly.
The quad uses a similar shader to the decal mentioned above.
The specular highlights might not be perfectly realistic, but with an
environment map, the overall water effect can be enhanced significantly.
Zoltan --can’t thank you enough. Seriously, to-the-point help doesn’t come around like that very often. Much appreciated! Thanks to all that contributed to helping me out as well…experimenting with all of the findings now in a test level :]
Upon further research it appears that spawning decals upon rigid body collision isn’t actually possible through Kismet specifically and would require me to jump into some scripting I may not be so hot with. I’m just curious as to a second opinion regarding the possibility of creating decals on a surface at the hit location of a rigid body collision, possibly using the rigid body collision Kismet event? Any think otherwise?
You might be able to spawn a decal actor with the ActorFactory node, but
you don’t have the poly normal at the point of impact. The RigidBodyCollision
node doesn’t provide it so you don’t know what the decal’s orientation should be.
So as I see it you have the following options:
Download all the mods you can and see if any of them has a mechanic, a
new actor class or a kismet node you could use.
Try to use the UT3 framework: create a new projectile type with your decal
and particle emitters. Then spawn that (invisible) projectile at the point of
impact where it instantly collides with the wall. The projectile management
should take care of the effects.
For a new projectile class you would need some basic, copy-paste kind of
coding.
Create your own special, decal and particle spawning RigidBody class. Most
elegant solution, but requires most programming.
Extend the rigid body collision node’s code so it outputs surface normal, and
try to fire up the ActorFactory for decals (A did a quick test with
DecalFactory and ArchetypeFactory but I wasn’t able to spawn a decal.)
Place the decals onto walls in advance, hide them, place triggers around
them, and make those unhide the decals. It’s messy, and you still need to do
some coding to fix the decal actor: it seems it can only be hid, the unhide
operation does nothing.
Fake everything with a matinee. It would be manual labor and would
obviously kill interactivity but if you focus on artwork it might be ok.
As always, you're a huge help. I've experimented with a number of those methods to get a feel for each and the results worked well enough for me. I've learned a lot just from messing with this particular element of the engine and am now looking into getting involved with more scripting outside of Kismet to kick start the possibilities for my functionality on future tests.
I really like your recent tutorial regarding shader interfacing with Mental Mill to simulate changing weather, etc. Really cool stuff. Keep tutorials like that coming!! Thanks again for all of your help.