Stretched texture

Hello everyone,
I have a problem with stretched textures, I use brick texture of size 1600x1600
Also, I tried to use a smaller size image for texture, but no real effect

        Texture brickTexture = assetManager.loadTexture("Textures/brick.jpg");
        brickTexture.setWrap(Texture.WrapMode.Repeat);

        Material stoneMaterial = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
        stoneMaterial.getAdditionalRenderState().setFaceCullMode(RenderState.FaceCullMode.Off);
        stoneMaterial.setTexture("DiffuseMap", brickTexture);
        wall.setMaterial(stoneMaterial);
        //stairs.setMaterial(stoneMaterial);
        nearestTower.setMaterial(stoneMaterial);
        farTower.setMaterial(stoneMaterial);

Despite I use .setWrap(Texture.WrapMode.Repeat); on texture it is stretched.
I tried forum search and found a couple of similar issues with several possible solutions.

  1. setScale() method on texture, which can already be removed from Texture class, as it is not here
  2. set texture coordinates, but I cannot found an example how to do that.

If someone know how to fix this I will be much appreciated for your help!

In this example, I am scaling a texture from a child geometry of a larger model that is compromised of half a dozen geometries, each with its own texture. You would need to know the geometry name you want to scale in advance, but this should get you on your way to what you want to do.

        Geometry geomTrav_Arch = (Geometry) coloseum.getChild("Level-1_0");
        geomTrav_Arch.getMesh().scaleTextureCoordinates(new Vector2f(64.0f, 64.0f));

This was for a learning exercise but its best to scale things before exporting your models imo.

Edit: https://wiki.jmonkeyengine.org/docs/3.3/tutorials/concepts/faq.html#how-do-i-scale-mirror-or-wrap-a-texture

Edit: not sure if you use Blender but this 2.8 tutorial explains whats wrong with and how to fix your model before exporting.

Numerous examples in the source code. Quad.java is my favorite go-to for quick-and-dirty cut-pasting:

For when scaling the texture coordinates is not enough.

We can’t see what “wall” is… but if it’s a JME Box then that would be a better place to look in the source for texture setting as its vertexes are in a specific order, etc…

In fact, you only need to modify the material shader to complete this operation, as follows:


Shader source code:
(SPLighting.vert):
#import “Common/ShaderLib/GLSLCompat.glsllib”
#import “Common/ShaderLib/Instancing.glsllib”
#import “Common/ShaderLib/Skinning.glsllib”
#import “Common/ShaderLib/Lighting.glsllib”
#ifdef VERTEX_LIGHTING
#import “Common/ShaderLib/BlinnPhongLighting.glsllib”
#endif

uniform vec4 m_Ambient;
uniform vec4 m_Diffuse;
uniform vec4 m_Specular;
uniform float m_Shininess;

#if defined(VERTEX_LIGHTING)
uniform vec4 g_LightData[NB_LIGHTS];
#endif
uniform vec4 g_AmbientLightColor;
varying vec2 texCoord;

#ifdef SEPARATE_TEXCOORD
varying vec2 texCoord2;
attribute vec2 inTexCoord2;
#endif

varying vec3 AmbientSum;
varying vec4 DiffuseSum;
varying vec3 SpecularSum;
#ifdef TEX_REPEAT_STEP
uniform vec2 m_TexRepeatStep;
#endif

attribute vec3 inPosition;
attribute vec2 inTexCoord;
attribute vec3 inNormal;

#ifdef VERTEX_COLOR
attribute vec4 inColor;
#endif

#ifndef VERTEX_LIGHTING
varying vec3 vNormal;
varying vec3 vPos;
#ifdef NORMALMAP
attribute vec4 inTangent;
varying vec4 vTangent;
#endif
#else
#ifdef COLORRAMP
uniform sampler2D m_ColorRamp;
#endif
#endif

#ifdef USE_REFLECTION
uniform vec3 g_CameraPosition;
uniform vec3 m_FresnelParams;
varying vec4 refVec;

