Search Unity

iPad full screen Image Effects

Discussion in 'iOS and tvOS' started by yonek, Dec 22, 2010.

  1. yonek

    yonek

    Joined:
    Jun 7, 2009
    Posts:
    64
    I was doing some tests with full screen Image Effects on iPad.
    The test shader was rendering one texture distorted with other (normal) texture.
    It seems that the shader attached to a plane that spans across whole screen is working quite fast
    but when it is used for blit in OnRenderImage it eats all the cpu.
    The funny is, when I look at the profiler it shows me that render and player cpu jumps from 1ms to 30ms.
    I bet that in first case it operates on square textures but when applying to screen the source and destination textures are 1024x768. This makes them handled in a special way. Anyone can confirm that ?
     
  2. FernandoRibeiro

    FernandoRibeiro

    Joined:
    Sep 23, 2009
    Posts:
    1,362
    "It seems that the shader attached to a plane that spans across whole screen is working quite fast" in terms of fps, how many are you getting in avarage? I'm having performance problems using bump map filling full screen.

    See ya!
     
  3. yonek

    yonek

    Joined:
    Jun 7, 2009
    Posts:
    64
    You won't get the iPad to fill the whole screen with proper bump map. What I did was just simple uv distortion.
    If you look at the Ininite Blade on different iOs devices you will notice that only 3GS is able to render all characters with per pixel bump mapping, when the resolution goes up the shaders are more and more simple. I think that there is no single bump mapped pixel on iPad.
    If they didn't make it I doubt that the hardware can handle it no mater what we try. I hope that next year they will come out with new generation of GPUs for mobile devices ;)

    ps.
    Remember that modifying/computing uv coords inside fragment program is very slow!!
     
  4. FernandoRibeiro

    FernandoRibeiro

    Joined:
    Sep 23, 2009
    Posts:
    1,362
    Thank you a lot = )))

    Here are some of my testes, in those, only the characters receive normal map, the rest is baked.





     
  5. francksitbon

    francksitbon

    Joined:
    Jan 22, 2010
    Posts:
    268
    Hi Fernando, did you used normal maps for the ground? when i use normal maps on iPad my frame rate is 4 fps.
     
  6. longshot

    longshot

    Joined:
    Sep 24, 2009
    Posts:
    71
    I'm currently using normal + spec mapping on objects that fill a large portion of the screen.

    I'm getting around 25fps, and this is with using two directional lights, and using the default not particularly optimized bump+spec shader.

    I also have a full screen effect warping an image in the background.

    If you are having fps issues, what I would suggest is -

    1. Download the latest XCode 4 preview. You will need to have it install debug data on the device you are using. Then, run the new OpenGL ES Analyzer in instruments, and VERIFY that the issue is fragment shader performance. I was quite surprised that when my game was dropping to 12 fps, it was regardless of fragment shaders, it was CPU bound due to the way I was handling collision. I'm not saying that this is the case with your games, but you might be surprised that something unrelated to bump mapping is causing issues.

    2. Make sure you are using sane numbers of lights. Every light adds an additional pass. For normal mapping on the iPad, I think one light is what you want to shoot for, you might be able to get away with two.

    3. Make sure you are using sane textures sizes. I'm using 256x256 PVRTC 4bpp color+spec maps, and 256x256 uncompressed normal maps. If the iPad has to load textures during the frame, this can cause performance issues.

    4. For the full screen image distortion in the background, the fragment shader is 6 instructions. I'm using a lookup table in a texture with all the calculations precomputed. For anything full screen, doing a lookup, even if it messes with UV coords, will be faster than doing the computation in the pixel shader( unless it's something very simple, like a few additions ). For the LUT, you will need to have it be an uncompressed texture, with mip-maps turned off, and have it set to repeat. In this case, the texture being warped is 128x128 PVRTC 4bpp compressed, with a 256x256 RGBA uncompressed LUT.


     
  7. francksitbon

    francksitbon

    Joined:
    Jan 22, 2010
    Posts:
    268
    ok thanks, i'm now 13.75fps in stead of 4fps, just changing my point light to directional.
    There is no frame rate difference for me using compressed or uncompressed texture or setting filter mode to point instead of bilinear. Insignificant frame rate enhancement if i resize my textures to 256 in stead of 1024 : 14.30fps
    I also tried to use the CRNM pro ultra-lite bumped diffuse, then my frame rate dropped to 9.15fps
    Update : with the with RNM1.1: 6.5 fps
    I changed my mesh collision to box collision and get 6fps in stead of 4 with point light, but there is no difference with directional light, 13.75fps

    I didn't tried the xcode4 preview, is there a really significant frame rate enhancement ?
     
    Last edited: Dec 29, 2010
  8. longshot

    longshot

    Joined:
    Sep 24, 2009
    Posts:
    71
    XCode 4 won't make the fps increase. The reason for installing it is so that you get access to the OpenGL Analysis instrument that comes with it. The instrument will enable you find out EXACTLY where the bottleneck is, so you can devote time to fixing what is actually causing the frame rate drop, instead of guessing.
     
  9. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Post FX always are costly, they overwrite the full screen and on ipad / iphone 4 where you are already fillrate F***ed due to the SGX535 + HD resolution (the SGX535 was meant for the 3GS generation screen size, not the new one)

    Also any kind of pixel light will burn your as it ends on redrawing every affected object (no thats no joke so add RNM on it and you get struck by lightning bolts as you see it. use RNM or make them affected by dynamic lights but NOT both) and a fillrate impact too.

    You can use it but do NOT make them affect large areas, instead use very local point lights.
    For anything that you could use directional, use lightmaps and comparable unless its dynamic and if it is dynamic, ensure to use layers to cut all static objects completely from its affect range
     
  10. FernandoRibeiro

    FernandoRibeiro

    Joined:
    Sep 23, 2009
    Posts:
    1,362
    Sorry for taking so long to answer!
    Nops, in my case only the characters are normal mapped, the rest is not dynamic light, its baked lightmaps.

    using point lights with small range highly improve performance on my tests.

    See ya!