Menu

Second UV-map

Help
Daniel
2021-09-25
2021-09-30
  • Daniel

    Daniel - 2021-09-25

    Hello!
    I am trying to use a second UV-map on my models that I make in Blender.
    I want to access it in the GLSL-shader. Does anyone know how to do that?
    Is it gl_MultiTexCoord that chooses UV-map?

    All the best!
    /Daniel

     
  • tambok

    tambok - 2021-09-25

    hi daniel.
    this is just my suggestion, maybe there is in demo folder.

    regards
    tbk

     
  • Daniel

    Daniel - 2021-09-25

    Hi Tambok!
    Yes, I have been searching, but no luck...
    Thanks anyway!

    Cheers!

     
  • Daniel

    Daniel - 2021-09-27

    I got this response in the Khronos forums:

    If you’re using the legacy (fixed-function) API, texture coordinates can be specified by glTexCoord, glMultiTexCoord or glTexCoordPointer. Which set of texture coordinates are affected is determined by glActiveTexture for glTexCoord, the target parameter for glMultiTexCoord, and glClientActiveTexture for glTexCoordPointer.

    Within shaders, the various texture coordinates can be accessed through the gl_MultiTexCoord* variables.

    With 3+ core profile, you use e.g. glVertexAttribPointer to associate an array of texture coordinates with a generic vertex shader input (attribute).

    Which approach you need to use depends upon what the loading library is doing, i.e. whether it’s using legacy attributes or generic attributes. If it’s just handing you the arrays, it’s up to you which approach you take to pass that data to the shader

    Any ideas how to use it in GLScene?

     
  • Jerome.D (BeanzMaster)

    Hi Daniel the better way is to create a child of TGLCustomShader like shaders samples in glscene's code. You'll can pass your array of coordinates to your shader with uniforms properties.
    The second way is render your object through a TGLDirectOpenGL and apply gl_MultiTexCoord but this solution is weird for me and it need more work.

     
  • Daniel

    Daniel - 2021-09-27

    Hi Jerome! Passing in the array sounds like a very good solution!
    But how can I get the array from a freeForm or 3ds-file?

    Thank you for the response!

     
  • Jerome.D (BeanzMaster)

    Hello, if i'm remember 3DS loader only load the first UV.
    What do you want to acheive exactly ? It is a simple blending textures or it is an animation effect ?
    Perhaps it can be done in other way.

     
  • Daniel

    Daniel - 2021-09-28

    Ok! Is there anyway to get the first UV as an array or vectorlist from the freeForm?
    Maybe I could store the coordinates as a separate file and load it in as a uniform.

    I am trying to add in ambient occlusion and baked shadows to my models on a second UV map. The first UV with the main textures uses texture atlas with overlapping UV's, so I thought I could apply the AO via the shader on a second UV map that is not overlapping.

     
  • Jerome.D (BeanzMaster)

    Hi, for baked shadow why don't you bake the whole texture ,texture + shadow in only one texture ?
    For ambient occlusion you can take look here https://sourceforge.net/p/glscene/discussion/93605/thread/ca6814bb01/
    for SSAO (Screen space ambient occlusion)

     
  • Jerome.D (BeanzMaster)

    To store uv you must use the property TexCoords in TGLMeshObject (in a TGLFreeForm)

     
  • Daniel

    Daniel - 2021-09-30

    Hi Jerome!
    The main reason is that my models are big, with just one or two repeating base textures. Exterior hulls of battleships or long interior corridors. So the full UV gets very low resolution. Therefor I want to use repeting texture/overlapping UV for the base texture and a full UV bake for shadows/AO.
    I am also considering texture splatting using an alpha mask with the second UV.

    Could these stored texcoords be sent in as an uniform to the shader?

    Thanks for the help Jerome!

     

Log in to post a comment.