What is Roblox's RGB Shift for Neon?

Roblox changes its RGB value when you have a neon part, as can be shown by these 2 pictures below.


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

However, this gives an incorrect result

Would anyone have any idea on how to achieve a more color correct change or what math would be need to used ?

2 Likes

This works for inverting apparently, but not for reverting.

Bump!!! Any help is appreciated!

Bump again!!!

editing again i didnt get the revert but try if u want

I believe you can also use color /= color and color ^= 2 etc to clean up the code.

it is still the same as the revert code but i think i get the idea, might be involving saving the neon colors

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

Have you seen this post?

If not it may contain what you need to know.

This only works if you know the previous one, I’m attempting to find the colour shift from the engine so I can apply it to blender.

Even more bumping, any help would be nice

Bumping this, having the same issue

Bumping once again, having to manually fix neon colors when exporting is mad time-consuming

1 Like

You might be able to plot out the colors and find the relation.

I also needed this information and wasn’t able to find it, so if anyone already has the formula it would be much appreciated.

bumping once again,

(character requirement)

Still need this, would be helpful if someone replied

Still need this, would be helpful if someone replied

Another bump please could use some help

1 Like

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.

-- Testing:
local function toRGB(color: Color3): Vector3
	return Vector3.new(math.round(color.R * 255), math.round(color.G * 255), math.round(color.B * 255))
end
print(toRGB(invertNeonColor(Color3.fromRGB(5,5,5)))) --> 37, 37, 37 (correct)
print(toRGB(invertNeonColor(Color3.fromRGB(9, 137, 207)))) --> 43, 97, 123 (correct)
print(toRGB(invertNeonColor(Color3.fromRGB(170, 85, 0)))) --> 108, 81, 0 (correct)
print(toRGB(invertNeonColor(Color3.fromRGB(231, 231, 236)))) --> 140, 140, 145 (correct)
2 Likes