Login  Register

Multi-Texturing with a single texture using different S, T texCoords.

Posted by Arniox on May 22, 2019; 12:59am
URL: https://forum.jogamp.org/Multi-Texturing-with-a-single-texture-using-different-S-T-texCoords-tp4039801.html

Hey all, new here.
I just asked a question on the stackoverflow forums here Link to post

What I am trying to do is texture my 3D triangle based terrain (using GL_TRIANGLE_STRIP) with different textures depending on a multitude of things such as height (a snowy texture), steepness (rocky texture) or flat (grass texture).

I started by trying to use shaders but as they are not required for this project (it's part of an assignment) and since I didn't know much about them I decided to go with more of a fixed pipeline solution. I first tried using multiTexCoords but found they didn't work the way I wanted so I ended up moving all my textures into one single texture.png and then using texCoords to try and place the correct S, T coords onto the terrain.
Currently my code is as such:


with the textures being bound with a Texture java utils object.

The current code makes my terrain display as such: Stripy Texture and Stripy Texture 2
What I want is to shift the S and T coords so that I can easily have the entire terrain be only the grass section of the .png file, or only snow, or only rocky. From there I could easily have different parts of the terrain use different S and T coords of the texture object.