Results 1 to 9 of 9

Thread: How can i change the side of surface with texture?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Junior Member
    Join Date
    Jun 2018
    Posts
    10

    How can i change the side of surface with texture?

    what attribute is responsible for the side of the surface on which the texture will apply?

  2. #2
    Are you trying to render double-sided surface, if not what do you mean with side? AFAIK, COLLADA and most other formats only specifies an image and texcoords for texture, not side. If you want to render texture to other side of surface then you could negate NORMAL to light other side after activated/enabled two-sided rendering. In this way you could render two side with same texture.

    But if you need different texture for back face then you may need you render that surface twice once for front face and once for back face. Or as alternative you could bind extra texture and if back face (simply by testing gl_FrontFacing) is being rendered then you could use different sampler.

    In the end I am not aware of an attribute which specifies texture side. Except if your texture is cube texture then COLLADA defines face attribute in init_from element (follow image element in spec):

    POSITIVE_X
    NEGATIVE_X
    POSITIVE_Y
    NEGATIVE_Y
    POSITIVE_Z
    NEGATIVE_Y
    POSITIVE_Z

    of course COLLADA can be extended via extensions. You could write an extension for your needs if you use application/engine-specific features.

  3. #3
    Junior Member
    Join Date
    Jun 2018
    Posts
    10
    Quote Originally Posted by recpas View Post
    Are you trying to render double-sided surface, if not what do you mean with side? AFAIK, COLLADA and most other formats only specifies an image and texcoords for texture, not side. If you want to render texture to other side of surface then you could negate NORMAL to light other side after activated/enabled two-sided rendering. In this way you could render two side with same texture.
    Can you please give me the example with xml code where and what should i write to render double-sided surface.

  4. #4
    Here an example of two-sided rendering: https://en.wikibooks.org/wiki/GLSL_P...Sided_Surfaces

    If you have normal like vNormal in fragment shader, then you could use -vNormal as normal:

    Disabling face culling will enable two-sided rendering.

    Code :
    glDisable(GL_CULL_FACE);

    GLSL fragment shader:
    Code :
    in vec3 vNormal;
     
    void main()
    {
      if (gl_FrontFacing) {
          // color calculated using vNormal
          gl_FragColor = color;
      } else {
          vec3 N;
     
          N  = -vNormal;
     
          // color calculated using N
     
          gl_FragColor = color;
      }
    }

    I think no need to give XML/COLLADA example since it doesn't matter for double-sided rendering. But in the future an extension would be great for specifying if material is double-sided. AFAIK, currently there is no such attrib like this (there is one in glTF)

    I guess this will render back face same as front.
    Last edited by recp; 06-19-2018 at 01:49 AM.

  5. #5
    Junior Member
    Join Date
    Jun 2018
    Posts
    10
    i work only with collada file, so i can change xml only. i see in spec 1.5 that there is semantic attribute with double_sided. I also find:
    <extra>
    <technique profile="GOOGLEEARTH">
    <double_sided>1</double_sided>
    </technique>
    </extra>
    But nothing from this help me to have texture on both side of my surface.

  6. #6
    It doesn't matter what data you put in COLLADA file as semantic or as extra/extension. Importer and/or renderer must parse and understand that data, otherwise it will no affect. It is not issue related to COLLADA, It is all about how importers and engines implemented COLLADA, AFAIK not all importers support all COLLADA features.

    IIRC, you mentioned about web, do you use THREE.js or something? Maybe you could ask them about double-sided is supported or not (if this is what you really want). Probably double-sided is supported in engine you use, since you need to pass this info via COLLADA file, importer/engine must support this feature.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean