Unity Community


Page 2 of 2 FirstFirst 12
Results 21 to 31 of 31

  1. Location
    Lost in Space....................*_*_*_....
    Posts
    298
    ....any news on this ?
    thxxxx
    would love to use Dof on Mobile....
    Life's What You Make It - don't forget it's YOU


  2. Location
    Orlando, Fl
    Posts
    649
    Yea i truely would love to utilize the light shafts and depth of field on mobile.

  3. Super Moderator
    Location
    Great Britain
    Posts
    9,661
    Drawing your own depth texture when the camera provides it seems like stupidity to me though.
    Currently working with Sony on our new
    PS4 and Vita game in Unity!

    This post is not representative of Simian Squared Ltd


  4. Posts
    9
    Just to add to what's already been said, crippling CheckSupport in PostEffectsBase.js does make DoF work on iPad2, although I also had to comment out the lines where the component was disabled (search for "enabled = false" in the same file). Otherwise even though the iPad could do it, the Mac I was building from couldn't, and disabled the component when it opened the scene.

    Oh, and it (fairly predictable) destroys the framerate on iPad 2...

    Looks very pretty though

  5. Super Moderator
    Location
    Great Britain
    Posts
    9,661
    Got to be a fast approximation though. Windwaker on gamecube (hardware that isn't as good as ipad2) - does it very quickly. But it is strangely limited. I think probably, camera slicing or something.

    Any tips on how this could be done on mobile in a very quick way? I think many of us would love to try it out.
    Currently working with Sony on our new
    PS4 and Vita game in Unity!

    This post is not representative of Simian Squared Ltd


  6. Location
    Bay Area
    Posts
    12

    Depth Textures support for Mobile (iOS/Android)

    You don't even have to write you own shader but you can just use the built-in one. If you attach this script to your camera you can make any post process effect work that uses the depth/normal texture:

    Code:  
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class CreateDepthNormals : MonoBehaviour
    5. {
    6.     RenderTexture depthNormalTexture;   
    7.     Camera theCam;
    8.     GameObject shaderCamera;
    9.    
    10.    
    11.     void OnDisable()
    12.     {                  
    13.         if(shaderCamera != null)
    14.             DestroyImmediate (shaderCamera);
    15.        
    16.         if (depthNormalTexture != null) {
    17.             RenderTexture.ReleaseTemporary (depthNormalTexture);
    18.             depthNormalTexture = null;
    19.         }
    20.        
    21.     }
    22.     void OnPreRender()
    23.     {
    24.         if (!enabled || !gameObject.active)
    25.             return;
    26.  
    27.         if(theCam == null)
    28.             theCam = this.GetComponent<Camera>();
    29.        
    30.         if(depthNormalTexture == null)         
    31.             depthNormalTexture = RenderTexture.GetTemporary((int)theCam.pixelWidth, (int)theCam.pixelHeight, 16);              
    32.                        
    33.         if (!shaderCamera) {           
    34.             shaderCamera = new GameObject("DepthNormalCamera", typeof(Camera));
    35.             shaderCamera.camera.enabled = false;
    36.             shaderCamera.hideFlags = HideFlags.HideAndDontSave;
    37.         }
    38.        
    39.         Camera cam = shaderCamera.camera;
    40.         cam.CopyFrom (theCam);
    41.         cam.backgroundColor = new Color(0,0,0,0);
    42.         cam.clearFlags = CameraClearFlags.SolidColor;
    43.         cam.targetTexture = depthNormalTexture;    
    44.         cam.depth = -2;
    45.         Shader s = Shader.Find("Hidden/Camera-DepthNormalTexture");    
    46.         cam.RenderWithShader (s, "");      
    47.         Shader.SetGlobalTexture("_CameraDepthNormalsTexture",depthNormalTexture);
    48.     }
    49.        
    50.     // Update is called once per frame
    51.     void Update () {
    52.    
    53.     }
    54. }


  7. Location
    Belguim
    Posts
    701
    arg unity Fix this allready will you!!!!


  8. Location
    Amsterdam
    Posts
    872
    Even games from 1988 had shadows ! why is Unity taking so long for to support this in iOS?
    http://www.youtube.com/watch?v=ALfnZ...eature=related


  9. Location
    Zürich, Switzerland
    Posts
    26,572
    0. That game didn't have shadows as it did not even have 3D. Thats pure cpu rendering
    Also casting shadows from this kind of objects is a thing you can easily do even with unity as projectors work fine here

    1. Older games and the first to have it on mobile relied on Stencil Buffer shadows. Stencils are a technology unity does not support in any form nor use to my knowledge and thats not gonna change as Stencils are a thing of the past and have been for a while. In addition they couldn't be exposed to shaderlab as you need low level access to use them, another reason why UT likely never approached it

    2. I would assume that Unity 4 will support them. ipad2+ , iphone 4S+ and the current generation of android high ends finally can make use of shadows.

    As for depth textures: There is a rumor (didn't verify it yet) that they actually work with unity on iOS at least yet that Unitys editor 'fake opengl es' renderer pretends that it isn't possible or more correctly: fails to return true on the 'is supported' function while it works otherwise.
    Last edited by Dreamora; 04-29-2012 at 02:03 PM.


  10. Posts
    44
    As for depth textures: There is a rumor (didn't verify it yet) that they actually work with unity on iOS at least yet that Unitys editor 'fake opengl es' renderer pretends that it isn't possible or more correctly: fails to return true on the 'is supported' function while it works otherwise.
    Does anyone have any more information on this? Are shaders that require depth information (i.e. sun shafts) actually supported, but this check just returns false regardless?

    When I commented out the check, the shader did work within the editor, but was flickering, weird. Anybody any information, if these shaders are now supported on devices 4S and above?


  11. Location
    Montréal Quebec
    Posts
    2,238
    Unity support rendertextures since v3.0. Prior to v4.0 (which is the official version that support automatic depth textures generation for mobile) you had to construct your own depth buffer to generate depth textures (which was quite easy btw). The big problem is making something like this runs on today's mobile hardware. I still believe current mobile hardware isn't ready for heavy post process. You have to be very careful and approximate your desired effect at the cost of being sometimes weird or unnatural.
    Shadows are hugely needed yes but they are also hugely slow on mobile hardware. Your scene have to be drawn multiple times, there's a lot of heavy operations on pixels that must be done, your drawcall will double for each light casting shadows. If shadowgun had shadows with their current scenes setup the requirement to play such a game will be iPad3 and iPhone5 (and they will still look blocky cause even such devices can't afford high res shadowmaps). There's no magic trick here, shadows are heavy as simple as that.

    The fastest shadows technique that you can implement in your game is simply "no shadows at all".
    Last edited by tatoforever; 12-30-2012 at 01:23 PM.
    Forgotten Memories Teaser
    Forgotten Memories Trailer
    I write shaders for the community!
    Dead Strike iOS (Top iOS game made with Unity).
    Nintendo Wii U and Sony (PS3/PS4/Vita) Licensed Developer/Publisher.
    __________________________________________________
    Georges Paz
    http://www.forgottenmemoriesthegame.com

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •