ZuluTangoDelta Posted January 26, 2014 Share Posted January 26, 2014 Hi i try to draw a circel with dxSetPixelColor for a texture so i can use it for a terrain shader.A recental works fine but when i try to change the colors of pixels in a circel radius >5 it lags ver much i select the pixels with math.cos and math. sin. Link to comment
xXMADEXx Posted January 26, 2014 Share Posted January 26, 2014 https://wiki.multitheftauto.com/wiki/DxDrawCircle https://wiki.multitheftauto.com/wiki/Dx ... tialCircle Link to comment
ZuluTangoDelta Posted January 26, 2014 Author Share Posted January 26, 2014 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
DiSaMe Posted January 26, 2014 Share Posted January 26, 2014 Instead of drawing it pixel by pixel you could draw it row by row out of horizontal lines (1 pixel height rectangles) using dxDrawRectangle. Link to comment
ZuluTangoDelta Posted January 26, 2014 Author Share Posted January 26, 2014 Ok thanks the only problem is to change the alpha of the outer pixels of the circel so i can use lerp(sand,gras,saturate(1-blendcolor.a)); in the shader so the sandtexture has smoother edges.Have you a solution for that? Link to comment
arezu Posted January 27, 2014 Share Posted January 27, 2014 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now