Search Unity

Cloth Renderer problems! - Double-sided meshes & Using more than 1 Material

Discussion in 'General Graphics' started by WF_Bart, Dec 5, 2014.

  1. WF_Bart

    WF_Bart

    Joined:
    Apr 16, 2014
    Posts:
    29
    So I'm having a number of problems with Unity's Cloth Renderer.

    First Problem - Double-Sided meshes

    I want my sails to be rendered from both sides. As far as I am aware the easiest way to do this should be to duplicate the geometry, and flip the duplicate faces. This works perfectly fine using the Mesh Renderer (I've tested it on exactly the same mesh). When I try to do this with the cloth renderer however, the following occurs:
    clothrendererlightingproblem.gif

    The Draw Normals script (the red lines) show that the normals seem to be in the right direction (reckoning from the undeformed mesh).

    I've discussed the problem in the #Unity3D chat channel on freenode and we came to the conclusion that the problem is probably with the cloth renderer (although I'm happy to be corrected there).

    I suppose a workaround would be to write a shader that does two passes on a single layer of geometry, which for me would unfortunately involve learning to write shaders... I'd prefer the cloth renderer to not be weird though!

    Maybe I should add the flickering only happens while the cloth is moving. If it's still, the dark and light areas are also still (but still there).

    To reproduce:
    Create a plane with a number of subdivisions in blender, duplicate the mesh in edit mode and 'flip normals'. 2. Export to Unity, add an interactive cloth component and a cloth renderer. Give it the right mesh, a material and add a collider so your cloth doesn't flutter away. Deactivate or remove the mesh renderer.
    Add some external/random acceleration so the cloth will move, hit play and you should be seeing something like the above.

    Second Problem - Cloth Renderer with more than One Material
    For clarity: in this situation I have not used any double geometry. I'm using a simple diffuse shader with backface culling turned off.

    To make my course sails look less flat when viewed from the side, I want to add a rope around it (as these sails in reality have). One problem is that it's a bit tricky to get the rope not to stretch too much as if it were cloth, but I can basically get that to look okay. Another problem is that my sail uses two textures - one for the sail and one for the rope. Again, this works fine on the mesh renderer, but the cloth renderer doesn't apply the right texture. Even more strangely (not visible in the gif) the Cloth Renderer applies a different texture on the backfaces than it does on the front faces (and this is a single one-sided mesh)!
    clothrenderer2materials.gif

    Unfortunately because it has to be part of the sail's physics simulation I can't seperate the rope from the sail... and because of the nature of our texture setup it wouldn't be ideal for me to have to put the rope on the same texture as the sail.. though I guess that would be a potential work-around.

    Again though I would prefer the Cloth Renderer to not be weird. Does anyone know why this is happening and perhaps how to fix it, or is that up to the Unity developers?
     
    pedromeleiro likes this.
  2. WF_Bart

    WF_Bart

    Joined:
    Apr 16, 2014
    Posts:
    29


    This wouldn't upload to the forum; but here you see the Cloth Renderer somehow applying one texture to the frontfaces and another to the backfaces.
    The shader I'm using is literally the Unity normal diffuse shader with backface culling turned offf.
     
  3. WF_Bart

    WF_Bart

    Joined:
    Apr 16, 2014
    Posts:
    29
    Can anyone confirm whether these are bugs or whether I'm doing something wrong?
     
  4. Creator126

    Creator126

    Joined:
    Jul 17, 2014
    Posts:
    4
    I don't know if you have fixed this yet or not, but I was experiencing the same problem. The solution I found was to take the model or mesh, and add more vertices to it in a modeling program.
     
  5. pedromeleiro

    pedromeleiro

    Joined:
    Jan 3, 2014
    Posts:
    2
    I'm experiencing the exact same problem regarding the use of multiple materials applied to the same Cloth Renderer component (v4.6.1f1). Is anyone familiar with a workaround that wouldn't require further changes to the uv maps, textures or meshes?

    Have yet to try it with Unity 5.0, but I believe this issue is not mentioned anywhere in the release notes.
     
  6. WF_Bart

    WF_Bart

    Joined:
    Apr 16, 2014
    Posts:
    29
    Unity 5 has a new Cloth component. While I still had trouble when I duplicated+flipped all faces, I gave my sails a little thickness and that seems to work fine.

    sails2.gif