This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vector xyzToLab(vector xyz) { | |
float vx = xyz[0] / 0.95047; | |
float vy = xyz[1]; | |
float vz = xyz[2] / 1.08883; | |
vx = select(7.787 * vx + 16.0 / 116.0, pow(vx, 1.0 / 3.0), vx > 0.008856); | |
vy = select(7.787 * vy + 16.0 / 116.0, pow(vy, 1.0 / 3.0), vy > 0.008856); | |
vz = select(7.787 * vz + 16.0 / 116.0, pow(vz, 1.0 / 3.0), vz > 0.008856); | |
return vector( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vector lRgbToXyz(color linear) { | |
return transform(matrix( | |
0.41241086, 0.21264935, 0.019331759, 0.0, | |
0.35758457, 0.71516913, 0.11919486 , 0.0, | |
0.1804538 , 0.07218152, 0.95039004 , 0.0, | |
0.0 , 0.0 , 0.0 , 1.0), | |
linear); | |
} | |
color xyzTolRgb(vector xyz) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vector le(vector a, float b) { | |
return vector(a[0] <= b, a[1] <= b, a[2] <= b); | |
} | |
vector gt(vector a, float b) { | |
return vector(a[0] > b, a[1] > b, a[2] > b); | |
} | |
color sRgbTolRgb(color standard) { | |
return select(pow((standard + 0.055) / 1.055, 2.4), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float scalarProj(vector a, vector b) { | |
return dot(a, b) / dot(b, b); | |
} | |
float uquantize(float x, int levels) { | |
return select( | |
max(0.0, (ceil(x * levels) - 1.0) / (levels - 1.0)), | |
x, levels < 2); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float quantize(float x, int levels) { | |
return select( | |
floor(0.5 + x * levels) / levels, | |
x, levels < 2); | |
} | |
shader circle1( | |
point Point = P, | |
point Center = 0.0, | |
float Radius = 1.5, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
color sRgbTolRgb(color standard) { | |
float sr = standard[0]; | |
float sg = standard[1]; | |
float sb = standard[2]; | |
return color( | |
select(pow((sr + 0.055) / 1.055, 2.4), sr / 12.92, sr <= 0.04045), | |
select(pow((sg + 0.055) / 1.055, 2.4), sg / 12.92, sg <= 0.04045), | |
select(pow((sb + 0.055) / 1.055, 2.4), sb / 12.92, sb <= 0.04045)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
shader circle0( | |
vector UV = vector(0.5, 0.5, 0.0), | |
vector Center = vector(0.5, 0.5, 0.0), | |
float Radius = 1.0, | |
float Blur = 0.0, | |
color Outside = color(1.0, 0.0, 0.0), | |
color Inside = 1.0, | |
output color Color = 0.8, | |
output float Fac = 0.5) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
import bmesh | |
import math | |
from mathutils import noise, Quaternion, Vector | |
# Create a Suzanne (monkey head); subdivide. | |
bm = bmesh.new() | |
bmesh.ops.create_monkey(bm) | |
bmesh.ops.subdivide_edges( | |
bm, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
import bmesh | |
import math | |
from mathutils import Vector | |
def lerp_vec_array(arr, step=0.5, easing_func=None): | |
len_arr = len(arr) | |
if len_arr == 0: | |
return Vector((0.0, 0.0, 0.0)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use Vector.Fill to create uniform scales. | |
scales = [ | |
Vector.Fill(3, 1.0), | |
Vector((0.25, 0.75, 0.5)), | |
Vector.Fill(3, 2 ** 0.5), | |
Vector((0.75, 0.5, 0.25)), | |
Vector.Fill(3, 2 ** -0.5), | |
Vector((0.5, 0.25, 0.75)), | |
Vector.Fill(3, 1.0) | |
] |