Creating custom texture

I’ve been using the default textures in the Blender API to generate some heightmaps for displacement in my models: http://www.blender.org/api/blender_python_api_2_69_release/bpy.types.Texture.html#bpy.types.Texture

However, i’m feeling the need to write some custom algorithms. I have implemented some basic simplex noise with my custom modifications, but i have no idea how to transform that into a Texture object in Blender. Is that possible? Can you send a byte array or something and create a texture object? Or do i have to save to the filesystem and then load it as a bitmap texture?

I think that i might have expressed myself badly. I’m not trying to apply the texture to the object or do anything like Substance or FilterForge. I’m just generating some 2D noise that i’m able to display in different levels of black and white. However, i don’t know how to transform that noise data i have into a bpy.types.Texture, so i can use it in modifiers like Displace. Take this, for example:


tex = bpy.data.textures.new('Voronoi', type='VORONOI')
mod = obj.modifiers.new(name='Displacement', type='DISPLACE')
mod.texture = tex

I want to, instead of invoking bpy.data.textures.new() with a prebuilt Blender texture, i want to use my raw bitmap data.

Hmm, then you might try to use an image texture with your data as image, to which you save your noise data before.


tex = bpy.data.textures.new('Noise', type='IMAGE')
tex.image = bpy.data.images["name_of_your_noise_image"]

mod = obj.modifiers.new(name='Displacement', type='DISPLACE')
mod.texture = tex

Yes, that’s the issue. I don’t want to save my bitmap data as a file before loading into the texture object, i was looking for a way of doing it directly.

Well, you cant do this without an image… you could try with an in-memory image if you dont wanna save to disk, and write your data via python into a blank generated image by filling the image.pixels 2D array with float values you generate… might be slow if you have many pixels. This image can be packed into the blend itself then.
There are no more options except image textures, though. Editing the procedural textures as in generating a new type would require changes in C code.

what kind of objects ?

the noise used to create say a mountain range would be different than for water in the ocean

or for the finish on a table top if it is a 20 step mirror finish or a single coat of urethane

i have normally used a gray 32bit floatingpoint image as a height map

— edit —
i am guessing rocks - after doing a username SEARCH of old posts