Jump to content

dxSetPixelColor circel


Recommended Posts

So you mean i should use rendertarget and draw a circel on it and give it to the shader?im not a pro in shaders so i dont know which solution is the best.But i need to draw a filled circel.I solve it without sin and cos and use pythagoras.

  
function draw (radius,x,y,r,g,b) --x,y the position of the player so the sandtex is drawn under the player 
local ox,oy,oz = getElementPosition(obj1) --obj1 is the testterrain on which the shader draws the sandtexture 
nx = (ox+x)*5+250-radius/2 
ny = (oy-y)*5+250-radius/2 
local pixels = dxGetTexturePixels (mapdraw) --mapdraw is the empty texture on which i draw the different colors so the shader can replace the colors for different textures  
  
for i=0,radius*2,1 do 
local x = -radius+i 
local y = math.sqrt(((radius*radius)-(x*x))) 
for ly=0,y*2,1 do 
dxSetPixelColor (pixels,nx+x, ny+y-ly, r,g,b, 255) 
end 
end 
  
dxSetTexturePixels (mapdraw, pixels) 
end 
  

this texture is given to the sahder which replace the white circel with a new sandtexture on a terrain.I hope you understood me :)

Link to comment

You can change to use a render target that you make transparent, and then when you want to draw a circle, draw an image with a circle in it with smoothed edges/glow (make the edges go from no transparency to full transparency in photoshop or whatever) on the render target. You can then blend using lerp in shader.

Drawing to render target using an image is much faster than using pixel functions.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...