Add Chromium-only Blender WebEngine parity work

This commit is contained in:
mes123456
2026-08-12 04:47:48 -04:00
commit 9fd26010f6
18225 changed files with 11622124 additions and 0 deletions

View File

@@ -0,0 +1,78 @@
/* An advanced perspective camera, implementing several examples
* of things you can do with custom cameras. */
float invertDistortionModel(float x, float y, float k1, float k2, float k3)
{
// Solves u = d*(1 + k1*d^2 + k2*d^4 + k3*d^6) for d.
// Returns stretch factor.
float u = sqrt(x * x + y * y);
float d = u;
for (int i = 0; i < 50; i++) {
float d2 = d * d;
float f = u - d * (1 + d2 * (k1 + d2 * (k2 + d2 * k3)));
float fp = -(1 + d2 * (3 * k1 + d2 * (5 * k2 + d2 * 7 * k3)));
float diff = f / fp;
d -= diff;
if (fabs(diff) < 1e-7) {
// Iteration is converging, return result.
return d / u;
}
if (d > 100.0) {
// Iteration is diverging, give up.
return -1.0;
}
}
// Reached iteration limit, give up.
return -1.0;
}
shader camera(float focal_length = 50.0 [[ float min = 0.0,
string unit = "mm",
float sensitivity = 0.2 ]],
int do_distortion = 0 [[ string widget = "checkBox"]],
int do_swirl = 0 [[ string widget = "checkBox"]],
int do_dof = 0 [[ string widget = "checkBox"]],
float distortion_k1 = -0.2,
float distortion_k2 = 0.0,
float distortion_k3 = 0.0,
float swirl_scale = 100.0,
float swirl_amplitude = 0.01,
float swirl_w = 0.0 [[ float sensitivity = 1]],
output point position = 0.0,
output vector direction = 0.0,
output color throughput = 1.0)
{
point Pcam = camera_shader_raster_position() - vector(0.5);
if (do_distortion) {
float distort = invertDistortionModel(
Pcam.x, Pcam.y, distortion_k1, distortion_k2, distortion_k3);
if (distort < 0.0) {
// Distortion model failed, skip the path.
throughput = color(0.0);
return;
}
Pcam *= distort;
}
vector sensor_size;
getattribute("cam:sensor_size", sensor_size);
Pcam = Pcam * sensor_size / focal_length;
if (do_swirl) {
Pcam += swirl_amplitude * noise("perlin", Pcam * swirl_scale, swirl_w);
}
direction = normalize(vector(Pcam.x, Pcam.y, 1.0));
if (do_dof) {
float focal_distance;
getattribute("cam:focal_distance", focal_distance);
getattribute("cam:aperture_position", position);
position *= focal_length * 1e-3;
point Pfocus = direction * focal_distance / direction.z;
direction = normalize(Pfocus - position);
}
}

View File

@@ -0,0 +1,16 @@
/* A basic perspective camera. */
shader camera(float focal_length = 90.0 [[ float min = 0.0,
string unit = "mm",
float sensitivity = 0.2 ]],
output point position = 0.0,
output vector direction = 0.0,
output color throughput = 1.0)
{
vector sensor_size;
getattribute("cam:sensor_size", sensor_size);
point Pcam = camera_shader_raster_position() - point(0.5);
Pcam *= sensor_size / focal_length;
direction = normalize(vector(Pcam.x, Pcam.y, 1.0));
}

View File

@@ -0,0 +1,10 @@
shader basic_shader(
float in_float = 1.0,
color in_color = color(1.0, 1.0, 1.0),
output float out_float = 0.0,
output color out_color = color(0.0, 0.0, 0.0)
)
{
out_float = in_float * 2.0;
out_color = in_color * 2.0;
}

View File

