-
Posts
476 -
Joined
-
Last visited
-
Days Won
1
Everything posted by iiv03
-
ديسكورد حقي xFabel.!<>#5613
-
ترا انت قايلي ملف avatars .... يعني سالفه بتطول لو يمديك تكلمني اقبل ديسكورد او اذا عندك طريق استخدم getElementData برا رندر قولي ديسكورد حقي xFabel.!<>#5613
-
المشكله مطوله ... هو ينفع لو اكلمك ديسكورد ؟
-
مزبط برضو لو انا سويته داخل رندر كذا راح يشتغل ويجي لوجو الآعب -- shader function onStart() maskShader = dxCreateShader(":deathlist/fx/mask.fx") maskTexture = dxCreateTexture(":deathlist/img/circle.png") defaultAvatar = dxCreateTexture(":avatars/img/default-avatar.png") dxSetShaderValue(maskShader, "maskTexture", maskTexture) end addEventHandler("onClientResourceStart", resourceRoot, onStart) -- render function render() local avatar = {} avatar = getElementData(player, "avatarHash") or false if avatar then local path = ":avatars/avatarcache/"..avatar if fileExists(path) then avatar = dxCreateTexture(path) else avatar = false end end local avatar = avatar or defaultAvatar dxDrawImage(x * (5/sx), y * (2/sy), x * (40/sx), y * (40/sy), ":deathlist/img/circle.png", 0, 0, 0, tocolor(0, 0, 0, 255), false) dxSetShaderValue(maskShader, "imageTexture", avatar) dxDrawImage(x * (5/sx), y * (2/sy), x * (40/sx), y * (40/sy), maskShader, 0, 0, 0, tocolor(255, 255, 255, 255), false) end addEventHandler("onClientRender", root, render) المشكله هنا يجي لاق فيه حل للاق؟
-
كود كآمل --shader local av = {} addEventHandler("onClientResourceStart", resourceRoot, function() av.maskShader = dxCreateShader(":deathlist/fx/mask.fx") av.maskTexture = dxCreateTexture(":deathlist/img/circle.png") av.defaultAvatar = dxCreateTexture(":avatars/img/default-avatar.png") dxSetShaderValue(av.maskShader, "maskTexture", av.maskTexture) end) --avatar local xd = {} function avatars() xd.avatar = getElementData(localPlayer, "avatarHash") or false if xd.avatar then local path = ":avatars/avatarcache/"..xd.avatar if fileExists(path) then xd.avatar = dxCreateTexture(path) else xd.avatar = false end end xd.player = player end --Render function render(player) local avatar = xd.avatar or av.defaultAvatar dxDrawImage(x * (5/sx), y * (2/sy), x * (40/sx), y * (40/sy), ":deathlist/img/circle.png", 0, 0, 0, tocolor(0, 0, 0, 255), false) dxSetShaderValue(av.maskShader, "imageTexture", avatar) dxDrawImage(x * (5/sx), y * (2/sy), x * (40/sx), y * (40/sy), av.maskShader, 0, 0, 0, tocolor(255, 255, 255, 255), false) end addEventHandler("onClientRender", root, render)
-
اوك جربته علي فاكشن اول مطلع ولا ارور جربته ب فاكشن الي فيه رندر outputChatBox(tostring(avatar)) طلع لي userdata: 000214C8 userdata: 000214C8 userdata: 000214C8 userdata: 000214C8 userdata: 000214C8 userdata: 000214C8 userdata: 000214C8 userdata: 000214C8 جربته كمان xd.avatar / tes.defaultAvatar طلع لي nil?
-
المشكله لو حطيت الكود ذاك داخل فاكشن فيه رندر يشتغل وتجي صوره وكل شي بس يجي لاق لو حطيته برا فاكشن ب فاكشن ثاني برضو يشتغل ومايجي صوره الاعب ومافي لاق مدري شسووي
-
داتا شغال ب ملف ثاني
-
مب مسويه انا حاط شيدر ب مكان الصوره dxDrawImage ...
-
الكود ذاك الي يعطي داتا انت قصدك من avatarHash?
-
سلام عليكم انا سويت سكريبت بسيط يسحب اللوجو لاعب بس المشكله مايسحب لوجو احس انه فيه شي خطئ ب getElementData مساعده تكفون local xd = {} function aaxd(player) if not isElement(player) then return end xd.avatar = getElementData(player, "avatarHash") or false if xd.avatar then local path = ":avatars/avatarcache/"..xd.avatar if fileExists(path) then xd.avatar = dxCreateTexture(path) else xd.avatar = false end end xd.player = player end function av() local avatar = xd.avatar or tes.defaultAvatar dxSetShaderValue(tes.maskShader, "imageTexture", avatar) dxDrawImage(drawX-iscale+pictureOffset, drawY - iscale+pictureOffset, pictureSize, pictureSize,tes.maskShader,0,0,0, tocolor(255, 255, 255, alpha),false) end addEventHandler("onClientRender ", root, av) الصوره ضاهره بس مايسحب لوجو ليش مآفي ولا آي خطا ارور
-
no i did not found any error in debugscript
-
hey guys i got problem in shader i wanna put anti-alias in dxdrawcircle but its give me error please guys i need help i really tired to fix that and i don't know shader shader: float sCircleHeightInPixel = 100; float sCircleWidthInPixel = 100; float sBorderWidthInPixel = 10; float sAngleStart = -3.14; float sAngleEnd = 3.14; float4x4 gWorldViewProjection : WORLDVIEWPROJECTION; struct VSInput { float3 Position : POSITION0; float4 Diffuse : COLOR0; float2 TexCoord : TEXCOORD0; }; struct PSInput { float4 Position : POSITION0; float4 Diffuse : COLOR0; float4 Diffuse2 : COLOR1; float2 TexCoord : TEXCOORD0; float2 Settings : TEXCOORD1; }; float4 PixelShaderFunction(float4 Diffuse : COLOR0, float2 TexCoord : TEXCOORD0) : COLOR0 { float2 uv = float2( TexCoord.x, TexCoord.y ) - float2( 0.5, 0.5 ); float angle = atan2( -uv.x, uv.y ); // -PI to +PI if ( sAngleStart > sAngleEnd ) { if ( angle < sAngleStart && angle > sAngleEnd ) return 0; } else { if ( angle < sAngleStart || angle > sAngleEnd ) return 0; } // Calc border width to use float2 vec = normalize( uv ); float CircleRadiusInPixel = lerp( sCircleWidthInPixel, sCircleHeightInPixel, vec.y * vec.y ); float borderWidth = sBorderWidthInPixel / CircleRadiusInPixel; // Check if pixel is inside circle float dist = sqrt( dot( uv, uv ) ); if ( ( dist > 0.5 ) || ( dist < 0.5 - borderWidth ) ) return 0; else return Diffuse; } technique tec0 { pass P0 { PixelShader = compile ps_2_0 PixelShaderFunction(); } } PSInput VertexShaderFunction(VSInput VS) { PSInput PS = (PSInput)0; PS.Position = mul(float4(VS.Position, 1), gWorldViewProjection); int bAntialias = floor(VS.Diffuse.a*255+0.5)%2; int bTwoColors = floor(VS.Diffuse.a*127+0.5)%2; [branch] if(bTwoColors == 1){ float aComp = floor(VS.Diffuse.a*63+0.5)%64;; PS.Diffuse = float4((floor(VS.Diffuse.rgb*15+0.5)%16)/15, (aComp%8)/7); PS.Diffuse2 = float4(floor((VS.Diffuse.rgb*255+0.5)%16)/15, ((aComp/8)%8)/7); } else { PS.Diffuse = float4(VS.Diffuse.rgb, floor(VS.Diffuse.a*63+0.5)%64/63); PS.Diffuse2 = PS.Diffuse; } PS.TexCoord = VS.TexCoord; PS.Settings = float2(bTwoColors,bAntialias); return PS; } float4 PixelShaderFunction(PSInput PS) : COLOR0 { const float dist = length(PS.TexCoord*2-1); float4 color = PS.Settings.x > 0.5 ? lerp(PS.Diffuse, PS.Diffuse2, dist) : PS.Diffuse; if (PS.Settings.y < 0.5){ return dist <= 1 ? color : float4(0,0,0,0); } return float4(color.rgb, smoothstep(1, 1 - fwidth(dist) * 2, dist)*color.a); } technique Technique1 { pass Pass1 { SrcBlend = SrcAlpha; DestBlend = InvSrcAlpha; VertexShader = compile vs_3_0 VertexShaderFunction(); } } client local floor = math.floor function fromColor(col) local r,g,b,a b = col%256 g = floor(col/0x100)%256 r = floor(col/0x10000)%256 a = floor(col/0x1000000)%256 return r,g,b,a end function dxDrawShaderCircle( x, y, width, height, color1, color2, angleStart, angleSweep, borderWidth, antialiasing) local shaderColCache = {} height = height or width color = color or tocolor(255,255,255) borderWidth = borderWidth or 1e9 angleStart = angleStart or 0 angleSweep = angleSweep or 360 - angleStart if ( angleSweep < 360 ) then angleEnd = math.fmod( angleStart + angleSweep, 360 ) + 0 else angleStart = 0 angleEnd = 360 end x = x - width / 2 y = y - height / 2 if not circleShader then circleShader = dxCreateShader ( "circle.fx" ) end assert(type(color1) == "number", "Expected number as color argument to dxDrawCircleShader") if (not color2) or (color2 == color1) then color2 = "def" end local finColor local col1 = shaderColCache[color1] if col1 then local col2 = col1[color2] if col2 then finColor = col2 end end if not finColor then shaderColCache[color1] = shaderColCache[color1] or {} local twoColors = (color2 ~= "def") if twoColors then local r1,g1,b1,a1 = fromColor(color1) local r2,g2,b2,a2 = fromColor(color2) local finR = floor((r1/256)*16)*16 + floor((r2/256)*16) local finG = floor((g1/256)*16)*16 + floor((g2/256)*16) local finB = floor((b1/256)*16)*16 + floor((b2/256)*16) local finA = floor((a1/256)*8)*32 + floor((a2/256)*8)*4 + 2 finColor = tocolor( finR, finG, finB, finA ) else local r,g,b,a = fromColor(color1) local finA = (floor((a/256)*64)*4)%256 finColor = tocolor( r,g,b, finA ) end shaderColCache[color1][color2] = finColor end local antialiasComp = 16777216 if not antialias then antialiasComp = 0 end finColor = finColor + antialiasComp dxSetShaderValue ( circleShader, "sCircleWidthInPixel", width ); dxSetShaderValue ( circleShader, "sCircleHeightInPixel", height ); dxSetShaderValue ( circleShader, "sBorderWidthInPixel", borderWidth ); dxSetShaderValue ( circleShader, "sAngleStart", math.rad( angleStart ) - math.pi ); dxSetShaderValue ( circleShader, "sAngleEnd", math.rad( angleEnd ) - math.pi ); dxDrawImage( x, y, width, height, circleShader, 0, 0, 0, color ) end addEventHandler("onClientRender",root, function() dxDrawShaderCircle(500,400,100,height,tocolor(0,0,255),tocolor(0,0,255),0,360,3,1) end ) i rlly tired to fix that :~
-
عدلت الآكواد الحين وكل شوي ارور وصلحته مشآكل بس الحين مزبط لي anti alias ذي محاولتي float sCircleHeightInPixel = 100; float sCircleWidthInPixel = 100; float sBorderWidthInPixel = 10; float sAngleStart = -3.14; float sAngleEnd = 3.14; float4x4 gWorldViewProjection : WORLDVIEWPROJECTION; struct VSInput { float3 Position : POSITION0; float4 Diffuse : COLOR0; float2 TexCoord : TEXCOORD0; }; struct PSInput { float4 Position : POSITION0; float4 Diffuse : COLOR0; float4 Diffuse2 : COLOR1; float2 TexCoord : TEXCOORD0; float2 Settings : TEXCOORD1; }; float4 PixelShaderFunction(float4 Diffuse : COLOR0, float2 TexCoord : TEXCOORD0) : COLOR0 { float2 uv = float2( TexCoord.x, TexCoord.y ) - float2( 0.5, 0.5 ); float angle = atan2( -uv.x, uv.y ); // -PI to +PI if ( sAngleStart > sAngleEnd ) { if ( angle < sAngleStart && angle > sAngleEnd ) return 0; } else { if ( angle < sAngleStart || angle > sAngleEnd ) return 0; } // Calc border width to use float2 vec = normalize( uv ); float CircleRadiusInPixel = lerp( sCircleWidthInPixel, sCircleHeightInPixel, vec.y * vec.y ); float borderWidth = sBorderWidthInPixel / CircleRadiusInPixel; // Check if pixel is inside circle float dist = sqrt( dot( uv, uv ) ); if ( ( dist > 0.5 ) || ( dist < 0.5 - borderWidth ) ) return 0; else return Diffuse; } technique tec0 { pass P0 { PixelShader = compile ps_2_0 PixelShaderFunction(); } } PSInput VertexShaderFunction(VSInput VS) { PSInput PS = (PSInput)0; PS.Position = mul(float4(VS.Position, 1), gWorldViewProjection); int bAntialias = floor(VS.Diffuse.a*255+0.5)%2; int bTwoColors = floor(VS.Diffuse.a*127+0.5)%2; [branch] if(bTwoColors == 1){ float aComp = floor(VS.Diffuse.a*63+0.5)%64;; PS.Diffuse = float4((floor(VS.Diffuse.rgb*15+0.5)%16)/15, (aComp%8)/7); PS.Diffuse2 = float4(floor((VS.Diffuse.rgb*255+0.5)%16)/15, ((aComp/8)%8)/7); } else { PS.Diffuse = float4(VS.Diffuse.rgb, floor(VS.Diffuse.a*63+0.5)%64/63); PS.Diffuse2 = PS.Diffuse; } PS.TexCoord = VS.TexCoord; PS.Settings = float2(bTwoColors,bAntialias); return PS; } float4 PixelShaderFunction(PSInput PS) : COLOR0 { const float dist = length(PS.TexCoord*2-1); float4 color = PS.Settings.x > 0.5 ? lerp(PS.Diffuse, PS.Diffuse2, dist) : PS.Diffuse; if (PS.Settings.y < 0.5){ return dist <= 1 ? color : float4(0,0,0,0); } return float4(color.rgb, smoothstep(1, 1 - fwidth(dist) * 2, dist)*color.a); } technique Technique1 { pass Pass1 { SrcBlend = SrcAlpha; DestBlend = InvSrcAlpha; VertexShader = compile vs_3_0 VertexShaderFunction(); } } local floor = math.floor function fromColor(col) local r,g,b,a b = col%256 g = floor(col/0x100)%256 r = floor(col/0x10000)%256 a = floor(col/0x1000000)%256 return r,g,b,a end function dxDrawShaderCircle( x, y, width, height, color1, color2, angleStart, angleSweep, borderWidth, antialiasing) local shaderColCache = {} height = height or width color = color or tocolor(255,255,255) borderWidth = borderWidth or 1e9 angleStart = angleStart or 0 angleSweep = angleSweep or 360 - angleStart if ( angleSweep < 360 ) then angleEnd = math.fmod( angleStart + angleSweep, 360 ) + 0 else angleStart = 0 angleEnd = 360 end x = x - width / 2 y = y - height / 2 if not circleShader then circleShader = dxCreateShader ( "circle.fx" ) end assert(type(color1) == "number", "Expected number as color argument to dxDrawCircleShader") if (not color2) or (color2 == color1) then color2 = "def" end local finColor local col1 = shaderColCache[color1] if col1 then local col2 = col1[color2] if col2 then finColor = col2 end end if not finColor then shaderColCache[color1] = shaderColCache[color1] or {} local twoColors = (color2 ~= "def") if twoColors then local r1,g1,b1,a1 = fromColor(color1) local r2,g2,b2,a2 = fromColor(color2) local finR = floor((r1/256)*16)*16 + floor((r2/256)*16) local finG = floor((g1/256)*16)*16 + floor((g2/256)*16) local finB = floor((b1/256)*16)*16 + floor((b2/256)*16) local finA = floor((a1/256)*8)*32 + floor((a2/256)*8)*4 + 2 finColor = tocolor( finR, finG, finB, finA ) else local r,g,b,a = fromColor(color1) local finA = (floor((a/256)*64)*4)%256 finColor = tocolor( r,g,b, finA ) end shaderColCache[color1][color2] = finColor end local antialiasComp = 16777216 if not antialias then antialiasComp = 0 end finColor = finColor + antialiasComp dxSetShaderValue ( circleShader, "sCircleWidthInPixel", width ); dxSetShaderValue ( circleShader, "sCircleHeightInPixel", height ); dxSetShaderValue ( circleShader, "sBorderWidthInPixel", borderWidth ); dxSetShaderValue ( circleShader, "sAngleStart", math.rad( angleStart ) - math.pi ); dxSetShaderValue ( circleShader, "sAngleEnd", math.rad( angleEnd ) - math.pi ); dxDrawImage( x, y, width, height, circleShader, 0, 0, 0, color ) end addEventHandler("onClientRender",root, function() dxDrawShaderCircle(500,400,100,height,tocolor(0,0,255),tocolor(0,0,255),0,360,3,1) end ) ديبوق مطلع ولا ارور والمود شغال anti alias مآزبط
-
MY TRYING EDIT: shader.fx float sCircleHeightInPixel = 100; float sCircleWidthInPixel = 100; float sBorderWidthInPixel = 10; float sAngleStart = -3.14; float sAngleEnd = 3.14; float4x4 gWorldViewProjection : WORLDVIEWPROJECTION; struct VSInput { float3 Position : POSITION0; float4 Diffuse : COLOR0; float2 TexCoord : TEXCOORD0; }; struct PSInput { float4 Position : POSITION0; float4 Diffuse : COLOR0; float4 Diffuse2 : COLOR1; float2 TexCoord : TEXCOORD0; float2 Settings : TEXCOORD1; }; float4 PixelShaderFunction(float4 Diffuse : COLOR0, float2 TexCoord : TEXCOORD0) : COLOR0 { float2 uv = float2( TexCoord.x, TexCoord.y ) - float2( 0.5, 0.5 ); float angle = atan2( -uv.x, uv.y ); // -PI to +PI if ( sAngleStart > sAngleEnd ) { if ( angle < sAngleStart && angle > sAngleEnd ) return 0; } else { if ( angle < sAngleStart || angle > sAngleEnd ) return 0; } // Calc border width to use float2 vec = normalize( uv ); float CircleRadiusInPixel = lerp( sCircleWidthInPixel, sCircleHeightInPixel, vec.y * vec.y ); float borderWidth = sBorderWidthInPixel / CircleRadiusInPixel; // Check if pixel is inside circle float dist = sqrt( dot( uv, uv ) ); if ( ( dist > 0.5 ) || ( dist < 0.5 - borderWidth ) ) return 0; else return Diffuse; } technique tec0 { pass P0 { PixelShader = compile ps_2_0 PixelShaderFunction(); } } PSInput VertexShaderFunction(VSInput VS) { PSInput PS = (PSInput)0; PS.Position = mul(float4(VS.Position, 1), gWorldViewProjection); int bAntialias = floor(VS.Diffuse.a*255+0.5)%2; int bTwoColors = floor(VS.Diffuse.a*127+0.5)%2; [branch] if(bTwoColors == 1){ float aComp = floor(VS.Diffuse.a*63+0.5)%64;; PS.Diffuse = float4((floor(VS.Diffuse.rgb*15+0.5)%16)/15, (aComp%8)/7); PS.Diffuse2 = float4(floor((VS.Diffuse.rgb*255+0.5)%16)/15, ((aComp/8)%8)/7); } else { PS.Diffuse = float4(VS.Diffuse.rgb, floor(VS.Diffuse.a*63+0.5)%64/63); PS.Diffuse2 = PS.Diffuse; } PS.TexCoord = VS.TexCoord; PS.Settings = float2(bTwoColors,bAntialias); return PS; } float4 PixelShaderFunction(PSInput PS) : COLOR0 { const float dist = length(PS.TexCoord*2-1); float4 color = PS.Settings.x > 0.5 ? lerp(PS.Diffuse, PS.Diffuse2, dist) : PS.Diffuse; if (PS.Settings.y < 0.5){ return dist <= 1 ? color : float4(0,0,0,0); } return float4(color.rgb, smoothstep(1, 1 - fwidth(dist) * 2, dist)*color.a); } technique Technique1 { pass Pass1 { SrcBlend = SrcAlpha; DestBlend = InvSrcAlpha; VertexShader = compile vs_3_0 VertexShaderFunction(); } } client.Lua local floor = math.floor function fromColor(col) local r,g,b,a b = col%256 g = floor(col/0x100)%256 r = floor(col/0x10000)%256 a = floor(col/0x1000000)%256 return r,g,b,a end function dxDrawShaderCircle( x, y, width, height, color1, color2, angleStart, angleSweep, borderWidth, antialiasing) local shaderColCache = {} height = height or width color = color or tocolor(255,255,255) borderWidth = borderWidth or 1e9 angleStart = angleStart or 0 angleSweep = angleSweep or 360 - angleStart if ( angleSweep < 360 ) then angleEnd = math.fmod( angleStart + angleSweep, 360 ) + 0 else angleStart = 0 angleEnd = 360 end x = x - width / 2 y = y - height / 2 if not circleShader then circleShader = dxCreateShader ( "circle.fx" ) end assert(type(color1) == "number", "Expected number as color argument to dxDrawCircleShader") if (not color2) or (color2 == color1) then color2 = "def" end local finColor local col1 = shaderColCache[color1] if col1 then local col2 = col1[color2] if col2 then finColor = col2 end end if not finColor then shaderColCache[color1] = shaderColCache[color1] or {} local twoColors = (color2 ~= "def") if twoColors then local r1,g1,b1,a1 = fromColor(color1) local r2,g2,b2,a2 = fromColor(color2) local finR = floor((r1/256)*16)*16 + floor((r2/256)*16) local finG = floor((g1/256)*16)*16 + floor((g2/256)*16) local finB = floor((b1/256)*16)*16 + floor((b2/256)*16) local finA = floor((a1/256)*8)*32 + floor((a2/256)*8)*4 + 2 finColor = tocolor( finR, finG, finB, finA ) else local r,g,b,a = fromColor(color1) local finA = (floor((a/256)*64)*4)%256 finColor = tocolor( r,g,b, finA ) end shaderColCache[color1][color2] = finColor end local antialiasComp = 16777216 if not antialias then antialiasComp = 0 end finColor = finColor + antialiasComp dxSetShaderValue ( circleShader, "sCircleWidthInPixel", width ); dxSetShaderValue ( circleShader, "sCircleHeightInPixel", height ); dxSetShaderValue ( circleShader, "sBorderWidthInPixel", borderWidth ); dxSetShaderValue ( circleShader, "sAngleStart", math.rad( angleStart ) - math.pi ); dxSetShaderValue ( circleShader, "sAngleEnd", math.rad( angleEnd ) - math.pi ); dxDrawImage( x, y, width, height, circleShader, 0, 0, 0, color ) end addEventHandler("onClientRender",root, function() dxDrawShaderCircle(500,400,100,height,tocolor(0,0,255),tocolor(0,0,255),0,360,3,1) end ) not work why? help guys please
- 2 replies
-
- shader circle + antialas
- shader
-
(and 1 more)
Tagged with:
-
hey guys, I wanna help on shader Im trying to put antialias with borderWidth circle.fx float sCircleHeightInPixel = 100; float sCircleWidthInPixel = 100; float sBorderWidthInPixel = 10; float4x4 gWorldViewProjection : WORLDVIEWPROJECTION; struct VSInput { float3 Position : POSITION0; float4 Diffuse : COLOR0; float2 TexCoord : TEXCOORD0; }; struct PSInput { float4 Position : POSITION0; float4 Diffuse : COLOR0; float4 Diffuse2 : COLOR1; float2 TexCoord : TEXCOORD0; float2 Settings : TEXCOORD1; }; PSInput VertexShaderFunction(VSInput VS) float4 PixelShaderFunction(float4 Diffuse : COLOR0, float2 TexCoord : TEXCOORD0) : COLOR0 { float2 uv = float2( TexCoord.x, TexCoord.y ) - float2( 0.5, 0.5 ); PSInput PS = (PSInput)0; PS.Position = mul(float4(VS.Position, 1), gWorldViewProjection); int bAntialias = floor(VS.Diffuse.a*255+0.5)%2; int bTwoColors = floor(VS.Diffuse.a*127+0.5)%2; [branch] if(bTwoColors == 1){ float aComp = floor(VS.Diffuse.a*63+0.5)%64;; PS.Diffuse = float4((floor(VS.Diffuse.rgb*15+0.5)%16)/15, (aComp%8)/7); PS.Diffuse2 = float4(floor((VS.Diffuse.rgb*255+0.5)%16)/15, ((aComp/8)%8)/7); } else { PS.Diffuse = float4(VS.Diffuse.rgb, floor(VS.Diffuse.a*63+0.5)%64/63); PS.Diffuse2 = PS.Diffuse; } PS.TexCoord = VS.TexCoord; PS.Settings = float2(bTwoColors,bAntialias); return PS; } float2 vec = normalize( uv ); float CircleRadiusInPixel = lerp( sCircleWidthInPixel, sCircleHeightInPixel, vec.y * vec.y ); float borderWidth = sBorderWidthInPixel / CircleRadiusInPixel; if ( ( dist > 0.5 ) || ( dist < 0.5 - borderWidth ) ) return 0; else return Diffuse; } float4 PixelShaderFunction(PSInput PS) : COLOR0 { const float dist = length(PS.TexCoord*2-1); float4 color = PS.Settings.x > 0.5 ? lerp(PS.Diffuse, PS.Diffuse2, dist) : PS.Diffuse; if (PS.Settings.y < 0.5){ return dist <= 1 ? color : float4(0,0,0,0); } return float4(color.rgb, smoothstep(1, 1 - fwidth(dist) * 2, dist)*color.a); } technique Technique1 { pass Pass1 { SrcBlend = SrcAlpha; DestBlend = InvSrcAlpha; VertexShader = compile vs_3_0 VertexShaderFunction(); PixelShader = compile ps_3_0 PixelShaderFunction(); } } client.Lua local floor = math.floor function fromColor(col) local r,g,b,a b = col%256 g = floor(col/0x100)%256 r = floor(col/0x10000)%256 a = floor(col/0x1000000)%256 return r,g,b,a end local shader = dxCreateShader( "circle.fx" ) local shaderColCache = {} function dxDrawCircleShader(posX,posY,radius,color1,color2,antialias,borderWidth) assert(type(color1) == "number", "Expected number as color argument to dxDrawCircleShader") if (not color2) or (color2 == color1) then color2 = "def" end borderWidth = borderWidth or 1e9 local finColor local col1 = shaderColCache[color1] if col1 then local col2 = col1[color2] if col2 then finColor = col2 end end if not finColor then shaderColCache[color1] = shaderColCache[color1] or {} local twoColors = (color2 ~= "def") if twoColors then local r1,g1,b1,a1 = fromColor(color1) local r2,g2,b2,a2 = fromColor(color2) local finR = floor((r1/256)*16)*16 + floor((r2/256)*16) local finG = floor((g1/256)*16)*16 + floor((g2/256)*16) local finB = floor((b1/256)*16)*16 + floor((b2/256)*16) local finA = floor((a1/256)*8)*32 + floor((a2/256)*8)*4 + 2 dxSetShaderValue ( shader, "sCircleWidthInPixel", width ); dxSetShaderValue ( shader, "sCircleHeightInPixel", height ); dxSetShaderValue ( shader, "sBorderWidthInPixel", borderWidth ); finColor = tocolor( finR, finG, finB, finA ) else local r,g,b,a = fromColor(color1) local finA = (floor((a/256)*64)*4)%256 finColor = tocolor( r,g,b, finA ) end shaderColCache[color1][color2] = finColor end local antialiasComp = 16777216 if not antialias then antialiasComp = 0 end finColor = finColor + antialiasComp dxDrawImage( posX-radius, posY-radius, radius*2, radius*2, shader, nil, nil, finColor ) end addEventHandler("onClientRender",root, function() dxDrawCircleShader(500,200,60,tocolor(255,255,255),tocolor(255,255,255),1,1) end ) im not good in shader and i don't know shader. anyone help me please? actually i wanna do like this but with antialas :
- 2 replies
-
- shader circle + antialas
- shader
-
(and 1 more)
Tagged with:
-
عندي سؤال هل يمدني انسخ اكواد شيدر الثاني ب شيدر ذا وبتجي مشاكل؟
-
آدري بس الخطوط اتشالت بس حين كيف اخليه علي دائره بس قآيلك الخطوطط مو صافيه ب صوره قبل والحين صافيه يعني الخطوط واضح الحين مثل صوره HD
-
السالفه طلعت من antialias بس فيه مشكله ثاني تصير دائره كامله مساعده بالله كيف احطه علي شكل خط؟ local floor = math.floor function fromColor(col) local r,g,b,a b = col%256 g = floor(col/0x100)%256 r = floor(col/0x10000)%256 a = floor(col/0x1000000)%256 return r,g,b,a end local shader = dxCreateShader( "circle.fx" ) local shaderColCache = {} function dxDrawCircleShader(posX,posY,radius,color1,color2,antialias) assert(type(color1) == "number", "Expected number as color argument to dxDrawCircleShader") if (not color2) or (color2 == color1) then color2 = "def" end local finColor local col1 = shaderColCache[color1] if col1 then local col2 = col1[color2] if col2 then finColor = col2 end end if not finColor then shaderColCache[color1] = shaderColCache[color1] or {} local twoColors = (color2 ~= "def") if twoColors then local r1,g1,b1,a1 = fromColor(color1) local r2,g2,b2,a2 = fromColor(color2) local finR = floor((r1/256)*16)*16 + floor((r2/256)*16) local finG = floor((g1/256)*16)*16 + floor((g2/256)*16) local finB = floor((b1/256)*16)*16 + floor((b2/256)*16) local finA = floor((a1/256)*8)*32 + floor((a2/256)*8)*4 + 2 finColor = tocolor( finR, finG, finB, finA ) else local r,g,b,a = fromColor(color1) local finA = (floor((a/256)*64)*4)%256 finColor = tocolor( r,g,b, finA ) end shaderColCache[color1][color2] = finColor end local antialiasComp = 16777216 if not antialias then antialiasComp = 0 end finColor = finColor + antialiasComp dxDrawImage( posX-radius, posY-radius, radius*2, radius*2, shader, nil, nil, finColor ) end addEventHandler("onClientRender",root, function() dxDrawCircleShader(500,200,60,tocolor(255,255,255),tocolor(255,255,255),1) end )
-
آتوقع ماتغير شي
-
الدائره صوره والدائره زرقاء و حمراء = dxDrawCircle
-
شوف هنا كيف وشوف حقتي كيف مدري ليش الجوده حق dxDrawCircle خرا آتوقع لازم شيدر؟؟
-
المشكله تحس الخط الي علي الصوره كآنه مرسوم يب هاذي صوره الي ورا الخط الازرق بس الخط الازرق dxdrawcircle هل فيه حل ؟ الكود function dxDrawCircle( x, y, width, height, color, angleStart, angleSweep, borderWidth ) height = height or width color = color or tocolor(255,255,255) borderWidth = borderWidth or 1e9 angleStart = angleStart or 0 angleSweep = angleSweep or 360 - angleStart if ( angleSweep < 360 ) then angleEnd = math.fmod( angleStart + angleSweep, 360 ) + 0 else angleStart = 0 angleEnd = 360 end x = x - width / 2 y = y - height / 2 if not circleShader then circleShader = dxCreateShader ( "circle.fx" ) end dxSetShaderValue ( circleShader, "sCircleWidthInPixel", width ); dxSetShaderValue ( circleShader, "sCircleHeightInPixel", height ); dxSetShaderValue ( circleShader, "sBorderWidthInPixel", borderWidth ); dxSetShaderValue ( circleShader, "sAngleStart", math.rad( angleStart ) - math.pi ); dxSetShaderValue ( circleShader, "sAngleEnd", math.rad( angleEnd ) - math.pi ); dxDrawImage( x, y, width, height, circleShader, 0, 0, 0, color ) end function drawCircleHud() if target and getElementType(target) == "vehicle" then localp = getVehicleOccupant(target) else localp = getLocalPlayer() end if(not localp) then return; end local x, y, z = getElementPosition(localp) local pr = getPedRotation(localp) local _,_,playerRotation = getElementRotation(localp) local px,py,pz = getElementPosition(localp) if(getPedOccupiedVehicle(localp)) then local veh = getPedOccupiedVehicle(localp); dxDrawCircle( 1212, 672, 45, height, tocolor(0,0,255),angleStart,360, 2.5 ) -- dxDrawImageSection(400, 200, 50, 50, 10, 0, 64, 64, 'circle.png', vehiclehealth, 0, 0, tocolor(255,0 ,0)) end addEventHandler("onClientRender", root, drawCircleHud)
-
كذا > تصير كذا بعدين< لو اخذت نيترو تتحرك الدآئره زرقاء اتمنى فهمتني المشكله الدآئره شكله خايس من الجوده هل فيه كود او شي يصلح الجوده؟ الكود حقي مسويه if target and getElementType(target) == "vehicle" then localp = getVehicleOccupant(target) else localp = getLocalPlayer() end if(not localp) then return; end local x, y, z = getElementPosition(localp) local pr = getPedRotation(localp) local _,_,playerRotation = getElementRotation(localp) local px,py,pz = getElementPosition(localp) if(getPedOccupiedVehicle(localp)) then local veh = getPedOccupiedVehicle(localp);