I’m working on a game where you echolocate to see and for it I need a material that fades from white to black depending on its position from the camera. This is the material and what it looks like (in unlit mode since that is what the game would be in).
The problem is that it just cuts off suddenly into greyness no matter how I seem to mess with the values
How do I make the gradient fade more gradually, without cutting off abruptly (ensuring it still fades fully from white to black)
Also you should not be using the unlit view mode if you’re trying to visualize the “pure” color. The output from the unlit viewmode is affected by the materials metalness.
One small thing though, is there anyway to make the fading circular, being dependant on the camera position rather than being affected by the orientation.
By that I mean these two screenshots were taken at the same camera position but rotating the camera 90 degrees. this changes where the white parts are. is there a way to make the gradient circular so this wouldn’t happen, and it would stay uniform no matter the camera orientation?
If not that’s fine, this effect works very well as it is.
Thanks for your help, I’ve gotten the effect mostly to how I want it now
Although I did prefer the look of the material as a postprocessing volume, I think it limited what I wanted to do with the effect so I decided to instead have it as a surface material that’s applied to the environment in unlit mode.
The reason being so that I can:
have certain objects be a different colour
alter the material parameters of the material through a blueprint, allowing the player to “screech“ and show the environment light up.
There are 2 problems with this however:
the entire environment would basically need to be one mesh because I’m creating a dynamic material instance to allow for the changing of parameters
obviously these two problems would be fixed if I knew how to edit parameters of a post process material in a blueprint and how to make certain textures different colours with that same post process material.
If this is not possible in blueprints that’s fine, I’m fairly happy with the effect currently and am fine with having the environment be one mesh, and I know these issues are kind of separate to my original issue so sorry for that.
Also if it isn’t possible, is there anyway to make the darkness black in unlit mode rather than grey?
you could use a custom stencil to get different colors into the pp material. that’s to avoid dynamic material instancing. the radial ligthing would still have to done in the main pass, since you require the “w-buffer” values, not the scene depth.
edit: actually built the “method”. you set custom stencil values in the editor or via blueprint. i’m using a 1D nearest filter color texture to avoid arithmetic for the (256 possible) colors. works, but the color/lighting pp input texture is bleeding. anti aliasing or some temporal stuff. aa method doesn’t change it, or temporality makes it worse.
(and i found a nice editor crash scenario. low screen percentage using the nearest filter implodes the engine. what if i wanna make a pixel art game @epic ?)
Ok so I looked into stencils and that allowed me to make objects that are different colours through the different stencil IDs, interpolating them with the existing PP material. so the 1st issue has been solved (it also outlined how i’d go about coding another mechanic where object emitting sound are visible from far away through walls, so that’s helpful)
I still need to implement the “screech” however. With the unlit version from before, I did this through creating a dynamic material instance, and having a timeline change the radius of the material at the press of a button (essentially meaning the player can press a button to temporarily improve their vision). the problem is that to do this I need to change the parameters of the material through blueprints.
from what I can tell you cannot “get material“ from a postprocess volume and you cannot change the parameters of a material by simply casting to that material
How would I go about changing the parameters of a postprocess material that is applied to the whole scene?
I have a feeling it would be by using something like this, but I’m not sure how to go about it.
i don’t think you need to change the postprocess material. what you wanna change? i didn’t do it. the main pass always renders the radial light using a single material and however many meshes. you can plug the ping mechanic into that. the stencil does the color logic and the pp material combines/multiplies the light with the colors. permanent.
the thru the wall bit is a lil more involved. you’d need one more material for that and you’d have to draw that without depth test so it is always in front and it would potentially require another step to skip the color multiplication in ppm. could be done testing if the stencil is above a certain value. all in post.
i’ll have more time in a bit. will build a testcase. : )
well… i revamped it. i used a material parameter collection to get a global shader variable. you don’t need the dynamic instance and all the material change hackery. i had to learn that real quick. you have a color you can instance static. or do some runtime stuff aswell.
this is the ppm to make the things visible thru the wall via stencil coloring. i added an xtra filter to make the third person character the top level (255) and it doesn’t “glow” thru it.