How heavy is Cubemap reflected shader for GPU

Hi!

In my Unity project there are lots of objects with Reflective VertexLit shader. How secure is it to use that kind of shaders a lot to maintain the good performance? Or should I rather use them just in special places where they are absolutely necessary? I already noticed that cube map makes one more draw call to the material.

The Unity’s shader guide says that reflective shader is not too expensive to render. Is that closer to light to render or heavy to render?

I’m planning to use a lod shader that switches the cubemap off from a specific distance to reduce unnecessary draw calls. However I’m not sure how to do it, can someone show me a way? :slight_smile:

The trick with cubemaps is to make them as small as possible if they’re going to be used a lot, especially as on old cards (and mobile?) large cubemaps tend to cause texture cache misses, due to their size. On modern cards, you can get away with them with virtually no slowdown though (as long as they’re not huge), but you should profile them anyway. That said the new GI in 3.5 uses a form of them (from a certain point of view), and I believe it was used in Shadowgun, which runs at 60fps on an iPad 2.

As for your shader to switch off the cubemaps at a certain distance, you could adapt the method used here for fog http://forum.unity3d.com/threads/76113-Volume-Fog-shader .

The baked lighting in Shadowgun and Unity 3.5 is stored as spherical harmonic coefficients. These take a lot less space than even the smallest cube map, and don’t require a texture lookup to apply.

However, I think cube maps are very cheap as long as you don’t make them huge, as Gaustwick says. The lookup happens in hardware, so I wouldn’t be surprised if it were almost as fast, or as fast as a regular texture lookup.

Oh, I thought they were using specular cube maps like HL2. My mistake:(

Thank you all very much for the answers and the link tuo that fog shader! So I can use small reflection maps without worrying about the gpu performance. :slight_smile:

EDIT:

Unfortunately that fog shader didn’t give me the solution, but searching the net gave me this:

http://entitycrisis.blogspot.com/2010/10/unity-shader-lod-script.html

However there’s no explanation how to use and where to put that. I tried to attach that to the object which shader should be lodded and the camera, but neither didn’t seem to work. I also found the Shader Level of detail from the Unity reference manual but I’m not sure where to use those commands. Or is it even possible to get rid off the draw call caused by the reflection map by using shader lods?

I’m totally beginner with coding the shaders as you can see. :smile:

Good info, I’m looking into writing games for mobile (specifically OUYA, actually) and I thought a reflective cubemapped shader could possibly be used to fake specular highlights / reflections on, say, weaponry (with much better detail than standard vertex lighting).
It seems I was correct in my thinking :slight_smile:
Now to figure out how to bake those cubemaps from an editor utility…