Page 1 of 2 12 LastLast
Results 1 to 10 of 13

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

  1. #1
    Junior Member Newbie
    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
    Member Contributor
    Join Date
    Dec 2015
    Posts
    74
    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 Newbie
    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
    Member Contributor
    Join Date
    Dec 2015
    Posts
    74
    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 02:49 AM.

  5. #5
    Junior Member Newbie
    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
    Member Contributor
    Join Date
    Dec 2015
    Posts
    74
    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.

  7. #7
    Junior Member Newbie
    Join Date
    Jun 2018
    Posts
    10
    i use c# to create xml with collada and export it in cesium (smth like google earth).

    - - - Updated - - -

    i also try to change normal array to change side of surface but nothing changed too

  8. #8
    Member Contributor
    Join Date
    Dec 2015
    Posts
    74
    Cesium has great community, you may want to move this issue to there: https://github.com/AnalyticalGraphicsInc/cesium by creating new issue: https://github.com/AnalyticalGraphic...ium/issues/new

  9. #9
    Junior Member Newbie
    Join Date
    Jun 2018
    Posts
    10
    Thank you.

  10. #10
    Senior Member Regular Contributor
    Join Date
    Mar 2016
    Posts
    120
    Going by the manual, there is mention of <semantic>DOUBLE_SIDED</semantic> used with <param> or <newparam> or <setparam> for instance via <material><instance_effect>.

    I think the Cg profile may have built-in parameters for this. The GLSL profile is more open-ended, but you can program shaders that branch on a fragments side-of-the-face.

    P.S. Sorry for my absence! I have not been receiving notifications about new posts in this forum, and so forgot it existed. Sorry. On the plus side, there is just two new threads. I thought there were more because I hadn't posted in some, but I do remember the others. I have to figure out why I am not receiving notifications
    This account can Moderator spam in the COLLADA forum.
    ColladaDOM 3 (COLLADA-DOM 2016)
    https://sourceforge.net/p/collada-do...ussion/531263/

Page 1 of 2 12 LastLast

Similar Threads

  1. Texture coordinates need to change when I change triangulation?
    By Grognard in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 12-05-2016, 02:35 AM
  2. hang when running two programs side by side
    By remdul in forum OpenGL: Windows
    Replies: 2
    Last Post: 12-29-2011, 09:03 AM
  3. Texture to only on the front side
    By Efreet in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 06-02-2010, 12:53 AM
  4. Right side and Left side Lighting not happening
    By iris_raj in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 12-11-2003, 06:39 PM
  5. wire appears to move from side to side on object
    By JoeFinn in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 01-18-2001, 09:18 PM

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