Sothh
September 20, 2010, 5:58pm
1
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.grassStage.setMode(TextureStage.MBlend)
self.aoMap = loader.loadTexture('gfx/environment/towns/vaelAO.png')
self.grass = self.model.find('**/Grass')
self.grass.setTexture(self.grassStage,self.aoMap,0)
self.grass.setTexScale(self.grassStage,1,1)
self.grass.setTexOffset(self.grassStage,-100,-100)
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.
Sothh
September 21, 2010, 12:14pm
3
I don’t quite understand what you just said.
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