![]() ![]() ![]() I’m not really the best at explaining this, so TL DR: linear color space is good for math, gamma color space is not.Īs a Roblox developer, I want to perform math directly on Color3 values, because it is more convenient than converting between data types. Linear colors don’t look like you expect them too, either, and different color gamuts make the problem more complicated. But it’s a mindset change 0-255 makes no sense, you really want 0.0-1.0. Maybe LinearColor3, for example, with conversion functions in between. Sure, it might be simple enough to make the distinction in your API. This issue is compounded by the fact that most image formats are in gamma space, and you need to convert back to gamma space when rendering. Fortunately, conversion is simple… but keeping track of it isn’t. Normals won’t look right, lighting and shading will be too dark or too bright. When you do math with colors in shaders, you must convert to linear space first or everything you do is wrong. Monitors show you color in gamma space because weird reasons I won’t go into. If I take white (255,255,255) and divide it by 2, I get (127.5,127.5,127.5), right? You might expect this to be half as bright. Mathematical operations on colors in gamma space are incorrect. but that seems beyond what you're asking here.Well, let’s think of it this way. There is more you could do to prevent the user from entering text that is not numbers, like checking the newValue string for non-numerical characters and removing them. G:GetPropert圜hangedSignal("Text"):Connect(updateColor)ī:GetPropert圜hangedSignal("Text"):Connect(updateColor) R:GetPropert圜hangedSignal("Text"):Connect(updateColor) listen for changes on each of the text boxes Warn("Failed to update colorIndicator with error : ", result) Indicator.BackgroundColor3 = omRGB(clampedR, clampedG, clampedB) use pcall to safely try and update the colors ![]() Return math.max(minimum, math.min(value, maximum)) ![]() Local function clamp(minimum, value, maximum) All Instances come with a GetPropert圜hangedSignal function that you can utilize to update the color anytime the text changes. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |