The second picture is in studio whereas the first picture is in Blender.
I’m trying to replicate the neon colouring of studio, I’ve attempted it by using information from this thread.
I reversed the function above resulting in this.
function invertNeonTransform(color)
color = color * color
color = color * 0.25
color = math.sqrt(color)
color = math.sqrt(color)
color = color / 1.35
return color
end
function revertNeonTransform(color)
color = color * 1.35
color = color^2
color = color^2
color = color / 0.25
color = math.sqrt(color)
return color
end
local colorSaves = {}
function invertNeonTransform(color)
local recentCSN = nil
table.insert(colorSaves, {})
recentCSN = #colorSaves
table.insert(colorSaves[recentCSN], color)
color ^= 2
color *= 0.25
color = math.sqrt(color)
color = math.sqrt(color)
color /= 1.35
table.insert(colorSaves[recentCSN], color)
return color
end
function revertNeonTransform(color)
for _, v in pairs(colorSaves) do
if table.find(v, color) then
local revertedColor = v[1]
return revertedColor
end
end
end
if one value in a table of colorSaves is different, the other value will be different, all tables will not have the same value if all of them has 1 slightly different value in it
I sampled various colors and then did a regression on the inverse of the data to obtain the following functions:
local function invertNeonSingular(desired: number): number
-- Clamp endpoints
if desired <= 0 then
return 0
elseif desired >= 1 then
return 1
end
local logit: number = math.log((1.13*desired) / (0.000171234*(1 - desired)))
-- Floating point imprecision could cause the result of the logit function to be NaN on the edges
if logit ~= logit then
return if desired >= 0.5 then 1 else 0
end
local result: number = 0.0288655*logit + 2.4907e-8 + 0.288981*desired + 0.620371*desired^2 - 5.33434*desired^3 + 13.4773*desired^4 - 14.4337*desired^5 + 5.70642*desired^6
return (math.clamp(result, 0, 1))
end
local function invertNeonColor(color: Color3): Color3
return Color3.new(invertNeonSingular(color.R), invertNeonSingular(color.G), invertNeonSingular(color.B))
end
I tested it with the following code (by putting the outputs into a neon brick with bloom enabled on future lighting then checking the color with a color picker), and ALL of them are within 1 of the original color for each channel.