@@ -0,0 +1,42 @@
/* A panorama camera implementing a full cubemap projection. */
shader camera(output point position = 0.0,
output vector direction = 0.0,
output color throughput = 1.0)
{
vector st = camera_shader_raster_position() * vector(4, 3, 0);
float s = fmod(st.x, 1.0) - 0.5;
float t = fmod(st.y, 1.0) - 0.5;
int s_face = int(floor(st.x));
int t_face = int(floor(st.y));
if (s_face == 0 && t_face == 1) {
/* Left face. */
direction = normalize(vector(-0.5, t, s));
}
else if (s_face == 1 && t_face == 1) {
/* Front face. */
direction = normalize(vector(s, t, 0.5));
}
else if (s_face == 2 && t_face == 1) {
/* Right face. */
direction = normalize(vector(0.5, t, -s));
}
else if (s_face == 3 && t_face == 1) {
/* Back face. */
direction = normalize(vector(-s, t, -0.5));
}
else if (s_face == 1 && t_face == 2) {
/* Top face. */
direction = normalize(vector(s, 0.5, -t));
}
else if (s_face == 1 && t_face == 0) {
/* Bottom face. */
direction = normalize(vector(s, -0.5, t));
}
else {
/* Outside cube map. */
throughput = color(0.0);
}
}

View File

@@ -0,0 +1,6 @@
shader name()
{
}

View File

@@ -0,0 +1,17 @@
shader gabor_noise(
point Point = P,
vector Direction = vector(1, 0, 0),
int Anisotropic = 0,
float Bandwidth = 1.0,
float Impulses = 16,
output float Gabor = 0.8)
{
Gabor = noise("gabor", Point,
"direction", Direction,
"anisotropic", Anisotropic,
"do_filter", 1, // Set to 0 to disable filtering/anti-aliasing
"bandwidth", Bandwidth,
"impulses", Impulses);
}

View File

