Would HSL support be useful?
(Check if there are any bugs plox.)
[img]https://dl.dropboxusercontent.com/u/14214411/HSL.png[/img]
[code]
local clamp = math.Clamp
local abs = math.abs
local min,max = math.min,math.max
function HSLToColor(H,S,L)
H = clamp(H,0,360)
S = clamp(S,0,1)
L = clamp(L,0,1)
local C = (1-abs(2*L-1)) * S
local X = C*(1-abs((H/60)%2-1))
local m = L-C/2
local R1,G1,B1 = 0,0,0
if H < 60 or H>=360 then R1,G1,B1 = C,X,0
elseif H < 120 then R1,G1,B1 = X,C,0
elseif H < 180 then R1,G1,B1 = 0,C,X
elseif H < 240 then R1,G1,B1 = 0,X,C
elseif H < 300 then R1,G1,B1 = X,0,C
else --[[ H<360 ]] R1,G1,B1 = C,0,X
end
return Color((R1+m)*255,(G1+m)*255,(B1+m)*255)
end
function ColorToHSL(R,G,B)
if type(R)=="table" then
R,G,B = clamp(R.r,0,255)/255,clamp(R.g,0,255)/255,clamp(R.b,0,255)/255
else
R,G,B = R/255,G/255,B/255
end
local max,min = max(R,G,B),min(R,G,B)
local del = max-min
-- Hue
local H = 0
if del<=0 then H = 0
elseif max==R then H = 60*( ( (G-B)/del ) %6 )
elseif max==G then H = 60*( ( (B-R)/del +2) %6 )
else--[[max==B]] H = 60*( ( (R-G)/del +4) %6 )
end
-- Lightness
local L = (max+min)/2
-- Saturation
local S = 0
if del!=0 then
S = del/(1-abs(2*L-1))
end
return H,S,L
end[/code]
[QUOTE=Nak;50675452]Would HSL support be useful?
(Check if there are any bugs plox.)
[code]
local clamp = math.Clamp
local abs = math.abs
local min,max = math.min,math.max
function HSLToColor(H,S,L)
H = clamp(H,0,360)
S = clamp(S,0,1)
L = clamp(L,0,1)
local C = (1-abs(2*L-1)) * S
local X = C*(1-abs((H/60)%2-1))
local m = L-C/2
local R1,G1,B1 = 0,0,0
if H < 60 or H>=360 then R1,G1,B1 = C,X,0
elseif H < 120 then R1,G1,B1 = X,C,0
elseif H < 180 then R1,G1,B1 = 0,C,X
elseif H < 240 then R1,G1,B1 = 0,X,C
elseif H < 300 then R1,G1,B1 = X,0,C
else --[[ H<360 ]] R1,G1,B1 = C,0,X
end
return Color((R1+m)*255,(G1+m)*255,(B1+m)*255)
end
function ColorToHSL(R,G,B)
if type(R)=="table" then
R,G,B = clamp(R.r,0,255)/255,clamp(R.g,0,255)/255,clamp(R.b,0,255)/255
else
R,G,B = R/255,G/255,B/255
end
local max,min = max(R,G,B),min(R,G,B)
local del = max-min
-- Hue
local H = 0
if del<=0 then H = 0
elseif max==R then H = 60*( ( (G-B)/del ) %6 )
elseif max==G then H = 60*( ( (B-R)/del +2) %6 )
else--[[max==B]] H = 60*( ( (R-G)/del +4) %6 )
end
-- Lightness
local L = (max+min)/2
-- Saturation
local S = 0
if del!=0 then
S = del/(1-abs(2*L-1))
end
return H,S,L
end[/code][/QUOTE]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/ColorToHSV]ColorToHSV[/url]?
[QUOTE=Nak;50675462][t]http://www.wisotop.de/assets/farbmodelle-hsv-hsl-zylinder.png[/t][/QUOTE]
Yep. Just realized they weren't synonymous. Carry on...
On my local windows gmod server, my console starts getting spammed with this sometimes:
[CODE]
Crazy origin on entity[number][prop_regdoll]
...
Defusing!
Removing!
[/CODE]
It continues all the time, I think it is not removing the entities correctly.
Anybody else with this problem?
Multicore Rendering seems to have issues with drawing circles.
[QUOTE=deinemudda32;50676028]Multicore Rendering seems to have issues with drawing circles.[/QUOTE]
There's several different methods of drawing circles in GMod, you need to be more specific.
[lua]
surface.DrawPoly
[/lua]
Works fine singlecored, but if you activate multicore rendering it sometimes flickrs around.
(Every 10 seconds or such)
[t]http://i.imgur.com/VN3rW7s.png[/t]
[img]http://i.imgur.com/stEuH3p.png[/img]
Works On My Machineā¢
Flickrs randomly.
So far I could see.
It is used in the payday hud on scriptfodder, which is unavailable to current time.
On my TTT-Server sometimes rarely it began to flickering around the screen.
Not all the time but frequently.
Without multicorerendering it did work well, but with enabled it flickrs.
I already took a look at the code and couldn't find anything related to "bad rendering" or such.
([url]https://scriptfodder.com/scripts/view/475[/url])
[QUOTE=Revenge282;50675467]Yep. Just realized they weren't synonymous. Carry on...[/QUOTE]
:snip:
[QUOTE=MPan1;50677270]If you're going to add support for that, [URL="https://github.com/EmmanuelOga/columns/blob/master/utils/color.lua"]this has been around since 2011[/URL] and offers support for multiple color things as well as HSL- it might be good since it gives you a little more range in what color types you can convert between[/QUOTE]
It offers the same color types since HSV is already in gmod.
Besides [url=https://github.com/EmmanuelOga/columns/blob/master/LICENSE]License[/url].
[QUOTE=Nak;50677321]Besides [url=https://github.com/EmmanuelOga/columns/blob/master/LICENSE]License[/url].[/QUOTE]
[URL="https://github.com/EmmanuelOga/columns/blob/master/LICENSE#L8-L9"]Can't you copy it and change it[/URL]? Also, yeah, you're right, I misread the hue2rgb function on line 57 as a separate one. It'd probably be a better idea to use your functions
[QUOTE=MPan1;50677371][URL="https://github.com/EmmanuelOga/columns/blob/master/LICENSE#L8-L9"]Can't you copy it and change it[/URL]? Also, yeah, you're right, I misread the hue2rgb function on line 57 as a separate one. It'd probably be a better idea to use your function[/QUOTE]
What if I hate license that requires you to give attribution?
And Hue as a color model, doesn't sound that useful.
[t]https://upload.wikimedia.org/wikipedia/commons/thumb/a/ad/HueScale.svg/360px-HueScale.svg.png[/t]
But sure
[code]function ColorToHue(R,G,B)
if type(R)=="table" then
R,G,B = clamp(R.r,0,255)/255,clamp(R.g,0,255)/255,clamp(R.b,0,255)/255
else
R,G,B = R/255,G/255,B/255
end
local max,min = max(R,G,B),min(R,G,B)
local del = max-min
-- Hue
local H = 0
if del<=0 then H = 0
elseif max==R then H = 60*( ( (G-B)/del ) %6 )
elseif max==G then H = 60*( ( (B-R)/del +2) %6 )
else--[[max==B]] H = 60*( ( (R-G)/del +4) %6 ) end
return H
end
function HueToColor(H)
H = clamp(H,0,360)
local X = 1-abs((H/60)%2-1)
local R1,G1,B1 = 0,0,0
if H < 60 or H>=360 then R1,G1,B1 = 1,X,0
elseif H < 120 then R1,G1,B1 = X,1,0
elseif H < 180 then R1,G1,B1 = 0,1,X
elseif H < 240 then R1,G1,B1 = 0,X,1
elseif H < 300 then R1,G1,B1 = X,0,1
else --[[ H<360 ]] R1,G1,B1 = 1,0,X
end
return Color(R1*255,G1*255,B1*255)
end
[/code]
I also find it disrespectful when someone shows up, and tells you that your work is invalid cause its been don before.
Btw, Hue is not a proper color-model. Its an element of the color wheel. It only offers "pure"-colors in no shade.
[QUOTE=Nak;50677453]I also find it disrespectful when someone shows up, and tells you that your work is invalid cause its been don before.[/QUOTE]
It's not invalid, I was just worried that since you've only made yours a few days ago it might be a bit buggy compared to one made a couple of years ago, which had more time to be tested, if you know what I mean. Sorry if it sounded disrespectful, someone who's able to make a ColorToHue function in less than a minute shouldn't be disrespected :)
[lua]studio_queue_mode 1[/lua] seems to boost my FPS about 5-10 FPS while having 40 FPS.
Why isn't it mentioned?
[QUOTE=deinemudda32;50678733][lua]studio_queue_mode 1[/lua] seems to boost my FPS about 5-10 FPS while having 40 FPS.
Why isn't it mentioned?[/QUOTE]
I'm getting 100% CPU-usage and ~4FPS.
[QUOTE=uRandomAlex;50679198]I'm getting 100% CPU-usage and ~4FPS.[/QUOTE]
Well, not for me.
[QUOTE=uRandomAlex;50679198]I'm getting 100% CPU-usage and ~4FPS.[/QUOTE]
straight up bullshit.
Even with radeon x300 series(12 years old), 128mb vram i managed to pull 30fps
[QUOTE=Nak;50677453]
[code]function ColorToHue(R,G,B) [...]
function HueToColor(H) [...]
[/code][/QUOTE]
He can already do that with builtin functions
[code]ColorToHue(r, g, b) = ColorToHSV(Color(r, g, b)) -- First return value is hue, no harm
HueToColor(h) = HSVToColor(h, 1, 1) -- unpack rgb values yourself or wrap it in a helper
[/code]
[QUOTE=deinemudda32;50678733][lua]studio_queue_mode 1[/lua] seems to boost my FPS about 5-10 FPS while having 40 FPS.
Why isn't it mentioned?[/QUOTE]
Prolly more unstable that mat_queue_mode and cl_threaded_bone_setup.
edit: or not :v:
[QUOTE=deinemudda32;50678733][lua]studio_queue_mode 1[/lua] seems to boost my FPS about 5-10 FPS while having 40 FPS.
Why isn't it mentioned?[/QUOTE]
That's the default
[QUOTE=xaviergmail;50680009]He can already do that with builtin functions
[code]ColorToHue(r, g, b) = ColorToHSV(Color(r, g, b)) -- First return value is hue, no harm
HueToColor(h) = HSVToColor(h, 1, 1) -- unpack rgb values yourself or wrap it in a helper
[/code][/QUOTE]
Its not the Hue that matters. That was for MPan1 who was asking for more color functions.
It is [url=https://facepunch.com/showthread.php?t=1516664&p=50675452&viewfull=1#post50675452]HSL support I'm after[/url]. But it got derailed.
[QUOTE=Willox;50680766]That's the default[/QUOTE]
Woops.
How about these:
[lua]cl_threaded_client_leaf_system
r_threaded_client_shadow_manager
r_threaded_particles
r_threaded_renderables
r_queued_ropes
host_thread_mode[/lua]
[QUOTE=Nak;50680905]That was for MPan1 who was asking for more color functions[/QUOTE]
I wasn't actually asking for it, I just misread one of the functions as a separate one. Good that you made it though.
I'm also having the issue with drawing circles when multicore rendering is enabled.
The circle should look like this:
[thumb] http://i.imgur.com/OVaVKRm.png [/thumb]
But instead comes out like this when looking around for a bit:
[thumb] http://i.imgur.com/iVEVPTK.png [/thumb]
The code for the circles is this:
[code]
function surface.PrecacheArc(cx,cy,radius,thickness,startang,endang,roughness)
local triarc = {}
-- local deg2rad = math.pi / 180
-- Define step
local roughness = math.max(roughness or 1, 1)
local step = roughness
-- Correct start/end ang
local startang,endang = startang or 0, endang or 0
if startang > endang then
step = math.abs(step) * -1
end
-- Create the inner circle's points.
local inner = {}
local r = radius - thickness
for deg=startang, endang, step do
local rad = math.rad(deg)
-- local rad = deg2rad * deg
local ox, oy = cx+(math.cos(rad)*r), cy+(-math.sin(rad)*r)
table.insert(inner, {
x=-ox,
y=-oy,
u=(-ox-cx)/radius,
v=(-oy-cy)/radius,
})
end
-- Create the outer circle's points.
local outer = {}
for deg=startang, endang, step do
local rad = math.rad(deg)
-- local rad = deg2rad * deg
local ox, oy = cx+(math.cos(rad)*radius), cy+(-math.sin(rad)*radius)
table.insert(outer, {
x=-ox,
y=-oy,
u=(ox-cx)/radius,
v=(oy-cy)/radius,
})
end
-- Triangulize the points.
for tri=1,#inner*2 do -- twice as many triangles as there are degrees.
local p1,p2,p3
p1 = outer[math.floor(tri/2)+1]
p3 = inner[math.floor((tri+1)/2)+1]
if tri%2 == 0 then --if the number is even use outer.
p2 = outer[math.floor((tri+1)/2)]
else
p2 = inner[math.floor((tri+1)/2)]
end
table.insert(triarc, {p1,p2,p3})
end
-- Return a table of triangles to draw.
return triarc
end
function surface.DrawArc(arc)
for k,v in ipairs(arc) do
surface.DrawPoly(v)
end
end
function draw.Arc(cx,cy,radius,thickness,startang,endang,roughness,color)
draw.NoTexture()
surface.SetDrawColor(color)
surface.DrawArc(surface.PrecacheArc(cx,cy,radius,thickness,startang,endang,roughness))
end
[/code]
[QUOTE=smithy285;50685065]
[code]
function surface.PrecacheArc(cx,cy,radius,thickness,startang,endang,roughness)
local triarc = {}
-- local deg2rad = math.pi / 180
-- Define step
local roughness = math.max(roughness or 1, 1)
local step = roughness
-- Correct start/end ang
local startang,endang = startang or 0, endang or 0
if startang > endang then
step = math.abs(step) * -1
end
-- Create the inner circle's points.
local inner = {}
local r = radius - thickness
for deg=startang, endang, step do
local rad = math.rad(deg)
-- local rad = deg2rad * deg
local ox, oy = cx+(math.cos(rad)*r), cy+(-math.sin(rad)*r)
table.insert(inner, {
x=-ox,
y=-oy,
u=(-ox-cx)/radius,
v=(-oy-cy)/radius,
})
end
-- Create the outer circle's points.
local outer = {}
for deg=startang, endang, step do
local rad = math.rad(deg)
-- local rad = deg2rad * deg
local ox, oy = cx+(math.cos(rad)*radius), cy+(-math.sin(rad)*radius)
table.insert(outer, {
x=-ox,
y=-oy,
u=(ox-cx)/radius,
v=(oy-cy)/radius,
})
end
-- Triangulize the points.
for tri=1,#inner*2 do -- twice as many triangles as there are degrees.
local p1,p2,p3
p1 = outer[math.floor(tri/2)+1]
p3 = inner[math.floor((tri+1)/2)+1]
if tri%2 == 0 then --if the number is even use outer.
p2 = outer[math.floor((tri+1)/2)]
else
p2 = inner[math.floor((tri+1)/2)]
end
table.insert(triarc, {p1,p2,p3})
end
-- Return a table of triangles to draw.
return triarc
end
function surface.DrawArc(arc)
for k,v in ipairs(arc) do
surface.DrawPoly(v)
end
end
function draw.Arc(cx,cy,radius,thickness,startang,endang,roughness,color)
draw.NoTexture()
surface.SetDrawColor(color)
surface.DrawArc(surface.PrecacheArc(cx,cy,radius,thickness,startang,endang,roughness))
end
[/code][/QUOTE]
credit to bobbleheadbob for that arc code
If I'm not mistaken the letter Q as your crosshair and letters as the weapon icons is usually from manually installing the HL font.
EDIT: Could equally be something related to the update but in the past I've had the font manually installed and it's had the same effect
[QUOTE=Noi;50685243]I've got letter Q instead of crosshair and all my fonts are messed up too (including the ones in Awesomium). Is this supposed to be funny or what.
[editline]10th July 2016[/editline]
Uh, what the
[img]http://i.imgur.com/vIvNkLj.png[/img].
[code]Failed to load custom font file 'e:\steam\steamapps\common\garrysmod\garrysmod\resource\halflife2.ttf'
Failed to load custom font file 'e:\steam\steamapps\common\garrysmod\sourceengine\resource\hl2ep2.ttf'
Failed to load custom font file 'e:\steam\steamapps\common\garrysmod\sourceengine\resource\marlett.ttf'
Failed to load custom font file 'e:\steam\steamapps\common\garrysmod\garrysmod\resource\fonts\akbar.ttf'
Failed to load custom font file 'e:\steam\steamapps\common\garrysmod\garrysmod\resource\fonts\coolvetica.ttf'
Failed to load custom font file 'e:\steam\steamapps\common\garrysmod\garrysmod\resource\fonts\csd.ttf'
Failed to load custom font file 'e:\steam\steamapps\common\garrysmod\garrysmod\resource\fonts\roboto-black.ttf'
Failed to load custom font file 'e:\steam\steamapps\common\garrysmod\garrysmod\resource\fonts\roboto-blackitalic.ttf'
Failed to load custom font file 'e:\steam\steamapps\common\garrysmod\garrysmod\resource\fonts\roboto-bold.ttf'
Failed to load custom font file 'e:\steam\steamapps\common\garrysmod\garrysmod\resource\fonts\roboto-boldcondensed.ttf'
Failed to load custom font file 'e:\steam\steamapps\common\garrysmod\garrysmod\resource\fonts\roboto-boldcondenseditalic.ttf'
Failed to load custom font file 'e:\steam\steamapps\common\garrysmod\garrysmod\resource\fonts\roboto-bolditalic.ttf'
Failed to load custom font file 'e:\steam\steamapps\common\garrysmod\garrysmod\resource\fonts\roboto-condensed.ttf'
Failed to load custom font file 'e:\steam\steamapps\common\garrysmod\garrysmod\resource\fonts\roboto-condenseditalic.ttf'
Failed to load custom font file 'e:\steam\steamapps\common\garrysmod\garrysmod\resource\fonts\roboto-italic.ttf'
Failed to load custom font file 'e:\steam\steamapps\common\garrysmod\garrysmod\resource\fonts\roboto-light.ttf'
Failed to load custom font file 'e:\steam\steamapps\common\garrysmod\garrysmod\resource\fonts\roboto-lightitalic.ttf'
Failed to load custom font file 'e:\steam\steamapps\common\garrysmod\garrysmod\resource\fonts\roboto-medium.ttf'
Failed to load custom font file 'e:\steam\steamapps\common\garrysmod\garrysmod\resource\fonts\roboto-mediumitalic.ttf'
Failed to load custom font file 'e:\steam\steamapps\common\garrysmod\garrysmod\resource\fonts\roboto-regular.ttf'
Failed to load custom font file 'e:\steam\steamapps\common\garrysmod\garrysmod\resource\fonts\roboto-thin.ttf'
Failed to load custom font file 'e:\steam\steamapps\common\garrysmod\garrysmod\resource\fonts\roboto-thinitalic.ttf'
Failed to load custom font file 'e:\steam\steamapps\common\garrysmod\garrysmod\cache\workshop\resource\fonts\clearsans-medium.ttf'
Failed to load custom font file 'e:\steam\steamapps\common\garrysmod\garrysmod\cache\workshop\resource\fonts\hidden.ttf'
Failed to load custom font file 'e:\steam\steamapps\common\garrysmod\garrysmod\cache\workshop\resource\fonts\roboto-bold.ttf'
Failed to load custom font file 'e:\steam\steamapps\common\garrysmod\garrysmod\cache\workshop\resource\fonts\roboto-light.ttf'
Failed to load custom font file 'e:\steam\steamapps\common\garrysmod\garrysmod\cache\workshop\resource\fonts\roboto-medium.ttf'
Failed to load custom font file 'e:\steam\steamapps\common\garrysmod\garrysmod\cache\workshop\resource\fonts\roboto-thin.ttf'
Failed to load custom font file 'e:\steam\steamapps\common\garrysmod\garrysmod\cache\workshop\resource\fonts\typenoksidi.ttf'
Failed to load custom font file 'e:\steam\steamapps\common\garrysmod\garrysmod\resource\halflife2.ttf'
Failed to load custom font file 'e:\steam\steamapps\common\garrysmod\garrysmod\resource\hl2mp.ttf'
Failed to load custom font file 'e:\steam\steamapps\common\garrysmod\garrysmod\resource\hl2crosshairs.ttf'
Failed to load custom font file 'e:\steam\steamapps\common\garrysmod\garrysmod\resource\halflife2.ttf'
Failed to load custom font file 'e:\steam\steamapps\common\garrysmod\sourceengine\resource\hl2ep2.ttf'[/code]
[editline]10th July 2016[/editline]
It happened after some windows update.[/QUOTE]
Holy shit someone else with the same problem as me, I've had this for months!
[QUOTE=smithy285;50685065]I'm also having the issue with drawing circles when multicore rendering is enabled.
The circle should look like this:
-snip-
But instead comes out like this when looking around for a bit:
[thumb] http://i.imgur.com/iVEVPTK.png [/thumb]
The code for the circles is this:
-snip-[/QUOTE]
Are you drawing using draw.Arc all every frame or surface.DrawArc?
Sorry, you need to Log In to post a reply to this thread.