Distance to nearest surface very costly?
Hi, I posted this in the forum earlier but figured it would be better to post here.
I recently built a material function that would add dirt on meshes based on distance fields using the Distance to Nearest Surface node. I added it to my master material that is used for the majority of our assets and added a static switch parameter for turning it on. It worked great and I applied it to a few instances and made sure it worked in our whole level.
Today, two days later I try opening the main level again and keep getting "Our of video memory" errors despite using a GTX 980TI (6gb vram). I loaded up a backup and that worked fine, I replaced the maps in the current version of our project with the ones in the backup and that didn't help. After that I turned the function off in every material instance, saved, restarted and loaded up the map again and got the same error. Then I reverted to the older version and only copied the master material and the function over from the newest version to see if it was caused by something else but that didn't help either. Even with the function off in every instance and no meshes in the level that have used it I get the error.
Our level is very big and It always uses quite a lot of vram. Streaming pool is set to 1800mb without any errors and with the whole map loaded in editor my VRAM usage is at just below 5gb (yeah I don't know why it's so high). With the function in the material but turned off it uses all 6gb and crashes. I was under the impression that turning it off would ensure it didn't affect the scene (much) but I'm apparently wrong.
This might be the wrong way to go about it, I couldn't really find much documentation on using DFAO in materials. If anyone have some ideas or help to lend I would really appreciate it.
There isn't a lot of documentation.
Since the error didn't disappeared after you removed the functions from your materials and instances, I'm inclined to believe that the "Out of video memory" is due to another problem. You can try opening up an stable version and running the command "MemReport -full" to dump a full memory report of your frame. Although it doesn't give you a complete list of what is on your VRam, at least you can know how much each stat group takes on the memory.
Distance to Nearest Surface isn't costly per se. At least not enough to fill up 1 gb of memory like that, if you don't have a big scene and using the function on every material. But they usually add a lot of instructions and the performance tends to be noticeable if you abuse of it. Personally I've only used it to create water planes.
If absolutely in need of doing something like this, a nice alternative to this is baking the AO and recovering it with "Precomputed AO" node on the material. Takes as much memory but costs only a texture sample - besides the after work with the mask.
Hope it helps!
answered Feb 09 '17 at 01:35 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here