Search Unity

Render to Texture and Beast lightmaps

Discussion in 'Editor & General Support' started by sstephane, Jan 18, 2012.

  1. sstephane

    sstephane

    Joined:
    Nov 5, 2009
    Posts:
    30
    Hi,

    Is there any reason for beast lightmaps not being displayed while rendering to texture?

    I mean, i am loading an assetbundle in my scene, doing all necessary stuff to bind beast lightmaps to the lightmap settings, the loaded model is correctly rendered with lightmaps but if I take a snapshot from the camera view in a Render texture, all i see is my shaded model without lightmaps.

    Maybe i am missing something so any help would be greatly appreciated.
     
  2. Swearsoft

    Swearsoft

    Joined:
    Mar 19, 2009
    Posts:
    1,632
    Settings for camera used for render to texture?
     
  3. sstephane

    sstephane

    Joined:
    Nov 5, 2009
    Posts:
    30
    Thanks for you reply but I can't see which settings in my camera could disable beast lightmapping while rendering to texture.

    I do something like this :

    Code (csharp):
    1.  
    2.             RenderTexture rt = RenderTexture.GetTemporary( width, height, 24, RenderTextureFormat.ARGB32 );
    3.             m_camera.targetTexture = rt;
    4.             m_camera.Render();
    5.  
    6.             Texture2D screenshotTex = new Texture2D( width, height, TextureFormat.ARGB32, false );
    7.             RenderTexture.active = rt;
    8.             screenshotTex.ReadPixels( new UnityEngine.Rect( 0, 0, width, height ), 0, 0 );
    9.             screenshotTex.Apply();
    10.  
    Perhaps, it is not the right way to do this and Camera.Render() is not doing all the setup required for lightmapping...
     
  4. sstephane

    sstephane

    Joined:
    Nov 5, 2009
    Posts:
    30
    Any ideas ?
     
  5. sstephane

    sstephane

    Joined:
    Nov 5, 2009
    Posts:
    30
    My bad, I finally simplified enough my problem and found out that the script initializing beast lightmap settings unexpectedly started after the the screenshot action. :p All is perfectly fine now, thx.