Ive attached a shader that might help, which is a modification to one of my first shaders that just blended 2d this is 3d version which im sure i got help along the way with
my shaders from both santman an janbo and the glsl shader library
this version uses a shader to blend a rendered image which im sure was on the shader thread but cant find it hope this helps also one of the games i procrastinate to much about finishing i used two gid objects and used that to move vertices with memblocks one being to reveal water and the other to create mountains. If you use a grid its allot easier to select verts the issue is selecting the right one(grid water and gid land)
// set wow properties
SetWindowTitle( "Paintball example" )
SetWindowSize( 800, 600, 0 )
SetWindowAllowResize( 0 ) // dont allow the user to resize the window
SetClearColor(75,175,75)
// ==========================================================================
// main loop
// --------------------------------------------------------------------------
palette=CreateSprite(LoadImage("palette.png"))
setSpriteSize(palette,16,16)
selected = createSprite(0)
SetSpriteSize (selected ,8,8)
setSpritePosition(selected,32,0)
type color
r as integer
g as integer
b as integer
a as integer
endtype
#constant IlluminationImageID=CreateImageColor(255,255,255,255)
#constant NormalMapID=CreateImageColor(128,128,255,255)
global xw = 256
global yw = 256
global brush as integer
//target= loadobject("plane.obj" ) ///""chassis.obj")
target=CreateObjectPlane(50,50)
defaultImg=loadimage("white.png") //"race\chassis2.png")
ResizeImage(defaultimg,xw,yw)
//SetObjectScalePermanent(target,.3,.3,.3)
//setObjectImage(target,defaultImg,0)
//SetObjectScalePermanent(target,3,3,3)
setupIlluminationShader(target,defaultImg,0)
SetObjectTransparency(target,1)
SetGenerateMipmaps(1)
defaultImg=LoadImage("white.png") // no need for alpha with this one
bulletHole=LoadImage("splash2.png") // with alpha ;)
//SetImageTransparentColor(bulletHole,0,0,0)
Brush = CreateSprite(bulletHole)
SetSpriteSize(brush,4,4)
SetSpritevisible(brush,0)
#constant renderImg = 1
CreateRenderImage( renderImg,GetVirtualWidth(), GetVirtualHeight(), 0, 0 )
LoadShader(3, "blend2.vs", "blend2.ps")
SetObjectShader(target,3)
SetObjectImage(target,defaultImg,0)
SetObjectImage(target,renderImg,1)
SetCameraPosition(1,0,0,-50) //-50)
setcameralookat(1,0,0,0,0)
//SetCameraPosition(1,0,5,-10)
//leftU#=0:rightU#=0:bottomU#=0:bottomV#=0
do
if GetRawKeyState(asc("W"))
SetCameraPosition(1,getcameraX(1),getcameraY(1),getcameraZ(1)+1)
endif
if GetRawKeyState(asc("S"))
SetCameraPosition(1,getcameraX(1),getcameraY(1),getcameraZ(1)-1)
endif
if GetRawKeyState(asc("A"))
SetCameraPosition(1,getcameraX(1)-1,getcameraY(1),getcameraZ(1))
endif
if GetRawKeyState(asc("D"))
SetCameraPosition(1,getcameraX(1)+1,getcameraY(1),getcameraZ(1))
endif
if GetPointerState()
// get the position of the pointer (mouse)
pointer_x = GetPointerX()
pointer_y = GetPointerY()
// get the x, y and z unit vectors based on the pointer position
unit_x# = Get3DVectorXFromScreen(pointer_x,pointer_y)
unit_y# = Get3DVectorYFromScreen(pointer_x,pointer_y)
unit_z# = Get3DVectorZFromScreen(pointer_x,pointer_y)
// calculate the start of the ray cast, which is the unit vector + the camera position
start_x# = unit_x#-10
start_y# = unit_y#-10
start_z# = unit_z#-100
// calculate the end of the vector, which is the unit vector multiplied by the length of the ray cast and then add the camera position to it
end_x# = 800*unit_x#+10
end_y# = 800*unit_y#+10
end_z# = 800*unit_z#+100
// only ray cast against the sphere
if ObjectRayCast(0,start_x#,start_y#,start_z#,end_x#,end_y#,end_z#) <>0
// get the coordinates of the intersect
intersect_x# = GetObjectRayCastX(0)
intersect_y# = GetObjectRayCastY(0)
intersect_z# = GetObjectRayCastZ(0)
// translate the object 3D coordinates to 2D screen coordinate
screen_x# = GetScreenXFrom3D( intersect_x#, intersect_y#, intersect_z#)
screen_y# = GetScreenYFrom3D( intersect_x#, intersect_y#, intersect_z#)
//print(screen_x#):print(getpointerx())
// if the ray cast intersects paint the brush
paint(screen_x#,screen_y#)
SetObjectImage(target,renderImg,1)
SetSpriteVisible(brush,0)
endif
endif
if GetRawMouseRightReleased ()
img=getColorImageFromScreen(getPointerX(),getpointerY())
tmpImg=GetSpriteImageID(selected)
SetSpriteImage(selected,img)
setSpriteSize(selected,64,64)
DeleteImage(tmpImg)
tmpImg=GetSpriteImageID(brush)
setSpriteImage(brush,img)
DeleteImage(tmpImg)
endif
//RotateObjectLocaly(target,.25)
//RotateObjectLocalx(target,.25)
SetSpritePositionByOffset(brush,GetPointerX(),getpointery())
sync()
loop
function Paint(x,y)
SetRenderToImage(renderImg, 0 )
SetSpritePositionByOffset(Brush,x,y)
SetSpriteAngle(Brush,random(0,360))
SetSpriteVisible(brush,1)
DrawSprite(Brush)
SetRenderToScreen()
endfunction
function setupIlluminationShader(objectId as integer,imageId as integer, bones as integer)
///////////////////////////////////////////////////////////////////////
SetObjectImage(objectId,imageId,0) //mixamorig:LeftHand
setobjectimage(objectId,illuminationImageID,1)
SetObjectNormalMap(objectId,NormalmapID)
SetObjectColorEmissive(objectId,20,20,20)
//SetobjectTransparency(objectid,3)
child as integer
for child = 1 to GetObjectNumChildren(objectId)
SetObjectImage(GetObjectChildID(objectID,Child),imageID,0)
SetObjectImage(GetObjectChildID(objectID,Child),illuminationImageID,1)
SetObjectNormalMap(GetObjectChildID(objectID,Child),NormalMapID)
SetObjectColorEmissive(GetObjectChildID(objectID,Child),20,20,20)
next child
endfunction
function SetObjectWithChildren(id,img,amnt,alpha)
SetobjectscalePermanent(id,amnt,amnt,amnt)
SetObjectImage(id,img,1)
SetObjectcolor(id,255,255,255,alpha)
SetobjectTransparency(id,1)
for child = 1 to GetObjectNumChildren(Id)
SetobjectscalePermanent(GetObjectChildID(ID,Child),amnt,amnt,amnt)
SetObjectImage(GetObjectChildID(ID,Child),img,1)
SetObjectColor(GetObjectChildID(ID,Child),255,255,255,alpha)
SetObjectTransparency(getObjectChildID(ID,Child),1)
next child
endfunction
Function getColorImageFromScreen(X,Y)
//color as integer
rem prepare image grab area
clearScreen()
setScissor(X,Y,X+1,Y+1)
render()
img = getImage(X,Y,X+1,Y+1)
rem create memblock
mem = createMemblockfromImage(img)
rem get memblock data
r = getMemblockbyte(mem,12):rem gets red channel data
g = getMemblockbyte(mem,13):rem gets green channel data
b = getMemblockbyte(mem,14):rem gets blue channel data
swap()
rem tidy up
deletememblock(mem)
//deleteimage(img)
setScissor(0,0,getDeviceWidth(),getDeviceHeight())
clearScreen()
color = makeColor(r,g,b)
endfunction img
goodluck
fubarpk
https://fubarpk.itch.io/