setTexOffset not working

I am trying to add an ambient occlusion map to my grass texture.

Loading and scaling the texture work fine, but the texture appears in the wrong position.

Here is my code:

#Texture maps:
self.grassStage = TextureStage('ts')

self.aoMap = loader.loadTexture('gfx/environment/towns/vaelAO.png')

self.grass = self.model.find('**/Grass')


I am using Panda 1.7.1

Any ideas?

offsets are in a space where 0-1 spans the entire-unscaled texture. from what it appears you try to offset it by 100 pixels. in this case you’d have calculate the offset based on the image resolution first.

I don’t quite understand what you just said. :slight_smile:

The texture is 1024x1024

if your texture looks like this:

1,2,3 … 1024
then the uv-coordinates go like this
0, 0.1 … 1

so if you offset your uv-map by 100, it will offset it 100 times the entire texture. since textures repeat by default you’ll get no visual difference.

if you want to offset 100 pixels on a 1024 texture you have to offset (1./1024)*100 . which is aproximately 0.09765625

Okay, thanks!