Perhaps someone can tell me if there is a way to solve my problem…
Right now I am using multi-texturing for my map, in example, applying a grass texture according to an alpha map. However, I want it to also tile the grass. If I attempt this, however, it also tiles the alpha and I end up with grass all over the place, and where it shouldn’t be. Can anyone tell me a way to tile a texture, “binding” it to the same alpha?
def setMultiTexture(self, alpha, texfile):
self.it += 1
colortex = loader.loadTexture(texfile, alpha)
ts = TextureStage('ts' + str(self.it))
ts.setMode(TextureStage.MDecal)
self.terrainRoot.setTexture(ts, colortex)
self.terrainRoot.setTexScale(ts, 10, 10)
However, that code produces this:
Any suggestions?
ynjh_jo
September 18, 2010, 8:44am
2
Is the model already textured before calling that method ?
If not, you should :
apply the color tex to the default stage
apply the alpha tex to the 2nd stage
loader.loadTexture(texfile, alpha) gives you 1 texture with alpha. If you want to control them separately, load them separately too.
Thanks, that sort-of fixed the problem.
How can I get TextureStage ts to adhere only to the white portion of ts2?
def setMultiTexture(self, alpha, texfile, alphaPriority=0, texfilePriority=0):
self.it += 1
colortex = loader.loadTexture(texfile)
alphatex = loader.loadTexture(alpha)
ts = TextureStage('ts_' + str(self.it))
ts.setMode(TextureStage.MDecal)
ts.setSort(texfilePriority)
ts2 = TextureStage('ts2_' + str(self.it))
ts2.setMode(TextureStage.MDecal)
ts2.setSort(alphaPriority)
self.terrainRoot.setTexture(ts, colortex)
self.terrainRoot.setTexture(ts2, alphatex)
self.terrainRoot.setTexScale(ts, 30, 30)
ynjh_jo
September 18, 2010, 3:41pm
4
like this ?
#_____SPOTLIGHT
img=PNMImage(32,32)
img.addAlpha()
img.renderSpot(Vec4D(1,1,1,1),Vec4D(1,1,1,0),.85,.9)
#_____DOUGHNUT o_0
img1=PNMImage()
img1.copyFrom(img)
img2=PNMImage(32,32)
img2.addAlpha()
img2.renderSpot(Vec4D(1,1,1,0),Vec4D(1,1,1,1),.35,.4)
img1.darkenSubImage(img2,0,0,0,0)
alphaTex = Texture()
alphaTex.load(img1)
CM = CardMaker('')
CM.setFrame(-1,1,-1,1)
card = render.attachNewNode(CM.generate())
card.setScale(3)
t = loader.loadTexture('maps/envir-treetrunk.jpg')
ts = TextureStage.getDefault()
ts.setSavedResult(True)
card.setTexture(ts,t)
t1 = loader.loadTexture('maps/envir-ground.jpg')
ts1 = TextureStage('1')
ts1.setMode(TextureStage.MReplace)
card.setTexture(ts1,t1)
card.setTexScale(ts1,15)
ts2 = TextureStage('2')
ts2.setCombineRgb(TextureStage.CMInterpolate,
TextureStage.CSLastSavedResult,TextureStage.COSrcColor,
TextureStage.CSPrevious,TextureStage.COSrcColor,
TextureStage.CSTexture,TextureStage.COSrcAlpha,
)
card.setTexture(ts2,alphaTex)
Thank you SO MUCH, this works like a charm!