Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Render to Texture: Skinned Mesh Renderer vs. Mesh Renderer

Discussion in 'General Graphics' started by hothead-brusnell, Dec 9, 2014.

  1. hothead-brusnell

    hothead-brusnell

    Joined:
    Apr 15, 2014
    Posts:
    18
    Hi,

    I am using Unity 4.6, and am running into the following problem:

    1) Scenario 1: Render to Texture and Mesh Renderer

    When I render a character model, using a mesh renderer, to a render texture, and then copy, using ReadPixels() and Apply(), to a Texture2D, everything works as expected, and I see my character in the resulting Texture2D.

    2) Scenario 2: Render to Texture and Skinned Mesh Renderer

    When I perform the same sequence as above, but switch to a Skinned Mesh Renderer, the resulting Texture2D does not contain my character.

    More Info for Skinned Mesh Renderer:
    When I look at the camera's target texture (the render texture) in the Editor, I can see my character. However, it looks like ReadPixels() and Apply() aren't performing the copy. When I switch between the above two scenarios, the only change I'm making is the rendering method. I can see the player model and the render texture is populated, but the resulting Texture2D is blank. Any ideas?

    Thanks.
     
  2. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Did you make sure that the camera's culling is correct? Are you using a different shader for the skinned mesh?
    Something that is often an issue with skinned meshes is that the bounding box is not correct and thus it is not rendered. Did you check that?
     
  3. hothead-brusnell

    hothead-brusnell

    Joined:
    Apr 15, 2014
    Posts:
    18
    Hi,

    Thanks for the reply. I *THINK* I've found the problem. We create our characters in an editor-only tool, and use AssetDatabase.CreateAsset() to write out the final mesh (using a .prefab extension). That said, when I load up the resulting .prefab file, the game loads it as a Mesh Renderer, instead of a Skinned Mesh Renderer. Could this be the issue? If it is, how can I write out the mesh and have unity store it as a Skinned Mesh Renderer?

    Thanks.
     
  4. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    You can use any mesh with a skinned mesh renderer as far as I know. But if you are creating it in an editor tool, it is very likely that the bounding box is not correct which would explain your issue.
     
  5. hothead-brusnell

    hothead-brusnell

    Joined:
    Apr 15, 2014
    Posts:
    18
    As it turns out, I need to do two things:

    1) Change the bounds of the Skinned Mesh Renderer
    2) Wait a frame after enabling my camera's and character's Game Object

    Thanks!