/**
 * Input:
 * attribute inPosition
 * attribute inNormal
 * uniform g_WorldMatrix
 * uniform g_CameraPosition
 *
 * Output:
 * varying refVec
 */
void computeRef(in vec4 modelSpacePos){
    // vec3 worldPos = (g_WorldMatrix * modelSpacePos).xyz;
    vec3 worldPos = TransformWorld(modelSpacePos).xyz;

    vec3 I = normalize( g_CameraPosition - worldPos  ).xyz;
    // vec3 N = normalize( (g_WorldMatrix * vec4(inNormal, 0.0)).xyz );
    vec3 N = normalize( TransformWorld(vec4(inNormal, 0.0)).xyz );

    refVec.xyz = reflect(I, N);
    refVec.w   = m_FresnelParams.x + m_FresnelParams.y * pow(1.0 + dot(I, N), m_FresnelParams.z);
}

#endif

void main(){
vec4 modelSpacePos = vec4(inPosition, 1.0);
vec3 modelSpaceNorm = inNormal;

#if defined(NORMALMAP) && !defined(VERTEX_LIGHTING)
vec3 modelSpaceTan = inTangent.xyz;
#endif

#ifdef NUM_BONES
#if defined(NORMALMAP) && !defined(VERTEX_LIGHTING)
Skinning_Compute(modelSpacePos, modelSpaceNorm, modelSpaceTan);
#else
Skinning_Compute(modelSpacePos, modelSpaceNorm);
#endif
#endif

gl_Position = TransformWorldViewProjection(modelSpacePos);

#ifdef TEX_REPEAT_STEP
texCoord = inTexCoord * m_TexRepeatStep;
#else
texCoord = inTexCoord;
#endif

#ifdef SEPARATE_TEXCOORD
texCoord2 = inTexCoord2;
#endif

vec3 wvPosition = TransformWorldView(modelSpacePos).xyz;
vec3 wvNormal = normalize(TransformNormal(modelSpaceNorm));
vec3 viewDir = normalize(-wvPosition);

#if defined(NORMALMAP) && !defined(VERTEX_LIGHTING)
  vTangent = vec4(TransformNormal(modelSpaceTan).xyz,inTangent.w);
  vNormal = wvNormal;         
  vPos = wvPosition;
#elif !defined(VERTEX_LIGHTING)
  vNormal = wvNormal;          
  vPos = wvPosition;
#endif

#ifdef MATERIAL_COLORS
    AmbientSum  = m_Ambient.rgb * g_AmbientLightColor.rgb; 
    SpecularSum = m_Specular.rgb;
    DiffuseSum = m_Diffuse;                   
#else
    // Defaults: Ambient and diffuse are white, specular is black.
    AmbientSum  = g_AmbientLightColor.rgb; 
    SpecularSum = vec3(0.0);
    DiffuseSum = vec4(1.0);
#endif
#ifdef VERTEX_COLOR               
    AmbientSum *= inColor.rgb;
    DiffuseSum *= inColor;
#endif
#ifdef VERTEX_LIGHTING
    int i = 0;
    vec3 diffuseAccum  = vec3(0.0);
    vec3 specularAccum = vec3(0.0);
    vec4 diffuseColor;
    vec3 specularColor;
    for (int i =0;i < NB_LIGHTS; i+=3){
        vec4 lightColor = g_LightData[i];            
        vec4 lightData1 = g_LightData[i+1];            
        #ifdef MATERIAL_COLORS
          diffuseColor  = m_Diffuse * vec4(lightColor.rgb, 1.0);                
          specularColor = m_Specular.rgb * lightColor.rgb;
        #else                
          diffuseColor  = vec4(lightColor.rgb, 1.0);
          specularColor = vec3(0.0);
        #endif

        vec4 lightDir;
        vec3 lightVec;
        lightComputeDir(wvPosition, lightColor.w, lightData1, lightDir, lightVec);
      //  lightDir = normalize(lightDir);
      //  lightVec = normalize(lightVec);
        
        float spotFallOff = 1.0;
        #if __VERSION__ >= 110
            // allow use of control flow
        if(lightColor.w > 1.0){
        #endif
           vec4 lightDirection = g_LightData[i+2];
           spotFallOff = computeSpotFalloff(lightDirection, lightVec);
        #if __VERSION__ >= 110
        }
        #endif
        vec2 light = computeLighting(wvNormal, viewDir, lightDir.xyz, lightDir.w  * spotFallOff, m_Shininess);

        #ifdef COLORRAMP
            diffuseAccum  += texture2D(m_ColorRamp, vec2(light.x, 0.0)).rgb * diffuseColor.rgb;
            specularAccum += texture2D(m_ColorRamp, vec2(light.y, 0.0)).rgb * specularColor;
        #else
            diffuseAccum  += light.x * diffuseColor.rgb;
            specularAccum += light.y * specularColor;
        #endif
    }

    DiffuseSum.rgb  *= diffuseAccum.rgb;
    SpecularSum.rgb *= specularAccum.rgb;
#endif


#ifdef USE_REFLECTION
    computeRef(modelSpacePos);
#endif 

}
(Lighting.vert):
#import “Common/ShaderLib/GLSLCompat.glsllib”
#import “Common/ShaderLib/Instancing.glsllib”
#import “Common/ShaderLib/Skinning.glsllib”
#import “Common/ShaderLib/Lighting.glsllib”
#ifdef VERTEX_LIGHTING
#import “Common/ShaderLib/BlinnPhongLighting.glsllib”
#endif

