Home Unreal Engine

Optimizations with cubemaps

One of the big concerns as I start the next part of my project is cubemaps and reflections. My environment is very shiny and sci-fi, and will be heavily dependent on cubemaps.

As far as my understanding right now, each time I use a new cubemap, I will need to create a new material instance specifically for that cubemap. That's a lot of material instances for a lot of objects that need duplicates just to swap the cubemap. Also, because of static switch parameters, each time the game cooks it is going to create a separate material. This will lead to an exponential amount of instances being cooked because I may need to make 20 versions of the same instance with a different cubemap plugged in.

My question is, how do I get around this? What are suggestions for optimizing with cubemaps? Is the general suggest to avoid or fake it as much as possible (or wait until UE4 when everything is just real time reflections anyway? :poly142: )

Does anyone have thoughts on how to go about this so I don't have 400 different material instances for 40 different cubemaps?

Replies

  • Hourences
    Offline / Send Message
    Hourences polycounter lvl 18
    I can't think of any faster way than what you described. I don't think it is doable, at best if you'd use Unrealscript you may be able to somewhat improve the process but creating that system in itself will take more time than just setting it up by hand.
  • Santewi
    Well, you could use just a few generic cubemaps, but if the surfaces are very reflective and really need somewhat correct reflections to look good, then what you were going to do is probably the best and easiest way to do it.
  • MooseCommander
    I was looking at the way Remember Me handles this, which is by using influence volumes that then seem to Lerp between two cubemaps based on player's distance between the two, using a trace. Unfortunately that is outside of my programming knowledge, and as Hourences noted, a lot of effort to prototype and the question would still be whether or not it works properly or is optimized, which is the main concern with all of this.

    Thanks guys. I've been sticking with UDK out of stubbornness, I may look into CryEngine soon enough since it can achieve what I am looking for probably much easier.
  • Vailias
    Offline / Send Message
    Vailias polycounter lvl 18
    Why not have the cubemap be a texture parameter? Then have that parameter update to new cube maps via uscript or Kismet as you move around from area to area. You don't need different instances if everything else is identical.

    You could lerp between two, OR you could just have the new cube pop in, or you could have a generic shiny cubemap that you always fade to based on distance as you transition between specific cube maps.
  • MooseCommander
    Vailias wrote: »
    Why not have the cubemap be a texture parameter? Then have that parameter update to new cube maps via uscript or Kismet as you move around from area to area. You don't need different instances if everything else is identical.

    You could lerp between two, OR you could just have the new cube pop in, or you could have a generic shiny cubemap that you always fade to based on distance as you transition between specific cube maps.

    Wouldn't I still need to call every material instance in code if I'm overriding the cubemap parameter? That's the issue I was concerned with. Or could I make one MaterialInstance, then create all others based from that, and only override the parent's cubemap parameter?

    I'll try some tests and see what I can end up with. Lerping between the two options based on distance is probably doable.

    I also may be overly worried. The main reflection will be coming from the floor, which will just have a reflect actor anyway. Most of the cubemaps will be blurred and so I will probably only need a few unique ones.
  • Vailias
    Offline / Send Message
    Vailias polycounter lvl 18
    Yeah one instance, then override the parameters per actor as needed. Something like MyActor.Materials[0].CubeMapParameter01 = Package.CubemapAsset

    Once you get which cube or cubes to use.. and however you build the distance formula to lerp between them.
  • /anty/
    Offline / Send Message
    /anty/ polycounter lvl 7
    You could build in in your shader multiple cubemaps, and then use world space mask or vertex colors painted directly in editor to blend between areas. Additionally you always could save multiple cubemaps/masks as R+G+B+A texture, and then tint them inside shader.
Sign In or Register to comment.