@@ -0,0 +1,141 @@
/*
* Lyapunov Shader - in memory of great mathematician Aleksandr Mikhailovich Lyapunov
* Original code: Sylvio Sell - maitag.de - Rostock Germany 2013
* OSL port by Thomas Dinges
* More information: https://projects.blender.org/blender/blender/issues/32305
*/
/* Fac_Type
* 0, SPREAD, Spread indices for fac output
* 1, ABS, Absolute values from indices
* 2, COLOR, Get fac output from used colors
* 3, REAL, Real indices
*/
/* Render_Type
* 0, NEG, Negative Lyapunov indices only
* 1, POS, Positive Lyapunov indices only
* 2, ALL, Positive and negative indices
*/
float lyapunov(point p, float iteration_pre, float iteration_main, float p1, float p2)
{
/* Coordinates */
float a = p[0];
float b = p[1];
float c = p[2];
int iter_pre = (int)floor(iteration_pre);
int iter_main = (int)floor(iteration_main);
float nabla_pre = iteration_pre - (float)iter_pre;
float nabla_main = iteration_main - (float)iter_main;
float x = 0.0;
float index = 0.0;
float derivation = 0.0;
int iter = 0;
/* Pre-iteration */
for (int i = 0; i < iter_pre; i++) {
x = p1 * sin(x + a) * sin(x + a) + p2;
x = p1 * sin(x + b) * sin(x + b) + p2;
x = p1 * sin(x + c) * sin(x + c) + p2;
}
if (nabla_pre != 0.0) {
float x_pre = x;
x = p1 * sin(x + a) * sin(x + a) + p2;
x = p1 * sin(x + b) * sin(x + b) + p2;
x = p1 * sin(x + c) * sin(x + c) + p2;
x = x * nabla_pre + x_pre * (1.0 - nabla_pre);
}
/* Main-iteration */
for (int i = 0; i < iter_main; i++) {
x = p1 * sin(x + a) * sin(x + a) + p2;
derivation = 2.0 *p1 *sin(x + a) * cos(x + a);
if (derivation != 0.0) { index += log(fabs(derivation)); iter++; }
x = p1 * sin(x + b) * sin(x + b) + p2;
derivation = 2.0 *p1 *sin(x + b) * cos(x + b);
if (derivation != 0.0) { index += log(fabs(derivation)); iter++; }
x = p1 * sin(x + c) * sin(x + c) + p2;
derivation = 2.0 *p1 *sin(x + c) * cos(x + c);
if (derivation != 0.0) { index += log(fabs(derivation)); iter++; }
}
if (nabla_main == 0.0) {
index = (iter != 0) ? index / (float)(iter) : 0.0;
}
else {
float index_pre = (iter != 0) ? index / (float)(iter) : 0.0;
x = p1 * sin(x + a) * sin(x + a) + p2;
derivation = 2.0 *p1 *sin(x + a) * cos(x + a);
if (derivation != 0.0) { index += log(fabs(derivation)); iter++; }
x = p1 * sin(x + b) * sin(x + b) + p2;
derivation = 2.0 *p1 *sin(x + b) * cos(x + b);
if (derivation != 0.0) { index += log(fabs(derivation)); iter++; }
x = p1 * sin(x + c) * sin(x + c) + p2;
derivation = 2.0 *p1 *sin(x + c) * cos(x + c);
if (derivation != 0.0) { index += log(fabs(derivation)); iter++; }
index = (iter != 0) ? index / (float)(iter) : 0.0;
index = index * nabla_main + index_pre * (1.0 - nabla_main);
}
return index;
}
shader node_lyapunov(
color Pos_Color = color(1.0, 0.0, 0.0),
color Mid_Color = color(0.0, 0.0, 0.0),
color Neg_Color = color(0.0, 0.0, 1.0),
float Pre_Iteration = 0.0,
float Main_Iteration = 1.0,
float Pos_Scale = 0.5,
float Neg_Scale = 0.5,
float Param1 = 2.0,
float Param2 = 2.0,
int Fac_Type = 0,
int Render_Type = 2,
float Scale = 0.25,
point Pos = P,
output float Fac = 0.0,
output color Color = 0.0)
{
/* Calculate Texture */
float index = lyapunov(Pos * Scale, Pre_Iteration, Main_Iteration, Param1, Param2);
/* Calculate Color */
if (index > 0.0 && (Render_Type != 0)) {
index *= Pos_Scale;
if (index > 1.0) { index = 1.0; }
Color = (Pos_Color - Mid_Color) * index + Mid_Color;
}
else if (index < 0.0 && (Render_Type != 1)) {
index *= Neg_Scale;
if (index < -1.0) { index = -1.0; }
Color = (Mid_Color - Neg_Color) * index + Mid_Color;
}
else {
Color = Mid_Color;
}
/* Adjust Index */
if (Fac_Type == 0) {
index = 0.5 + index * 0.5;
}
else if (Fac_Type == 1) {
index = fabs(index);
}
else if (Fac_Type == 2) {
index = (Color[0] + Color[1] + Color[2]) * (1.0 / 3.0);
}
Fac = index;
}

View File

@@ -0,0 +1,27 @@
shader noise(
float Time = 1.0,
point Point = P,
output float Cell = 0.0,
output color Perlin = 0.8,
output color UPerlin = 0.8,
output color Simplex = 0.8,
output color USimplex = 0.8)
{
/* Cell Noise */
Cell = noise("cell", Point);
/* Perlin 4D Noise */
Perlin = noise("perlin", Point, Time);
/* UPerlin 4D Noise */
UPerlin = noise("uperlin", Point, Time);
/* Simplex 4D Noise */
Simplex = noise("simplex", Point, Time);
/* USimplex 4D Noise */
USimplex = noise("usimplex", Point, Time);
}

View File

@@ -0,0 +1,20 @@
shader node_ramp_bsdf(
float Exponent = 10.0,
color Color1 = color(0.8, 0.0, 0.0),
color Color2 = color(0.0, 0.8, 0.0),
color Color3 = color(0.0, 0.0, 0.8),
color Color4 = 0.1,
color Color5 = 0.2,
color Color6 = 0.3,
color Color7 = 0.4,
color Color8 = 0.5,
normal Normal = N,
output closure color Phong = 0,
output closure color Diffuse = 0)
{
color Color[8] = {Color1, Color2, Color3, Color4, Color5, Color6, Color7, Color8};
Phong = phong_ramp(Normal, Exponent, Color);
Diffuse = diffuse_ramp(Normal, Color);
}