uniform vec4 m_Ambient;
uniform vec4 m_Diffuse;
uniform vec4 m_Specular;
uniform float m_Shininess;
#ifdef TEX_REPEAT_STEP
uniform vec2 m_TexRepeatStep;
#endif

uniform vec4 g_LightColor;
uniform vec4 g_LightPosition;
uniform vec4 g_AmbientLightColor;

varying vec2 texCoord;
#ifdef SEPARATE_TEXCOORD
varying vec2 texCoord2;
attribute vec2 inTexCoord2;
#endif

varying vec3 AmbientSum;
varying vec4 DiffuseSum;
varying vec3 SpecularSum;

attribute vec3 inPosition;
attribute vec2 inTexCoord;
attribute vec3 inNormal;

varying vec3 lightVec;

#ifdef VERTEX_COLOR
attribute vec4 inColor;
#endif

#ifndef VERTEX_LIGHTING
attribute vec4 inTangent;

#ifndef NORMALMAP
varying vec3 vNormal;
#endif
varying vec3 vViewDir;
varying vec4 vLightDir;
#else
varying vec2 vertexLightValues;
uniform vec4 g_LightDirection;
#endif

#if (defined(PARALLAXMAP) || (defined(NORMALMAP_PARALLAX) && defined(NORMALMAP))) && !defined(VERTEX_LIGHTING)
varying vec3 vViewDirPrlx;
#endif

#ifdef USE_REFLECTION
uniform vec3 g_CameraPosition;

uniform vec3 m_FresnelParams;
varying vec4 refVec;

/**
 * Input:
 * attribute inPosition
 * attribute inNormal
 * uniform g_WorldMatrix
 * uniform g_CameraPosition
 *
 * Output:
 * varying refVec
 */
void computeRef(in vec4 modelSpacePos){
    // vec3 worldPos = (g_WorldMatrix * modelSpacePos).xyz;
    vec3 worldPos = TransformWorld(modelSpacePos).xyz;

    vec3 I = normalize( g_CameraPosition - worldPos  ).xyz;
    // vec3 N = normalize( (g_WorldMatrix * vec4(inNormal, 0.0)).xyz );
    vec3 N = normalize( TransformWorld(vec4(inNormal, 0.0)).xyz );

    refVec.xyz = reflect(I, N);
    refVec.w   = m_FresnelParams.x + m_FresnelParams.y * pow(1.0 + dot(I, N), m_FresnelParams.z);
}

#endif

void main(){
vec4 modelSpacePos = vec4(inPosition, 1.0);
vec3 modelSpaceNorm = inNormal;

#ifndef VERTEX_LIGHTING
vec3 modelSpaceTan = inTangent.xyz;
#endif

#ifdef NUM_BONES
#ifndef VERTEX_LIGHTING
Skinning_Compute(modelSpacePos, modelSpaceNorm, modelSpaceTan);
#else
Skinning_Compute(modelSpacePos, modelSpaceNorm);
#endif
#endif

gl_Position = TransformWorldViewProjection(modelSpacePos);// g_WorldViewProjectionMatrix * modelSpacePos;

#ifdef TEX_REPEAT_STEP
texCoord = inTexCoord * m_TexRepeatStep;
#else
texCoord = inTexCoord;
#endif

#ifdef SEPARATE_TEXCOORD
texCoord2 = inTexCoord2;
#endif

vec3 wvPosition = TransformWorldView(modelSpacePos).xyz;// (g_WorldViewMatrix * modelSpacePos).xyz;
vec3 wvNormal = normalize(TransformNormal(modelSpaceNorm));//normalize(g_NormalMatrix * modelSpaceNorm);
vec3 viewDir = normalize(-wvPosition);

vec4 wvLightPos = (g_ViewMatrix * vec4(g_LightPosition.xyz,clamp(g_LightColor.w,0.0,1.0)));
wvLightPos.w = g_LightPosition.w;
vec4 lightColor = g_LightColor;

#if (defined(NORMALMAP) || defined(PARALLAXMAP)) && !defined(VERTEX_LIGHTING)
vec3 wvTangent = normalize(TransformNormal(modelSpaceTan));
vec3 wvBinormal = cross(wvNormal, wvTangent);
mat3 tbnMat = mat3(wvTangent, wvBinormal * inTangent.w,wvNormal);
#endif

#if defined(NORMALMAP) && !defined(VERTEX_LIGHTING)
vViewDir = -wvPosition * tbnMat;
#if (defined(PARALLAXMAP) || (defined(NORMALMAP_PARALLAX) && defined(NORMALMAP)))
vViewDirPrlx = vViewDir;
#endif
lightComputeDir(wvPosition, lightColor.w, wvLightPos, vLightDir, lightVec);
vLightDir.xyz = (vLightDir.xyz * tbnMat).xyz;
#elif !defined(VERTEX_LIGHTING)
vNormal = wvNormal;
vViewDir = viewDir;
#if defined(PARALLAXMAP)
vViewDirPrlx = -wvPosition * tbnMat;
#endif
lightComputeDir(wvPosition, lightColor.w, wvLightPos, vLightDir, lightVec);
#endif

#ifdef MATERIAL_COLORS
AmbientSum = (m_Ambient * g_AmbientLightColor).rgb;
DiffuseSum = m_Diffuse * vec4(lightColor.rgb, 1.0);
SpecularSum = (m_Specular * lightColor).rgb;
#else
// Defaults: Ambient and diffuse are white, specular is black.
AmbientSum = g_AmbientLightColor.rgb;
DiffuseSum = vec4(lightColor.rgb, 1.0);
SpecularSum = vec3(0.0);
#endif

#ifdef VERTEX_COLOR
  AmbientSum *= inColor.rgb;
  DiffuseSum *= inColor;
#endif

#ifdef VERTEX_LIGHTING
    float spotFallOff = 1.0;
    vec4 vLightDir;
    lightComputeDir(wvPosition, lightColor.w, wvLightPos, vLightDir, lightVec);
    #if __VERSION__ >= 110
        // allow use of control flow
    if(lightColor.w > 1.0){
    #endif           
       spotFallOff = computeSpotFalloff(g_LightDirection, lightVec);
    #if __VERSION__ >= 110           
    }
    #endif
    
    vertexLightValues = computeLighting(wvNormal, viewDir, vLightDir.xyz, vLightDir.w * spotFallOff, m_Shininess);
#endif

#ifdef USE_REFLECTION 
    computeRef(modelSpacePos);
#endif 

}
MyLighting.j3md:
MaterialDef Phong Lighting {

MaterialParameters {

    // Compute vertex lighting in the shader
    // For better performance
    Boolean VertexLighting

    // Alpha threshold for fragment discarding
    Float AlphaDiscardThreshold 

    // Use the provided ambient, diffuse, and specular colors
    Boolean UseMaterialColors

    // Use vertex color as an additional diffuse color.
    Boolean UseVertexColor
    
    // Texture repeat step
    Vector2 TexRepeatStep

    // Ambient color
    Color Ambient

    // Diffuse color
    Color Diffuse

    // Specular color
    Color Specular

    // Specular power/shininess
    Float Shininess : 1

    // Diffuse map
    Texture2D DiffuseMap

    // Normal map
    Texture2D NormalMap -LINEAR

    // Specular/gloss map
    Texture2D SpecularMap

    // Parallax/height map
    Texture2D ParallaxMap -LINEAR

    //Set to true is parallax map is stored in the alpha channel of the normal map
    Boolean PackedNormalParallax   

    //Sets the relief height for parallax mapping
    Float ParallaxHeight : 0.05       

    //Set to true to activate Steep Parallax mapping
    Boolean SteepParallax

    // Texture that specifies alpha values
    Texture2D AlphaMap -LINEAR

    // Color ramp, will map diffuse and specular values through it.
    Texture2D ColorRamp

    // Texture of the glowing parts of the material
    Texture2D GlowMap

    // Set to Use Lightmap
    Texture2D LightMap

    // Set to use TexCoord2 for the lightmap sampling
    Boolean SeparateTexCoord

    // The glow color of the object
    Color GlowColor

    // Parameters for fresnel
    // X = bias
    // Y = scale
    // Z = power
    Vector3 FresnelParams

    // Env Map for reflection
    TextureCubeMap EnvMap

    // the env map is a spheremap and not a cube map
    Boolean EnvMapAsSphereMap

    //shadows
     Int FilterMode
    Boolean HardwareShadows

    Texture2D ShadowMap0
    Texture2D ShadowMap1
    Texture2D ShadowMap2
    Texture2D ShadowMap3
    //pointLights
    Texture2D ShadowMap4
    Texture2D ShadowMap5
    
    Float ShadowIntensity
    Vector4 Splits
    Vector2 FadeInfo

    Matrix4 LightViewProjectionMatrix0
    Matrix4 LightViewProjectionMatrix1
    Matrix4 LightViewProjectionMatrix2
    Matrix4 LightViewProjectionMatrix3
    //pointLight
    Matrix4 LightViewProjectionMatrix4
    Matrix4 LightViewProjectionMatrix5   
    Vector3 LightPos
    Vector3 LightDir

    Float PCFEdge
    Float ShadowMapSize

    // For hardware skinning
    Int NumberOfBones
    Matrix4Array BoneMatrices
            
    //For instancing
    Boolean UseInstancing

    Boolean BackfaceShadows : false
}

Technique {
    LightMode SinglePass

    VertexShader GLSL100 GLSL150:   Shaders/Standard/SPLighting.vert
    FragmentShader GLSL100 GLSL150: Common/MatDefs/Light/SPLighting.frag

    WorldParameters {
        WorldViewProjectionMatrix
        NormalMatrix
        WorldViewMatrix
        ViewMatrix
        CameraPosition
        WorldMatrix
        ViewProjectionMatrix            
    }

    Defines {           
        VERTEX_COLOR : UseVertexColor
        VERTEX_LIGHTING : VertexLighting           
        MATERIAL_COLORS : UseMaterialColors         
        TEX_REPEAT_STEP : TexRepeatStep
        DIFFUSEMAP : DiffuseMap
        NORMALMAP : NormalMap
        SPECULARMAP : SpecularMap
        PARALLAXMAP : ParallaxMap
        NORMALMAP_PARALLAX : PackedNormalParallax
        STEEP_PARALLAX : SteepParallax
        ALPHAMAP : AlphaMap
        COLORRAMP : ColorRamp
        LIGHTMAP : LightMap
        SEPARATE_TEXCOORD : SeparateTexCoord
        DISCARD_ALPHA : AlphaDiscardThreshold
        USE_REFLECTION : EnvMap
        SPHERE_MAP : EnvMapAsSphereMap  
        NUM_BONES : NumberOfBones                        
        INSTANCING : UseInstancing
    }
}

Technique {

    LightMode MultiPass

    VertexShader GLSL100 GLSL150:   Shaders/Standard/Lighting.vert
    FragmentShader GLSL100 GLSL150: Common/MatDefs/Light/Lighting.frag

    WorldParameters {
        WorldViewProjectionMatrix
        NormalMatrix
        WorldViewMatrix
        ViewMatrix
        CameraPosition
        WorldMatrix
        ViewProjectionMatrix            
    }

    Defines {
        VERTEX_COLOR : UseVertexColor
        VERTEX_LIGHTING : VertexLighting            
        MATERIAL_COLORS : UseMaterialColors
        TEX_REPEAT_STEP : TexRepeatStep
        DIFFUSEMAP : DiffuseMap
        NORMALMAP : NormalMap
        SPECULARMAP : SpecularMap
        PARALLAXMAP : ParallaxMap
        NORMALMAP_PARALLAX : PackedNormalParallax
        STEEP_PARALLAX : SteepParallax
        ALPHAMAP : AlphaMap
        COLORRAMP : ColorRamp
        LIGHTMAP : LightMap
        SEPARATE_TEXCOORD : SeparateTexCoord
        DISCARD_ALPHA : AlphaDiscardThreshold
        USE_REFLECTION : EnvMap
        SPHERE_MAP : EnvMapAsSphereMap  
        NUM_BONES : NumberOfBones                        
        INSTANCING : UseInstancing
    }
}

Technique PreShadow {

    VertexShader GLSL100 GLSL150 :   Common/MatDefs/Shadow/PreShadow.vert
    FragmentShader GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.frag

    WorldParameters {
        WorldViewProjectionMatrix
        WorldViewMatrix
        ViewProjectionMatrix
        ViewMatrix
    }

    Defines {
        DISCARD_ALPHA : AlphaDiscardThreshold
        NUM_BONES : NumberOfBones
        INSTANCING : UseInstancing
    }

    ForcedRenderState {
        FaceCull Off
        DepthTest On
        DepthWrite On
        PolyOffset 5 3
        ColorWrite Off
    }

}


Technique PostShadow {
    VertexShader GLSL100 GLSL150:   Common/MatDefs/Shadow/PostShadow.vert
    FragmentShader GLSL100 GLSL150: Common/MatDefs/Shadow/PostShadow.frag

    WorldParameters {
        WorldViewProjectionMatrix
        WorldMatrix
        ViewProjectionMatrix
        ViewMatrix
        NormalMatrix
    }

    Defines {
        HARDWARE_SHADOWS : HardwareShadows
        FILTER_MODE : FilterMode
        PCFEDGE : PCFEdge
        DISCARD_ALPHA : AlphaDiscardThreshold
        SHADOWMAP_SIZE : ShadowMapSize
        FADE : FadeInfo
        PSSM : Splits
        POINTLIGHT : LightViewProjectionMatrix5
        NUM_BONES : NumberOfBones
        INSTANCING : UseInstancing
        BACKFACE_SHADOWS: BackfaceShadows
    }

    ForcedRenderState {
        Blend Modulate
        DepthWrite Off                 
        PolyOffset -0.1 0
    }
}

Technique PreNormalPass {

    VertexShader GLSL100 GLSL150 :   Common/MatDefs/SSAO/normal.vert
    FragmentShader GLSL100 GLSL150 : Common/MatDefs/SSAO/normal.frag

    WorldParameters {
        WorldViewProjectionMatrix
        WorldViewMatrix
        NormalMatrix
        ViewProjectionMatrix
        ViewMatrix
    }

    Defines {
        DIFFUSEMAP_ALPHA : DiffuseMap
        NUM_BONES : NumberOfBones
        INSTANCING : UseInstancing
    }

}

Technique Glow {

    VertexShader GLSL100 GLSL150:   Common/MatDefs/Misc/Unshaded.vert
    FragmentShader GLSL100 GLSL150: Common/MatDefs/Light/Glow.frag

    WorldParameters {
        WorldViewProjectionMatrix
        ViewProjectionMatrix
        ViewMatrix
    }

    Defines {
        NEED_TEXCOORD1
        HAS_GLOWMAP : GlowMap
        HAS_GLOWCOLOR : GlowColor

        NUM_BONES : NumberOfBones
        INSTANCING : UseInstancing
    }
}

}

