Quick actions

cmd+k|ctrl+k

Navigation

Languages

Correction du gamma des couleurs RGB

Snippet info

Language

Python

Visibility

unlisted

Author

legacy-anonymous

Created

2021-01-31T17:46:46Z

Updated

2021-01-31T17:46:46Z

def  linearToGammaCorrected(col, name):
    components = list(map(lambda x: pow(x / 255, 2.2) * 1000 , col))
    components = ", ".join([ "{:.2f}".format(c) for c in components ])
    print("%(name)s = vec3(%(components)s)" % {'name':name, 'components':components})

sphere_color = [89 , 66 , 54 ]
floor_color  = [255, 186, 73 ]
sky_color    = [10 , 157, 255]

linearToGammaCorrected(sphere_color, "sphere")
linearToGammaCorrected(floor_color, "floor")
linearToGammaCorrected(sky_color, "sky")
INFO