The official texture thread

pytexwire08.jpg ==> e=0.01

pytexwire08.jpg ==> e=60.0

# pytex
#    jms 09/2005
#  pytexwire08.jpg ==> e=0.01
#  pytexwire10.jpg ==> e=0.01    transparent
#  pytexwire11.jpg ==> e=150.0   transparent
#  pytexwire09.jpg ==> e=60.0
import Blender
from Blender import Mathutils

tex = Blender.Texture.Get("Tex")
texvec = Mathutils.Vector(tex.getPytexCoords())
try :
 if Blender.texvec2 :
   if abs(Blender.A-A)>=e:
          r = 1.0#/abs(Blender.A-A)
          g = 0.0
          b = 0.0
          tex.setPytexColour(r, g, b)
          print Blender.A-A
          r = 1.0
          g = 1.0
          b = 1.0
          tex.setPytexColour(r, g, b)
 else :
except :

Nice to see a PyTex topic pop up already. I haven’t had a chance to change to wiki doc yet, but I highly recommend you no longer use Blender.Texture.Get for pytex instead:

tex = Blender.Texture.GetCurrentPytex()

This allows a couple of things :
a) inherent error checking
b) a pytex script can be linked to any number of textures, instead of being limited by the value given the Blender.Texture.Get.
c) its several times faster than Blender.Texture.Get, and this can climb to 10-15 times faster if there are a lot of textures in the scene.

I hope to see more pytex scritps begin shared around.


[edit]: btw nice work jms, looks good :slight_smile:

Sorry, but now, with this, blender fails (yesterday blenderpytex version, and
it fails witout too…)


I was just thinking, if you want to play with PyTex, how’s this for an idea for a cool experiment…

Create a load of falling empties (keyframe it, bake a physics simulation, particle system or whatever). Then define your texture plane (that has been subdivided multiple times) at a certain height. Using python and Pytex, create an animated texture (or more specifically a displacement map) that creates ripples everytime an empty passes through the texture plane! :smiley:

This sort of thing would be so very cool for simulating rain falling into a lake or something. Essentially it is like the ripple texture plugin except that it is triggered correctly.

Problem is getting some fast ripple code.

What do you think?


Use of a bunch of empties is a good idea but Pytex seems to work in a 3d space and not only on a plane .


The idea is that you use normal blender python to find the location of the empties in three dimensional space. When the z-value of one of the coordinates drops below a certain value (the height of the plane), python reads off the other two coordinates in world space and somehow (I don’t know how) ensures that on the next frame a ripple is generated at the point the empty crossed the plane.

I know that Python works in 3D but this is the simplest implementation I can think of.


for the moment , i just can do this :

import Blender
from  math  import *

tex = Blender.Texture.Get("Tex")
texvec = tex.getPytexCoords()

def col_func2(tex, c):
   global b,r,g 
   tex.setPytexColour(r, g, b)

col_func2(tex, texvec)