First: How to type code blocks

Second: that’s a LOT of work to go through just to avoid setting proper texture coordinates.

1 Like

Thanks all for replies, will try later today.
My models ,i.e. wall or farTower are simplest models(without any materials or effects applied) exported as gltf from blender and converted to j3o using SDK.
Imported like this:

        Spatial wall = assetManager.loadModel("Models/wall.j3o");

Also this morning I tried to create a geometry with the cube instead of loading j3o model, with the same material appliedl:

        //Spatial farTower = assetManager.loadModel("Models/tower.j3o");
        Box box = new Box(10,10,10);
        Spatial farTower = new Geometry("", box);

And… this works, maybe it can help find out where I can fail

Without scaling the texture coordinates on the box, if you make it really long then it will stretch the texture coordinates.

Taking a step back, do you understand how texture coordinates work?

For models you will be exporting from Blender anyway, it’s best to get the UVs correct there before exporting.

1 Like

No, not yet, will read about it

Now my issue is solved. Thanks everyone

Working solution described in @mitm message. Scaling texture coordinates and playing with UV mapping in blender models fixed the issue for me.
@JhonKkk It seems that I don’t have a “TexRepeatStep” point in my material editor, which version of sdk do you use?

He was suggesting a “work around” the involved creating custom shaders and stuff instead of just fixing the UVs.

