My basic premise works like this...

Firstly, set up your terrain textures as global BMAPs, if you havent already.
The bmaps Sand_BM, Grass_BM, Rock_BM, & Snow_BM, that is.
They can now be referenced directly from the shader using the line
texture Sand_BM_bmap, Grass_BM_bmap, Rock_BM_bmap, Snow_BM_bmap;

Then (in the 'Terrain_Paint' script), you want to FIRST create an empty BMAP,
([/i]using bmap_createblack(512,512,24);[/i]) and apply it to the entity as a skin.
Then apply our new shader-material to the entity too.

Then we wait one frame for the shader to do its work, and create a new texture straight into the skin.
Then remove the shader material and thats the painting part completed.


Now, in the shader itself, I feel it SHOULD go something like !this.

You want to set up 'sampler' pointers for all the terrain texture maps, like so...
sampler2D SandSrc = sampler_state { texture = <Sand_BM_bmp>; };, etc

Then we set up the vertex-shader portion to ignore camera angle and to just
generate a heightmap for all vertices of the model. I DUNNO how to do this!

Finally we reach the pixel-shader part. if I understand correctly, the height-map-data
cant be retrieved from the POSITION0.Z value passed into the pixel shader. I think.
You can then use this height to extract pixels from the texture of your choice...
Its just a simple if ... ifelse ... proxess.
People will say IF's in shaders is 'dirty' but its just a ONE frame shader so
that makes it acceptable...


[EDIT] woohoo! Thats a lot of time for the SEEMINGLY minimal
changes I made... but the important thing is ....
Was it still 'painting' correctly, or had I mangled the results of get_height?

Last edited by EvilSOB; 11/05/11 14:59.

"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial