realtime texture painting

hi, just a random question came up to me, could the paint have a unique property?
just asking, because if that could be done then we can make something like the repulsion gel from portal 2 or stuff like that :smiley:

Hey, is there any new feature of this tool? 2d23d, you said that you would try to plot images to the texture…

I was thinking about preparing a brush with alpha before plotting it. So, we can create dynamic wrinkles in a portion of the texture. The code will take an small image of the (normal) wrinkle, multiply to the value of it and plot it (in the correct place) with MIX mode, overwritting the previous state of the wrinkle, but, using alpha, not tocuching the rest of the image (because another wrinkle could be near).

I’m trying to make dynamic wrinkles using ImageMix, but I reported a bug that avoid to change the weight of the images. This is a more complex way, because any wrinkle must be a different texture. In a face, there would be about 10 textures!

It’s easy to put a personalized brush, as you can see in the image.


You have to change this (in init.py):

GameLogic.brush = brush

to this:

file = GameLogic.expandPath(’//heart.png’)
image = bge.texture.ImageFFmpeg(file)
GameLogic.brush = image

And (in paint.py):
GameLogic.tex.source.plot(GameLogic.brush,32,32,x,y,0)
to:
GameLogic.tex.source.plot(GameLogic.brush,32,32,x,y,1) (1 instead of 0, to do MIX blending)

Now, I’m working to use this with GLSL and previously applying a texture to the object. For the moment I’m having problems to load an image to ImageFFmpeg… it has a strange behaviour (buggy).

It’s easy to put a personalized brush, as you can see in the image.


You have to change this (in init.py):

GameLogic.brush = brush

to this:

file = GameLogic.expandPath('//heart.png')
image = bge.texture.ImageFFmpeg(file)
GameLogic.brush = image

And (in paint.py):

GameLogic.tex.source.plot(GameLogic.brush,32,32,x,y,0)

to:

GameLogic.tex.source.plot(GameLogic.brush,32,32,x,y,1)

(1 instead of 0, to do MIX blending)

Now, I’m working to use this with GLSL and previously applying a texture to the object. For the moment I’m having problems to load an image to ImageFFmpeg… it has a strange behaviour (buggy).

Well… after some hours, I got it.

Texture Paint (with base)
Here, we have a base texture and a nice heart brush:


What we need to do this is:

  • Use ImageFFmpeg to load the PNG brush with alpha.
  • Use ImageFFmpeg to load the PNG base texture.
  • Create the ImageBuff
  • Load a clean empty image
  • Plot the base texture on it
  • Then, we plot the brush image using the original way.

Important: in texture panel, we use the “paint” texture that has the same texture as in the BGE. It doesn’t need to be the same… but we won’t use a texture to view in the viewport and another in BGE…

Bump Paint (basic normal painting)

And, here we have the BumpPaint: the same base texture, but the brush acts as bump brush:


We need to:

  • Use two textures in the stack.
  • The first texture (at top) is what we will use as Bump Paint. This will have Color unckecked and Normal ckecked (because Colour will be overwritten by the texture at the second place). Bump Mapping option as Low-Hi-Best Quality (not the others).
  • The second texture will be the base texture. This will be the same in the Engine.
  • In the code, we load the brush with ImageFFmpeg and use it. It will change the bump of the object.

What about Normal? I’m working on that… and many other things.

Attachments

Texture-Bump-Paint.zip (1.23 MB)

This is wonderful. Can please someone explain to me how to trade the mouse for an object (a cube that would leave a mark on a plane)? I already transfered all the logic bricks from the torus to my plane, it works and I can write on it (wow) now what can I use to make the plane texture aware of the (rig body) cube ?

A property sensor? A collision sensor? I tried both but maybe I messed up… Help?

This is wonderful. Can please someone explain to me how to trade the mouse for an object (a cube that would leave a mark on a plane)? I already transfered all the logic bricks from the torus to my plane, it works and I can write on it (wow) now what can I use to make the plane texture aware of the (rig body) cube ?

A property sensor? A collision sensor? I tried both but maybe I messed up… Help?

xaccrocheur: I think you will need something SCA_MouseSensor.hitUV, that returns UV data about the place that the mouse is over… but with Collision Sensor. I think it should be coded… and I don’t think it would be so difficult.

The blender API is incomplete. From MouseSensor, in the page, there’re 3 methods… but it already has

[‘class’, ‘delattr’, ‘dir’, ‘doc’, ‘eq’, ‘format’, ‘ge’, ‘getattribute’, ‘gt’, ‘hash’, ‘init’, ‘le’, ‘lt’, ‘ne’, ‘new’, ‘reduce’, ‘reduce_ex’, ‘repr’, ‘setattr’, ‘sizeof’, ‘str’, ‘subclasshook’, ‘executePriority’, ‘frequency’, ‘getButtonStatus’, ‘hitNormal’, ‘hitObject’, ‘hitPosition’, ‘hitUV’, ‘invalid’, ‘invert’, ‘level’, ‘mode’, ‘name’, ‘neg_ticks’, ‘owner’, ‘pos_ticks’, ‘position’, ‘positive’, ‘propName’, ‘rayDirection’, ‘raySource’, ‘rayTarget’, ‘reset’, ‘status’, ‘tap’, ‘triggered’, ‘useMaterial’, ‘useNegPulseMode’, ‘usePosPulseMode’, ‘usePulseFocus’, ‘useXRay’]

And, the API for Collision Sensor does not exist… it has:

[‘class’, ‘delattr’, ‘dir’, ‘doc’, ‘eq’, ‘format’, ‘ge’, ‘getattribute’, ‘gt’, ‘hash’, ‘init’, ‘le’, ‘lt’, ‘ne’, ‘new’, ‘reduce’, ‘reduce_ex’, ‘repr’, ‘setattr’, ‘sizeof’, ‘str’, ‘subclasshook’, ‘executePriority’, ‘frequency’, ‘hitMaterial’, ‘hitObject’, ‘hitObjectList’, ‘invalid’, ‘invert’, ‘level’, ‘name’, ‘neg_ticks’, ‘owner’, ‘pos_ticks’, ‘positive’, ‘propName’, ‘reset’, ‘status’, ‘tap’, ‘triggered’, ‘useMaterial’, ‘useNegPulseMode’, ‘usePosPulseMode’, ‘usePulseCollision’]

You should talk with devs about developing what you need… it will be very usefull.

Have you figured out how to do it? If so, please share it.

Hi, everyone! Does anyone know how i can save the painted texture? I need it because i want to generate a 2d heat map.

‘Image / Save as Image’ menu

Thanks for the fast answer!
The problem is that the texture only exists as long as the engine runs. So you can’t use the menu. I need some code that allows ‘save image as’ at the runtime of the application.

@farhani No, not really. All I could muster was a “add object” (the mark) that is very cycle-expensive ; I still dream about skidmarks in the snow :slight_smile:

I there also a way to erase the parts that were painted? Having something that acts like a rubber tool?

here is another file id like to contribute. I implemented it as snow in my project. just to see.


here is the test file.

testTexPaint_26.blend (247 KB)

Cuervo, can you show a example of how to texture the snow? (shaded) ?

like where I can just replace the texture ? I don’t know GLSL @ all :expressionless:

can you bind it to collision with a property ? (then people would be using it tomorrow)
that said, it’s amazing :smiley:

here is another file id like to contribute. I implemented it as snow in my project. just to see.

Nice work.:wink:

This thing is awesome. But how do I test on collision where to paint? Like when object collides, than paint this…

Also - maybe this can be used for object collision based destruction? It looks pretty well and doesn’t lool like resource eater:)

And how to use this type of texture(painted like this) in nodes? I wanna get a stencil for scratches…

@adriansnetlis I’m using the rayCast() 5th element. lol sounds funny. but yeah. there is an empty casting a ray -Z and its parented to mario above his head. the acts as the mouse. ground positive is click.

yeah… You have different thing in there. Can it detect collision point and draw there? I want it to be like:


if col == True:
    pos = col.position
    texture.drawIt(pos)

As I haven’t read through the script, I typed a basic fake script to show you a basic example of what I need. How would this be possible?