Note that if the UVs are properly setup in blender then you don’t need to scale the textures but I’m glad you have something working. Working > perfect.

2 Likes

My approach is that the model still keeps the texture coordinates as 0-1 instead of 0-n (n represents the repeated value of the repeated texture coordinates), and then only needs to transform the texture coordinates in the material definition (in fact, there is only one multiplication operation). In this way, you don’t have to modify the texture coordinates every time to achieve the required number of repetitions, but only need to update one parameter of the material, such as repeat 5 times or repeat 10 times. I think it is more appropriate to solve this problem from the material definition. Doing so can avoid the need to modify different texture coordinates for different repeated textures.

The reply above lists my changes to Lighting.j3md. If you don’t understand, I can submit a complete and revised Lighting.j3md to you.

Ah, that was modified texture, then everything are on their place :slight_smile:
Thank you, but going deeper in UV mapping (as per Paul’s comment) allows me got the correct result without apply the texture scale.

I had the same issue (stretched texture). And I have same experience as the author of this topic. But I do not work with Blender. I working with SceneComposer (add Spatial/Primitives/Box) and .jpg textures.
2 things I don’t understand:

  1. Do I have to do the math myself for every mesh? (I want texture not stretches but repeats)
  2. Do I need every time insert? (I use Lighting j3md)
TangentBinormalGenerator.generate(wall);

Can I declare this in .j3m or j3o file or my mesh or my material

  1. I think doing this step should work: Stretched texture - #4 by JhonKkk
    You just need to click ‘repeat’ for the texture in the material editor.