2017-03-27 00:28:52 -04:00
|
|
|
|
|
|
|
uniform mat4 ModelViewMatrix;
|
2017-05-17 19:40:21 +02:00
|
|
|
#ifndef EEVEE_ENGINE
|
2017-03-27 00:28:52 -04:00
|
|
|
uniform mat4 ProjectionMatrix;
|
2017-06-03 01:43:25 +02:00
|
|
|
uniform mat4 ViewMatrixInverse;
|
2017-06-01 13:22:30 +02:00
|
|
|
uniform mat4 ViewMatrix;
|
2017-06-22 03:10:39 +02:00
|
|
|
#endif
|
2017-05-18 14:29:57 +02:00
|
|
|
uniform mat4 ModelMatrix;
|
2017-05-04 17:39:50 +02:00
|
|
|
uniform mat4 ModelMatrixInverse;
|
2017-03-27 00:28:52 -04:00
|
|
|
uniform mat4 ModelViewMatrixInverse;
|
|
|
|
uniform mat4 ProjectionMatrixInverse;
|
|
|
|
uniform mat3 NormalMatrix;
|
2017-05-07 15:22:25 +02:00
|
|
|
uniform vec4 CameraTexCoFactors;
|
2017-03-27 00:28:52 -04:00
|
|
|
|
2017-07-03 21:39:52 +02:00
|
|
|
/* Old glsl mode compat. */
|
|
|
|
|
2017-07-09 12:01:29 +02:00
|
|
|
#ifndef CLOSURE_DEFAULT
|
2017-07-03 21:39:52 +02:00
|
|
|
|
|
|
|
struct Closure {
|
|
|
|
vec3 radiance;
|
|
|
|
float opacity;
|
|
|
|
};
|
|
|
|
|
2017-07-11 01:11:25 +02:00
|
|
|
#define CLOSURE_DEFAULT Closure(vec3(0.0), 1.0)
|
2017-07-03 21:39:52 +02:00
|
|
|
|
|
|
|
Closure closure_mix(Closure cl1, Closure cl2, float fac)
|
|
|
|
{
|
|
|
|
Closure cl;
|
|
|
|
cl.radiance = mix(cl1.radiance, cl2.radiance, fac);
|
|
|
|
cl.opacity = mix(cl1.opacity, cl2.opacity, fac);
|
|
|
|
return cl;
|
|
|
|
}
|
|
|
|
|
|
|
|
Closure closure_add(Closure cl1, Closure cl2)
|
|
|
|
{
|
|
|
|
Closure cl;
|
|
|
|
cl.radiance = cl1.radiance + cl2.radiance;
|
|
|
|
cl.opacity = cl1.opacity + cl2.opacity;
|
|
|
|
return cl;
|
|
|
|
}
|
|
|
|
|
|
|
|
Closure nodetree_exec(void); /* Prototype */
|
|
|
|
|
2017-07-09 12:01:29 +02:00
|
|
|
#endif /* CLOSURE_DEFAULT */
|
2017-07-03 21:39:52 +02:00
|
|
|
|
2017-03-27 01:16:18 -04:00
|
|
|
|
2016-02-02 12:48:18 +01:00
|
|
|
/* Converters */
|
|
|
|
|
|
|
|
float convert_rgba_to_float(vec4 color)
|
|
|
|
{
|
|
|
|
#ifdef USE_NEW_SHADING
|
2017-05-19 14:20:08 -04:00
|
|
|
return dot(color.rgb, vec3(0.2126, 0.7152, 0.0722));
|
2016-02-02 12:48:18 +01:00
|
|
|
#else
|
2017-05-19 14:20:08 -04:00
|
|
|
return (color.r + color.g + color.b) * 0.333333;
|
2016-02-02 12:48:18 +01:00
|
|
|
#endif
|
|
|
|
}
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
float exp_blender(float f)
|
|
|
|
{
|
|
|
|
return pow(2.71828182846, f);
|
|
|
|
}
|
|
|
|
|
2012-11-06 19:58:48 +00:00
|
|
|
float compatible_pow(float x, float y)
|
|
|
|
{
|
2016-05-23 10:31:36 +02:00
|
|
|
if (y == 0.0) /* x^0 -> 1, including 0^0 */
|
2014-01-14 22:58:07 +04:00
|
|
|
return 1.0;
|
|
|
|
|
2012-11-06 19:58:48 +00:00
|
|
|
/* glsl pow doesn't accept negative x */
|
2016-05-23 10:31:36 +02:00
|
|
|
if (x < 0.0) {
|
|
|
|
if (mod(-y, 2.0) == 0.0)
|
2012-11-06 19:58:48 +00:00
|
|
|
return pow(-x, y);
|
|
|
|
else
|
|
|
|
return -pow(-x, y);
|
|
|
|
}
|
2016-05-23 10:31:36 +02:00
|
|
|
else if (x == 0.0)
|
2012-11-06 19:58:48 +00:00
|
|
|
return 0.0;
|
|
|
|
|
|
|
|
return pow(x, y);
|
|
|
|
}
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
void rgb_to_hsv(vec4 rgb, out vec4 outcol)
|
|
|
|
{
|
|
|
|
float cmax, cmin, h, s, v, cdelta;
|
|
|
|
vec3 c;
|
|
|
|
|
|
|
|
cmax = max(rgb[0], max(rgb[1], rgb[2]));
|
|
|
|
cmin = min(rgb[0], min(rgb[1], rgb[2]));
|
2016-05-26 18:46:12 +10:00
|
|
|
cdelta = cmax - cmin;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
v = cmax;
|
2016-05-26 18:46:12 +10:00
|
|
|
if (cmax != 0.0)
|
|
|
|
s = cdelta / cmax;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
else {
|
|
|
|
s = 0.0;
|
|
|
|
h = 0.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (s == 0.0) {
|
|
|
|
h = 0.0;
|
|
|
|
}
|
|
|
|
else {
|
2017-05-19 14:20:08 -04:00
|
|
|
c = (vec3(cmax) - rgb.xyz) / cdelta;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
if (rgb.x == cmax) h = c[2] - c[1];
|
|
|
|
else if (rgb.y == cmax) h = 2.0 + c[0] - c[2];
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
else h = 4.0 + c[1] - c[0];
|
|
|
|
|
|
|
|
h /= 6.0;
|
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
if (h < 0.0)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
h += 1.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
outcol = vec4(h, s, v, rgb.w);
|
|
|
|
}
|
|
|
|
|
|
|
|
void hsv_to_rgb(vec4 hsv, out vec4 outcol)
|
|
|
|
{
|
|
|
|
float i, f, p, q, t, h, s, v;
|
|
|
|
vec3 rgb;
|
|
|
|
|
|
|
|
h = hsv[0];
|
|
|
|
s = hsv[1];
|
|
|
|
v = hsv[2];
|
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
if (s == 0.0) {
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
rgb = vec3(v, v, v);
|
|
|
|
}
|
|
|
|
else {
|
2016-05-26 18:46:12 +10:00
|
|
|
if (h == 1.0)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
h = 0.0;
|
2016-05-26 18:46:12 +10:00
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
h *= 6.0;
|
|
|
|
i = floor(h);
|
|
|
|
f = h - i;
|
|
|
|
rgb = vec3(f, f, f);
|
2016-05-26 18:46:12 +10:00
|
|
|
p = v * (1.0 - s);
|
|
|
|
q = v * (1.0 - (s * f));
|
|
|
|
t = v * (1.0 - (s * (1.0 - f)));
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
if (i == 0.0) rgb = vec3(v, t, p);
|
|
|
|
else if (i == 1.0) rgb = vec3(q, v, p);
|
|
|
|
else if (i == 2.0) rgb = vec3(p, v, t);
|
|
|
|
else if (i == 3.0) rgb = vec3(p, q, v);
|
|
|
|
else if (i == 4.0) rgb = vec3(t, p, v);
|
|
|
|
else rgb = vec3(v, p, q);
|
|
|
|
}
|
|
|
|
|
|
|
|
outcol = vec4(rgb, hsv.w);
|
|
|
|
}
|
|
|
|
|
2010-07-29 10:09:20 +00:00
|
|
|
float srgb_to_linearrgb(float c)
|
|
|
|
{
|
2016-05-23 10:31:36 +02:00
|
|
|
if (c < 0.04045)
|
2016-05-26 18:46:12 +10:00
|
|
|
return (c < 0.0) ? 0.0 : c * (1.0 / 12.92);
|
2010-07-29 10:09:20 +00:00
|
|
|
else
|
2016-05-26 18:46:12 +10:00
|
|
|
return pow((c + 0.055) * (1.0 / 1.055), 2.4);
|
2010-07-29 10:09:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
float linearrgb_to_srgb(float c)
|
|
|
|
{
|
2016-05-23 10:31:36 +02:00
|
|
|
if (c < 0.0031308)
|
2016-05-26 18:46:12 +10:00
|
|
|
return (c < 0.0) ? 0.0 : c * 12.92;
|
2010-07-29 10:09:20 +00:00
|
|
|
else
|
2016-05-26 18:46:12 +10:00
|
|
|
return 1.055 * pow(c, 1.0 / 2.4) - 0.055;
|
2010-07-29 10:09:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void srgb_to_linearrgb(vec4 col_from, out vec4 col_to)
|
|
|
|
{
|
|
|
|
col_to.r = srgb_to_linearrgb(col_from.r);
|
|
|
|
col_to.g = srgb_to_linearrgb(col_from.g);
|
|
|
|
col_to.b = srgb_to_linearrgb(col_from.b);
|
|
|
|
col_to.a = col_from.a;
|
|
|
|
}
|
|
|
|
|
|
|
|
void linearrgb_to_srgb(vec4 col_from, out vec4 col_to)
|
|
|
|
{
|
|
|
|
col_to.r = linearrgb_to_srgb(col_from.r);
|
|
|
|
col_to.g = linearrgb_to_srgb(col_from.g);
|
|
|
|
col_to.b = linearrgb_to_srgb(col_from.b);
|
|
|
|
col_to.a = col_from.a;
|
|
|
|
}
|
|
|
|
|
2016-04-26 18:43:02 +10:00
|
|
|
void color_to_normal(vec3 color, out vec3 normal)
|
|
|
|
{
|
|
|
|
normal.x = 2.0 * ((color.r) - 0.5);
|
|
|
|
normal.y = -2.0 * ((color.g) - 0.5);
|
|
|
|
normal.z = 2.0 * ((color.b) - 0.5);
|
|
|
|
}
|
|
|
|
|
2016-05-23 16:12:52 +03:00
|
|
|
void color_to_normal_new_shading(vec3 color, out vec3 normal)
|
|
|
|
{
|
|
|
|
normal.x = 2.0 * ((color.r) - 0.5);
|
|
|
|
normal.y = 2.0 * ((color.g) - 0.5);
|
|
|
|
normal.z = 2.0 * ((color.b) - 0.5);
|
|
|
|
}
|
|
|
|
|
|
|
|
void color_to_blender_normal_new_shading(vec3 color, out vec3 normal)
|
|
|
|
{
|
|
|
|
normal.x = 2.0 * ((color.r) - 0.5);
|
|
|
|
normal.y = -2.0 * ((color.g) - 0.5);
|
|
|
|
normal.z = -2.0 * ((color.b) - 0.5);
|
|
|
|
}
|
2017-05-05 12:10:59 +02:00
|
|
|
#ifndef M_PI
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
#define M_PI 3.14159265358979323846
|
2017-05-05 12:10:59 +02:00
|
|
|
#endif
|
|
|
|
#ifndef M_1_PI
|
2017-04-27 22:27:09 +02:00
|
|
|
#define M_1_PI 0.318309886183790671538
|
2017-05-05 12:10:59 +02:00
|
|
|
#endif
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
/*********** SHADER NODES ***************/
|
|
|
|
|
|
|
|
void vcol_attribute(vec4 attvcol, out vec4 vcol)
|
|
|
|
{
|
2017-05-19 14:20:08 -04:00
|
|
|
vcol = vec4(attvcol.xyz, 1.0);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void uv_attribute(vec2 attuv, out vec3 uv)
|
|
|
|
{
|
2016-05-26 18:46:12 +10:00
|
|
|
uv = vec3(attuv * 2.0 - vec2(1.0, 1.0), 0.0);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
2016-05-23 19:56:50 +10:00
|
|
|
void geom(
|
|
|
|
vec3 co, vec3 nor, mat4 viewinvmat, vec3 attorco, vec2 attuv, vec4 attvcol,
|
|
|
|
out vec3 global, out vec3 local, out vec3 view, out vec3 orco, out vec3 uv,
|
|
|
|
out vec3 normal, out vec4 vcol, out float vcol_alpha, out float frontback)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
|
|
|
local = co;
|
2017-03-26 21:19:23 -04:00
|
|
|
view = (ProjectionMatrix[3][3] == 0.0) ? normalize(local) : vec3(0.0, 0.0, -1.0);
|
2016-05-26 18:46:12 +10:00
|
|
|
global = (viewinvmat * vec4(local, 1.0)).xyz;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
orco = attorco;
|
|
|
|
uv_attribute(attuv, uv);
|
2016-05-26 18:46:12 +10:00
|
|
|
normal = -normalize(nor); /* blender render normal is negated */
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
vcol_attribute(attvcol, vcol);
|
2015-08-25 01:02:28 +10:00
|
|
|
srgb_to_linearrgb(vcol, vcol);
|
2011-11-14 12:47:47 +00:00
|
|
|
vcol_alpha = attvcol.a;
|
2016-05-26 18:46:12 +10:00
|
|
|
frontback = (gl_FrontFacing) ? 1.0 : 0.0;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
2016-05-23 19:56:50 +10:00
|
|
|
void particle_info(
|
|
|
|
vec4 sprops, vec3 loc, vec3 vel, vec3 avel,
|
|
|
|
out float index, out float age, out float life_time, out vec3 location,
|
|
|
|
out float size, out vec3 velocity, out vec3 angular_velocity)
|
2015-07-14 18:48:54 +02:00
|
|
|
{
|
2016-05-23 19:56:50 +10:00
|
|
|
index = sprops.x;
|
|
|
|
age = sprops.y;
|
|
|
|
life_time = sprops.z;
|
|
|
|
size = sprops.w;
|
2015-07-14 18:48:54 +02:00
|
|
|
|
2016-05-23 19:56:50 +10:00
|
|
|
location = loc;
|
|
|
|
velocity = vel;
|
|
|
|
angular_velocity = avel;
|
2015-07-14 18:48:54 +02:00
|
|
|
}
|
|
|
|
|
Vector Transform node support for GLSL mode and the internal renderer
The Vector Transform node is a useful node which is present in the Cycles renderer.
{F144283}
This patch implements the Vector Transform node for GLSL mode and the internal renderer.
Example: {F273060}
Alexander (Blend4Web Team)
Reviewers: brecht, campbellbarton, sergey
Reviewed By: campbellbarton, sergey
Subscribers: psy-fi, duarteframos, RobM, lightbwk, sergey, AlexKowel, valentin_b4w, Evgeny_Rodygin, yurikovelenov
Projects: #bf_blender:_next
Differential Revision: https://developer.blender.org/D909
2016-01-23 15:27:36 +03:00
|
|
|
void vect_normalize(vec3 vin, out vec3 vout)
|
|
|
|
{
|
|
|
|
vout = normalize(vin);
|
|
|
|
}
|
|
|
|
|
|
|
|
void direction_transform_m4v3(vec3 vin, mat4 mat, out vec3 vout)
|
|
|
|
{
|
2016-05-26 18:46:12 +10:00
|
|
|
vout = (mat * vec4(vin, 0.0)).xyz;
|
Vector Transform node support for GLSL mode and the internal renderer
The Vector Transform node is a useful node which is present in the Cycles renderer.
{F144283}
This patch implements the Vector Transform node for GLSL mode and the internal renderer.
Example: {F273060}
Alexander (Blend4Web Team)
Reviewers: brecht, campbellbarton, sergey
Reviewed By: campbellbarton, sergey
Subscribers: psy-fi, duarteframos, RobM, lightbwk, sergey, AlexKowel, valentin_b4w, Evgeny_Rodygin, yurikovelenov
Projects: #bf_blender:_next
Differential Revision: https://developer.blender.org/D909
2016-01-23 15:27:36 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void point_transform_m4v3(vec3 vin, mat4 mat, out vec3 vout)
|
|
|
|
{
|
2016-05-26 18:46:12 +10:00
|
|
|
vout = (mat * vec4(vin, 1.0)).xyz;
|
Vector Transform node support for GLSL mode and the internal renderer
The Vector Transform node is a useful node which is present in the Cycles renderer.
{F144283}
This patch implements the Vector Transform node for GLSL mode and the internal renderer.
Example: {F273060}
Alexander (Blend4Web Team)
Reviewers: brecht, campbellbarton, sergey
Reviewed By: campbellbarton, sergey
Subscribers: psy-fi, duarteframos, RobM, lightbwk, sergey, AlexKowel, valentin_b4w, Evgeny_Rodygin, yurikovelenov
Projects: #bf_blender:_next
Differential Revision: https://developer.blender.org/D909
2016-01-23 15:27:36 +03:00
|
|
|
}
|
|
|
|
|
2016-05-30 10:23:43 +02:00
|
|
|
void point_texco_remap_square(vec3 vin, out vec3 vout)
|
|
|
|
{
|
|
|
|
vout = vec3(vin - vec3(0.5, 0.5, 0.5)) * 2.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void point_map_to_sphere(vec3 vin, out vec3 vout)
|
|
|
|
{
|
|
|
|
float len = length(vin);
|
|
|
|
float v, u;
|
|
|
|
if (len > 0.0) {
|
|
|
|
if (vin.x == 0.0 && vin.y == 0.0)
|
|
|
|
u = 0.0;
|
|
|
|
else
|
|
|
|
u = (1.0 - atan(vin.x, vin.y) / M_PI) / 2.0;
|
|
|
|
|
|
|
|
v = 1.0 - acos(vin.z / len) / M_PI;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
v = u = 0.0;
|
|
|
|
|
|
|
|
vout = vec3(u, v, 0.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void point_map_to_tube(vec3 vin, out vec3 vout)
|
|
|
|
{
|
|
|
|
float u, v;
|
|
|
|
v = (vin.z + 1.0) * 0.5;
|
|
|
|
float len = sqrt(vin.x * vin.x + vin.y * vin[1]);
|
|
|
|
if (len > 0.0)
|
|
|
|
u = (1.0 - (atan(vin.x / len, vin.y / len) / M_PI)) * 0.5;
|
|
|
|
else
|
|
|
|
v = u = 0.0;
|
|
|
|
|
|
|
|
vout = vec3(u, v, 0.0);
|
|
|
|
}
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
void mapping(vec3 vec, mat4 mat, vec3 minvec, vec3 maxvec, float domin, float domax, out vec3 outvec)
|
|
|
|
{
|
|
|
|
outvec = (mat * vec4(vec, 1.0)).xyz;
|
2016-05-23 10:31:36 +02:00
|
|
|
if (domin == 1.0)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
outvec = max(outvec, minvec);
|
2016-05-23 10:31:36 +02:00
|
|
|
if (domax == 1.0)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
outvec = min(outvec, maxvec);
|
|
|
|
}
|
|
|
|
|
|
|
|
void camera(vec3 co, out vec3 outview, out float outdepth, out float outdist)
|
|
|
|
{
|
|
|
|
outdepth = abs(co.z);
|
|
|
|
outdist = length(co);
|
2013-11-25 02:19:14 +09:00
|
|
|
outview = normalize(co);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
2016-05-23 19:56:50 +10:00
|
|
|
void lamp(
|
|
|
|
vec4 col, float energy, vec3 lv, float dist, vec3 shadow, float visifac,
|
|
|
|
out vec4 outcol, out vec3 outlv, out float outdist, out vec4 outshadow, out float outvisifac)
|
2013-11-25 20:58:23 +09:00
|
|
|
{
|
2015-01-27 16:34:27 +01:00
|
|
|
outcol = col * energy;
|
2013-11-25 20:58:23 +09:00
|
|
|
outlv = lv;
|
|
|
|
outdist = dist;
|
|
|
|
outshadow = vec4(shadow, 1.0);
|
|
|
|
outvisifac = visifac;
|
|
|
|
}
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
void math_add(float val1, float val2, out float outval)
|
|
|
|
{
|
|
|
|
outval = val1 + val2;
|
|
|
|
}
|
|
|
|
|
|
|
|
void math_subtract(float val1, float val2, out float outval)
|
|
|
|
{
|
|
|
|
outval = val1 - val2;
|
|
|
|
}
|
|
|
|
|
|
|
|
void math_multiply(float val1, float val2, out float outval)
|
|
|
|
{
|
|
|
|
outval = val1 * val2;
|
|
|
|
}
|
|
|
|
|
|
|
|
void math_divide(float val1, float val2, out float outval)
|
|
|
|
{
|
|
|
|
if (val2 == 0.0)
|
|
|
|
outval = 0.0;
|
|
|
|
else
|
|
|
|
outval = val1 / val2;
|
|
|
|
}
|
|
|
|
|
|
|
|
void math_sine(float val, out float outval)
|
|
|
|
{
|
|
|
|
outval = sin(val);
|
|
|
|
}
|
|
|
|
|
|
|
|
void math_cosine(float val, out float outval)
|
|
|
|
{
|
|
|
|
outval = cos(val);
|
|
|
|
}
|
|
|
|
|
|
|
|
void math_tangent(float val, out float outval)
|
|
|
|
{
|
|
|
|
outval = tan(val);
|
|
|
|
}
|
|
|
|
|
|
|
|
void math_asin(float val, out float outval)
|
|
|
|
{
|
|
|
|
if (val <= 1.0 && val >= -1.0)
|
|
|
|
outval = asin(val);
|
|
|
|
else
|
|
|
|
outval = 0.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void math_acos(float val, out float outval)
|
|
|
|
{
|
|
|
|
if (val <= 1.0 && val >= -1.0)
|
|
|
|
outval = acos(val);
|
|
|
|
else
|
|
|
|
outval = 0.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void math_atan(float val, out float outval)
|
|
|
|
{
|
|
|
|
outval = atan(val);
|
|
|
|
}
|
|
|
|
|
|
|
|
void math_pow(float val1, float val2, out float outval)
|
|
|
|
{
|
2012-11-06 19:58:48 +00:00
|
|
|
if (val1 >= 0.0) {
|
|
|
|
outval = compatible_pow(val1, val2);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
float val2_mod_1 = mod(abs(val2), 1.0);
|
|
|
|
|
2013-03-16 14:42:05 +00:00
|
|
|
if (val2_mod_1 > 0.999 || val2_mod_1 < 0.001)
|
2012-11-06 19:58:48 +00:00
|
|
|
outval = compatible_pow(val1, floor(val2 + 0.5));
|
|
|
|
else
|
|
|
|
outval = 0.0;
|
|
|
|
}
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void math_log(float val1, float val2, out float outval)
|
|
|
|
{
|
2016-05-23 10:31:36 +02:00
|
|
|
if (val1 > 0.0 && val2 > 0.0)
|
2016-05-26 18:46:12 +10:00
|
|
|
outval = log2(val1) / log2(val2);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
else
|
2016-05-26 18:46:12 +10:00
|
|
|
outval = 0.0;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void math_max(float val1, float val2, out float outval)
|
|
|
|
{
|
|
|
|
outval = max(val1, val2);
|
|
|
|
}
|
|
|
|
|
|
|
|
void math_min(float val1, float val2, out float outval)
|
|
|
|
{
|
|
|
|
outval = min(val1, val2);
|
|
|
|
}
|
|
|
|
|
|
|
|
void math_round(float val, out float outval)
|
|
|
|
{
|
2016-05-26 18:46:12 +10:00
|
|
|
outval = floor(val + 0.5);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void math_less_than(float val1, float val2, out float outval)
|
|
|
|
{
|
2016-05-23 10:31:36 +02:00
|
|
|
if (val1 < val2)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
outval = 1.0;
|
|
|
|
else
|
|
|
|
outval = 0.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void math_greater_than(float val1, float val2, out float outval)
|
|
|
|
{
|
2016-05-23 10:31:36 +02:00
|
|
|
if (val1 > val2)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
outval = 1.0;
|
|
|
|
else
|
|
|
|
outval = 0.0;
|
|
|
|
}
|
|
|
|
|
2013-05-20 14:38:47 +00:00
|
|
|
void math_modulo(float val1, float val2, out float outval)
|
|
|
|
{
|
|
|
|
if (val2 == 0.0)
|
|
|
|
outval = 0.0;
|
|
|
|
else
|
|
|
|
outval = mod(val1, val2);
|
2015-02-03 15:08:28 +01:00
|
|
|
|
|
|
|
/* change sign to match C convention, mod in GLSL will take absolute for negative numbers,
|
|
|
|
* see https://www.opengl.org/sdk/docs/man/html/mod.xhtml */
|
2017-05-09 12:31:19 +02:00
|
|
|
outval = (val1 > 0.0) ? outval : outval - val2;
|
2013-05-20 14:38:47 +00:00
|
|
|
}
|
|
|
|
|
2014-05-07 16:20:17 +02:00
|
|
|
void math_abs(float val1, out float outval)
|
|
|
|
{
|
2016-05-23 19:56:50 +10:00
|
|
|
outval = abs(val1);
|
2014-05-07 16:20:17 +02:00
|
|
|
}
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
void squeeze(float val, float width, float center, out float outval)
|
|
|
|
{
|
2016-05-26 18:46:12 +10:00
|
|
|
outval = 1.0 / (1.0 + pow(2.71828183, -((val - center) * width)));
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void vec_math_add(vec3 v1, vec3 v2, out vec3 outvec, out float outval)
|
|
|
|
{
|
|
|
|
outvec = v1 + v2;
|
2017-05-19 14:20:08 -04:00
|
|
|
outval = (abs(outvec[0]) + abs(outvec[1]) + abs(outvec[2])) * 0.333333;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void vec_math_sub(vec3 v1, vec3 v2, out vec3 outvec, out float outval)
|
|
|
|
{
|
|
|
|
outvec = v1 - v2;
|
2017-05-19 14:20:08 -04:00
|
|
|
outval = (abs(outvec[0]) + abs(outvec[1]) + abs(outvec[2])) * 0.333333;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void vec_math_average(vec3 v1, vec3 v2, out vec3 outvec, out float outval)
|
|
|
|
{
|
|
|
|
outvec = v1 + v2;
|
|
|
|
outval = length(outvec);
|
|
|
|
outvec = normalize(outvec);
|
|
|
|
}
|
2016-04-26 18:43:02 +10:00
|
|
|
void vec_math_mix(float strength, vec3 v1, vec3 v2, out vec3 outvec)
|
|
|
|
{
|
2016-05-26 18:46:12 +10:00
|
|
|
outvec = strength * v1 + (1 - strength) * v2;
|
2016-04-26 18:43:02 +10:00
|
|
|
}
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
void vec_math_dot(vec3 v1, vec3 v2, out vec3 outvec, out float outval)
|
|
|
|
{
|
2017-05-19 14:20:08 -04:00
|
|
|
outvec = vec3(0);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
outval = dot(v1, v2);
|
|
|
|
}
|
|
|
|
|
|
|
|
void vec_math_cross(vec3 v1, vec3 v2, out vec3 outvec, out float outval)
|
|
|
|
{
|
|
|
|
outvec = cross(v1, v2);
|
|
|
|
outval = length(outvec);
|
2015-01-17 14:57:10 +01:00
|
|
|
outvec /= outval;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void vec_math_normalize(vec3 v, out vec3 outvec, out float outval)
|
|
|
|
{
|
|
|
|
outval = length(v);
|
|
|
|
outvec = normalize(v);
|
|
|
|
}
|
|
|
|
|
|
|
|
void vec_math_negate(vec3 v, out vec3 outv)
|
|
|
|
{
|
|
|
|
outv = -v;
|
|
|
|
}
|
|
|
|
|
2016-02-01 18:46:32 +03:00
|
|
|
void invert_z(vec3 v, out vec3 outv)
|
|
|
|
{
|
2016-05-23 19:56:50 +10:00
|
|
|
v.z = -v.z;
|
|
|
|
outv = v;
|
2016-02-01 18:46:32 +03:00
|
|
|
}
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
void normal(vec3 dir, vec3 nor, out vec3 outnor, out float outdot)
|
|
|
|
{
|
2011-12-28 19:42:22 +00:00
|
|
|
outnor = nor;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
outdot = -dot(dir, nor);
|
|
|
|
}
|
|
|
|
|
2014-12-10 19:12:54 +05:00
|
|
|
void normal_new_shading(vec3 dir, vec3 nor, out vec3 outnor, out float outdot)
|
|
|
|
{
|
|
|
|
outnor = normalize(nor);
|
|
|
|
outdot = dot(normalize(dir), nor);
|
|
|
|
}
|
|
|
|
|
2011-09-09 11:55:38 +00:00
|
|
|
void curves_vec(float fac, vec3 vec, sampler2D curvemap, out vec3 outvec)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
2017-05-19 10:23:07 -04:00
|
|
|
outvec.x = texture(curvemap, vec2((vec.x + 1.0) * 0.5, 0.0)).x;
|
|
|
|
outvec.y = texture(curvemap, vec2((vec.y + 1.0) * 0.5, 0.0)).y;
|
|
|
|
outvec.z = texture(curvemap, vec2((vec.z + 1.0) * 0.5, 0.0)).z;
|
2009-11-09 16:00:12 +00:00
|
|
|
|
|
|
|
if (fac != 1.0)
|
2016-05-26 18:46:12 +10:00
|
|
|
outvec = (outvec * fac) + (vec * (1.0 - fac));
|
2009-11-09 16:00:12 +00:00
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
2011-09-09 11:55:38 +00:00
|
|
|
void curves_rgb(float fac, vec4 col, sampler2D curvemap, out vec4 outcol)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
2017-05-19 10:23:07 -04:00
|
|
|
outcol.r = texture(curvemap, vec2(texture(curvemap, vec2(col.r, 0.0)).a, 0.0)).r;
|
|
|
|
outcol.g = texture(curvemap, vec2(texture(curvemap, vec2(col.g, 0.0)).a, 0.0)).g;
|
|
|
|
outcol.b = texture(curvemap, vec2(texture(curvemap, vec2(col.b, 0.0)).a, 0.0)).b;
|
2009-11-09 16:00:12 +00:00
|
|
|
|
|
|
|
if (fac != 1.0)
|
2016-05-26 18:46:12 +10:00
|
|
|
outcol = (outcol * fac) + (col * (1.0 - fac));
|
2009-11-09 16:00:12 +00:00
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
outcol.a = col.a;
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_value(float val, out float outval)
|
|
|
|
{
|
|
|
|
outval = val;
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_rgb(vec3 col, out vec3 outcol)
|
|
|
|
{
|
|
|
|
outcol = col;
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_rgba(vec4 col, out vec4 outcol)
|
|
|
|
{
|
|
|
|
outcol = col;
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_value_zero(out float outval)
|
|
|
|
{
|
|
|
|
outval = 0.0;
|
|
|
|
}
|
|
|
|
|
2008-09-05 20:34:35 +00:00
|
|
|
void set_value_one(out float outval)
|
|
|
|
{
|
|
|
|
outval = 1.0;
|
|
|
|
}
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
void set_rgb_zero(out vec3 outval)
|
|
|
|
{
|
|
|
|
outval = vec3(0.0);
|
|
|
|
}
|
|
|
|
|
2013-11-12 10:59:40 +00:00
|
|
|
void set_rgb_one(out vec3 outval)
|
|
|
|
{
|
|
|
|
outval = vec3(1.0);
|
|
|
|
}
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
void set_rgba_zero(out vec4 outval)
|
|
|
|
{
|
|
|
|
outval = vec4(0.0);
|
|
|
|
}
|
|
|
|
|
2013-11-12 10:59:40 +00:00
|
|
|
void set_rgba_one(out vec4 outval)
|
|
|
|
{
|
|
|
|
outval = vec4(1.0);
|
|
|
|
}
|
|
|
|
|
2013-02-15 11:46:31 +00:00
|
|
|
void brightness_contrast(vec4 col, float brightness, float contrast, out vec4 outcol)
|
|
|
|
{
|
|
|
|
float a = 1.0 + contrast;
|
2016-05-26 18:46:12 +10:00
|
|
|
float b = brightness - contrast * 0.5;
|
2013-02-15 11:46:31 +00:00
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
outcol.r = max(a * col.r + b, 0.0);
|
|
|
|
outcol.g = max(a * col.g + b, 0.0);
|
|
|
|
outcol.b = max(a * col.b + b, 0.0);
|
2013-02-15 11:46:31 +00:00
|
|
|
outcol.a = col.a;
|
|
|
|
}
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
void mix_blend(float fac, vec4 col1, vec4 col2, out vec4 outcol)
|
|
|
|
{
|
|
|
|
fac = clamp(fac, 0.0, 1.0);
|
|
|
|
outcol = mix(col1, col2, fac);
|
|
|
|
outcol.a = col1.a;
|
|
|
|
}
|
|
|
|
|
|
|
|
void mix_add(float fac, vec4 col1, vec4 col2, out vec4 outcol)
|
|
|
|
{
|
|
|
|
fac = clamp(fac, 0.0, 1.0);
|
|
|
|
outcol = mix(col1, col1 + col2, fac);
|
|
|
|
outcol.a = col1.a;
|
|
|
|
}
|
|
|
|
|
|
|
|
void mix_mult(float fac, vec4 col1, vec4 col2, out vec4 outcol)
|
|
|
|
{
|
|
|
|
fac = clamp(fac, 0.0, 1.0);
|
|
|
|
outcol = mix(col1, col1 * col2, fac);
|
|
|
|
outcol.a = col1.a;
|
|
|
|
}
|
|
|
|
|
|
|
|
void mix_screen(float fac, vec4 col1, vec4 col2, out vec4 outcol)
|
|
|
|
{
|
|
|
|
fac = clamp(fac, 0.0, 1.0);
|
|
|
|
float facm = 1.0 - fac;
|
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
outcol = vec4(1.0) - (vec4(facm) + fac * (vec4(1.0) - col2)) * (vec4(1.0) - col1);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
outcol.a = col1.a;
|
|
|
|
}
|
|
|
|
|
|
|
|
void mix_overlay(float fac, vec4 col1, vec4 col2, out vec4 outcol)
|
|
|
|
{
|
|
|
|
fac = clamp(fac, 0.0, 1.0);
|
|
|
|
float facm = 1.0 - fac;
|
|
|
|
|
|
|
|
outcol = col1;
|
|
|
|
|
2016-05-23 10:31:36 +02:00
|
|
|
if (outcol.r < 0.5)
|
2016-05-26 18:46:12 +10:00
|
|
|
outcol.r *= facm + 2.0 * fac * col2.r;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
else
|
2016-05-26 18:46:12 +10:00
|
|
|
outcol.r = 1.0 - (facm + 2.0 * fac * (1.0 - col2.r)) * (1.0 - outcol.r);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2016-05-23 10:31:36 +02:00
|
|
|
if (outcol.g < 0.5)
|
2016-05-26 18:46:12 +10:00
|
|
|
outcol.g *= facm + 2.0 * fac * col2.g;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
else
|
2016-05-26 18:46:12 +10:00
|
|
|
outcol.g = 1.0 - (facm + 2.0 * fac * (1.0 - col2.g)) * (1.0 - outcol.g);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2016-05-23 10:31:36 +02:00
|
|
|
if (outcol.b < 0.5)
|
2016-05-26 18:46:12 +10:00
|
|
|
outcol.b *= facm + 2.0 * fac * col2.b;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
else
|
2016-05-26 18:46:12 +10:00
|
|
|
outcol.b = 1.0 - (facm + 2.0 * fac * (1.0 - col2.b)) * (1.0 - outcol.b);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void mix_sub(float fac, vec4 col1, vec4 col2, out vec4 outcol)
|
|
|
|
{
|
|
|
|
fac = clamp(fac, 0.0, 1.0);
|
|
|
|
outcol = mix(col1, col1 - col2, fac);
|
|
|
|
outcol.a = col1.a;
|
|
|
|
}
|
|
|
|
|
|
|
|
void mix_div(float fac, vec4 col1, vec4 col2, out vec4 outcol)
|
|
|
|
{
|
|
|
|
fac = clamp(fac, 0.0, 1.0);
|
|
|
|
float facm = 1.0 - fac;
|
|
|
|
|
|
|
|
outcol = col1;
|
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
if (col2.r != 0.0) outcol.r = facm * outcol.r + fac * outcol.r / col2.r;
|
|
|
|
if (col2.g != 0.0) outcol.g = facm * outcol.g + fac * outcol.g / col2.g;
|
|
|
|
if (col2.b != 0.0) outcol.b = facm * outcol.b + fac * outcol.b / col2.b;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void mix_diff(float fac, vec4 col1, vec4 col2, out vec4 outcol)
|
|
|
|
{
|
|
|
|
fac = clamp(fac, 0.0, 1.0);
|
|
|
|
outcol = mix(col1, abs(col1 - col2), fac);
|
|
|
|
outcol.a = col1.a;
|
|
|
|
}
|
|
|
|
|
|
|
|
void mix_dark(float fac, vec4 col1, vec4 col2, out vec4 outcol)
|
|
|
|
{
|
|
|
|
fac = clamp(fac, 0.0, 1.0);
|
2016-05-26 18:46:12 +10:00
|
|
|
outcol.rgb = min(col1.rgb, col2.rgb * fac);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
outcol.a = col1.a;
|
|
|
|
}
|
|
|
|
|
|
|
|
void mix_light(float fac, vec4 col1, vec4 col2, out vec4 outcol)
|
|
|
|
{
|
|
|
|
fac = clamp(fac, 0.0, 1.0);
|
2016-05-26 18:46:12 +10:00
|
|
|
outcol.rgb = max(col1.rgb, col2.rgb * fac);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
outcol.a = col1.a;
|
|
|
|
}
|
|
|
|
|
|
|
|
void mix_dodge(float fac, vec4 col1, vec4 col2, out vec4 outcol)
|
|
|
|
{
|
|
|
|
fac = clamp(fac, 0.0, 1.0);
|
|
|
|
outcol = col1;
|
|
|
|
|
2016-05-23 10:31:36 +02:00
|
|
|
if (outcol.r != 0.0) {
|
2016-05-26 18:46:12 +10:00
|
|
|
float tmp = 1.0 - fac * col2.r;
|
2016-05-23 10:31:36 +02:00
|
|
|
if (tmp <= 0.0)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
outcol.r = 1.0;
|
2016-05-26 18:46:12 +10:00
|
|
|
else if ((tmp = outcol.r / tmp) > 1.0)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
outcol.r = 1.0;
|
|
|
|
else
|
|
|
|
outcol.r = tmp;
|
|
|
|
}
|
2016-05-23 10:31:36 +02:00
|
|
|
if (outcol.g != 0.0) {
|
2016-05-26 18:46:12 +10:00
|
|
|
float tmp = 1.0 - fac * col2.g;
|
2016-05-23 10:31:36 +02:00
|
|
|
if (tmp <= 0.0)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
outcol.g = 1.0;
|
2016-05-26 18:46:12 +10:00
|
|
|
else if ((tmp = outcol.g / tmp) > 1.0)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
outcol.g = 1.0;
|
|
|
|
else
|
|
|
|
outcol.g = tmp;
|
|
|
|
}
|
2016-05-23 10:31:36 +02:00
|
|
|
if (outcol.b != 0.0) {
|
2016-05-26 18:46:12 +10:00
|
|
|
float tmp = 1.0 - fac * col2.b;
|
2016-05-23 10:31:36 +02:00
|
|
|
if (tmp <= 0.0)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
outcol.b = 1.0;
|
2016-05-26 18:46:12 +10:00
|
|
|
else if ((tmp = outcol.b / tmp) > 1.0)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
outcol.b = 1.0;
|
|
|
|
else
|
|
|
|
outcol.b = tmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void mix_burn(float fac, vec4 col1, vec4 col2, out vec4 outcol)
|
|
|
|
{
|
|
|
|
fac = clamp(fac, 0.0, 1.0);
|
|
|
|
float tmp, facm = 1.0 - fac;
|
|
|
|
|
|
|
|
outcol = col1;
|
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
tmp = facm + fac * col2.r;
|
2016-05-23 10:31:36 +02:00
|
|
|
if (tmp <= 0.0)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
outcol.r = 0.0;
|
2016-05-26 18:46:12 +10:00
|
|
|
else if ((tmp = (1.0 - (1.0 - outcol.r) / tmp)) < 0.0)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
outcol.r = 0.0;
|
2016-05-23 10:31:36 +02:00
|
|
|
else if (tmp > 1.0)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
outcol.r = 1.0;
|
|
|
|
else
|
|
|
|
outcol.r = tmp;
|
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
tmp = facm + fac * col2.g;
|
2016-05-23 10:31:36 +02:00
|
|
|
if (tmp <= 0.0)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
outcol.g = 0.0;
|
2016-05-26 18:46:12 +10:00
|
|
|
else if ((tmp = (1.0 - (1.0 - outcol.g) / tmp)) < 0.0)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
outcol.g = 0.0;
|
2016-05-23 10:31:36 +02:00
|
|
|
else if (tmp > 1.0)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
outcol.g = 1.0;
|
|
|
|
else
|
|
|
|
outcol.g = tmp;
|
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
tmp = facm + fac * col2.b;
|
2016-05-23 10:31:36 +02:00
|
|
|
if (tmp <= 0.0)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
outcol.b = 0.0;
|
2016-05-26 18:46:12 +10:00
|
|
|
else if ((tmp = (1.0 - (1.0 - outcol.b) / tmp)) < 0.0)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
outcol.b = 0.0;
|
2016-05-23 10:31:36 +02:00
|
|
|
else if (tmp > 1.0)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
outcol.b = 1.0;
|
|
|
|
else
|
|
|
|
outcol.b = tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
void mix_hue(float fac, vec4 col1, vec4 col2, out vec4 outcol)
|
|
|
|
{
|
|
|
|
fac = clamp(fac, 0.0, 1.0);
|
|
|
|
float facm = 1.0 - fac;
|
|
|
|
|
|
|
|
outcol = col1;
|
|
|
|
|
|
|
|
vec4 hsv, hsv2, tmp;
|
|
|
|
rgb_to_hsv(col2, hsv2);
|
|
|
|
|
2016-05-23 10:31:36 +02:00
|
|
|
if (hsv2.y != 0.0) {
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
rgb_to_hsv(outcol, hsv);
|
|
|
|
hsv.x = hsv2.x;
|
2016-05-26 18:46:12 +10:00
|
|
|
hsv_to_rgb(hsv, tmp);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
outcol = mix(outcol, tmp, fac);
|
|
|
|
outcol.a = col1.a;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void mix_sat(float fac, vec4 col1, vec4 col2, out vec4 outcol)
|
|
|
|
{
|
|
|
|
fac = clamp(fac, 0.0, 1.0);
|
|
|
|
float facm = 1.0 - fac;
|
|
|
|
|
|
|
|
outcol = col1;
|
|
|
|
|
|
|
|
vec4 hsv, hsv2;
|
|
|
|
rgb_to_hsv(outcol, hsv);
|
|
|
|
|
2016-05-23 10:31:36 +02:00
|
|
|
if (hsv.y != 0.0) {
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
rgb_to_hsv(col2, hsv2);
|
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
hsv.y = facm * hsv.y + fac * hsv2.y;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
hsv_to_rgb(hsv, outcol);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void mix_val(float fac, vec4 col1, vec4 col2, out vec4 outcol)
|
|
|
|
{
|
|
|
|
fac = clamp(fac, 0.0, 1.0);
|
|
|
|
float facm = 1.0 - fac;
|
|
|
|
|
|
|
|
vec4 hsv, hsv2;
|
|
|
|
rgb_to_hsv(col1, hsv);
|
|
|
|
rgb_to_hsv(col2, hsv2);
|
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
hsv.z = facm * hsv.z + fac * hsv2.z;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
hsv_to_rgb(hsv, outcol);
|
|
|
|
}
|
|
|
|
|
|
|
|
void mix_color(float fac, vec4 col1, vec4 col2, out vec4 outcol)
|
|
|
|
{
|
|
|
|
fac = clamp(fac, 0.0, 1.0);
|
|
|
|
float facm = 1.0 - fac;
|
|
|
|
|
|
|
|
outcol = col1;
|
|
|
|
|
|
|
|
vec4 hsv, hsv2, tmp;
|
|
|
|
rgb_to_hsv(col2, hsv2);
|
|
|
|
|
2016-05-23 10:31:36 +02:00
|
|
|
if (hsv2.y != 0.0) {
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
rgb_to_hsv(outcol, hsv);
|
|
|
|
hsv.x = hsv2.x;
|
|
|
|
hsv.y = hsv2.y;
|
2016-05-26 18:46:12 +10:00
|
|
|
hsv_to_rgb(hsv, tmp);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
outcol = mix(outcol, tmp, fac);
|
|
|
|
outcol.a = col1.a;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-19 11:50:01 +00:00
|
|
|
void mix_soft(float fac, vec4 col1, vec4 col2, out vec4 outcol)
|
|
|
|
{
|
|
|
|
fac = clamp(fac, 0.0, 1.0);
|
|
|
|
float facm = 1.0 - fac;
|
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
vec4 one = vec4(1.0);
|
|
|
|
vec4 scr = one - (one - col2) * (one - col1);
|
|
|
|
outcol = facm * col1 + fac * ((one - col1) * col2 * col1 + col1 * scr);
|
2009-10-19 11:50:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void mix_linear(float fac, vec4 col1, vec4 col2, out vec4 outcol)
|
|
|
|
{
|
|
|
|
fac = clamp(fac, 0.0, 1.0);
|
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
outcol = col1 + fac * (2.0 * (col2 - vec4(0.5)));
|
2009-10-19 11:50:01 +00:00
|
|
|
}
|
|
|
|
|
2011-09-09 11:55:38 +00:00
|
|
|
void valtorgb(float fac, sampler2D colormap, out vec4 outcol, out float outalpha)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
2017-05-19 10:23:07 -04:00
|
|
|
outcol = texture(colormap, vec2(fac, 0.0));
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
outalpha = outcol.a;
|
|
|
|
}
|
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
void rgbtobw(vec4 color, out float outval)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
2016-02-02 12:48:18 +01:00
|
|
|
#ifdef USE_NEW_SHADING
|
2017-05-19 14:20:08 -04:00
|
|
|
vec3 factors = vec3(0.2126, 0.7152, 0.0722);
|
2016-02-02 12:48:18 +01:00
|
|
|
#else
|
2017-05-19 14:20:08 -04:00
|
|
|
vec3 factors = vec3(0.35, 0.45, 0.2); /* keep these factors in sync with texture.h:RGBTOBW */
|
2016-02-02 12:48:18 +01:00
|
|
|
#endif
|
2017-05-19 14:20:08 -04:00
|
|
|
outval = dot(color.rgb, factors);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void invert(float fac, vec4 col, out vec4 outcol)
|
|
|
|
{
|
2017-05-19 14:20:08 -04:00
|
|
|
outcol.xyz = mix(col.xyz, vec3(1.0) - col.xyz, fac);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
outcol.w = col.w;
|
|
|
|
}
|
|
|
|
|
2014-11-07 13:17:26 +05:00
|
|
|
void clamp_vec3(vec3 vec, vec3 min, vec3 max, out vec3 out_vec)
|
2014-11-04 16:50:29 +05:00
|
|
|
{
|
|
|
|
out_vec = clamp(vec, min, max);
|
|
|
|
}
|
|
|
|
|
|
|
|
void clamp_val(float value, float min, float max, out float out_value)
|
|
|
|
{
|
|
|
|
out_value = clamp(value, min, max);
|
|
|
|
}
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
void hue_sat(float hue, float sat, float value, float fac, vec4 col, out vec4 outcol)
|
|
|
|
{
|
|
|
|
vec4 hsv;
|
|
|
|
|
|
|
|
rgb_to_hsv(col, hsv);
|
|
|
|
|
|
|
|
hsv[0] += (hue - 0.5);
|
2016-05-26 18:46:12 +10:00
|
|
|
if (hsv[0] > 1.0) hsv[0] -= 1.0; else if (hsv[0] < 0.0) hsv[0] += 1.0;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
hsv[1] *= sat;
|
2016-05-26 18:46:12 +10:00
|
|
|
if (hsv[1] > 1.0) hsv[1] = 1.0; else if (hsv[1] < 0.0) hsv[1] = 0.0;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
hsv[2] *= value;
|
2016-05-26 18:46:12 +10:00
|
|
|
if (hsv[2] > 1.0) hsv[2] = 1.0; else if (hsv[2] < 0.0) hsv[2] = 0.0;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
hsv_to_rgb(hsv, outcol);
|
|
|
|
|
|
|
|
outcol = mix(col, outcol, fac);
|
|
|
|
}
|
|
|
|
|
|
|
|
void separate_rgb(vec4 col, out float r, out float g, out float b)
|
|
|
|
{
|
|
|
|
r = col.r;
|
|
|
|
g = col.g;
|
|
|
|
b = col.b;
|
|
|
|
}
|
|
|
|
|
|
|
|
void combine_rgb(float r, float g, float b, out vec4 col)
|
|
|
|
{
|
|
|
|
col = vec4(r, g, b, 1.0);
|
|
|
|
}
|
|
|
|
|
2014-06-13 23:23:35 +02:00
|
|
|
void separate_xyz(vec3 vec, out float x, out float y, out float z)
|
|
|
|
{
|
|
|
|
x = vec.r;
|
|
|
|
y = vec.g;
|
|
|
|
z = vec.b;
|
|
|
|
}
|
|
|
|
|
|
|
|
void combine_xyz(float x, float y, float z, out vec3 vec)
|
|
|
|
{
|
|
|
|
vec = vec3(x, y, z);
|
|
|
|
}
|
|
|
|
|
2013-11-21 04:02:00 +09:00
|
|
|
void separate_hsv(vec4 col, out float h, out float s, out float v)
|
|
|
|
{
|
|
|
|
vec4 hsv;
|
|
|
|
|
|
|
|
rgb_to_hsv(col, hsv);
|
|
|
|
h = hsv[0];
|
|
|
|
s = hsv[1];
|
|
|
|
v = hsv[2];
|
|
|
|
}
|
|
|
|
|
|
|
|
void combine_hsv(float h, float s, float v, out vec4 col)
|
|
|
|
{
|
|
|
|
hsv_to_rgb(vec4(h, s, v, 1.0), col);
|
|
|
|
}
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
void output_node(vec4 rgb, float alpha, out vec4 outrgb)
|
|
|
|
{
|
|
|
|
outrgb = vec4(rgb.rgb, alpha);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********** TEXTURES ***************/
|
|
|
|
|
|
|
|
void texture_flip_blend(vec3 vec, out vec3 outvec)
|
|
|
|
{
|
|
|
|
outvec = vec.yxz;
|
|
|
|
}
|
|
|
|
|
|
|
|
void texture_blend_lin(vec3 vec, out float outval)
|
|
|
|
{
|
2017-05-19 14:20:08 -04:00
|
|
|
outval = (1.0 + vec.x) * 0.5;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void texture_blend_quad(vec3 vec, out float outval)
|
|
|
|
{
|
2017-05-19 14:20:08 -04:00
|
|
|
outval = max((1.0 + vec.x) * 0.5, 0.0);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
outval *= outval;
|
|
|
|
}
|
|
|
|
|
|
|
|
void texture_wood_sin(vec3 vec, out float value, out vec4 color, out vec3 normal)
|
|
|
|
{
|
2016-05-26 18:46:12 +10:00
|
|
|
float a = sqrt(vec.x * vec.x + vec.y * vec.y + vec.z * vec.z) * 20.0;
|
|
|
|
float wi = 0.5 + 0.5 * sin(a);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
value = wi;
|
|
|
|
color = vec4(wi, wi, wi, 1.0);
|
2017-05-19 14:20:08 -04:00
|
|
|
normal = vec3(0.0);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void texture_image(vec3 vec, sampler2D ima, out float value, out vec4 color, out vec3 normal)
|
|
|
|
{
|
2017-05-19 14:20:08 -04:00
|
|
|
color = texture(ima, (vec.xy + vec2(1.0)) * 0.5);
|
2013-04-24 15:05:43 +00:00
|
|
|
value = color.a;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
normal.x = 2.0 * (color.r - 0.5);
|
|
|
|
normal.y = 2.0 * (0.5 - color.g);
|
|
|
|
normal.z = 2.0 * (color.b - 0.5);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/************* MTEX *****************/
|
|
|
|
|
|
|
|
void texco_orco(vec3 attorco, out vec3 orco)
|
|
|
|
{
|
|
|
|
orco = attorco;
|
|
|
|
}
|
|
|
|
|
|
|
|
void texco_uv(vec2 attuv, out vec3 uv)
|
|
|
|
{
|
|
|
|
/* disabled for now, works together with leaving out mtex_2d_mapping
|
2017-05-19 14:20:08 -04:00
|
|
|
uv = vec3(attuv * 2.0 - vec2(1.0), 0.0); */
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
uv = vec3(attuv, 0.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void texco_norm(vec3 normal, out vec3 outnormal)
|
|
|
|
{
|
|
|
|
/* corresponds to shi->orn, which is negated so cancels
|
|
|
|
out blender normal negation */
|
|
|
|
outnormal = normalize(normal);
|
|
|
|
}
|
|
|
|
|
2011-02-14 18:18:46 +00:00
|
|
|
void texco_tangent(vec4 tangent, out vec3 outtangent)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
2011-02-14 18:18:46 +00:00
|
|
|
outtangent = normalize(tangent.xyz);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void texco_global(mat4 viewinvmat, vec3 co, out vec3 global)
|
|
|
|
{
|
2016-05-26 18:46:12 +10:00
|
|
|
global = (viewinvmat * vec4(co, 1.0)).xyz;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void texco_object(mat4 viewinvmat, mat4 obinvmat, vec3 co, out vec3 object)
|
|
|
|
{
|
2016-05-26 18:46:12 +10:00
|
|
|
object = (obinvmat * (viewinvmat * vec4(co, 1.0))).xyz;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void texco_refl(vec3 vn, vec3 view, out vec3 ref)
|
|
|
|
{
|
2016-05-26 18:46:12 +10:00
|
|
|
ref = view - 2.0 * dot(vn, view) * vn;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void shade_norm(vec3 normal, out vec3 outnormal)
|
|
|
|
{
|
|
|
|
/* blender render normal is negated */
|
|
|
|
outnormal = -normalize(normal);
|
|
|
|
}
|
|
|
|
|
2016-03-21 14:36:33 +03:00
|
|
|
void mtex_mirror(vec3 tcol, vec4 refcol, float tin, float colmirfac, out vec4 outrefcol)
|
|
|
|
{
|
2016-05-23 19:56:50 +10:00
|
|
|
outrefcol = mix(refcol, vec4(1.0, tcol), tin * colmirfac);
|
2016-03-21 14:36:33 +03:00
|
|
|
}
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
void mtex_rgb_blend(vec3 outcol, vec3 texcol, float fact, float facg, out vec3 incol)
|
|
|
|
{
|
|
|
|
float facm;
|
|
|
|
|
|
|
|
fact *= facg;
|
2016-05-26 18:46:12 +10:00
|
|
|
facm = 1.0 - fact;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
incol = fact * texcol + facm * outcol;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void mtex_rgb_mul(vec3 outcol, vec3 texcol, float fact, float facg, out vec3 incol)
|
|
|
|
{
|
|
|
|
float facm;
|
|
|
|
|
|
|
|
fact *= facg;
|
2016-05-26 18:46:12 +10:00
|
|
|
facm = 1.0 - fact;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
incol = (facm + fact * texcol) * outcol;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void mtex_rgb_screen(vec3 outcol, vec3 texcol, float fact, float facg, out vec3 incol)
|
|
|
|
{
|
|
|
|
float facm;
|
|
|
|
|
|
|
|
fact *= facg;
|
2016-05-26 18:46:12 +10:00
|
|
|
facm = 1.0 - fact;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
incol = vec3(1.0) - (vec3(facm) + fact * (vec3(1.0) - texcol)) * (vec3(1.0) - outcol);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void mtex_rgb_overlay(vec3 outcol, vec3 texcol, float fact, float facg, out vec3 incol)
|
|
|
|
{
|
|
|
|
float facm;
|
|
|
|
|
|
|
|
fact *= facg;
|
2016-05-26 18:46:12 +10:00
|
|
|
facm = 1.0 - fact;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2016-05-23 10:31:36 +02:00
|
|
|
if (outcol.r < 0.5)
|
2016-05-26 18:46:12 +10:00
|
|
|
incol.r = outcol.r * (facm + 2.0 * fact * texcol.r);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
else
|
2016-05-26 18:46:12 +10:00
|
|
|
incol.r = 1.0 - (facm + 2.0 * fact * (1.0 - texcol.r)) * (1.0 - outcol.r);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2016-05-23 10:31:36 +02:00
|
|
|
if (outcol.g < 0.5)
|
2016-05-26 18:46:12 +10:00
|
|
|
incol.g = outcol.g * (facm + 2.0 * fact * texcol.g);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
else
|
2016-05-26 18:46:12 +10:00
|
|
|
incol.g = 1.0 - (facm + 2.0 * fact * (1.0 - texcol.g)) * (1.0 - outcol.g);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2016-05-23 10:31:36 +02:00
|
|
|
if (outcol.b < 0.5)
|
2016-05-26 18:46:12 +10:00
|
|
|
incol.b = outcol.b * (facm + 2.0 * fact * texcol.b);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
else
|
2016-05-26 18:46:12 +10:00
|
|
|
incol.b = 1.0 - (facm + 2.0 * fact * (1.0 - texcol.b)) * (1.0 - outcol.b);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void mtex_rgb_sub(vec3 outcol, vec3 texcol, float fact, float facg, out vec3 incol)
|
|
|
|
{
|
2016-05-26 18:46:12 +10:00
|
|
|
incol = -fact * facg * texcol + outcol;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void mtex_rgb_add(vec3 outcol, vec3 texcol, float fact, float facg, out vec3 incol)
|
|
|
|
{
|
2016-05-26 18:46:12 +10:00
|
|
|
incol = fact * facg * texcol + outcol;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void mtex_rgb_div(vec3 outcol, vec3 texcol, float fact, float facg, out vec3 incol)
|
|
|
|
{
|
|
|
|
float facm;
|
|
|
|
|
|
|
|
fact *= facg;
|
2016-05-26 18:46:12 +10:00
|
|
|
facm = 1.0 - fact;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
if (texcol.r != 0.0) incol.r = facm * outcol.r + fact * outcol.r / texcol.r;
|
|
|
|
if (texcol.g != 0.0) incol.g = facm * outcol.g + fact * outcol.g / texcol.g;
|
|
|
|
if (texcol.b != 0.0) incol.b = facm * outcol.b + fact * outcol.b / texcol.b;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void mtex_rgb_diff(vec3 outcol, vec3 texcol, float fact, float facg, out vec3 incol)
|
|
|
|
{
|
|
|
|
float facm;
|
|
|
|
|
|
|
|
fact *= facg;
|
2016-05-26 18:46:12 +10:00
|
|
|
facm = 1.0 - fact;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
incol = facm * outcol + fact * abs(texcol - outcol);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void mtex_rgb_dark(vec3 outcol, vec3 texcol, float fact, float facg, out vec3 incol)
|
|
|
|
{
|
|
|
|
float facm, col;
|
|
|
|
|
|
|
|
fact *= facg;
|
2016-05-26 18:46:12 +10:00
|
|
|
facm = 1.0 - fact;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2014-04-28 17:38:34 +02:00
|
|
|
incol.r = min(outcol.r, texcol.r) * fact + outcol.r * facm;
|
|
|
|
incol.g = min(outcol.g, texcol.g) * fact + outcol.g * facm;
|
|
|
|
incol.b = min(outcol.b, texcol.b) * fact + outcol.b * facm;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void mtex_rgb_light(vec3 outcol, vec3 texcol, float fact, float facg, out vec3 incol)
|
|
|
|
{
|
|
|
|
float facm, col;
|
|
|
|
|
|
|
|
fact *= facg;
|
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
col = fact * texcol.r;
|
2016-05-23 10:31:36 +02:00
|
|
|
if (col > outcol.r) incol.r = col; else incol.r = outcol.r;
|
2016-05-26 18:46:12 +10:00
|
|
|
col = fact * texcol.g;
|
2016-05-23 10:31:36 +02:00
|
|
|
if (col > outcol.g) incol.g = col; else incol.g = outcol.g;
|
2016-05-26 18:46:12 +10:00
|
|
|
col = fact * texcol.b;
|
2016-05-23 10:31:36 +02:00
|
|
|
if (col > outcol.b) incol.b = col; else incol.b = outcol.b;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void mtex_rgb_hue(vec3 outcol, vec3 texcol, float fact, float facg, out vec3 incol)
|
|
|
|
{
|
|
|
|
vec4 col;
|
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
mix_hue(fact * facg, vec4(outcol, 1.0), vec4(texcol, 1.0), col);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
incol.rgb = col.rgb;
|
|
|
|
}
|
|
|
|
|
|
|
|
void mtex_rgb_sat(vec3 outcol, vec3 texcol, float fact, float facg, out vec3 incol)
|
|
|
|
{
|
|
|
|
vec4 col;
|
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
mix_sat(fact * facg, vec4(outcol, 1.0), vec4(texcol, 1.0), col);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
incol.rgb = col.rgb;
|
|
|
|
}
|
|
|
|
|
|
|
|
void mtex_rgb_val(vec3 outcol, vec3 texcol, float fact, float facg, out vec3 incol)
|
|
|
|
{
|
|
|
|
vec4 col;
|
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
mix_val(fact * facg, vec4(outcol, 1.0), vec4(texcol, 1.0), col);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
incol.rgb = col.rgb;
|
|
|
|
}
|
|
|
|
|
|
|
|
void mtex_rgb_color(vec3 outcol, vec3 texcol, float fact, float facg, out vec3 incol)
|
|
|
|
{
|
|
|
|
vec4 col;
|
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
mix_color(fact * facg, vec4(outcol, 1.0), vec4(texcol, 1.0), col);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
incol.rgb = col.rgb;
|
|
|
|
}
|
|
|
|
|
2014-08-18 19:14:51 +02:00
|
|
|
void mtex_rgb_soft(vec3 outcol, vec3 texcol, float fact, float facg, out vec3 incol)
|
|
|
|
{
|
2016-07-24 01:04:54 +02:00
|
|
|
vec4 col;
|
2014-08-18 19:14:51 +02:00
|
|
|
|
2016-07-24 01:04:54 +02:00
|
|
|
mix_soft(fact * facg, vec4(outcol, 1.0), vec4(texcol, 1.0), col);
|
|
|
|
incol.rgb = col.rgb;
|
2014-08-18 19:14:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void mtex_rgb_linear(vec3 outcol, vec3 texcol, float fact, float facg, out vec3 incol)
|
|
|
|
{
|
|
|
|
fact *= facg;
|
|
|
|
|
2016-05-23 10:31:36 +02:00
|
|
|
if (texcol.r > 0.5)
|
2016-05-26 18:46:12 +10:00
|
|
|
incol.r = outcol.r + fact * (2.0 * (texcol.r - 0.5));
|
2014-08-18 19:14:51 +02:00
|
|
|
else
|
2016-05-26 18:46:12 +10:00
|
|
|
incol.r = outcol.r + fact * (2.0 * (texcol.r) - 1.0);
|
2014-08-18 19:14:51 +02:00
|
|
|
|
2016-05-23 10:31:36 +02:00
|
|
|
if (texcol.g > 0.5)
|
2016-05-26 18:46:12 +10:00
|
|
|
incol.g = outcol.g + fact * (2.0 * (texcol.g - 0.5));
|
2014-08-18 19:14:51 +02:00
|
|
|
else
|
2016-05-26 18:46:12 +10:00
|
|
|
incol.g = outcol.g + fact * (2.0 * (texcol.g) - 1.0);
|
2014-08-18 19:14:51 +02:00
|
|
|
|
2016-05-23 10:31:36 +02:00
|
|
|
if (texcol.b > 0.5)
|
2016-05-26 18:46:12 +10:00
|
|
|
incol.b = outcol.b + fact * (2.0 * (texcol.b - 0.5));
|
2014-08-18 19:14:51 +02:00
|
|
|
else
|
2016-05-26 18:46:12 +10:00
|
|
|
incol.b = outcol.b + fact * (2.0 * (texcol.b) - 1.0);
|
2014-08-18 19:14:51 +02:00
|
|
|
}
|
|
|
|
|
2009-10-01 17:15:23 +00:00
|
|
|
void mtex_value_vars(inout float fact, float facg, out float facm)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
2009-10-01 17:15:23 +00:00
|
|
|
fact *= abs(facg);
|
2016-05-26 18:46:12 +10:00
|
|
|
facm = 1.0 - fact;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2016-05-23 10:31:36 +02:00
|
|
|
if (facg < 0.0) {
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
float tmp = fact;
|
|
|
|
fact = facm;
|
|
|
|
facm = tmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-01 17:15:23 +00:00
|
|
|
void mtex_value_blend(float outcol, float texcol, float fact, float facg, out float incol)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
|
|
|
float facm;
|
2009-10-01 17:15:23 +00:00
|
|
|
mtex_value_vars(fact, facg, facm);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
incol = fact * texcol + facm * outcol;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
2009-10-01 17:15:23 +00:00
|
|
|
void mtex_value_mul(float outcol, float texcol, float fact, float facg, out float incol)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
|
|
|
float facm;
|
2009-10-01 17:15:23 +00:00
|
|
|
mtex_value_vars(fact, facg, facm);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
facm = 1.0 - facg;
|
2016-05-26 18:46:12 +10:00
|
|
|
incol = (facm + fact * texcol) * outcol;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
2009-10-01 17:15:23 +00:00
|
|
|
void mtex_value_screen(float outcol, float texcol, float fact, float facg, out float incol)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
|
|
|
float facm;
|
2009-10-01 17:15:23 +00:00
|
|
|
mtex_value_vars(fact, facg, facm);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
facm = 1.0 - facg;
|
2016-05-26 18:46:12 +10:00
|
|
|
incol = 1.0 - (facm + fact * (1.0 - texcol)) * (1.0 - outcol);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
2009-10-01 17:15:23 +00:00
|
|
|
void mtex_value_sub(float outcol, float texcol, float fact, float facg, out float incol)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
|
|
|
float facm;
|
2009-10-01 17:15:23 +00:00
|
|
|
mtex_value_vars(fact, facg, facm);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
fact = -fact;
|
2016-05-26 18:46:12 +10:00
|
|
|
incol = fact * texcol + outcol;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
2009-10-01 17:15:23 +00:00
|
|
|
void mtex_value_add(float outcol, float texcol, float fact, float facg, out float incol)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
|
|
|
float facm;
|
2009-10-01 17:15:23 +00:00
|
|
|
mtex_value_vars(fact, facg, facm);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
fact = fact;
|
2016-05-26 18:46:12 +10:00
|
|
|
incol = fact * texcol + outcol;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
2009-10-01 17:15:23 +00:00
|
|
|
void mtex_value_div(float outcol, float texcol, float fact, float facg, out float incol)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
|
|
|
float facm;
|
2009-10-01 17:15:23 +00:00
|
|
|
mtex_value_vars(fact, facg, facm);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2016-05-23 10:31:36 +02:00
|
|
|
if (texcol != 0.0)
|
2016-05-26 18:46:12 +10:00
|
|
|
incol = facm * outcol + fact * outcol / texcol;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
else
|
|
|
|
incol = 0.0;
|
|
|
|
}
|
|
|
|
|
2009-10-01 17:15:23 +00:00
|
|
|
void mtex_value_diff(float outcol, float texcol, float fact, float facg, out float incol)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
|
|
|
float facm;
|
2009-10-01 17:15:23 +00:00
|
|
|
mtex_value_vars(fact, facg, facm);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
incol = facm * outcol + fact * abs(texcol - outcol);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
2009-10-01 17:15:23 +00:00
|
|
|
void mtex_value_dark(float outcol, float texcol, float fact, float facg, out float incol)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
|
|
|
float facm;
|
2009-10-01 17:15:23 +00:00
|
|
|
mtex_value_vars(fact, facg, facm);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
incol = facm * outcol + fact * min(outcol, texcol);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
2009-10-01 17:15:23 +00:00
|
|
|
void mtex_value_light(float outcol, float texcol, float fact, float facg, out float incol)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
|
|
|
float facm;
|
2009-10-01 17:15:23 +00:00
|
|
|
mtex_value_vars(fact, facg, facm);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
float col = fact * texcol;
|
2016-05-23 10:31:36 +02:00
|
|
|
if (col > outcol) incol = col; else incol = outcol;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void mtex_value_clamp_positive(float fac, out float outfac)
|
|
|
|
{
|
|
|
|
outfac = max(fac, 0.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void mtex_value_clamp(float fac, out float outfac)
|
|
|
|
{
|
|
|
|
outfac = clamp(fac, 0.0, 1.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void mtex_har_divide(float har, out float outhar)
|
|
|
|
{
|
2016-05-26 18:46:12 +10:00
|
|
|
outhar = har / 128.0;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void mtex_har_multiply_clamp(float har, out float outhar)
|
|
|
|
{
|
2017-05-19 14:20:08 -04:00
|
|
|
outhar = clamp(har * 128.0, 1.0, 511.0);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void mtex_alpha_from_col(vec4 col, out float alpha)
|
|
|
|
{
|
|
|
|
alpha = col.a;
|
|
|
|
}
|
|
|
|
|
|
|
|
void mtex_alpha_to_col(vec4 col, float alpha, out vec4 outcol)
|
|
|
|
{
|
|
|
|
outcol = vec4(col.rgb, alpha);
|
|
|
|
}
|
|
|
|
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
void mtex_alpha_multiply_value(vec4 col, float value, out vec4 outcol)
|
|
|
|
{
|
2016-05-23 19:56:50 +10:00
|
|
|
outcol = vec4(col.rgb, col.a * value);
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
}
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
void mtex_rgbtoint(vec4 rgb, out float intensity)
|
|
|
|
{
|
|
|
|
intensity = dot(vec3(0.35, 0.45, 0.2), rgb.rgb);
|
|
|
|
}
|
|
|
|
|
|
|
|
void mtex_value_invert(float invalue, out float outvalue)
|
|
|
|
{
|
|
|
|
outvalue = 1.0 - invalue;
|
|
|
|
}
|
|
|
|
|
|
|
|
void mtex_rgb_invert(vec4 inrgb, out vec4 outrgb)
|
|
|
|
{
|
|
|
|
outrgb = vec4(vec3(1.0) - inrgb.rgb, inrgb.a);
|
|
|
|
}
|
|
|
|
|
|
|
|
void mtex_value_stencil(float stencil, float intensity, out float outstencil, out float outintensity)
|
|
|
|
{
|
|
|
|
float fact = intensity;
|
2016-05-26 18:46:12 +10:00
|
|
|
outintensity = intensity * stencil;
|
|
|
|
outstencil = stencil * fact;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void mtex_rgb_stencil(float stencil, vec4 rgb, out float outstencil, out vec4 outrgb)
|
|
|
|
{
|
|
|
|
float fact = rgb.a;
|
2016-05-26 18:46:12 +10:00
|
|
|
outrgb = vec4(rgb.rgb, rgb.a * stencil);
|
|
|
|
outstencil = stencil * fact;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void mtex_mapping_ofs(vec3 texco, vec3 ofs, out vec3 outtexco)
|
|
|
|
{
|
|
|
|
outtexco = texco + ofs;
|
|
|
|
}
|
|
|
|
|
|
|
|
void mtex_mapping_size(vec3 texco, vec3 size, out vec3 outtexco)
|
|
|
|
{
|
2016-05-26 18:46:12 +10:00
|
|
|
outtexco = size * texco;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void mtex_2d_mapping(vec3 vec, out vec3 outvec)
|
|
|
|
{
|
2016-05-26 18:46:12 +10:00
|
|
|
outvec = vec3(vec.xy * 0.5 + vec2(0.5), vec.z);
|
2014-09-02 15:58:38 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
vec3 mtex_2d_mapping(vec3 vec)
|
|
|
|
{
|
2016-05-26 18:46:12 +10:00
|
|
|
return vec3(vec.xy * 0.5 + vec2(0.5), vec.z);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
void mtex_cube_map(vec3 co, samplerCube ima, out float value, out vec4 color)
|
|
|
|
{
|
2017-05-19 10:23:07 -04:00
|
|
|
color = texture(ima, co);
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
value = 1.0;
|
|
|
|
}
|
|
|
|
|
2016-07-04 11:19:13 +03:00
|
|
|
void mtex_cube_map_refl_from_refldir(
|
|
|
|
samplerCube ima, vec3 reflecteddirection, out float value, out vec4 color)
|
|
|
|
{
|
2017-05-19 10:23:07 -04:00
|
|
|
color = texture(ima, reflecteddirection);
|
2017-01-17 11:52:02 +03:00
|
|
|
value = color.a;
|
2016-07-04 11:19:13 +03:00
|
|
|
}
|
|
|
|
|
2016-05-23 19:56:50 +10:00
|
|
|
void mtex_cube_map_refl(
|
|
|
|
samplerCube ima, vec3 vp, vec3 vn, mat4 viewmatrixinverse, mat4 viewmatrix,
|
|
|
|
out float value, out vec4 color)
|
2016-02-05 04:28:16 +11:00
|
|
|
{
|
|
|
|
vec3 viewdirection = vec3(viewmatrixinverse * vec4(vp, 0.0));
|
|
|
|
vec3 normaldirection = normalize(vec3(vec4(vn, 0.0) * viewmatrix));
|
|
|
|
vec3 reflecteddirection = reflect(viewdirection, normaldirection);
|
2017-05-19 10:23:07 -04:00
|
|
|
color = texture(ima, reflecteddirection);
|
2016-02-05 04:28:16 +11:00
|
|
|
value = 1.0;
|
|
|
|
}
|
|
|
|
|
2011-01-29 12:01:11 +00:00
|
|
|
void mtex_image(vec3 texco, sampler2D ima, out float value, out vec4 color)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
2017-05-19 10:23:07 -04:00
|
|
|
color = texture(ima, texco.xy);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
value = 1.0;
|
2011-01-29 12:01:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void mtex_normal(vec3 texco, sampler2D ima, out vec3 normal)
|
|
|
|
{
|
2011-02-23 11:58:36 +00:00
|
|
|
// The invert of the red channel is to make
|
|
|
|
// the normal map compliant with the outside world.
|
|
|
|
// It needs to be done because in Blender
|
|
|
|
// the normal used points inward.
|
|
|
|
// Should this ever change this negate must be removed.
|
2017-05-19 10:23:07 -04:00
|
|
|
vec4 color = texture(ima, texco.xy);
|
2016-05-26 18:46:12 +10:00
|
|
|
normal = 2.0 * (vec3(-color.r, color.g, color.b) - vec3(-0.5, 0.5, 0.5));
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
void mtex_bump_normals_init(vec3 vN, out vec3 vNorg, out vec3 vNacc, out float fPrevMagnitude)
|
2011-01-29 12:01:11 +00:00
|
|
|
{
|
2011-02-07 21:57:40 +00:00
|
|
|
vNorg = vN;
|
|
|
|
vNacc = vN;
|
|
|
|
fPrevMagnitude = 1.0;
|
2011-01-29 12:01:11 +00:00
|
|
|
}
|
|
|
|
|
2011-01-29 16:13:15 +00:00
|
|
|
/** helper method to extract the upper left 3x3 matrix from a 4x4 matrix */
|
|
|
|
mat3 to_mat3(mat4 m4)
|
|
|
|
{
|
|
|
|
mat3 m3;
|
|
|
|
m3[0] = m4[0].xyz;
|
|
|
|
m3[1] = m4[1].xyz;
|
|
|
|
m3[2] = m4[2].xyz;
|
|
|
|
return m3;
|
|
|
|
}
|
|
|
|
|
2016-05-23 19:56:50 +10:00
|
|
|
void mtex_bump_init_objspace(
|
|
|
|
vec3 surf_pos, vec3 surf_norm,
|
|
|
|
mat4 mView, mat4 mViewInv, mat4 mObj, mat4 mObjInv,
|
|
|
|
float fPrevMagnitude_in, vec3 vNacc_in,
|
|
|
|
out float fPrevMagnitude_out, out vec3 vNacc_out,
|
|
|
|
out vec3 vR1, out vec3 vR2, out float fDet)
|
2011-01-29 12:01:11 +00:00
|
|
|
{
|
2017-03-26 21:19:23 -04:00
|
|
|
mat3 obj2view = to_mat3(ModelViewMatrix);
|
|
|
|
mat3 view2obj = to_mat3(ModelViewMatrixInverse);
|
2011-01-29 12:01:11 +00:00
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
vec3 vSigmaS = view2obj * dFdx(surf_pos);
|
|
|
|
vec3 vSigmaT = view2obj * dFdy(surf_pos);
|
|
|
|
vec3 vN = normalize(surf_norm * obj2view);
|
|
|
|
|
|
|
|
vR1 = cross(vSigmaT, vN);
|
|
|
|
vR2 = cross(vN, vSigmaS);
|
|
|
|
fDet = dot(vSigmaS, vR1);
|
|
|
|
|
2011-02-07 21:57:40 +00:00
|
|
|
/* pretransform vNacc (in mtex_bump_apply) using the inverse transposed */
|
2011-01-30 14:43:24 +00:00
|
|
|
vR1 = vR1 * view2obj;
|
|
|
|
vR2 = vR2 * view2obj;
|
|
|
|
vN = vN * view2obj;
|
2016-05-26 18:46:12 +10:00
|
|
|
|
2011-02-07 21:57:40 +00:00
|
|
|
float fMagnitude = abs(fDet) * length(vN);
|
|
|
|
vNacc_out = vNacc_in * (fMagnitude / fPrevMagnitude_in);
|
|
|
|
fPrevMagnitude_out = fMagnitude;
|
|
|
|
}
|
|
|
|
|
2016-05-23 19:56:50 +10:00
|
|
|
void mtex_bump_init_texturespace(
|
|
|
|
vec3 surf_pos, vec3 surf_norm,
|
|
|
|
float fPrevMagnitude_in, vec3 vNacc_in,
|
|
|
|
out float fPrevMagnitude_out, out vec3 vNacc_out,
|
|
|
|
out vec3 vR1, out vec3 vR2, out float fDet)
|
2011-02-07 21:57:40 +00:00
|
|
|
{
|
2016-05-26 18:46:12 +10:00
|
|
|
vec3 vSigmaS = dFdx(surf_pos);
|
|
|
|
vec3 vSigmaT = dFdy(surf_pos);
|
2011-02-07 21:57:40 +00:00
|
|
|
vec3 vN = surf_norm; /* normalized interpolated vertex normal */
|
2016-05-26 18:46:12 +10:00
|
|
|
|
|
|
|
vR1 = normalize(cross(vSigmaT, vN));
|
|
|
|
vR2 = normalize(cross(vN, vSigmaS));
|
|
|
|
fDet = sign(dot(vSigmaS, vR1));
|
|
|
|
|
2011-02-07 21:57:40 +00:00
|
|
|
float fMagnitude = abs(fDet);
|
|
|
|
vNacc_out = vNacc_in * (fMagnitude / fPrevMagnitude_in);
|
|
|
|
fPrevMagnitude_out = fMagnitude;
|
|
|
|
}
|
2011-01-30 14:43:24 +00:00
|
|
|
|
2016-05-23 19:56:50 +10:00
|
|
|
void mtex_bump_init_viewspace(
|
|
|
|
vec3 surf_pos, vec3 surf_norm,
|
|
|
|
float fPrevMagnitude_in, vec3 vNacc_in,
|
|
|
|
out float fPrevMagnitude_out, out vec3 vNacc_out,
|
|
|
|
out vec3 vR1, out vec3 vR2, out float fDet)
|
2011-02-07 21:57:40 +00:00
|
|
|
{
|
2016-05-26 18:46:12 +10:00
|
|
|
vec3 vSigmaS = dFdx(surf_pos);
|
|
|
|
vec3 vSigmaT = dFdy(surf_pos);
|
2011-02-07 21:57:40 +00:00
|
|
|
vec3 vN = surf_norm; /* normalized interpolated vertex normal */
|
2016-05-26 18:46:12 +10:00
|
|
|
|
|
|
|
vR1 = cross(vSigmaT, vN);
|
|
|
|
vR2 = cross(vN, vSigmaS);
|
|
|
|
fDet = dot(vSigmaS, vR1);
|
|
|
|
|
2011-02-07 21:57:40 +00:00
|
|
|
float fMagnitude = abs(fDet);
|
|
|
|
vNacc_out = vNacc_in * (fMagnitude / fPrevMagnitude_in);
|
|
|
|
fPrevMagnitude_out = fMagnitude;
|
2011-01-29 12:01:11 +00:00
|
|
|
}
|
|
|
|
|
2016-05-23 19:56:50 +10:00
|
|
|
void mtex_bump_tap3(
|
|
|
|
vec3 texco, sampler2D ima, float hScale,
|
|
|
|
out float dBs, out float dBt)
|
2011-01-29 12:01:11 +00:00
|
|
|
{
|
|
|
|
vec2 STll = texco.xy;
|
2016-05-26 18:46:12 +10:00
|
|
|
vec2 STlr = texco.xy + dFdx(texco.xy);
|
|
|
|
vec2 STul = texco.xy + dFdy(texco.xy);
|
|
|
|
|
|
|
|
float Hll, Hlr, Hul;
|
2017-05-19 10:23:07 -04:00
|
|
|
rgbtobw(texture(ima, STll), Hll);
|
|
|
|
rgbtobw(texture(ima, STlr), Hlr);
|
|
|
|
rgbtobw(texture(ima, STul), Hul);
|
2016-05-26 18:46:12 +10:00
|
|
|
|
2011-01-29 12:01:11 +00:00
|
|
|
dBs = hScale * (Hlr - Hll);
|
|
|
|
dBt = hScale * (Hul - Hll);
|
|
|
|
}
|
|
|
|
|
2011-12-15 13:58:09 +00:00
|
|
|
#ifdef BUMP_BICUBIC
|
|
|
|
|
2016-05-23 19:56:50 +10:00
|
|
|
void mtex_bump_bicubic(
|
|
|
|
vec3 texco, sampler2D ima, float hScale,
|
|
|
|
out float dBs, out float dBt )
|
2011-12-15 13:58:09 +00:00
|
|
|
{
|
2012-01-31 22:12:33 +00:00
|
|
|
float Hl;
|
|
|
|
float Hr;
|
|
|
|
float Hd;
|
|
|
|
float Hu;
|
2016-05-26 18:46:12 +10:00
|
|
|
|
2011-12-15 13:58:09 +00:00
|
|
|
vec2 TexDx = dFdx(texco.xy);
|
|
|
|
vec2 TexDy = dFdy(texco.xy);
|
2016-05-26 18:46:12 +10:00
|
|
|
|
|
|
|
vec2 STl = texco.xy - 0.5 * TexDx;
|
|
|
|
vec2 STr = texco.xy + 0.5 * TexDx;
|
|
|
|
vec2 STd = texco.xy - 0.5 * TexDy;
|
|
|
|
vec2 STu = texco.xy + 0.5 * TexDy;
|
|
|
|
|
2017-05-19 10:23:07 -04:00
|
|
|
rgbtobw(texture(ima, STl), Hl);
|
|
|
|
rgbtobw(texture(ima, STr), Hr);
|
|
|
|
rgbtobw(texture(ima, STd), Hd);
|
|
|
|
rgbtobw(texture(ima, STu), Hu);
|
2016-05-26 18:46:12 +10:00
|
|
|
|
2011-12-15 13:58:09 +00:00
|
|
|
vec2 dHdxy = vec2(Hr - Hl, Hu - Hd);
|
2016-05-26 18:46:12 +10:00
|
|
|
float fBlend = clamp(1.0 - textureQueryLOD(ima, texco.xy).x, 0.0, 1.0);
|
|
|
|
if (fBlend != 0.0) {
|
2011-12-15 13:58:09 +00:00
|
|
|
// the derivative of the bicubic sampling of level 0
|
|
|
|
ivec2 vDim;
|
|
|
|
vDim = textureSize(ima, 0);
|
|
|
|
|
2012-02-01 17:47:13 +00:00
|
|
|
// taking the fract part of the texture coordinate is a hardcoded wrap mode.
|
2016-05-26 18:46:12 +10:00
|
|
|
// this is acceptable as textures use wrap mode exclusively in 3D view elsewhere in blender.
|
2012-02-01 17:47:13 +00:00
|
|
|
// this is done so that we can still get a valid texel with uvs outside the 0,1 range
|
|
|
|
// by texelFetch below, as coordinates are clamped when using this function.
|
2016-05-26 18:46:12 +10:00
|
|
|
vec2 fTexLoc = vDim * fract(texco.xy) - vec2(0.5, 0.5);
|
2011-12-15 13:58:09 +00:00
|
|
|
ivec2 iTexLoc = ivec2(floor(fTexLoc));
|
2016-05-26 18:46:12 +10:00
|
|
|
vec2 t = clamp(fTexLoc - iTexLoc, 0.0, 1.0); // sat just to be pedantic
|
2011-12-15 13:58:09 +00:00
|
|
|
|
|
|
|
/*******************************************************************************************
|
|
|
|
* This block will replace the one below when one channel textures are properly supported. *
|
|
|
|
*******************************************************************************************
|
2016-05-26 18:46:12 +10:00
|
|
|
vec4 vSamplesUL = textureGather(ima, (iTexLoc+ivec2(-1,-1) + vec2(0.5,0.5))/vDim);
|
|
|
|
vec4 vSamplesUR = textureGather(ima, (iTexLoc+ivec2(1,-1) + vec2(0.5,0.5))/vDim);
|
|
|
|
vec4 vSamplesLL = textureGather(ima, (iTexLoc+ivec2(-1,1) + vec2(0.5,0.5))/vDim);
|
|
|
|
vec4 vSamplesLR = textureGather(ima, (iTexLoc+ivec2(1,1) + vec2(0.5,0.5))/vDim);
|
2012-01-31 22:12:33 +00:00
|
|
|
|
2011-12-15 13:58:09 +00:00
|
|
|
mat4 H = mat4(vSamplesUL.w, vSamplesUL.x, vSamplesLL.w, vSamplesLL.x,
|
2016-05-26 18:46:12 +10:00
|
|
|
vSamplesUL.z, vSamplesUL.y, vSamplesLL.z, vSamplesLL.y,
|
|
|
|
vSamplesUR.w, vSamplesUR.x, vSamplesLR.w, vSamplesLR.x,
|
|
|
|
vSamplesUR.z, vSamplesUR.y, vSamplesLR.z, vSamplesLR.y);
|
|
|
|
*/
|
2012-01-31 22:12:33 +00:00
|
|
|
ivec2 iTexLocMod = iTexLoc + ivec2(-1, -1);
|
|
|
|
|
2011-12-15 13:58:09 +00:00
|
|
|
mat4 H;
|
2016-05-26 18:46:12 +10:00
|
|
|
|
2016-05-23 10:31:36 +02:00
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
|
for (int j = 0; j < 4; j++) {
|
2016-05-26 18:46:12 +10:00
|
|
|
ivec2 iTexTmp = iTexLocMod + ivec2(i, j);
|
|
|
|
|
2012-02-01 17:47:13 +00:00
|
|
|
// wrap texture coordinates manually for texelFetch to work on uvs oitside the 0,1 range.
|
|
|
|
// this is guaranteed to work since we take the fractional part of the uv above.
|
2016-05-26 18:46:12 +10:00
|
|
|
iTexTmp.x = (iTexTmp.x < 0) ? iTexTmp.x + vDim.x : ((iTexTmp.x >= vDim.x) ? iTexTmp.x - vDim.x : iTexTmp.x);
|
|
|
|
iTexTmp.y = (iTexTmp.y < 0) ? iTexTmp.y + vDim.y : ((iTexTmp.y >= vDim.y) ? iTexTmp.y - vDim.y : iTexTmp.y);
|
2012-02-01 17:47:13 +00:00
|
|
|
|
|
|
|
rgbtobw(texelFetch(ima, iTexTmp, 0), H[i][j]);
|
2011-12-15 13:58:09 +00:00
|
|
|
}
|
|
|
|
}
|
2016-05-26 18:46:12 +10:00
|
|
|
|
2011-12-15 13:58:09 +00:00
|
|
|
float x = t.x, y = t.y;
|
|
|
|
float x2 = x * x, x3 = x2 * x, y2 = y * y, y3 = y2 * y;
|
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
vec4 X = vec4(-0.5 * (x3 + x) + x2, 1.5 * x3 - 2.5 * x2 + 1, -1.5 * x3 + 2 * x2 + 0.5 * x, 0.5 * (x3 - x2));
|
|
|
|
vec4 Y = vec4(-0.5 * (y3 + y) + y2, 1.5 * y3 - 2.5 * y2 + 1, -1.5 * y3 + 2 * y2 + 0.5 * y, 0.5 * (y3 - y2));
|
|
|
|
vec4 dX = vec4(-1.5 * x2 + 2 * x - 0.5, 4.5 * x2 - 5 * x, -4.5 * x2 + 4 * x + 0.5, 1.5 * x2 - x);
|
|
|
|
vec4 dY = vec4(-1.5 * y2 + 2 * y - 0.5, 4.5 * y2 - 5 * y, -4.5 * y2 + 4 * y + 0.5, 1.5 * y2 - y);
|
|
|
|
|
2011-12-15 13:58:09 +00:00
|
|
|
// complete derivative in normalized coordinates (mul by vDim)
|
|
|
|
vec2 dHdST = vDim * vec2(dot(Y, H * dX), dot(dY, H * X));
|
|
|
|
|
|
|
|
// transform derivative to screen-space
|
2016-05-26 18:46:12 +10:00
|
|
|
vec2 dHdxy_bicubic = vec2(dHdST.x * TexDx.x + dHdST.y * TexDx.y,
|
|
|
|
dHdST.x * TexDy.x + dHdST.y * TexDy.y);
|
2011-12-15 13:58:09 +00:00
|
|
|
|
|
|
|
// blend between the two
|
2016-05-26 18:46:12 +10:00
|
|
|
dHdxy = dHdxy * (1 - fBlend) + dHdxy_bicubic * fBlend;
|
2011-12-15 13:58:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
dBs = hScale * dHdxy.x;
|
|
|
|
dBt = hScale * dHdxy.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2016-05-23 19:56:50 +10:00
|
|
|
void mtex_bump_tap5(
|
|
|
|
vec3 texco, sampler2D ima, float hScale,
|
|
|
|
out float dBs, out float dBt)
|
2011-01-29 12:01:11 +00:00
|
|
|
{
|
|
|
|
vec2 TexDx = dFdx(texco.xy);
|
|
|
|
vec2 TexDy = dFdy(texco.xy);
|
|
|
|
|
|
|
|
vec2 STc = texco.xy;
|
2016-05-26 18:46:12 +10:00
|
|
|
vec2 STl = texco.xy - 0.5 * TexDx;
|
|
|
|
vec2 STr = texco.xy + 0.5 * TexDx;
|
|
|
|
vec2 STd = texco.xy - 0.5 * TexDy;
|
|
|
|
vec2 STu = texco.xy + 0.5 * TexDy;
|
|
|
|
|
|
|
|
float Hc, Hl, Hr, Hd, Hu;
|
2017-05-19 10:23:07 -04:00
|
|
|
rgbtobw(texture(ima, STc), Hc);
|
|
|
|
rgbtobw(texture(ima, STl), Hl);
|
|
|
|
rgbtobw(texture(ima, STr), Hr);
|
|
|
|
rgbtobw(texture(ima, STd), Hd);
|
|
|
|
rgbtobw(texture(ima, STu), Hu);
|
2016-05-26 18:46:12 +10:00
|
|
|
|
2011-01-29 12:01:11 +00:00
|
|
|
dBs = hScale * (Hr - Hl);
|
|
|
|
dBt = hScale * (Hu - Hd);
|
|
|
|
}
|
|
|
|
|
2016-05-23 19:56:50 +10:00
|
|
|
void mtex_bump_deriv(
|
|
|
|
vec3 texco, sampler2D ima, float ima_x, float ima_y, float hScale,
|
|
|
|
out float dBs, out float dBt)
|
2011-08-22 19:57:54 +00:00
|
|
|
{
|
2016-05-26 18:46:12 +10:00
|
|
|
float s = 1.0; // negate this if flipped texture coordinate
|
2011-08-22 19:57:54 +00:00
|
|
|
vec2 TexDx = dFdx(texco.xy);
|
|
|
|
vec2 TexDy = dFdy(texco.xy);
|
2016-05-26 18:46:12 +10:00
|
|
|
|
2011-08-22 19:57:54 +00:00
|
|
|
// this variant using a derivative map is described here
|
|
|
|
// http://mmikkelsen3d.blogspot.com/2011/07/derivative-maps.html
|
|
|
|
vec2 dim = vec2(ima_x, ima_y);
|
2017-05-19 10:23:07 -04:00
|
|
|
vec2 dBduv = hScale * dim * (2.0 * texture(ima, texco.xy).xy - 1.0);
|
2016-05-26 18:46:12 +10:00
|
|
|
|
|
|
|
dBs = dBduv.x * TexDx.x + s * dBduv.y * TexDx.y;
|
|
|
|
dBt = dBduv.x * TexDy.x + s * dBduv.y * TexDy.y;
|
2011-08-22 19:57:54 +00:00
|
|
|
}
|
|
|
|
|
2016-05-23 19:56:50 +10:00
|
|
|
void mtex_bump_apply(
|
|
|
|
float fDet, float dBs, float dBt, vec3 vR1, vec3 vR2, vec3 vNacc_in,
|
|
|
|
out vec3 vNacc_out, out vec3 perturbed_norm)
|
2011-01-29 12:01:11 +00:00
|
|
|
{
|
2016-05-26 18:46:12 +10:00
|
|
|
vec3 vSurfGrad = sign(fDet) * (dBs * vR1 + dBt * vR2);
|
|
|
|
|
2011-02-07 21:57:40 +00:00
|
|
|
vNacc_out = vNacc_in - vSurfGrad;
|
2016-05-26 18:46:12 +10:00
|
|
|
perturbed_norm = normalize(vNacc_out);
|
2011-01-29 12:01:11 +00:00
|
|
|
}
|
2011-01-30 14:43:24 +00:00
|
|
|
|
2016-05-23 19:56:50 +10:00
|
|
|
void mtex_bump_apply_texspace(
|
|
|
|
float fDet, float dBs, float dBt, vec3 vR1, vec3 vR2,
|
|
|
|
sampler2D ima, vec3 texco, float ima_x, float ima_y, vec3 vNacc_in,
|
|
|
|
out vec3 vNacc_out, out vec3 perturbed_norm)
|
2011-01-29 12:01:11 +00:00
|
|
|
{
|
|
|
|
vec2 TexDx = dFdx(texco.xy);
|
|
|
|
vec2 TexDy = dFdy(texco.xy);
|
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
vec3 vSurfGrad = sign(fDet) * (
|
|
|
|
dBs / length(vec2(ima_x * TexDx.x, ima_y * TexDx.y)) * vR1 +
|
|
|
|
dBt / length(vec2(ima_x * TexDy.x, ima_y * TexDy.y)) * vR2);
|
2016-05-23 19:56:50 +10:00
|
|
|
|
2011-02-07 21:57:40 +00:00
|
|
|
vNacc_out = vNacc_in - vSurfGrad;
|
2016-05-26 18:46:12 +10:00
|
|
|
perturbed_norm = normalize(vNacc_out);
|
2011-01-29 12:01:11 +00:00
|
|
|
}
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
void mtex_negate_texnormal(vec3 normal, out vec3 outnormal)
|
|
|
|
{
|
|
|
|
outnormal = vec3(-normal.x, -normal.y, normal.z);
|
|
|
|
}
|
|
|
|
|
2011-02-14 18:18:46 +00:00
|
|
|
void mtex_nspace_tangent(vec4 tangent, vec3 normal, vec3 texnormal, out vec3 outnormal)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
2011-02-14 18:18:46 +00:00
|
|
|
vec3 B = tangent.w * cross(normal, tangent.xyz);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
outnormal = texnormal.x * tangent.xyz + texnormal.y * B + texnormal.z * normal;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
outnormal = normalize(outnormal);
|
|
|
|
}
|
|
|
|
|
2013-09-20 11:55:43 +00:00
|
|
|
void mtex_nspace_world(mat4 viewmat, vec3 texnormal, out vec3 outnormal)
|
|
|
|
{
|
2016-05-26 18:46:12 +10:00
|
|
|
outnormal = normalize((viewmat * vec4(texnormal, 0.0)).xyz);
|
2013-09-20 11:55:43 +00:00
|
|
|
}
|
|
|
|
|
2014-10-21 15:00:12 +02:00
|
|
|
void mtex_nspace_object(vec3 texnormal, out vec3 outnormal)
|
2013-09-20 11:55:43 +00:00
|
|
|
{
|
2017-03-26 21:19:23 -04:00
|
|
|
outnormal = normalize(NormalMatrix * texnormal);
|
2013-09-20 11:55:43 +00:00
|
|
|
}
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
void mtex_blend_normal(float norfac, vec3 normal, vec3 newnormal, out vec3 outnormal)
|
|
|
|
{
|
2016-05-26 18:46:12 +10:00
|
|
|
outnormal = (1.0 - norfac) * normal + norfac * newnormal;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
outnormal = normalize(outnormal);
|
|
|
|
}
|
|
|
|
|
|
|
|
/******* MATERIAL *********/
|
|
|
|
|
|
|
|
void lamp_visibility_sun_hemi(vec3 lampvec, out vec3 lv, out float dist, out float visifac)
|
|
|
|
{
|
|
|
|
lv = lampvec;
|
|
|
|
dist = 1.0;
|
|
|
|
visifac = 1.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void lamp_visibility_other(vec3 co, vec3 lampco, out vec3 lv, out float dist, out float visifac)
|
|
|
|
{
|
|
|
|
lv = co - lampco;
|
|
|
|
dist = length(lv);
|
|
|
|
lv = normalize(lv);
|
|
|
|
visifac = 1.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void lamp_falloff_invlinear(float lampdist, float dist, out float visifac)
|
|
|
|
{
|
2016-05-26 18:46:12 +10:00
|
|
|
visifac = lampdist / (lampdist + dist);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void lamp_falloff_invsquare(float lampdist, float dist, out float visifac)
|
|
|
|
{
|
2016-05-26 18:46:12 +10:00
|
|
|
visifac = lampdist / (lampdist + dist * dist);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void lamp_falloff_sliders(float lampdist, float ld1, float ld2, float dist, out float visifac)
|
|
|
|
{
|
2016-05-26 18:46:12 +10:00
|
|
|
float lampdistkw = lampdist * lampdist;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
visifac = lampdist / (lampdist + ld1 * dist);
|
|
|
|
visifac *= lampdistkw / (lampdistkw + ld2 * dist * dist);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
2016-03-13 02:00:12 +01:00
|
|
|
void lamp_falloff_invcoefficients(float coeff_const, float coeff_lin, float coeff_quad, float dist, out float visifac)
|
|
|
|
{
|
|
|
|
vec3 coeff = vec3(coeff_const, coeff_lin, coeff_quad);
|
2016-05-26 18:46:12 +10:00
|
|
|
vec3 d_coeff = vec3(1.0, dist, dist * dist);
|
2016-03-13 02:00:12 +01:00
|
|
|
float visifac_r = dot(coeff, d_coeff);
|
|
|
|
if (visifac_r > 0.0)
|
|
|
|
visifac = 1.0 / visifac_r;
|
|
|
|
else
|
|
|
|
visifac = 0.0;
|
|
|
|
}
|
|
|
|
|
2011-09-09 11:55:38 +00:00
|
|
|
void lamp_falloff_curve(float lampdist, sampler2D curvemap, float dist, out float visifac)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
2017-05-19 10:23:07 -04:00
|
|
|
visifac = texture(curvemap, vec2(dist / lampdist, 0.0)).x;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void lamp_visibility_sphere(float lampdist, float dist, float visifac, out float outvisifac)
|
|
|
|
{
|
2016-05-26 18:46:12 +10:00
|
|
|
float t = lampdist - dist;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
outvisifac = visifac * max(t, 0.0) / lampdist;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
2015-10-15 22:36:31 +11:00
|
|
|
void lamp_visibility_spot_square(vec3 lampvec, mat4 lampimat, vec2 scale, vec3 lv, out float inpr)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
2016-05-23 10:31:36 +02:00
|
|
|
if (dot(lv, lampvec) > 0.0) {
|
2016-05-26 18:46:12 +10:00
|
|
|
vec3 lvrot = (lampimat * vec4(lv, 0.0)).xyz;
|
2015-10-15 22:36:31 +11:00
|
|
|
/* without clever non-uniform scale, we could do: */
|
|
|
|
// float x = max(abs(lvrot.x / lvrot.z), abs(lvrot.y / lvrot.z));
|
|
|
|
float x = max(abs((lvrot.x / scale.x) / lvrot.z), abs((lvrot.y / scale.y) / lvrot.z));
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
inpr = 1.0 / sqrt(1.0 + x * x);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
inpr = 0.0;
|
|
|
|
}
|
|
|
|
|
2015-10-15 22:36:31 +11:00
|
|
|
void lamp_visibility_spot_circle(vec3 lampvec, mat4 lampimat, vec2 scale, vec3 lv, out float inpr)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
2015-10-15 22:36:31 +11:00
|
|
|
/* without clever non-uniform scale, we could do: */
|
|
|
|
// inpr = dot(lv, lampvec);
|
|
|
|
if (dot(lv, lampvec) > 0.0) {
|
|
|
|
vec3 lvrot = (lampimat * vec4(lv, 0.0)).xyz;
|
|
|
|
float x = abs(lvrot.x / lvrot.z);
|
|
|
|
float y = abs(lvrot.y / lvrot.z);
|
|
|
|
|
|
|
|
float ellipse = abs((x * x) / (scale.x * scale.x) + (y * y) / (scale.y * scale.y));
|
|
|
|
|
|
|
|
inpr = 1.0 / sqrt(1.0 + ellipse);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
inpr = 0.0;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void lamp_visibility_spot(float spotsi, float spotbl, float inpr, float visifac, out float outvisifac)
|
|
|
|
{
|
|
|
|
float t = spotsi;
|
|
|
|
|
2016-05-23 10:31:36 +02:00
|
|
|
if (inpr <= t) {
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
outvisifac = 0.0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
t = inpr - t;
|
|
|
|
|
|
|
|
/* soft area */
|
2016-05-23 10:31:36 +02:00
|
|
|
if (spotbl != 0.0)
|
2016-05-26 18:46:12 +10:00
|
|
|
inpr *= smoothstep(0.0, 1.0, t / spotbl);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
outvisifac = visifac * inpr;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void lamp_visibility_clamp(float visifac, out float outvisifac)
|
|
|
|
{
|
2016-05-26 18:46:12 +10:00
|
|
|
outvisifac = (visifac < 0.001) ? 0.0 : visifac;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
void world_paper_view(vec3 vec, out vec3 outvec)
|
|
|
|
{
|
|
|
|
vec3 nvec = normalize(vec);
|
2017-03-26 21:19:23 -04:00
|
|
|
outvec = (ProjectionMatrix[3][3] == 0.0) ? vec3(nvec.x, 0.0, nvec.y) : vec3(0.0, 0.0, -1.0);
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void world_zen_mapping(vec3 view, float zenup, float zendown, out float zenfac)
|
|
|
|
{
|
|
|
|
if (view.z >= 0.0)
|
|
|
|
zenfac = zenup;
|
|
|
|
else
|
|
|
|
zenfac = zendown;
|
|
|
|
}
|
|
|
|
|
|
|
|
void world_blend_paper_real(vec3 vec, out float blend)
|
|
|
|
{
|
|
|
|
blend = abs(vec.y);
|
|
|
|
}
|
|
|
|
|
|
|
|
void world_blend_paper(vec3 vec, out float blend)
|
|
|
|
{
|
|
|
|
blend = (vec.y + 1.0) * 0.5;
|
|
|
|
}
|
|
|
|
|
|
|
|
void world_blend_real(vec3 vec, out float blend)
|
|
|
|
{
|
|
|
|
blend = abs(normalize(vec).z);
|
|
|
|
}
|
|
|
|
|
|
|
|
void world_blend(vec3 vec, out float blend)
|
|
|
|
{
|
|
|
|
blend = (normalize(vec).z + 1) * 0.5;
|
|
|
|
}
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
void shade_view(vec3 co, out vec3 view)
|
|
|
|
{
|
|
|
|
/* handle perspective/orthographic */
|
2017-03-26 21:19:23 -04:00
|
|
|
view = (ProjectionMatrix[3][3] == 0.0) ? normalize(co) : vec3(0.0, 0.0, -1.0);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void shade_tangent_v(vec3 lv, vec3 tang, out vec3 vn)
|
|
|
|
{
|
|
|
|
vec3 c = cross(lv, tang);
|
|
|
|
vec3 vnor = cross(c, tang);
|
|
|
|
|
|
|
|
vn = -normalize(vnor);
|
|
|
|
}
|
|
|
|
|
|
|
|
void shade_inp(vec3 vn, vec3 lv, out float inp)
|
|
|
|
{
|
|
|
|
inp = dot(vn, lv);
|
|
|
|
}
|
|
|
|
|
|
|
|
void shade_is_no_diffuse(out float is)
|
|
|
|
{
|
|
|
|
is = 0.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void shade_is_hemi(float inp, out float is)
|
|
|
|
{
|
2016-05-26 18:46:12 +10:00
|
|
|
is = 0.5 * inp + 0.5;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
float area_lamp_energy(mat4 area, vec3 co, vec3 vn)
|
|
|
|
{
|
|
|
|
vec3 vec[4], c[4];
|
|
|
|
float rad[4], fac;
|
2016-05-26 18:46:12 +10:00
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
vec[0] = normalize(co - area[0].xyz);
|
|
|
|
vec[1] = normalize(co - area[1].xyz);
|
|
|
|
vec[2] = normalize(co - area[2].xyz);
|
|
|
|
vec[3] = normalize(co - area[3].xyz);
|
|
|
|
|
|
|
|
c[0] = normalize(cross(vec[0], vec[1]));
|
|
|
|
c[1] = normalize(cross(vec[1], vec[2]));
|
|
|
|
c[2] = normalize(cross(vec[2], vec[3]));
|
|
|
|
c[3] = normalize(cross(vec[3], vec[0]));
|
|
|
|
|
|
|
|
rad[0] = acos(dot(vec[0], vec[1]));
|
|
|
|
rad[1] = acos(dot(vec[1], vec[2]));
|
|
|
|
rad[2] = acos(dot(vec[2], vec[3]));
|
|
|
|
rad[3] = acos(dot(vec[3], vec[0]));
|
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
fac = rad[0] * dot(vn, c[0]);
|
|
|
|
fac += rad[1] * dot(vn, c[1]);
|
|
|
|
fac += rad[2] * dot(vn, c[2]);
|
|
|
|
fac += rad[3] * dot(vn, c[3]);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
return max(fac, 0.0);
|
|
|
|
}
|
|
|
|
|
2016-05-23 19:56:50 +10:00
|
|
|
void shade_inp_area(
|
|
|
|
vec3 position, vec3 lampco, vec3 lampvec, vec3 vn, mat4 area, float areasize, float k,
|
|
|
|
out float inp)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
|
|
|
vec3 co = position;
|
|
|
|
vec3 vec = co - lampco;
|
|
|
|
|
2016-05-23 10:31:36 +02:00
|
|
|
if (dot(vec, lampvec) < 0.0) {
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
inp = 0.0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
float intens = area_lamp_energy(area, co, vn);
|
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
inp = pow(intens * areasize, k);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void shade_diffuse_oren_nayer(float nl, vec3 n, vec3 l, vec3 v, float rough, out float is)
|
|
|
|
{
|
|
|
|
vec3 h = normalize(v + l);
|
|
|
|
float nh = max(dot(n, h), 0.0);
|
|
|
|
float nv = max(dot(n, v), 0.0);
|
|
|
|
float realnl = dot(n, l);
|
|
|
|
|
2016-05-23 10:31:36 +02:00
|
|
|
if (realnl < 0.0) {
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
is = 0.0;
|
|
|
|
}
|
2016-05-23 10:31:36 +02:00
|
|
|
else if (nl < 0.0) {
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
is = 0.0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
float vh = max(dot(v, h), 0.0);
|
|
|
|
float Lit_A = acos(realnl);
|
|
|
|
float View_A = acos(nv);
|
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
vec3 Lit_B = normalize(l - realnl * n);
|
|
|
|
vec3 View_B = normalize(v - nv * n);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
float t = max(dot(Lit_B, View_B), 0.0);
|
|
|
|
|
|
|
|
float a, b;
|
|
|
|
|
2016-05-23 10:31:36 +02:00
|
|
|
if (Lit_A > View_A) {
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
a = Lit_A;
|
|
|
|
b = View_A;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
a = View_A;
|
|
|
|
b = Lit_A;
|
|
|
|
}
|
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
float A = 1.0 - (0.5 * ((rough * rough) / ((rough * rough) + 0.33)));
|
|
|
|
float B = 0.45 * ((rough * rough) / ((rough * rough) + 0.09));
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
b *= 0.95;
|
2016-05-26 18:46:12 +10:00
|
|
|
is = nl * (A + (B * t * sin(a) * tan(b)));
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void shade_diffuse_toon(vec3 n, vec3 l, vec3 v, float size, float tsmooth, out float is)
|
|
|
|
{
|
|
|
|
float rslt = dot(n, l);
|
|
|
|
float ang = acos(rslt);
|
|
|
|
|
2016-05-23 10:31:36 +02:00
|
|
|
if (ang < size) is = 1.0;
|
|
|
|
else if (ang > (size + tsmooth) || tsmooth == 0.0) is = 0.0;
|
2016-05-26 18:46:12 +10:00
|
|
|
else is = 1.0 - ((ang - size) / tsmooth);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void shade_diffuse_minnaert(float nl, vec3 n, vec3 v, float darkness, out float is)
|
|
|
|
{
|
2016-05-23 10:31:36 +02:00
|
|
|
if (nl <= 0.0) {
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
is = 0.0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
float nv = max(dot(n, v), 0.0);
|
|
|
|
|
2016-05-23 10:31:36 +02:00
|
|
|
if (darkness <= 1.0)
|
2016-05-26 18:46:12 +10:00
|
|
|
is = nl * pow(max(nv * nl, 0.1), darkness - 1.0);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
else
|
2016-05-26 18:46:12 +10:00
|
|
|
is = nl * pow(1.0001 - nv, darkness - 1.0);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
float fresnel_fac(vec3 view, vec3 vn, float grad, float fac)
|
|
|
|
{
|
|
|
|
float t1, t2;
|
|
|
|
float ffac;
|
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
if (fac == 0.0) {
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
ffac = 1.0;
|
|
|
|
}
|
|
|
|
else {
|
2016-05-26 18:46:12 +10:00
|
|
|
t1 = dot(view, vn);
|
|
|
|
if (t1 > 0.0) t2 = 1.0 + t1;
|
|
|
|
else t2 = 1.0 - t1;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
t2 = grad + (1.0 - grad) * pow(t2, fac);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
if (t2 < 0.0) ffac = 0.0;
|
|
|
|
else if (t2 > 1.0) ffac = 1.0;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
else ffac = t2;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ffac;
|
|
|
|
}
|
|
|
|
|
|
|
|
void shade_diffuse_fresnel(vec3 vn, vec3 lv, vec3 view, float fac_i, float fac, out float is)
|
|
|
|
{
|
|
|
|
is = fresnel_fac(lv, vn, fac_i, fac);
|
|
|
|
}
|
|
|
|
|
|
|
|
void shade_cubic(float is, out float outis)
|
|
|
|
{
|
2016-05-26 18:46:12 +10:00
|
|
|
if (is > 0.0 && is < 1.0)
|
|
|
|
outis = smoothstep(0.0, 1.0, is);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
else
|
2016-05-26 18:46:12 +10:00
|
|
|
outis = is;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void shade_visifac(float i, float visifac, float refl, out float outi)
|
|
|
|
{
|
2016-05-23 10:31:36 +02:00
|
|
|
/*if (i > 0.0)*/
|
2016-05-26 18:46:12 +10:00
|
|
|
outi = max(i * visifac * refl, 0.0);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
/*else
|
2016-05-26 18:46:12 +10:00
|
|
|
outi = i;*/
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void shade_tangent_v_spec(vec3 tang, out vec3 vn)
|
|
|
|
{
|
|
|
|
vn = tang;
|
|
|
|
}
|
|
|
|
|
|
|
|
void shade_add_to_diffuse(float i, vec3 lampcol, vec3 col, out vec3 outcol)
|
|
|
|
{
|
2016-05-23 10:31:36 +02:00
|
|
|
if (i > 0.0)
|
2016-05-26 18:46:12 +10:00
|
|
|
outcol = i * lampcol * col;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
else
|
2017-05-19 14:20:08 -04:00
|
|
|
outcol = vec3(0.0);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void shade_hemi_spec(vec3 vn, vec3 lv, vec3 view, float spec, float hard, float visifac, out float t)
|
|
|
|
{
|
|
|
|
lv += view;
|
|
|
|
lv = normalize(lv);
|
|
|
|
|
|
|
|
t = dot(vn, lv);
|
2016-05-26 18:46:12 +10:00
|
|
|
t = 0.5 * t + 0.5;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
t = visifac * spec * pow(t, hard);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void shade_phong_spec(vec3 n, vec3 l, vec3 v, float hard, out float specfac)
|
|
|
|
{
|
|
|
|
vec3 h = normalize(l + v);
|
|
|
|
float rslt = max(dot(h, n), 0.0);
|
|
|
|
|
|
|
|
specfac = pow(rslt, hard);
|
|
|
|
}
|
|
|
|
|
|
|
|
void shade_cooktorr_spec(vec3 n, vec3 l, vec3 v, float hard, out float specfac)
|
|
|
|
{
|
|
|
|
vec3 h = normalize(v + l);
|
|
|
|
float nh = dot(n, h);
|
|
|
|
|
2016-05-23 10:31:36 +02:00
|
|
|
if (nh < 0.0) {
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
specfac = 0.0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
float nv = max(dot(n, v), 0.0);
|
|
|
|
float i = pow(nh, hard);
|
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
i = i / (0.1 + nv);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
specfac = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void shade_blinn_spec(vec3 n, vec3 l, vec3 v, float refrac, float spec_power, out float specfac)
|
|
|
|
{
|
2016-05-23 10:31:36 +02:00
|
|
|
if (refrac < 1.0) {
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
specfac = 0.0;
|
|
|
|
}
|
2016-05-23 10:31:36 +02:00
|
|
|
else if (spec_power == 0.0) {
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
specfac = 0.0;
|
|
|
|
}
|
|
|
|
else {
|
2016-05-26 18:46:12 +10:00
|
|
|
if (spec_power < 100.0)
|
|
|
|
spec_power = sqrt(1.0 / spec_power);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
else
|
2016-05-26 18:46:12 +10:00
|
|
|
spec_power = 10.0 / spec_power;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
vec3 h = normalize(v + l);
|
|
|
|
float nh = dot(n, h);
|
2016-05-23 10:31:36 +02:00
|
|
|
if (nh < 0.0) {
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
specfac = 0.0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
float nv = max(dot(n, v), 0.01);
|
|
|
|
float nl = dot(n, l);
|
2016-05-23 10:31:36 +02:00
|
|
|
if (nl <= 0.01) {
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
specfac = 0.0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
float vh = max(dot(v, h), 0.01);
|
|
|
|
|
|
|
|
float a = 1.0;
|
2016-05-26 18:46:12 +10:00
|
|
|
float b = (2.0 * nh * nv) / vh;
|
|
|
|
float c = (2.0 * nh * nl) / vh;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2008-09-05 20:34:35 +00:00
|
|
|
float g = 0.0;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2016-05-23 10:31:36 +02:00
|
|
|
if (a < b && a < c) g = a;
|
|
|
|
else if (b < a && b < c) g = b;
|
|
|
|
else if (c < a && c < b) g = c;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2016-05-23 19:56:50 +10:00
|
|
|
float p = sqrt(((refrac * refrac) + (vh * vh) - 1.0));
|
|
|
|
float f = ((((p - vh) * (p - vh)) / ((p + vh) * (p + vh))) *
|
|
|
|
(1.0 + ((((vh * (p + vh)) - 1.0) * ((vh * (p + vh)) - 1.0)) /
|
|
|
|
(((vh * (p - vh)) + 1.0) * ((vh * (p - vh)) + 1.0)))));
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
float ang = acos(nh);
|
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
specfac = max(f * g * exp_blender((-(ang * ang) / (2.0 * spec_power * spec_power))), 0.0);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void shade_wardiso_spec(vec3 n, vec3 l, vec3 v, float rms, out float specfac)
|
|
|
|
{
|
|
|
|
vec3 h = normalize(l + v);
|
|
|
|
float nh = max(dot(n, h), 0.001);
|
|
|
|
float nv = max(dot(n, v), 0.001);
|
|
|
|
float nl = max(dot(n, l), 0.001);
|
|
|
|
float angle = tan(acos(nh));
|
|
|
|
float alpha = max(rms, 0.001);
|
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
specfac = nl * (1.0 / (4.0 * M_PI * alpha * alpha)) * (exp_blender(-(angle * angle) / (alpha * alpha)) / (sqrt(nv * nl)));
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void shade_toon_spec(vec3 n, vec3 l, vec3 v, float size, float tsmooth, out float specfac)
|
|
|
|
{
|
|
|
|
vec3 h = normalize(l + v);
|
|
|
|
float rslt = dot(h, n);
|
|
|
|
float ang = acos(rslt);
|
|
|
|
|
2016-05-23 10:31:36 +02:00
|
|
|
if (ang < size) rslt = 1.0;
|
|
|
|
else if (ang >= (size + tsmooth) || tsmooth == 0.0) rslt = 0.0;
|
2016-05-26 18:46:12 +10:00
|
|
|
else rslt = 1.0 - ((ang - size) / tsmooth);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
specfac = rslt;
|
|
|
|
}
|
|
|
|
|
|
|
|
void shade_spec_area_inp(float specfac, float inp, out float outspecfac)
|
|
|
|
{
|
2016-05-26 18:46:12 +10:00
|
|
|
outspecfac = specfac * inp;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void shade_spec_t(float shadfac, float spec, float visifac, float specfac, out float t)
|
|
|
|
{
|
2016-05-26 18:46:12 +10:00
|
|
|
t = shadfac * spec * visifac * specfac;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void shade_add_spec(float t, vec3 lampcol, vec3 speccol, out vec3 outcol)
|
|
|
|
{
|
2016-05-26 18:46:12 +10:00
|
|
|
outcol = t * lampcol * speccol;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
2016-03-21 14:36:33 +03:00
|
|
|
void shade_add_mirror(vec3 mir, vec4 refcol, vec3 combined, out vec3 result)
|
|
|
|
{
|
2016-05-23 19:56:50 +10:00
|
|
|
result = mir * refcol.gba + (vec3(1.0) - mir * refcol.rrr) * combined;
|
2016-03-21 14:36:33 +03:00
|
|
|
}
|
|
|
|
|
2014-11-09 15:22:44 +01:00
|
|
|
void alpha_spec_correction(vec3 spec, float spectra, float alpha, out float outalpha)
|
|
|
|
{
|
|
|
|
if (spectra > 0.0) {
|
|
|
|
float t = clamp(max(max(spec.r, spec.g), spec.b) * spectra, 0.0, 1.0);
|
|
|
|
outalpha = (1.0 - t) * alpha + t;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
outalpha = alpha;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
void shade_add(vec4 col1, vec4 col2, out vec4 outcol)
|
|
|
|
{
|
|
|
|
outcol = col1 + col2;
|
|
|
|
}
|
|
|
|
|
|
|
|
void shade_madd(vec4 col, vec4 col1, vec4 col2, out vec4 outcol)
|
|
|
|
{
|
2016-05-26 18:46:12 +10:00
|
|
|
outcol = col + col1 * col2;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
2011-05-02 14:01:45 +00:00
|
|
|
|
|
|
|
void shade_add_clamped(vec4 col1, vec4 col2, out vec4 outcol)
|
|
|
|
{
|
2017-05-19 14:20:08 -04:00
|
|
|
outcol = col1 + max(col2, vec4(0.0));
|
2011-05-02 14:01:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void shade_madd_clamped(vec4 col, vec4 col1, vec4 col2, out vec4 outcol)
|
|
|
|
{
|
2017-05-19 14:20:08 -04:00
|
|
|
outcol = col + max(col1 * col2, vec4(0.0));
|
2011-05-02 14:01:45 +00:00
|
|
|
}
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2016-08-30 17:15:26 +03:00
|
|
|
void env_apply(vec4 col, vec3 hor, vec3 zen, vec4 f, mat4 vm, vec3 vn, out vec4 outcol)
|
Environment lighting for the GLSL mode
Environment lighting (aka ambient) is a key component of any renderer.
It's implemented like the Environment lighting of BI render for Approximate Gather mode. It support "Sky Color" and "White" Environment lighting modes.
It would be great if the user could see actual lighting conditions right in the Blender viewport instead of waiting for the renderer to complete the final image, exporting for external renderer or for a game engine.
Before:
{F113921}
After:
{F113922}
Example file: {F319013}
Original author: valentin_b4w
Alexander (Blend4Web Team)
Reviewers: valentin_b4w, campbellbarton, merwin, brecht
Reviewed By: brecht
Subscribers: panzergame, youle, duarteframos, AlexKowel, yurikovelenov, dingto, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx
Differential Revision: https://developer.blender.org/D810
2016-07-04 11:01:32 +03:00
|
|
|
{
|
|
|
|
vec3 vv = normalize(vm[2].xyz);
|
|
|
|
float skyfac = 0.5 * (1.0 + dot(vn, -vv));
|
2016-08-30 17:15:26 +03:00
|
|
|
outcol = col + f * vec4(mix(hor, zen, skyfac), 0);
|
Environment lighting for the GLSL mode
Environment lighting (aka ambient) is a key component of any renderer.
It's implemented like the Environment lighting of BI render for Approximate Gather mode. It support "Sky Color" and "White" Environment lighting modes.
It would be great if the user could see actual lighting conditions right in the Blender viewport instead of waiting for the renderer to complete the final image, exporting for external renderer or for a game engine.
Before:
{F113921}
After:
{F113922}
Example file: {F319013}
Original author: valentin_b4w
Alexander (Blend4Web Team)
Reviewers: valentin_b4w, campbellbarton, merwin, brecht
Reviewed By: brecht
Subscribers: panzergame, youle, duarteframos, AlexKowel, yurikovelenov, dingto, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx
Differential Revision: https://developer.blender.org/D810
2016-07-04 11:01:32 +03:00
|
|
|
}
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
void shade_maddf(vec4 col, float f, vec4 col1, out vec4 outcol)
|
|
|
|
{
|
2016-05-26 18:46:12 +10:00
|
|
|
outcol = col + f * col1;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void shade_mul(vec4 col1, vec4 col2, out vec4 outcol)
|
|
|
|
{
|
2016-05-26 18:46:12 +10:00
|
|
|
outcol = col1 * col2;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void shade_mul_value(float fac, vec4 col, out vec4 outcol)
|
|
|
|
{
|
2016-05-26 18:46:12 +10:00
|
|
|
outcol = col * fac;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
2014-10-07 11:06:38 +02:00
|
|
|
void shade_mul_value_v3(float fac, vec3 col, out vec3 outcol)
|
|
|
|
{
|
2016-05-26 18:46:12 +10:00
|
|
|
outcol = col * fac;
|
2014-10-07 11:06:38 +02:00
|
|
|
}
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
void shade_obcolor(vec4 col, vec4 obcol, out vec4 outcol)
|
|
|
|
{
|
2016-05-26 18:46:12 +10:00
|
|
|
outcol = vec4(col.rgb * obcol.rgb, col.a);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ramp_rgbtobw(vec3 color, out float outval)
|
|
|
|
{
|
2017-05-19 14:20:08 -04:00
|
|
|
outval = dot(color, vec3(0.3, 0.58, 0.12));
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
2014-05-30 16:57:15 +09:00
|
|
|
void shade_only_shadow(float i, float shadfac, float energy, vec3 shadcol, out vec3 outshadrgb)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
2016-05-26 18:46:12 +10:00
|
|
|
outshadrgb = i * energy * (1.0 - shadfac) * (vec3(1.0) - shadcol);
|
2008-09-05 15:08:01 +00:00
|
|
|
}
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2014-05-30 16:57:15 +09:00
|
|
|
void shade_only_shadow_diffuse(vec3 shadrgb, vec3 rgb, vec4 diff, out vec4 outdiff)
|
2008-09-05 15:08:01 +00:00
|
|
|
{
|
2016-05-26 18:46:12 +10:00
|
|
|
outdiff = diff - vec4(rgb * shadrgb, 0.0);
|
2008-09-05 15:08:01 +00:00
|
|
|
}
|
|
|
|
|
2014-05-30 16:57:15 +09:00
|
|
|
void shade_only_shadow_specular(vec3 shadrgb, vec3 specrgb, vec4 spec, out vec4 outspec)
|
2008-09-05 15:08:01 +00:00
|
|
|
{
|
2016-05-26 18:46:12 +10:00
|
|
|
outspec = spec - vec4(specrgb * shadrgb, 0.0);
|
2014-05-30 16:57:15 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
void shade_clamp_positive(vec4 col, out vec4 outcol)
|
|
|
|
{
|
|
|
|
outcol = max(col, vec4(0.0));
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
2016-05-23 19:56:50 +10:00
|
|
|
void test_shadowbuf(
|
|
|
|
vec3 rco, sampler2DShadow shadowmap, mat4 shadowpersmat, float shadowbias, float inp,
|
|
|
|
out float result)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
2016-05-23 10:31:36 +02:00
|
|
|
if (inp <= 0.0) {
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
result = 0.0;
|
|
|
|
}
|
|
|
|
else {
|
2016-05-26 18:46:12 +10:00
|
|
|
vec4 co = shadowpersmat * vec4(rco, 1.0);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
//float bias = (1.5 - inp*inp)*shadowbias;
|
2016-05-26 18:46:12 +10:00
|
|
|
co.z -= shadowbias * co.w;
|
|
|
|
|
2017-05-17 10:46:42 +10:00
|
|
|
if (co.w > 0.0 && co.x > 0.0 && co.x / co.w < 1.0 && co.y > 0.0 && co.y / co.w < 1.0) {
|
2017-05-09 16:29:48 +02:00
|
|
|
result = textureProj(shadowmap, co);
|
2017-05-17 10:46:42 +10:00
|
|
|
}
|
|
|
|
else {
|
2012-05-01 02:50:17 +00:00
|
|
|
result = 1.0;
|
2017-05-17 10:46:42 +10:00
|
|
|
}
|
2012-05-01 02:50:17 +00:00
|
|
|
}
|
|
|
|
}
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2016-05-23 19:56:50 +10:00
|
|
|
void test_shadowbuf_vsm(
|
|
|
|
vec3 rco, sampler2D shadowmap, mat4 shadowpersmat, float shadowbias, float bleedbias, float inp,
|
|
|
|
out float result)
|
2012-05-01 02:50:17 +00:00
|
|
|
{
|
2016-05-23 10:31:36 +02:00
|
|
|
if (inp <= 0.0) {
|
2012-05-01 02:50:17 +00:00
|
|
|
result = 0.0;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
2012-05-01 02:50:17 +00:00
|
|
|
else {
|
2016-05-26 18:46:12 +10:00
|
|
|
vec4 co = shadowpersmat * vec4(rco, 1.0);
|
|
|
|
if (co.w > 0.0 && co.x > 0.0 && co.x / co.w < 1.0 && co.y > 0.0 && co.y / co.w < 1.0) {
|
2017-05-19 10:23:07 -04:00
|
|
|
vec2 moments = textureProj(shadowmap, co).rg;
|
2016-05-26 18:46:12 +10:00
|
|
|
float dist = co.z / co.w;
|
2012-05-01 02:50:17 +00:00
|
|
|
float p = 0.0;
|
2016-05-26 18:46:12 +10:00
|
|
|
|
2016-05-23 10:31:36 +02:00
|
|
|
if (dist <= moments.x)
|
2012-05-01 02:50:17 +00:00
|
|
|
p = 1.0;
|
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
float variance = moments.y - (moments.x * moments.x);
|
|
|
|
variance = max(variance, shadowbias / 10.0);
|
2012-05-01 02:50:17 +00:00
|
|
|
|
|
|
|
float d = moments.x - dist;
|
2016-05-26 18:46:12 +10:00
|
|
|
float p_max = variance / (variance + d * d);
|
2012-05-01 02:50:17 +00:00
|
|
|
|
|
|
|
// Now reduce light-bleeding by removing the [0, x] tail and linearly rescaling (x, 1]
|
2016-05-26 18:46:12 +10:00
|
|
|
p_max = clamp((p_max - bleedbias) / (1.0 - bleedbias), 0.0, 1.0);
|
2012-05-01 02:50:17 +00:00
|
|
|
|
|
|
|
result = max(p, p_max);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
result = 1.0;
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2012-05-01 02:50:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-23 19:56:50 +10:00
|
|
|
void shadows_only(
|
|
|
|
vec3 rco, sampler2DShadow shadowmap, mat4 shadowpersmat,
|
|
|
|
float shadowbias, vec3 shadowcolor, float inp,
|
|
|
|
out vec3 result)
|
2013-11-25 20:58:23 +09:00
|
|
|
{
|
|
|
|
result = vec3(1.0);
|
|
|
|
|
2016-05-23 10:31:36 +02:00
|
|
|
if (inp > 0.0) {
|
2013-11-25 20:58:23 +09:00
|
|
|
float shadfac;
|
|
|
|
|
|
|
|
test_shadowbuf(rco, shadowmap, shadowpersmat, shadowbias, inp, shadfac);
|
|
|
|
result -= (1.0 - shadfac) * (vec3(1.0) - shadowcolor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-23 19:56:50 +10:00
|
|
|
void shadows_only_vsm(
|
|
|
|
vec3 rco, sampler2D shadowmap, mat4 shadowpersmat,
|
|
|
|
float shadowbias, float bleedbias, vec3 shadowcolor, float inp,
|
|
|
|
out vec3 result)
|
2013-11-25 20:58:23 +09:00
|
|
|
{
|
|
|
|
result = vec3(1.0);
|
|
|
|
|
2016-05-23 10:31:36 +02:00
|
|
|
if (inp > 0.0) {
|
2013-11-25 20:58:23 +09:00
|
|
|
float shadfac;
|
|
|
|
|
|
|
|
test_shadowbuf_vsm(rco, shadowmap, shadowpersmat, shadowbias, bleedbias, inp, shadfac);
|
|
|
|
result -= (1.0 - shadfac) * (vec3(1.0) - shadowcolor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-01 02:50:17 +00:00
|
|
|
void shade_light_texture(vec3 rco, sampler2D cookie, mat4 shadowpersmat, out vec4 result)
|
|
|
|
{
|
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
vec4 co = shadowpersmat * vec4(rco, 1.0);
|
2012-05-01 02:50:17 +00:00
|
|
|
|
2017-05-19 10:23:07 -04:00
|
|
|
result = textureProj(cookie, co);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void shade_exposure_correct(vec3 col, float linfac, float logfac, out vec3 outcol)
|
|
|
|
{
|
2016-05-26 18:46:12 +10:00
|
|
|
outcol = linfac * (1.0 - exp(col * logfac));
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
2016-05-23 19:56:50 +10:00
|
|
|
void shade_mist_factor(
|
|
|
|
vec3 co, float enable, float miststa, float mistdist, float misttype, float misi,
|
|
|
|
out float outfac)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
2016-05-23 10:31:36 +02:00
|
|
|
if (enable == 1.0) {
|
2015-03-23 22:32:49 +01:00
|
|
|
float fac, zcor;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2017-03-26 21:19:23 -04:00
|
|
|
zcor = (ProjectionMatrix[3][3] == 0.0) ? length(co) : -co[2];
|
2016-05-26 18:46:12 +10:00
|
|
|
|
2015-03-23 22:32:49 +01:00
|
|
|
fac = clamp((zcor - miststa) / mistdist, 0.0, 1.0);
|
2016-05-23 10:31:36 +02:00
|
|
|
if (misttype == 0.0) fac *= fac;
|
2016-05-26 18:46:12 +10:00
|
|
|
else if (misttype == 1.0) ;
|
2015-03-23 22:32:49 +01:00
|
|
|
else fac = sqrt(fac);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2015-03-23 22:32:49 +01:00
|
|
|
outfac = 1.0 - (1.0 - fac) * (1.0 - misi);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
outfac = 0.0;
|
|
|
|
}
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void shade_world_mix(vec3 hor, vec4 col, out vec4 outcol)
|
|
|
|
{
|
|
|
|
float fac = clamp(col.a, 0.0, 1.0);
|
|
|
|
outcol = vec4(mix(hor, col.rgb, fac), col.a);
|
|
|
|
}
|
|
|
|
|
|
|
|
void shade_alpha_opaque(vec4 col, out vec4 outcol)
|
|
|
|
{
|
|
|
|
outcol = vec4(col.rgb, 1.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void shade_alpha_obcolor(vec4 col, vec4 obcol, out vec4 outcol)
|
|
|
|
{
|
2016-05-26 18:46:12 +10:00
|
|
|
outcol = vec4(col.rgb, col.a * obcol.a);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
2011-11-08 11:38:16 +00:00
|
|
|
/*********** NEW SHADER UTILITIES **************/
|
|
|
|
|
2017-04-18 11:43:09 +02:00
|
|
|
float fresnel_dielectric_0(float eta)
|
|
|
|
{
|
|
|
|
/* compute fresnel reflactance at normal incidence => cosi = 1.0 */
|
|
|
|
float A = (eta - 1.0) / (eta + 1.0);
|
|
|
|
|
|
|
|
return A * A;
|
|
|
|
}
|
|
|
|
|
|
|
|
float fresnel_dielectric_cos(float cosi, float eta)
|
2011-11-08 11:38:16 +00:00
|
|
|
{
|
2012-06-05 22:12:17 +00:00
|
|
|
/* compute fresnel reflectance without explicitly computing
|
|
|
|
* the refracted direction */
|
2017-04-18 11:43:09 +02:00
|
|
|
float c = abs(cosi);
|
2012-06-05 22:12:17 +00:00
|
|
|
float g = eta * eta - 1.0 + c * c;
|
|
|
|
float result;
|
|
|
|
|
2016-05-23 10:31:36 +02:00
|
|
|
if (g > 0.0) {
|
2012-06-05 22:12:17 +00:00
|
|
|
g = sqrt(g);
|
2016-05-26 18:46:12 +10:00
|
|
|
float A = (g - c) / (g + c);
|
|
|
|
float B = (c * (g + c) - 1.0) / (c * (g - c) + 1.0);
|
|
|
|
result = 0.5 * A * A * (1.0 + B * B);
|
2012-06-05 22:12:17 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
result = 1.0; /* TIR (no refracted component) */
|
|
|
|
}
|
2011-11-08 11:38:16 +00:00
|
|
|
|
2012-06-05 22:12:17 +00:00
|
|
|
return result;
|
2011-11-08 11:38:16 +00:00
|
|
|
}
|
|
|
|
|
2017-04-18 11:43:09 +02:00
|
|
|
float fresnel_dielectric(vec3 Incoming, vec3 Normal, float eta)
|
|
|
|
{
|
|
|
|
/* compute fresnel reflectance without explicitly computing
|
|
|
|
* the refracted direction */
|
|
|
|
return fresnel_dielectric_cos(dot(Incoming, Normal), eta);
|
|
|
|
}
|
|
|
|
|
2011-11-08 11:38:16 +00:00
|
|
|
float hypot(float x, float y)
|
|
|
|
{
|
2016-05-26 18:46:12 +10:00
|
|
|
return sqrt(x * x + y * y);
|
2011-11-08 11:38:16 +00:00
|
|
|
}
|
|
|
|
|
2016-05-20 15:18:40 +02:00
|
|
|
void generated_from_orco(vec3 orco, out vec3 generated)
|
|
|
|
{
|
2017-07-04 18:02:13 +02:00
|
|
|
#ifdef VOLUMETRICS
|
|
|
|
generated = worldPosition;
|
|
|
|
#else
|
2017-05-17 20:05:21 +02:00
|
|
|
generated = orco;
|
2017-07-04 18:02:13 +02:00
|
|
|
#endif
|
2016-05-20 15:18:40 +02:00
|
|
|
}
|
|
|
|
|
2016-05-30 10:17:55 +02:00
|
|
|
int floor_to_int(float x)
|
|
|
|
{
|
|
|
|
return int(floor(x));
|
|
|
|
}
|
2016-05-30 13:07:11 +02:00
|
|
|
|
|
|
|
int quick_floor(float x)
|
|
|
|
{
|
|
|
|
return int(x) - ((x < 0) ? 1 : 0);
|
|
|
|
}
|
|
|
|
|
2016-05-20 16:13:44 +02:00
|
|
|
float integer_noise(int n)
|
|
|
|
{
|
|
|
|
int nn;
|
|
|
|
n = (n + 1013) & 0x7fffffff;
|
|
|
|
n = (n >> 13) ^ n;
|
|
|
|
nn = (n * (n * n * 60493 + 19990303) + 1376312589) & 0x7fffffff;
|
2016-05-20 18:14:04 +02:00
|
|
|
return 0.5 * (float(nn) / 1073741824.0);
|
2016-05-20 16:13:44 +02:00
|
|
|
}
|
|
|
|
|
2016-05-20 18:05:29 +02:00
|
|
|
uint hash(uint kx, uint ky, uint kz)
|
|
|
|
{
|
2016-05-26 18:46:12 +10:00
|
|
|
#define rot(x, k) (((x) << (k)) | ((x) >> (32 - (k))))
|
|
|
|
#define final(a, b, c) \
|
2016-05-20 18:05:29 +02:00
|
|
|
{ \
|
2016-05-26 18:46:12 +10:00
|
|
|
c ^= b; c -= rot(b, 14); \
|
|
|
|
a ^= c; a -= rot(c, 11); \
|
|
|
|
b ^= a; b -= rot(a, 25); \
|
|
|
|
c ^= b; c -= rot(b, 16); \
|
|
|
|
a ^= c; a -= rot(c, 4); \
|
|
|
|
b ^= a; b -= rot(a, 14); \
|
|
|
|
c ^= b; c -= rot(b, 24); \
|
2016-05-20 18:05:29 +02:00
|
|
|
}
|
|
|
|
// now hash the data!
|
|
|
|
uint a, b, c, len = 3u;
|
|
|
|
a = b = c = 0xdeadbeefu + (len << 2u) + 13u;
|
|
|
|
|
|
|
|
c += kz;
|
|
|
|
b += ky;
|
|
|
|
a += kx;
|
2016-05-26 18:46:12 +10:00
|
|
|
final (a, b, c);
|
2016-05-20 18:05:29 +02:00
|
|
|
|
|
|
|
return c;
|
|
|
|
#undef rot
|
|
|
|
#undef final
|
|
|
|
}
|
|
|
|
|
2016-05-20 18:58:56 +02:00
|
|
|
uint hash(int kx, int ky, int kz)
|
|
|
|
{
|
|
|
|
return hash(uint(kx), uint(ky), uint(kz));
|
|
|
|
}
|
|
|
|
|
2016-05-20 18:05:29 +02:00
|
|
|
float bits_to_01(uint bits)
|
|
|
|
{
|
|
|
|
float x = float(bits) * (1.0 / float(0xffffffffu));
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
|
|
|
|
float cellnoise(vec3 p)
|
|
|
|
{
|
2016-05-30 13:07:11 +02:00
|
|
|
int ix = quick_floor(p.x);
|
|
|
|
int iy = quick_floor(p.y);
|
|
|
|
int iz = quick_floor(p.z);
|
2016-05-20 18:05:29 +02:00
|
|
|
|
|
|
|
return bits_to_01(hash(uint(ix), uint(iy), uint(iz)));
|
|
|
|
}
|
|
|
|
|
|
|
|
vec3 cellnoise_color(vec3 p)
|
|
|
|
{
|
|
|
|
float r = cellnoise(p);
|
|
|
|
float g = cellnoise(vec3(p.y, p.x, p.z));
|
|
|
|
float b = cellnoise(vec3(p.y, p.z, p.x));
|
|
|
|
|
|
|
|
return vec3(r, g, b);
|
|
|
|
}
|
|
|
|
|
2016-05-20 18:58:56 +02:00
|
|
|
float floorfrac(float x, out int i)
|
|
|
|
{
|
|
|
|
i = floor_to_int(x);
|
|
|
|
return x - i;
|
|
|
|
}
|
|
|
|
|
2017-04-18 11:43:09 +02:00
|
|
|
|
|
|
|
/* Principled BSDF operations */
|
|
|
|
|
|
|
|
float sqr(float a)
|
|
|
|
{
|
|
|
|
return a*a;
|
|
|
|
}
|
|
|
|
|
|
|
|
float schlick_fresnel(float u)
|
|
|
|
{
|
|
|
|
float m = clamp(1.0 - u, 0.0, 1.0);
|
|
|
|
float m2 = m * m;
|
|
|
|
return m2 * m2 * m; // pow(m,5)
|
|
|
|
}
|
|
|
|
|
|
|
|
float GTR1(float NdotH, float a)
|
|
|
|
{
|
|
|
|
if (a >= 1.0) return M_1_PI;
|
|
|
|
float a2 = a*a;
|
|
|
|
float t = 1.0 + (a2 - 1.0) * NdotH*NdotH;
|
|
|
|
return (a2 - 1.0) / (M_PI * log(a2) * t);
|
|
|
|
}
|
|
|
|
|
|
|
|
float GTR2(float NdotH, float a)
|
|
|
|
{
|
|
|
|
float a2 = a*a;
|
|
|
|
float t = 1.0 + (a2 - 1.0) * NdotH*NdotH;
|
|
|
|
return a2 / (M_PI * t*t);
|
|
|
|
}
|
|
|
|
|
|
|
|
float GTR2_aniso(float NdotH, float HdotX, float HdotY, float ax, float ay)
|
|
|
|
{
|
|
|
|
return 1.0 / (M_PI * ax*ay * sqr(sqr(HdotX / ax) + sqr(HdotY / ay) + NdotH*NdotH));
|
|
|
|
}
|
|
|
|
|
|
|
|
float smithG_GGX(float NdotV, float alphaG)
|
|
|
|
{
|
|
|
|
float a = alphaG*alphaG;
|
|
|
|
float b = NdotV*NdotV;
|
|
|
|
return 1.0 / (NdotV + sqrt(a + b - a * b));
|
|
|
|
}
|
|
|
|
|
|
|
|
vec3 rotate_vector(vec3 p, vec3 n, float theta) {
|
|
|
|
return (
|
|
|
|
p * cos(theta) + cross(n, p) *
|
|
|
|
sin(theta) + n * dot(p, n) *
|
|
|
|
(1.0 - cos(theta))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-06-30 14:12:25 +02:00
|
|
|
void prepare_tangent(
|
|
|
|
float anisotropic, float anisotropic_rotation, float roughness, vec3 N, vec3 T,
|
|
|
|
out vec3 X, out vec3 Y, out float ax, out float ay)
|
2017-06-29 01:22:23 +02:00
|
|
|
{
|
2017-06-30 14:12:25 +02:00
|
|
|
/* rotate tangent */
|
|
|
|
if (anisotropic_rotation != 0.0) {
|
|
|
|
T = rotate_vector(T, N, anisotropic_rotation * 2.0 * M_PI);
|
|
|
|
}
|
|
|
|
|
|
|
|
Y = normalize(cross(T, N));
|
|
|
|
|
|
|
|
float aspect = sqrt(1.0 - anisotropic * 0.9);
|
|
|
|
float a = sqr(roughness);
|
|
|
|
ax = max(0.001, a / aspect);
|
|
|
|
ay = max(0.001, a * aspect);
|
|
|
|
}
|
|
|
|
|
|
|
|
void convert_metallic_to_specular(vec3 basecol, float metallic, float specular_fac, out vec3 diffuse, out vec3 f0)
|
|
|
|
{
|
|
|
|
vec3 dielectric = vec3(0.034) * specular_fac * 2.0;
|
|
|
|
diffuse = mix(basecol, vec3(0.0), metallic);
|
2017-06-29 01:22:23 +02:00
|
|
|
f0 = mix(dielectric, basecol, metallic);
|
|
|
|
}
|
2017-04-18 11:43:09 +02:00
|
|
|
|
2017-06-30 14:12:25 +02:00
|
|
|
void convert_metallic_to_specular_tinted(
|
|
|
|
vec3 basecol, float metallic, float specular_fac, float specular_tint,
|
|
|
|
out vec3 diffuse, out vec3 f0)
|
|
|
|
{
|
|
|
|
vec3 dielectric = vec3(0.034) * specular_fac * 2.0;
|
|
|
|
float lum = dot(basecol, vec3(0.3, 0.6, 0.1)); /* luminance approx. */
|
|
|
|
vec3 tint = lum > 0 ? basecol / lum : vec3(1.0); /* normalize lum. to isolate hue+sat */
|
|
|
|
f0 = mix(dielectric * mix(vec3(1.0), tint, specular_tint), basecol, metallic);
|
|
|
|
diffuse = mix(basecol, vec3(0.0), metallic);
|
|
|
|
}
|
|
|
|
|
2011-11-08 11:38:16 +00:00
|
|
|
/*********** NEW SHADER NODES ***************/
|
|
|
|
|
|
|
|
#define NUM_LIGHTS 3
|
|
|
|
|
2017-05-05 12:10:59 +02:00
|
|
|
struct glLight {
|
|
|
|
vec4 position;
|
|
|
|
vec4 diffuse;
|
|
|
|
vec4 specular;
|
|
|
|
vec4 halfVector;
|
|
|
|
};
|
|
|
|
|
|
|
|
layout(std140) uniform lightSource {
|
|
|
|
glLight glLightSource[NUM_LIGHTS];
|
|
|
|
};
|
|
|
|
|
2017-07-03 22:08:07 +02:00
|
|
|
#ifndef VOLUMETRICS
|
2011-11-08 11:38:16 +00:00
|
|
|
/* bsdfs */
|
2017-07-03 21:39:52 +02:00
|
|
|
void node_bsdf_diffuse(vec4 color, float roughness, vec3 N, out Closure result)
|
2011-11-08 11:38:16 +00:00
|
|
|
{
|
2017-07-06 13:31:36 +02:00
|
|
|
#ifdef EEVEE_ENGINE
|
|
|
|
vec3 L = eevee_surface_diffuse_lit(N, vec3(1.0), 1.0);
|
2017-07-24 15:36:22 +02:00
|
|
|
vec3 vN = normalize(mat3(ViewMatrix) * N);
|
|
|
|
result = Closure(L * color.rgb, 1.0, vec4(0.0), normal_encode(N, viewCameraVec), -1);
|
2017-07-06 13:31:36 +02:00
|
|
|
#else
|
2011-11-08 11:38:16 +00:00
|
|
|
/* ambient light */
|
|
|
|
vec3 L = vec3(0.2);
|
|
|
|
|
|
|
|
/* directional lights */
|
2016-05-23 10:31:36 +02:00
|
|
|
for (int i = 0; i < NUM_LIGHTS; i++) {
|
2017-05-05 12:10:59 +02:00
|
|
|
vec3 light_position = glLightSource[i].position.xyz;
|
|
|
|
vec3 light_diffuse = glLightSource[i].diffuse.rgb;
|
2011-11-08 11:38:16 +00:00
|
|
|
|
|
|
|
float bsdf = max(dot(N, light_position), 0.0);
|
2016-05-26 18:46:12 +10:00
|
|
|
L += light_diffuse * bsdf;
|
2011-11-08 11:38:16 +00:00
|
|
|
}
|
|
|
|
|
2017-07-03 21:39:52 +02:00
|
|
|
result = Closure(L * color.rgb, 1.0);
|
2017-07-16 23:49:25 +02:00
|
|
|
#endif
|
2011-11-08 11:38:16 +00:00
|
|
|
}
|
|
|
|
|
2017-07-16 23:49:25 +02:00
|
|
|
void node_bsdf_glossy(vec4 color, float roughness, vec3 N, float ssr_id, out Closure result)
|
2011-11-08 11:38:16 +00:00
|
|
|
{
|
2017-07-06 13:31:36 +02:00
|
|
|
#ifdef EEVEE_ENGINE
|
2017-07-16 23:49:25 +02:00
|
|
|
vec3 ssr_spec;
|
2017-07-20 16:54:57 +02:00
|
|
|
roughness = sqrt(roughness);
|
2017-07-16 23:49:25 +02:00
|
|
|
vec3 L = eevee_surface_glossy_lit(N, vec3(1.0), roughness, 1.0, int(ssr_id), ssr_spec);
|
2017-07-17 13:39:03 +02:00
|
|
|
vec3 vN = normalize(mat3(ViewMatrix) * N);
|
|
|
|
result = Closure(L * color.rgb, 1.0, vec4(ssr_spec * color.rgb, roughness), normal_encode(vN, viewCameraVec), int(ssr_id));
|
2017-07-06 13:31:36 +02:00
|
|
|
#else
|
2011-11-14 17:31:47 +00:00
|
|
|
/* ambient light */
|
|
|
|
vec3 L = vec3(0.2);
|
2011-11-08 11:38:16 +00:00
|
|
|
|
2017-07-06 13:31:36 +02:00
|
|
|
direction_transform_m4v3(N, ViewMatrix, N);
|
|
|
|
|
2011-11-08 11:38:16 +00:00
|
|
|
/* directional lights */
|
2016-05-23 10:31:36 +02:00
|
|
|
for (int i = 0; i < NUM_LIGHTS; i++) {
|
2017-05-05 12:10:59 +02:00
|
|
|
vec3 light_position = glLightSource[i].position.xyz;
|
|
|
|
vec3 H = glLightSource[i].halfVector.xyz;
|
|
|
|
vec3 light_diffuse = glLightSource[i].diffuse.rgb;
|
|
|
|
vec3 light_specular = glLightSource[i].specular.rgb;
|
2011-11-08 11:38:16 +00:00
|
|
|
|
2011-11-14 17:31:47 +00:00
|
|
|
/* we mix in some diffuse so low roughness still shows up */
|
2016-05-26 18:46:12 +10:00
|
|
|
float bsdf = 0.5 * pow(max(dot(N, H), 0.0), 1.0 / roughness);
|
|
|
|
bsdf += 0.5 * max(dot(N, light_position), 0.0);
|
|
|
|
L += light_specular * bsdf;
|
2011-11-08 11:38:16 +00:00
|
|
|
}
|
|
|
|
|
2017-07-03 21:39:52 +02:00
|
|
|
result = Closure(L * color.rgb, 1.0);
|
2017-07-16 23:49:25 +02:00
|
|
|
#endif
|
2011-11-08 11:38:16 +00:00
|
|
|
}
|
|
|
|
|
2016-05-23 19:56:50 +10:00
|
|
|
void node_bsdf_anisotropic(
|
|
|
|
vec4 color, float roughness, float anisotropy, float rotation, vec3 N, vec3 T,
|
2017-07-03 21:39:52 +02:00
|
|
|
out Closure result)
|
2011-11-08 11:38:16 +00:00
|
|
|
{
|
2011-11-14 17:31:47 +00:00
|
|
|
node_bsdf_diffuse(color, 0.0, N, result);
|
2011-11-08 11:38:16 +00:00
|
|
|
}
|
|
|
|
|
2017-07-03 21:39:52 +02:00
|
|
|
void node_bsdf_glass(vec4 color, float roughness, float ior, vec3 N, out Closure result)
|
2011-11-08 11:38:16 +00:00
|
|
|
{
|
2011-11-14 17:31:47 +00:00
|
|
|
node_bsdf_diffuse(color, 0.0, N, result);
|
2011-11-08 11:38:16 +00:00
|
|
|
}
|
|
|
|
|
2017-07-03 21:39:52 +02:00
|
|
|
void node_bsdf_toon(vec4 color, float size, float tsmooth, vec3 N, out Closure result)
|
2013-05-23 17:45:20 +00:00
|
|
|
{
|
|
|
|
node_bsdf_diffuse(color, 0.0, N, result);
|
|
|
|
}
|
|
|
|
|
2017-07-16 23:49:25 +02:00
|
|
|
#ifndef EEVEE_ENGINE
|
2017-04-18 11:43:09 +02:00
|
|
|
void node_bsdf_principled(vec4 base_color, float subsurface, vec3 subsurface_radius, vec4 subsurface_color, float metallic, float specular,
|
|
|
|
float specular_tint, float roughness, float anisotropic, float anisotropic_rotation, float sheen, float sheen_tint, float clearcoat,
|
2017-07-03 21:39:52 +02:00
|
|
|
float clearcoat_roughness, float ior, float transmission, float transmission_roughness, vec3 N, vec3 CN, vec3 T, vec3 I, out Closure result)
|
2017-04-18 11:43:09 +02:00
|
|
|
{
|
2017-06-30 14:12:25 +02:00
|
|
|
vec3 X, Y;
|
|
|
|
float ax, ay;
|
|
|
|
prepare_tangent(anisotropic, anisotropic_rotation, roughness, N, T, X, Y, ax, ay);
|
2017-06-29 15:49:51 +02:00
|
|
|
|
2017-04-18 11:43:09 +02:00
|
|
|
/* ambient light */
|
|
|
|
// TODO: set ambient light to an appropriate value
|
2017-07-02 17:59:31 +02:00
|
|
|
vec3 L = mix(0.1, 0.03, metallic) * mix(base_color.rgb, subsurface_color.rgb, subsurface * (1.0 - metallic));
|
2017-04-18 11:43:09 +02:00
|
|
|
|
|
|
|
float eta = (2.0 / (1.0 - sqrt(0.08 * specular))) - 1.0;
|
|
|
|
|
|
|
|
/* set the viewing vector */
|
2017-06-26 12:14:19 +02:00
|
|
|
vec3 V = (ProjectionMatrix[3][3] == 0.0) ? -normalize(I) : vec3(0.0, 0.0, 1.0);
|
2017-04-18 11:43:09 +02:00
|
|
|
|
|
|
|
/* fresnel normalization parameters */
|
|
|
|
float F0 = fresnel_dielectric_0(eta);
|
|
|
|
float F0_norm = 1.0 / (1.0 - F0);
|
|
|
|
|
|
|
|
/* directional lights */
|
|
|
|
for (int i = 0; i < NUM_LIGHTS; i++) {
|
2017-05-05 12:10:59 +02:00
|
|
|
vec3 light_position_world = glLightSource[i].position.xyz;
|
2017-07-02 17:59:31 +02:00
|
|
|
vec3 light_position = normalize(light_position_world);
|
2017-04-18 11:43:09 +02:00
|
|
|
|
|
|
|
vec3 H = normalize(light_position + V);
|
|
|
|
|
2017-07-03 15:07:14 +02:00
|
|
|
vec3 light_diffuse = glLightSource[i].diffuse.rgb;
|
2017-05-05 12:10:59 +02:00
|
|
|
vec3 light_specular = glLightSource[i].specular.rgb;
|
2017-04-18 11:43:09 +02:00
|
|
|
|
|
|
|
float NdotL = dot(N, light_position);
|
|
|
|
float NdotV = dot(N, V);
|
|
|
|
float LdotH = dot(light_position, H);
|
|
|
|
|
|
|
|
vec3 diffuse_and_specular_bsdf = vec3(0.0);
|
|
|
|
if (NdotL >= 0.0 && NdotV >= 0.0) {
|
|
|
|
float NdotH = dot(N, H);
|
|
|
|
|
2017-05-19 14:20:08 -04:00
|
|
|
float Cdlum = dot(base_color.rgb, vec3(0.3, 0.6, 0.1)); // luminance approx.
|
2017-04-18 11:43:09 +02:00
|
|
|
|
|
|
|
vec3 Ctint = Cdlum > 0 ? base_color.rgb / Cdlum : vec3(1.0); // normalize lum. to isolate hue+sat
|
|
|
|
vec3 Cspec0 = mix(specular * 0.08 * mix(vec3(1.0), Ctint, specular_tint), base_color.rgb, metallic);
|
|
|
|
vec3 Csheen = mix(vec3(1.0), Ctint, sheen_tint);
|
|
|
|
|
|
|
|
// Diffuse fresnel - go from 1 at normal incidence to .5 at grazing
|
|
|
|
// and mix in diffuse retro-reflection based on roughness
|
|
|
|
|
|
|
|
float FL = schlick_fresnel(NdotL), FV = schlick_fresnel(NdotV);
|
|
|
|
float Fd90 = 0.5 + 2.0 * LdotH*LdotH * roughness;
|
|
|
|
float Fd = mix(1.0, Fd90, FL) * mix(1.0, Fd90, FV);
|
|
|
|
|
|
|
|
// Based on Hanrahan-Krueger brdf approximation of isotropic bssrdf
|
|
|
|
// 1.25 scale is used to (roughly) preserve albedo
|
|
|
|
// Fss90 used to "flatten" retroreflection based on roughness
|
|
|
|
float Fss90 = LdotH*LdotH * roughness;
|
|
|
|
float Fss = mix(1.0, Fss90, FL) * mix(1.0, Fss90, FV);
|
|
|
|
float ss = 1.25 * (Fss * (1.0 / (NdotL + NdotV) - 0.5) + 0.5);
|
|
|
|
|
|
|
|
// specular
|
|
|
|
float Ds = GTR2_aniso(NdotH, dot(H, X), dot(H, Y), ax, ay); //GTR2(NdotH, a);
|
|
|
|
float FH = (fresnel_dielectric_cos(LdotH, eta) - F0) * F0_norm;
|
|
|
|
vec3 Fs = mix(Cspec0, vec3(1.0), FH);
|
|
|
|
float roughg = sqr(roughness * 0.5 + 0.5);
|
|
|
|
float Gs = smithG_GGX(NdotL, roughg) * smithG_GGX(NdotV, roughg);
|
|
|
|
|
|
|
|
// sheen
|
|
|
|
vec3 Fsheen = schlick_fresnel(LdotH) * sheen * Csheen;
|
|
|
|
|
2017-07-02 17:59:31 +02:00
|
|
|
vec3 diffuse_bsdf = (mix(Fd * base_color.rgb, ss * subsurface_color.rgb, subsurface) + Fsheen) * light_diffuse;
|
|
|
|
vec3 specular_bsdf = Gs * Fs * Ds * light_specular;
|
|
|
|
diffuse_and_specular_bsdf = diffuse_bsdf * (1.0 - metallic) + specular_bsdf;
|
2017-04-18 11:43:09 +02:00
|
|
|
}
|
|
|
|
diffuse_and_specular_bsdf *= max(NdotL, 0.0);
|
|
|
|
|
|
|
|
float CNdotL = dot(CN, light_position);
|
|
|
|
float CNdotV = dot(CN, V);
|
|
|
|
|
|
|
|
vec3 clearcoat_bsdf = vec3(0.0);
|
|
|
|
if (CNdotL >= 0.0 && CNdotV >= 0.0 && clearcoat > 0.0) {
|
|
|
|
float CNdotH = dot(CN, H);
|
|
|
|
//float FH = schlick_fresnel(LdotH);
|
|
|
|
|
|
|
|
// clearcoat (ior = 1.5 -> F0 = 0.04)
|
2017-06-21 19:24:57 +02:00
|
|
|
float Dr = GTR1(CNdotH, sqr(clearcoat_roughness));
|
2017-04-18 11:43:09 +02:00
|
|
|
float Fr = fresnel_dielectric_cos(LdotH, 1.5); //mix(0.04, 1.0, FH);
|
|
|
|
float Gr = smithG_GGX(CNdotL, 0.25) * smithG_GGX(CNdotV, 0.25);
|
|
|
|
|
2017-07-02 17:59:31 +02:00
|
|
|
clearcoat_bsdf = clearcoat * Gr * Fr * Dr * vec3(0.25) * light_specular;
|
2017-04-18 11:43:09 +02:00
|
|
|
}
|
|
|
|
clearcoat_bsdf *= max(CNdotL, 0.0);
|
|
|
|
|
2017-07-02 17:59:31 +02:00
|
|
|
L += diffuse_and_specular_bsdf + clearcoat_bsdf;
|
2017-04-18 11:43:09 +02:00
|
|
|
}
|
|
|
|
|
2017-07-03 21:39:52 +02:00
|
|
|
result = Closure(L, 1.0);
|
2017-06-30 14:12:25 +02:00
|
|
|
}
|
2017-07-16 23:49:25 +02:00
|
|
|
#endif
|
2017-06-30 14:12:25 +02:00
|
|
|
|
|
|
|
void node_bsdf_principled_simple(vec4 base_color, float subsurface, vec3 subsurface_radius, vec4 subsurface_color, float metallic, float specular,
|
|
|
|
float specular_tint, float roughness, float anisotropic, float anisotropic_rotation, float sheen, float sheen_tint, float clearcoat,
|
2017-07-15 16:09:44 +02:00
|
|
|
float clearcoat_roughness, float ior, float transmission, float transmission_roughness, vec3 N, vec3 CN, vec3 T, vec3 I, float ssr_id, out Closure result)
|
2017-06-30 14:12:25 +02:00
|
|
|
{
|
|
|
|
#ifdef EEVEE_ENGINE
|
2017-07-16 23:49:25 +02:00
|
|
|
vec3 diffuse, f0, ssr_spec;
|
2017-06-30 14:12:25 +02:00
|
|
|
convert_metallic_to_specular_tinted(base_color.rgb, metallic, specular, specular_tint, diffuse, f0);
|
|
|
|
|
2017-07-16 23:49:25 +02:00
|
|
|
vec3 L = eevee_surface_lit(N, diffuse, f0, roughness, 1.0, int(ssr_id), ssr_spec);
|
2017-07-17 13:39:03 +02:00
|
|
|
vec3 vN = normalize(mat3(ViewMatrix) * N);
|
|
|
|
result = Closure(L, 1.0, vec4(ssr_spec, roughness), normal_encode(vN, viewCameraVec), int(ssr_id));
|
2017-06-30 14:12:25 +02:00
|
|
|
#else
|
|
|
|
node_bsdf_principled(base_color, subsurface, subsurface_radius, subsurface_color, metallic, specular,
|
|
|
|
specular_tint, roughness, anisotropic, anisotropic_rotation, sheen, sheen_tint, clearcoat,
|
|
|
|
clearcoat_roughness, ior, transmission, transmission_roughness, N, CN, T, I, result);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void node_bsdf_principled_clearcoat(vec4 base_color, float subsurface, vec3 subsurface_radius, vec4 subsurface_color, float metallic, float specular,
|
|
|
|
float specular_tint, float roughness, float anisotropic, float anisotropic_rotation, float sheen, float sheen_tint, float clearcoat,
|
2017-07-15 16:09:44 +02:00
|
|
|
float clearcoat_roughness, float ior, float transmission, float transmission_roughness, vec3 N, vec3 CN, vec3 T, vec3 I, float ssr_id, out Closure result)
|
2017-06-30 14:12:25 +02:00
|
|
|
{
|
|
|
|
#ifdef EEVEE_ENGINE
|
2017-07-16 23:49:25 +02:00
|
|
|
vec3 diffuse, f0, ssr_spec;
|
2017-06-30 14:12:25 +02:00
|
|
|
convert_metallic_to_specular_tinted(base_color.rgb, metallic, specular, specular_tint, diffuse, f0);
|
|
|
|
|
|
|
|
clearcoat *= 0.25;
|
|
|
|
#if 0 /* Wait until temporal AA (aka. denoising) */
|
|
|
|
|
|
|
|
vec3 X, Y;
|
|
|
|
float ax, ay;
|
|
|
|
prepare_tangent(anisotropic, anisotropic_rotation, roughness, N, T, X, Y, ax, ay);
|
|
|
|
|
|
|
|
/* Distribute N in anisotropy direction. */
|
|
|
|
vec4 surface_color = vec4(0.0);
|
|
|
|
for (float i = 0.0; i < 5.0; ++i) {
|
|
|
|
vec4 rand = texture(utilTex, vec3((gl_FragCoord.xy + i) / LUT_SIZE, 2.0));
|
|
|
|
|
|
|
|
float tmp = sqrt( rand.x / (1.0 - rand.x) );
|
|
|
|
float x = (ax > ay ? ax : 0.0) * tmp * rand.z;
|
|
|
|
float y = (ay > ax ? ay : 0.0) * tmp * rand.w;
|
|
|
|
vec3 Ht = normalize(vec3(x, y, 1.0));
|
|
|
|
N = tangent_to_world(Ht, N, Y, X);
|
|
|
|
|
|
|
|
if (dot(N, cameraVec) > 0) {
|
2017-07-15 16:09:44 +02:00
|
|
|
surface_color.rgb += eevee_surface_clearcoat_lit(N, diffuse, f0, sqrt(min(ax, ay)), CN, clearcoat, clearcoat_roughness, 1.0, ssr_id);
|
2017-06-30 14:12:25 +02:00
|
|
|
surface_color.a += 1.0;
|
|
|
|
}
|
|
|
|
}
|
2017-07-03 21:39:52 +02:00
|
|
|
result = Closure(surface_color.rgb / surface_color.a, 1.0);
|
2017-06-30 14:12:25 +02:00
|
|
|
#else
|
2017-07-16 23:49:25 +02:00
|
|
|
|
|
|
|
vec3 L = eevee_surface_clearcoat_lit(N, diffuse, f0, roughness, CN, clearcoat, clearcoat_roughness, 1.0, int(ssr_id), ssr_spec);
|
2017-07-17 13:39:03 +02:00
|
|
|
vec3 vN = normalize(mat3(ViewMatrix) * N);
|
|
|
|
result = Closure(L, 1.0, vec4(ssr_spec, roughness), normal_encode(vN, viewCameraVec), int(ssr_id));
|
2017-06-30 14:12:25 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#else
|
|
|
|
node_bsdf_principled(base_color, subsurface, subsurface_radius, subsurface_color, metallic, specular,
|
|
|
|
specular_tint, roughness, anisotropic, anisotropic_rotation, sheen, sheen_tint, clearcoat,
|
|
|
|
clearcoat_roughness, ior, transmission, transmission_roughness, N, CN, T, I, result);
|
2017-06-29 01:22:23 +02:00
|
|
|
#endif
|
2017-04-18 11:43:09 +02:00
|
|
|
}
|
|
|
|
|
2017-07-03 21:39:52 +02:00
|
|
|
void node_bsdf_translucent(vec4 color, vec3 N, out Closure result)
|
2011-11-08 11:38:16 +00:00
|
|
|
{
|
2011-11-14 17:31:47 +00:00
|
|
|
node_bsdf_diffuse(color, 0.0, N, result);
|
2011-11-08 11:38:16 +00:00
|
|
|
}
|
|
|
|
|
2017-07-03 21:39:52 +02:00
|
|
|
void node_bsdf_transparent(vec4 color, out Closure result)
|
2011-11-08 11:38:16 +00:00
|
|
|
{
|
|
|
|
/* this isn't right */
|
2017-07-03 21:39:52 +02:00
|
|
|
result.radiance = color.rgb;
|
2017-07-09 12:01:29 +02:00
|
|
|
result.opacity = color.a;
|
2011-11-08 11:38:16 +00:00
|
|
|
}
|
|
|
|
|
2017-07-03 21:39:52 +02:00
|
|
|
void node_bsdf_velvet(vec4 color, float sigma, vec3 N, out Closure result)
|
2011-11-08 11:38:16 +00:00
|
|
|
{
|
2011-11-14 17:31:47 +00:00
|
|
|
node_bsdf_diffuse(color, 0.0, N, result);
|
2011-11-08 11:38:16 +00:00
|
|
|
}
|
|
|
|
|
2016-05-23 19:56:50 +10:00
|
|
|
void node_subsurface_scattering(
|
|
|
|
vec4 color, float scale, vec3 radius, float sharpen, float texture_blur, vec3 N,
|
2017-07-03 21:39:52 +02:00
|
|
|
out Closure result)
|
2013-04-01 20:26:52 +00:00
|
|
|
{
|
|
|
|
node_bsdf_diffuse(color, 0.0, N, result);
|
|
|
|
}
|
|
|
|
|
2017-07-16 23:49:25 +02:00
|
|
|
/* Unsupported for now */
|
|
|
|
#ifndef EEVEE_ENGINE
|
2017-07-03 21:39:52 +02:00
|
|
|
void node_bsdf_hair(vec4 color, float offset, float roughnessu, float roughnessv, vec3 tangent, out Closure result)
|
2013-09-15 23:58:00 +00:00
|
|
|
{
|
2017-07-03 21:39:52 +02:00
|
|
|
result = Closure(color.rgb, color.a);
|
2013-09-15 23:58:00 +00:00
|
|
|
}
|
|
|
|
|
2017-07-03 21:39:52 +02:00
|
|
|
void node_bsdf_refraction(vec4 color, float roughness, float ior, vec3 N, out Closure result)
|
2015-07-28 11:15:29 +02:00
|
|
|
{
|
|
|
|
node_bsdf_diffuse(color, 0.0, N, result);
|
|
|
|
}
|
|
|
|
|
2017-07-03 21:39:52 +02:00
|
|
|
void node_ambient_occlusion(vec4 color, out Closure result)
|
2015-07-28 15:56:34 +02:00
|
|
|
{
|
2017-07-03 21:39:52 +02:00
|
|
|
result = Closure(color.rgb, color.a);
|
2015-07-28 15:56:34 +02:00
|
|
|
}
|
2017-07-16 23:49:25 +02:00
|
|
|
#endif /* EEVEE_ENGINE */
|
|
|
|
|
2017-07-03 22:08:07 +02:00
|
|
|
#endif /* VOLUMETRICS */
|
2015-07-28 15:56:34 +02:00
|
|
|
|
2011-11-08 11:38:16 +00:00
|
|
|
/* emission */
|
|
|
|
|
2017-07-03 21:39:52 +02:00
|
|
|
void node_emission(vec4 color, float strength, vec3 N, out Closure result)
|
2011-11-08 11:38:16 +00:00
|
|
|
{
|
2017-07-03 22:08:07 +02:00
|
|
|
#ifndef VOLUMETRICS
|
2017-07-03 21:39:52 +02:00
|
|
|
color *= strength;
|
2017-07-16 23:49:25 +02:00
|
|
|
#ifdef EEVEE_ENGINE
|
2017-07-24 15:36:22 +02:00
|
|
|
result = Closure(color.rgb, color.a, vec4(0.0), normal_encode(N, viewCameraVec), -1);
|
2017-07-16 23:49:25 +02:00
|
|
|
#else
|
2017-07-03 21:39:52 +02:00
|
|
|
result = Closure(color.rgb, color.a);
|
2017-07-16 23:49:25 +02:00
|
|
|
#endif
|
2017-07-03 22:08:07 +02:00
|
|
|
#else
|
|
|
|
result = Closure(vec3(0.0), vec3(0.0), color.rgb * strength, 0.0);
|
|
|
|
#endif
|
2011-11-08 11:38:16 +00:00
|
|
|
}
|
|
|
|
|
2014-11-24 17:18:56 +01:00
|
|
|
/* background */
|
|
|
|
|
|
|
|
void background_transform_to_world(vec3 viewvec, out vec3 worldvec)
|
|
|
|
{
|
2017-03-26 21:19:23 -04:00
|
|
|
vec4 v = (ProjectionMatrix[3][3] == 0.0) ? vec4(viewvec, 1.0) : vec4(0.0, 0.0, 1.0, 1.0);
|
|
|
|
vec4 co_homogenous = (ProjectionMatrixInverse * v);
|
2014-11-24 17:18:56 +01:00
|
|
|
|
|
|
|
vec4 co = vec4(co_homogenous.xyz / co_homogenous.w, 0.0);
|
2017-06-29 20:22:52 +02:00
|
|
|
#if defined(WORLD_BACKGROUND) || defined(PROBE_CAPTURE)
|
2017-05-07 15:22:25 +02:00
|
|
|
worldvec = (ViewMatrixInverse * co).xyz;
|
|
|
|
#else
|
2017-03-26 21:19:23 -04:00
|
|
|
worldvec = (ModelViewMatrixInverse * co).xyz;
|
2017-05-07 15:22:25 +02:00
|
|
|
#endif
|
2014-11-24 17:18:56 +01:00
|
|
|
}
|
|
|
|
|
2017-07-03 21:39:52 +02:00
|
|
|
void node_background(vec4 color, float strength, out Closure result)
|
2014-11-24 17:18:56 +01:00
|
|
|
{
|
2017-07-03 22:08:07 +02:00
|
|
|
#ifndef VOLUMETRICS
|
2017-07-03 21:39:52 +02:00
|
|
|
color *= strength;
|
2017-07-16 23:49:25 +02:00
|
|
|
#ifdef EEVEE_ENGINE
|
|
|
|
result = Closure(color.rgb, color.a, vec4(0.0), vec2(0.0), -1);
|
|
|
|
#else
|
2017-07-03 21:39:52 +02:00
|
|
|
result = Closure(color.rgb, color.a);
|
2017-07-16 23:49:25 +02:00
|
|
|
#endif
|
2017-07-03 22:08:07 +02:00
|
|
|
#else
|
|
|
|
result = CLOSURE_DEFAULT;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* volumes */
|
|
|
|
|
|
|
|
void node_volume_scatter(vec4 color, float density, float anisotropy, out Closure result)
|
|
|
|
{
|
|
|
|
#ifdef VOLUMETRICS
|
|
|
|
result = Closure(vec3(0.0), color.rgb * density, vec3(0.0), anisotropy);
|
|
|
|
#else
|
|
|
|
result = CLOSURE_DEFAULT;
|
|
|
|
#endif
|
2014-11-24 17:18:56 +01:00
|
|
|
}
|
|
|
|
|
2017-07-04 15:29:18 +02:00
|
|
|
void node_volume_absorption(vec4 color, float density, out Closure result)
|
|
|
|
{
|
|
|
|
#ifdef VOLUMETRICS
|
|
|
|
result = Closure((1.0 - color.rgb) * density, vec3(0.0), vec3(0.0), 0.0);
|
|
|
|
#else
|
|
|
|
result = CLOSURE_DEFAULT;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2011-11-08 11:38:16 +00:00
|
|
|
/* closures */
|
|
|
|
|
2017-07-03 21:39:52 +02:00
|
|
|
void node_mix_shader(float fac, Closure shader1, Closure shader2, out Closure shader)
|
2011-11-08 11:38:16 +00:00
|
|
|
{
|
2017-07-03 21:39:52 +02:00
|
|
|
shader = closure_mix(shader1, shader2, fac);
|
2011-11-08 11:38:16 +00:00
|
|
|
}
|
|
|
|
|
2017-07-03 21:39:52 +02:00
|
|
|
void node_add_shader(Closure shader1, Closure shader2, out Closure shader)
|
2011-11-08 11:38:16 +00:00
|
|
|
{
|
2017-07-03 21:39:52 +02:00
|
|
|
shader = closure_add(shader1, shader2);
|
2011-11-08 11:38:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* fresnel */
|
|
|
|
|
2016-03-05 14:29:32 +01:00
|
|
|
void node_fresnel(float ior, vec3 N, vec3 I, out float result)
|
2011-11-08 11:38:16 +00:00
|
|
|
{
|
2014-06-04 19:35:56 +02:00
|
|
|
/* handle perspective/orthographic */
|
2017-03-26 21:19:23 -04:00
|
|
|
vec3 I_view = (ProjectionMatrix[3][3] == 0.0) ? normalize(I) : vec3(0.0, 0.0, -1.0);
|
2014-06-04 19:35:56 +02:00
|
|
|
|
2011-11-08 11:38:16 +00:00
|
|
|
float eta = max(ior, 0.00001);
|
2016-05-26 18:46:12 +10:00
|
|
|
result = fresnel_dielectric(I_view, N, (gl_FrontFacing) ? eta : 1.0 / eta);
|
2011-11-08 11:38:16 +00:00
|
|
|
}
|
|
|
|
|
2013-11-22 00:33:28 +01:00
|
|
|
/* layer_weight */
|
|
|
|
|
2016-03-05 14:29:32 +01:00
|
|
|
void node_layer_weight(float blend, vec3 N, vec3 I, out float fresnel, out float facing)
|
2013-11-22 00:33:28 +01:00
|
|
|
{
|
|
|
|
/* fresnel */
|
|
|
|
float eta = max(1.0 - blend, 0.00001);
|
2017-03-26 21:19:23 -04:00
|
|
|
vec3 I_view = (ProjectionMatrix[3][3] == 0.0) ? normalize(I) : vec3(0.0, 0.0, -1.0);
|
2014-11-06 15:03:34 +01:00
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
fresnel = fresnel_dielectric(I_view, N, (gl_FrontFacing) ? 1.0 / eta : eta);
|
2013-11-22 00:33:28 +01:00
|
|
|
|
|
|
|
/* facing */
|
2016-03-05 14:29:32 +01:00
|
|
|
facing = abs(dot(I_view, N));
|
2016-05-23 10:31:36 +02:00
|
|
|
if (blend != 0.5) {
|
2013-11-22 00:33:28 +01:00
|
|
|
blend = clamp(blend, 0.0, 0.99999);
|
2016-05-26 18:46:12 +10:00
|
|
|
blend = (blend < 0.5) ? 2.0 * blend : 0.5 / (1.0 - blend);
|
2013-11-22 00:33:28 +01:00
|
|
|
facing = pow(facing, blend);
|
|
|
|
}
|
|
|
|
facing = 1.0 - facing;
|
|
|
|
}
|
|
|
|
|
2013-09-30 12:11:27 +00:00
|
|
|
/* gamma */
|
|
|
|
|
|
|
|
void node_gamma(vec4 col, float gamma, out vec4 outcol)
|
|
|
|
{
|
|
|
|
outcol = col;
|
|
|
|
|
2016-05-23 10:31:36 +02:00
|
|
|
if (col.r > 0.0)
|
2013-09-30 12:11:27 +00:00
|
|
|
outcol.r = compatible_pow(col.r, gamma);
|
2016-05-23 10:31:36 +02:00
|
|
|
if (col.g > 0.0)
|
2013-09-30 12:11:27 +00:00
|
|
|
outcol.g = compatible_pow(col.g, gamma);
|
2016-05-23 10:31:36 +02:00
|
|
|
if (col.b > 0.0)
|
2013-09-30 12:11:27 +00:00
|
|
|
outcol.b = compatible_pow(col.b, gamma);
|
|
|
|
}
|
|
|
|
|
2011-11-08 11:38:16 +00:00
|
|
|
/* geometry */
|
|
|
|
|
2016-05-22 18:24:53 +02:00
|
|
|
void node_attribute(vec3 attr, out vec4 outcol, out vec3 outvec, out float outf)
|
2013-06-05 15:54:39 +00:00
|
|
|
{
|
2016-05-22 18:24:53 +02:00
|
|
|
outcol = vec4(attr, 1.0);
|
|
|
|
outvec = attr;
|
2016-05-26 18:46:12 +10:00
|
|
|
outf = (attr.x + attr.y + attr.z) / 3.0;
|
2013-06-05 15:54:39 +00:00
|
|
|
}
|
|
|
|
|
2014-07-19 14:59:41 +02:00
|
|
|
void node_uvmap(vec3 attr_uv, out vec3 outvec)
|
|
|
|
{
|
|
|
|
outvec = attr_uv;
|
|
|
|
}
|
|
|
|
|
2017-05-18 14:29:57 +02:00
|
|
|
void tangent_orco_x(vec3 orco_in, out vec3 orco_out)
|
|
|
|
{
|
2017-06-29 15:49:20 +02:00
|
|
|
orco_out = orco_in.xzy * vec3(0.0, -0.25, 0.25);
|
2017-05-18 14:29:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void tangent_orco_y(vec3 orco_in, out vec3 orco_out)
|
|
|
|
{
|
2017-06-29 15:49:20 +02:00
|
|
|
orco_out = orco_in.zyx * vec3(-0.25, 0.0, 0.25);
|
2017-05-18 14:29:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void tangent_orco_z(vec3 orco_in, out vec3 orco_out)
|
|
|
|
{
|
2017-06-29 15:49:20 +02:00
|
|
|
orco_out = orco_in.yxz * vec3(-0.25, 0.25, 0.0);
|
2017-05-18 14:29:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void node_tangentmap(vec4 attr_tangent, mat4 toworld, out vec3 tangent)
|
|
|
|
{
|
|
|
|
tangent = (toworld * vec4(attr_tangent.xyz, 0.0)).xyz;
|
|
|
|
}
|
|
|
|
|
|
|
|
void node_tangent(vec3 N, vec3 orco, mat4 objmat, mat4 toworld, out vec3 T)
|
|
|
|
{
|
|
|
|
N = (toworld * vec4(N, 0.0)).xyz;
|
|
|
|
T = (objmat * vec4(orco, 0.0)).xyz;
|
|
|
|
T = cross(N, normalize(cross(T, N)));
|
|
|
|
}
|
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
void node_geometry(
|
2017-05-18 14:29:57 +02:00
|
|
|
vec3 I, vec3 N, vec3 orco, mat4 objmat, mat4 toworld,
|
2016-05-26 18:46:12 +10:00
|
|
|
out vec3 position, out vec3 normal, out vec3 tangent,
|
|
|
|
out vec3 true_normal, out vec3 incoming, out vec3 parametric,
|
|
|
|
out float backfacing, out float pointiness)
|
2011-11-08 11:38:16 +00:00
|
|
|
{
|
2017-07-04 18:02:13 +02:00
|
|
|
#ifdef EEVEE_ENGINE
|
|
|
|
position = worldPosition;
|
|
|
|
#else
|
2016-05-26 18:46:12 +10:00
|
|
|
position = (toworld * vec4(I, 1.0)).xyz;
|
2017-07-04 18:02:13 +02:00
|
|
|
#endif
|
2016-05-26 18:46:12 +10:00
|
|
|
normal = (toworld * vec4(N, 0.0)).xyz;
|
2017-05-18 14:29:57 +02:00
|
|
|
tangent_orco_z(orco, orco);
|
|
|
|
node_tangent(N, orco, objmat, toworld, tangent);
|
2014-06-04 19:35:56 +02:00
|
|
|
true_normal = normal;
|
|
|
|
|
|
|
|
/* handle perspective/orthographic */
|
2017-03-26 21:19:23 -04:00
|
|
|
vec3 I_view = (ProjectionMatrix[3][3] == 0.0) ? normalize(I) : vec3(0.0, 0.0, -1.0);
|
2016-05-26 18:46:12 +10:00
|
|
|
incoming = -(toworld * vec4(I_view, 0.0)).xyz;
|
2014-06-04 19:35:56 +02:00
|
|
|
|
2011-11-08 11:38:16 +00:00
|
|
|
parametric = vec3(0.0);
|
2016-05-26 18:46:12 +10:00
|
|
|
backfacing = (gl_FrontFacing) ? 0.0 : 1.0;
|
2016-10-01 14:44:11 +02:00
|
|
|
pointiness = 0.5;
|
2011-11-08 11:38:16 +00:00
|
|
|
}
|
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
void node_tex_coord(
|
|
|
|
vec3 I, vec3 N, mat4 viewinvmat, mat4 obinvmat, vec4 camerafac,
|
|
|
|
vec3 attr_orco, vec3 attr_uv,
|
|
|
|
out vec3 generated, out vec3 normal, out vec3 uv, out vec3 object,
|
|
|
|
out vec3 camera, out vec3 window, out vec3 reflection)
|
2011-11-08 11:38:16 +00:00
|
|
|
{
|
2017-06-29 15:49:20 +02:00
|
|
|
generated = attr_orco * 0.5 + 0.5;
|
2016-05-26 18:46:12 +10:00
|
|
|
normal = normalize((obinvmat * (viewinvmat * vec4(N, 0.0))).xyz);
|
2011-11-08 11:38:16 +00:00
|
|
|
uv = attr_uv;
|
2016-05-26 18:46:12 +10:00
|
|
|
object = (obinvmat * (viewinvmat * vec4(I, 1.0))).xyz;
|
2014-12-31 15:48:05 +01:00
|
|
|
camera = vec3(I.xy, -I.z);
|
2017-03-26 21:19:23 -04:00
|
|
|
vec4 projvec = ProjectionMatrix * vec4(I, 1.0);
|
2016-05-26 18:46:12 +10:00
|
|
|
window = vec3(mtex_2d_mapping(projvec.xyz / projvec.w).xy * camerafac.xy + camerafac.zw, 0.0);
|
2011-11-08 11:38:16 +00:00
|
|
|
|
2014-09-02 15:34:07 +06:00
|
|
|
vec3 shade_I;
|
|
|
|
shade_view(I, shade_I);
|
|
|
|
vec3 view_reflection = reflect(shade_I, normalize(N));
|
2016-05-26 18:46:12 +10:00
|
|
|
reflection = (viewinvmat * vec4(view_reflection, 0.0)).xyz;
|
2011-11-08 11:38:16 +00:00
|
|
|
}
|
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
void node_tex_coord_background(
|
|
|
|
vec3 I, vec3 N, mat4 viewinvmat, mat4 obinvmat, vec4 camerafac,
|
|
|
|
vec3 attr_orco, vec3 attr_uv,
|
|
|
|
out vec3 generated, out vec3 normal, out vec3 uv, out vec3 object,
|
|
|
|
out vec3 camera, out vec3 window, out vec3 reflection)
|
2014-11-24 17:18:56 +01:00
|
|
|
{
|
2017-03-26 21:19:23 -04:00
|
|
|
vec4 v = (ProjectionMatrix[3][3] == 0.0) ? vec4(I, 1.0) : vec4(0.0, 0.0, 1.0, 1.0);
|
|
|
|
vec4 co_homogenous = (ProjectionMatrixInverse * v);
|
2014-11-24 17:18:56 +01:00
|
|
|
|
|
|
|
vec4 co = vec4(co_homogenous.xyz / co_homogenous.w, 0.0);
|
|
|
|
|
|
|
|
co = normalize(co);
|
2017-05-04 17:39:50 +02:00
|
|
|
|
2017-06-29 17:07:41 +02:00
|
|
|
#if defined(WORLD_BACKGROUND) || defined(PROBE_CAPTURE)
|
2017-05-07 15:22:25 +02:00
|
|
|
vec3 coords = (ViewMatrixInverse * co).xyz;
|
2017-05-04 17:39:50 +02:00
|
|
|
#else
|
2017-03-26 21:19:23 -04:00
|
|
|
vec3 coords = (ModelViewMatrixInverse * co).xyz;
|
2017-05-04 17:39:50 +02:00
|
|
|
#endif
|
2014-11-24 17:18:56 +01:00
|
|
|
|
|
|
|
generated = coords;
|
|
|
|
normal = -coords;
|
2014-12-31 15:00:18 +01:00
|
|
|
uv = vec3(attr_uv.xy, 0.0);
|
2014-11-24 17:18:56 +01:00
|
|
|
object = coords;
|
|
|
|
|
2014-12-31 15:00:18 +01:00
|
|
|
camera = vec3(co.xy, -co.z);
|
2017-03-26 21:19:23 -04:00
|
|
|
window = (ProjectionMatrix[3][3] == 0.0) ?
|
2016-05-26 18:46:12 +10:00
|
|
|
vec3(mtex_2d_mapping(I).xy * camerafac.xy + camerafac.zw, 0.0) :
|
|
|
|
vec3(vec2(0.5) * camerafac.xy + camerafac.zw, 0.0);
|
2014-11-24 17:18:56 +01:00
|
|
|
|
|
|
|
reflection = -coords;
|
|
|
|
}
|
|
|
|
|
2017-05-17 19:40:21 +02:00
|
|
|
#if defined(WORLD_BACKGROUND) || (defined(PROBE_CAPTURE) && !defined(MESH_SHADER))
|
2017-05-04 17:39:50 +02:00
|
|
|
#define node_tex_coord node_tex_coord_background
|
|
|
|
#endif
|
|
|
|
|
2011-11-08 11:38:16 +00:00
|
|
|
/* textures */
|
|
|
|
|
2016-05-20 16:39:45 +02:00
|
|
|
float calc_gradient(vec3 p, int gradient_type)
|
|
|
|
{
|
|
|
|
float x, y, z;
|
|
|
|
x = p.x;
|
|
|
|
y = p.y;
|
|
|
|
z = p.z;
|
2016-05-23 10:31:36 +02:00
|
|
|
if (gradient_type == 0) { /* linear */
|
2016-05-20 16:39:45 +02:00
|
|
|
return x;
|
|
|
|
}
|
2016-05-23 10:31:36 +02:00
|
|
|
else if (gradient_type == 1) { /* quadratic */
|
2016-05-20 16:39:45 +02:00
|
|
|
float r = max(x, 0.0);
|
2016-05-26 18:46:12 +10:00
|
|
|
return r * r;
|
2016-05-20 16:39:45 +02:00
|
|
|
}
|
2016-05-23 10:31:36 +02:00
|
|
|
else if (gradient_type == 2) { /* easing */
|
2016-05-20 16:39:45 +02:00
|
|
|
float r = min(max(x, 0.0), 1.0);
|
2016-05-26 18:46:12 +10:00
|
|
|
float t = r * r;
|
|
|
|
return (3.0 * t - 2.0 * t * r);
|
2016-05-20 16:39:45 +02:00
|
|
|
}
|
2016-05-23 10:31:36 +02:00
|
|
|
else if (gradient_type == 3) { /* diagonal */
|
2016-05-20 16:39:45 +02:00
|
|
|
return (x + y) * 0.5;
|
|
|
|
}
|
2016-05-23 10:31:36 +02:00
|
|
|
else if (gradient_type == 4) { /* radial */
|
2016-05-20 16:39:45 +02:00
|
|
|
return atan(y, x) / (M_PI * 2) + 0.5;
|
|
|
|
}
|
|
|
|
else {
|
2016-05-26 18:46:12 +10:00
|
|
|
float r = max(1.0 - sqrt(x * x + y * y + z * z), 0.0);
|
2016-05-23 10:31:36 +02:00
|
|
|
if (gradient_type == 5) { /* quadratic sphere */
|
2016-05-26 18:46:12 +10:00
|
|
|
return r * r;
|
2016-05-20 16:39:45 +02:00
|
|
|
}
|
2016-05-23 10:31:36 +02:00
|
|
|
else if (gradient_type == 6) { /* sphere */
|
2016-05-20 16:39:45 +02:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void node_tex_gradient(vec3 co, float gradient_type, out vec4 color, out float fac)
|
2011-11-08 11:38:16 +00:00
|
|
|
{
|
2016-05-20 16:39:45 +02:00
|
|
|
float f = calc_gradient(co, int(gradient_type));
|
|
|
|
f = clamp(f, 0.0, 1.0);
|
|
|
|
|
|
|
|
color = vec4(f, f, f, 1.0);
|
|
|
|
fac = f;
|
2011-11-08 11:38:16 +00:00
|
|
|
}
|
|
|
|
|
2012-02-08 16:48:26 +00:00
|
|
|
void node_tex_checker(vec3 co, vec4 color1, vec4 color2, float scale, out vec4 color, out float fac)
|
2011-11-08 11:38:16 +00:00
|
|
|
{
|
2016-05-20 15:18:40 +02:00
|
|
|
vec3 p = co * scale;
|
|
|
|
|
|
|
|
/* Prevent precision issues on unit coordinates. */
|
2016-05-26 18:46:12 +10:00
|
|
|
p.x = (p.x + 0.000001) * 0.999999;
|
|
|
|
p.y = (p.y + 0.000001) * 0.999999;
|
|
|
|
p.z = (p.z + 0.000001) * 0.999999;
|
2016-05-20 15:18:40 +02:00
|
|
|
|
2016-05-31 12:30:56 +02:00
|
|
|
int xi = int(abs(floor(p.x)));
|
|
|
|
int yi = int(abs(floor(p.y)));
|
|
|
|
int zi = int(abs(floor(p.z)));
|
2016-05-20 15:18:40 +02:00
|
|
|
|
2016-05-31 12:30:56 +02:00
|
|
|
bool check = ((mod(xi, 2) == mod(yi, 2)) == bool(mod(zi, 2)));
|
2016-05-20 15:18:40 +02:00
|
|
|
|
|
|
|
color = check ? color1 : color2;
|
|
|
|
fac = check ? 1.0 : 0.0;
|
2011-11-08 11:38:16 +00:00
|
|
|
}
|
|
|
|
|
2016-11-07 20:55:12 +01:00
|
|
|
vec2 calc_brick_texture(vec3 p, float mortar_size, float mortar_smooth, float bias,
|
2016-05-20 16:13:44 +02:00
|
|
|
float brick_width, float row_height,
|
|
|
|
float offset_amount, int offset_frequency,
|
|
|
|
float squash_amount, int squash_frequency)
|
2012-09-04 13:29:07 +00:00
|
|
|
{
|
2016-05-20 16:13:44 +02:00
|
|
|
int bricknum, rownum;
|
|
|
|
float offset = 0.0;
|
|
|
|
float x, y;
|
|
|
|
|
|
|
|
rownum = floor_to_int(p.y / row_height);
|
|
|
|
|
2016-05-23 10:31:36 +02:00
|
|
|
if (offset_frequency != 0 && squash_frequency != 0) {
|
2016-05-20 16:13:44 +02:00
|
|
|
brick_width *= (rownum % squash_frequency != 0) ? 1.0 : squash_amount; /* squash */
|
2016-05-26 18:46:12 +10:00
|
|
|
offset = (rownum % offset_frequency != 0) ? 0.0 : (brick_width * offset_amount); /* offset */
|
2016-05-20 16:13:44 +02:00
|
|
|
}
|
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
bricknum = floor_to_int((p.x + offset) / brick_width);
|
2016-05-20 16:13:44 +02:00
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
x = (p.x + offset) - brick_width * bricknum;
|
|
|
|
y = p.y - row_height * rownum;
|
2016-05-20 16:13:44 +02:00
|
|
|
|
2016-11-07 20:55:12 +01:00
|
|
|
float tint = clamp((integer_noise((rownum << 16) + (bricknum & 0xFFFF)) + bias), 0.0, 1.0);
|
|
|
|
|
|
|
|
float min_dist = min(min(x, y), min(brick_width - x, row_height - y));
|
2017-06-02 15:38:04 +10:00
|
|
|
if (min_dist >= mortar_size) {
|
2016-11-07 20:55:12 +01:00
|
|
|
return vec2(tint, 0.0);
|
|
|
|
}
|
2017-06-02 15:38:04 +10:00
|
|
|
else if (mortar_smooth == 0.0) {
|
2016-11-07 20:55:12 +01:00
|
|
|
return vec2(tint, 1.0);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
min_dist = 1.0 - min_dist/mortar_size;
|
|
|
|
return vec2(tint, smoothstep(0.0, mortar_smooth, min_dist));
|
|
|
|
}
|
2016-05-20 16:13:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void node_tex_brick(vec3 co,
|
|
|
|
vec4 color1, vec4 color2,
|
|
|
|
vec4 mortar, float scale,
|
2016-11-07 20:55:12 +01:00
|
|
|
float mortar_size, float mortar_smooth, float bias,
|
2016-05-20 16:13:44 +02:00
|
|
|
float brick_width, float row_height,
|
|
|
|
float offset_amount, float offset_frequency,
|
|
|
|
float squash_amount, float squash_frequency,
|
|
|
|
out vec4 color, out float fac)
|
|
|
|
{
|
2016-05-26 18:46:12 +10:00
|
|
|
vec2 f2 = calc_brick_texture(co * scale,
|
2016-11-07 20:55:12 +01:00
|
|
|
mortar_size, mortar_smooth, bias,
|
2016-05-20 16:13:44 +02:00
|
|
|
brick_width, row_height,
|
|
|
|
offset_amount, int(offset_frequency),
|
|
|
|
squash_amount, int(squash_frequency));
|
|
|
|
float tint = f2.x;
|
|
|
|
float f = f2.y;
|
2016-05-23 10:31:36 +02:00
|
|
|
if (f != 1.0) {
|
2016-05-20 16:13:44 +02:00
|
|
|
float facm = 1.0 - tint;
|
|
|
|
color1 = facm * color1 + tint * color2;
|
|
|
|
}
|
2016-11-07 20:59:09 +01:00
|
|
|
color = mix(color1, mortar, f);
|
2016-05-20 16:13:44 +02:00
|
|
|
fac = f;
|
2012-09-04 13:29:07 +00:00
|
|
|
}
|
|
|
|
|
2012-02-08 16:48:26 +00:00
|
|
|
void node_tex_clouds(vec3 co, float size, out vec4 color, out float fac)
|
2011-11-08 11:38:16 +00:00
|
|
|
{
|
2012-02-08 16:48:26 +00:00
|
|
|
color = vec4(1.0);
|
2011-11-08 11:38:16 +00:00
|
|
|
fac = 1.0;
|
|
|
|
}
|
|
|
|
|
2014-11-20 19:43:32 +01:00
|
|
|
void node_tex_environment_equirectangular(vec3 co, sampler2D ima, out vec4 color)
|
2011-11-08 11:38:16 +00:00
|
|
|
{
|
2014-11-20 19:43:32 +01:00
|
|
|
vec3 nco = normalize(co);
|
2016-05-26 18:46:12 +10:00
|
|
|
float u = -atan(nco.y, nco.x) / (2.0 * M_PI) + 0.5;
|
|
|
|
float v = atan(nco.z, hypot(nco.x, nco.y)) / M_PI + 0.5;
|
2014-11-20 19:43:32 +01:00
|
|
|
|
2017-05-04 19:12:19 +02:00
|
|
|
/* Fix pole bleeding */
|
|
|
|
float half_width = 0.5 / float(textureSize(ima, 0).x);
|
|
|
|
v = clamp(v, half_width, 1.0 - half_width);
|
|
|
|
|
|
|
|
/* Fix u = 0 seam */
|
|
|
|
/* This is caused by texture filtering, since uv don't have smooth derivatives
|
|
|
|
* at u = 0 or 2PI, hardware filtering is using the smallest mipmap for certain
|
|
|
|
* texels. So we force the highest mipmap and don't do anisotropic filtering. */
|
|
|
|
color = textureLod(ima, vec2(u, v), 0.0);
|
2014-11-20 19:43:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void node_tex_environment_mirror_ball(vec3 co, sampler2D ima, out vec4 color)
|
|
|
|
{
|
|
|
|
vec3 nco = normalize(co);
|
|
|
|
|
|
|
|
nco.y -= 1.0;
|
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
float div = 2.0 * sqrt(max(-0.5 * nco.y, 0.0));
|
2016-05-23 10:31:36 +02:00
|
|
|
if (div > 0.0)
|
2014-11-20 19:43:32 +01:00
|
|
|
nco /= div;
|
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
float u = 0.5 * (nco.x + 1.0);
|
|
|
|
float v = 0.5 * (nco.z + 1.0);
|
2011-11-08 11:38:16 +00:00
|
|
|
|
2017-05-19 10:23:07 -04:00
|
|
|
color = texture(ima, vec2(u, v));
|
2011-11-08 11:38:16 +00:00
|
|
|
}
|
|
|
|
|
2012-05-18 13:30:34 +00:00
|
|
|
void node_tex_environment_empty(vec3 co, out vec4 color)
|
|
|
|
{
|
2014-11-26 19:19:25 +01:00
|
|
|
color = vec4(1.0, 0.0, 1.0, 1.0);
|
2012-05-18 13:30:34 +00:00
|
|
|
}
|
|
|
|
|
2012-04-04 16:11:10 +00:00
|
|
|
void node_tex_image(vec3 co, sampler2D ima, out vec4 color, out float alpha)
|
2011-11-08 11:38:16 +00:00
|
|
|
{
|
2017-05-19 10:23:07 -04:00
|
|
|
color = texture(ima, co.xy);
|
2012-06-05 22:12:17 +00:00
|
|
|
alpha = color.a;
|
2011-11-08 11:38:16 +00:00
|
|
|
}
|
|
|
|
|
2016-05-30 10:23:43 +02:00
|
|
|
void node_tex_image_box(vec3 texco,
|
|
|
|
vec3 nob,
|
|
|
|
sampler2D ima,
|
|
|
|
float blend,
|
|
|
|
out vec4 color,
|
|
|
|
out float alpha)
|
|
|
|
{
|
|
|
|
/* project from direction vector to barycentric coordinates in triangles */
|
|
|
|
nob = vec3(abs(nob.x), abs(nob.y), abs(nob.z));
|
|
|
|
nob /= (nob.x + nob.y + nob.z);
|
|
|
|
|
|
|
|
/* basic idea is to think of this as a triangle, each corner representing
|
|
|
|
* one of the 3 faces of the cube. in the corners we have single textures,
|
|
|
|
* in between we blend between two textures, and in the middle we a blend
|
|
|
|
* between three textures.
|
|
|
|
*
|
|
|
|
* the Nxyz values are the barycentric coordinates in an equilateral
|
|
|
|
* triangle, which in case of blending, in the middle has a smaller
|
|
|
|
* equilateral triangle where 3 textures blend. this divides things into
|
|
|
|
* 7 zones, with an if () test for each zone */
|
|
|
|
|
|
|
|
vec3 weight = vec3(0.0, 0.0, 0.0);
|
|
|
|
float limit = 0.5 * (1.0 + blend);
|
|
|
|
|
|
|
|
/* first test for corners with single texture */
|
|
|
|
if (nob.x > limit * (nob.x + nob.y) && nob.x > limit * (nob.x + nob.z)) {
|
|
|
|
weight.x = 1.0;
|
|
|
|
}
|
|
|
|
else if (nob.y > limit * (nob.x + nob.y) && nob.y > limit * (nob.y + nob.z)) {
|
|
|
|
weight.y = 1.0;
|
|
|
|
}
|
|
|
|
else if (nob.z > limit * (nob.x + nob.z) && nob.z > limit * (nob.y + nob.z)) {
|
|
|
|
weight.z = 1.0;
|
|
|
|
}
|
|
|
|
else if (blend > 0.0) {
|
|
|
|
/* in case of blending, test for mixes between two textures */
|
|
|
|
if (nob.z < (1.0 - limit) * (nob.y + nob.x)) {
|
|
|
|
weight.x = nob.x / (nob.x + nob.y);
|
|
|
|
weight.x = clamp((weight.x - 0.5 * (1.0 - blend)) / blend, 0.0, 1.0);
|
|
|
|
weight.y = 1.0 - weight.x;
|
|
|
|
}
|
|
|
|
else if (nob.x < (1.0 - limit) * (nob.y + nob.z)) {
|
|
|
|
weight.y = nob.y / (nob.y + nob.z);
|
|
|
|
weight.y = clamp((weight.y - 0.5 * (1.0 - blend)) / blend, 0.0, 1.0);
|
|
|
|
weight.z = 1.0 - weight.y;
|
|
|
|
}
|
|
|
|
else if (nob.y < (1.0 - limit) * (nob.x + nob.z)) {
|
|
|
|
weight.x = nob.x / (nob.x + nob.z);
|
|
|
|
weight.x = clamp((weight.x - 0.5 * (1.0 - blend)) / blend, 0.0, 1.0);
|
|
|
|
weight.z = 1.0 - weight.x;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* last case, we have a mix between three */
|
|
|
|
weight.x = ((2.0 - limit) * nob.x + (limit - 1.0)) / (2.0 * limit - 1.0);
|
|
|
|
weight.y = ((2.0 - limit) * nob.y + (limit - 1.0)) / (2.0 * limit - 1.0);
|
|
|
|
weight.z = ((2.0 - limit) * nob.z + (limit - 1.0)) / (2.0 * limit - 1.0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* Desperate mode, no valid choice anyway, fallback to one side.*/
|
|
|
|
weight.x = 1.0;
|
|
|
|
}
|
2016-05-31 09:49:27 +02:00
|
|
|
color = vec4(0);
|
2016-05-30 10:23:43 +02:00
|
|
|
if (weight.x > 0.0) {
|
2017-05-19 10:23:07 -04:00
|
|
|
color += weight.x * texture(ima, texco.yz);
|
2016-05-30 10:23:43 +02:00
|
|
|
}
|
|
|
|
if (weight.y > 0.0) {
|
2017-05-19 10:23:07 -04:00
|
|
|
color += weight.y * texture(ima, texco.xz);
|
2016-05-30 10:23:43 +02:00
|
|
|
}
|
|
|
|
if (weight.z > 0.0) {
|
2017-05-19 10:23:07 -04:00
|
|
|
color += weight.z * texture(ima, texco.yx);
|
2016-05-30 10:23:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
alpha = color.a;
|
|
|
|
}
|
|
|
|
|
2012-05-18 13:30:34 +00:00
|
|
|
void node_tex_image_empty(vec3 co, out vec4 color, out float alpha)
|
|
|
|
{
|
|
|
|
color = vec4(0.0);
|
2012-06-05 22:12:17 +00:00
|
|
|
alpha = 0.0;
|
2012-05-18 13:30:34 +00:00
|
|
|
}
|
|
|
|
|
2016-05-20 16:58:40 +02:00
|
|
|
void node_tex_magic(vec3 co, float scale, float distortion, float depth, out vec4 color, out float fac)
|
2011-11-08 11:38:16 +00:00
|
|
|
{
|
2016-05-20 16:58:40 +02:00
|
|
|
vec3 p = co * scale;
|
2016-05-26 18:46:12 +10:00
|
|
|
float x = sin((p.x + p.y + p.z) * 5.0);
|
|
|
|
float y = cos((-p.x + p.y - p.z) * 5.0);
|
|
|
|
float z = -cos((-p.x - p.y + p.z) * 5.0);
|
2016-05-20 16:58:40 +02:00
|
|
|
|
2016-05-23 10:31:36 +02:00
|
|
|
if (depth > 0) {
|
2016-05-20 16:58:40 +02:00
|
|
|
x *= distortion;
|
|
|
|
y *= distortion;
|
|
|
|
z *= distortion;
|
2016-05-26 18:46:12 +10:00
|
|
|
y = -cos(x - y + z);
|
2016-05-20 16:58:40 +02:00
|
|
|
y *= distortion;
|
2016-05-23 10:31:36 +02:00
|
|
|
if (depth > 1) {
|
2016-05-26 18:46:12 +10:00
|
|
|
x = cos(x - y - z);
|
2016-05-20 16:58:40 +02:00
|
|
|
x *= distortion;
|
2016-05-23 10:31:36 +02:00
|
|
|
if (depth > 2) {
|
2016-05-26 18:46:12 +10:00
|
|
|
z = sin(-x - y - z);
|
2016-05-20 16:58:40 +02:00
|
|
|
z *= distortion;
|
2016-05-23 10:31:36 +02:00
|
|
|
if (depth > 3) {
|
2016-05-26 18:46:12 +10:00
|
|
|
x = -cos(-x + y - z);
|
2016-05-20 16:58:40 +02:00
|
|
|
x *= distortion;
|
2016-05-23 10:31:36 +02:00
|
|
|
if (depth > 4) {
|
2016-05-26 18:46:12 +10:00
|
|
|
y = -sin(-x + y + z);
|
2016-05-20 16:58:40 +02:00
|
|
|
y *= distortion;
|
2016-05-23 10:31:36 +02:00
|
|
|
if (depth > 5) {
|
2016-05-26 18:46:12 +10:00
|
|
|
y = -cos(-x + y + z);
|
2016-05-20 16:58:40 +02:00
|
|
|
y *= distortion;
|
2016-05-23 10:31:36 +02:00
|
|
|
if (depth > 6) {
|
2016-05-26 18:46:12 +10:00
|
|
|
x = cos(x + y + z);
|
2016-05-20 16:58:40 +02:00
|
|
|
x *= distortion;
|
2016-05-23 10:31:36 +02:00
|
|
|
if (depth > 7) {
|
2016-05-26 18:46:12 +10:00
|
|
|
z = sin(x + y - z);
|
2016-05-20 16:58:40 +02:00
|
|
|
z *= distortion;
|
2016-05-23 10:31:36 +02:00
|
|
|
if (depth > 8) {
|
2016-05-26 18:46:12 +10:00
|
|
|
x = -cos(-x - y + z);
|
2016-05-20 16:58:40 +02:00
|
|
|
x *= distortion;
|
2016-05-23 10:31:36 +02:00
|
|
|
if (depth > 9) {
|
2016-05-26 18:46:12 +10:00
|
|
|
y = -sin(x - y + z);
|
2016-05-20 16:58:40 +02:00
|
|
|
y *= distortion;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-05-23 10:31:36 +02:00
|
|
|
if (distortion != 0.0) {
|
2016-05-20 16:58:40 +02:00
|
|
|
distortion *= 2.0;
|
|
|
|
x /= distortion;
|
|
|
|
y /= distortion;
|
|
|
|
z /= distortion;
|
|
|
|
}
|
|
|
|
|
2016-05-30 10:21:55 +02:00
|
|
|
color = vec4(0.5 - x, 0.5 - y, 0.5 - z, 1.0);
|
2016-05-20 16:58:40 +02:00
|
|
|
fac = (color.x + color.y + color.z) / 3.0;
|
2011-11-08 11:38:16 +00:00
|
|
|
}
|
|
|
|
|
2016-05-20 18:58:56 +02:00
|
|
|
float noise_fade(float t)
|
|
|
|
{
|
|
|
|
return t * t * t * (t * (t * 6.0 - 15.0) + 10.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
float noise_scale3(float result)
|
|
|
|
{
|
|
|
|
return 0.9820 * result;
|
|
|
|
}
|
|
|
|
|
|
|
|
float noise_nerp(float t, float a, float b)
|
|
|
|
{
|
|
|
|
return (1.0 - t) * a + t * b;
|
|
|
|
}
|
|
|
|
|
|
|
|
float noise_grad(uint hash, float x, float y, float z)
|
|
|
|
{
|
|
|
|
uint h = hash & 15u;
|
|
|
|
float u = h < 8u ? x : y;
|
|
|
|
float vt = ((h == 12u) || (h == 14u)) ? x : z;
|
|
|
|
float v = h < 4u ? y : vt;
|
|
|
|
return (((h & 1u) != 0u) ? -u : u) + (((h & 2u) != 0u) ? -v : v);
|
|
|
|
}
|
|
|
|
|
|
|
|
float noise_perlin(float x, float y, float z)
|
|
|
|
{
|
|
|
|
int X; float fx = floorfrac(x, X);
|
|
|
|
int Y; float fy = floorfrac(y, Y);
|
|
|
|
int Z; float fz = floorfrac(z, Z);
|
|
|
|
|
|
|
|
float u = noise_fade(fx);
|
|
|
|
float v = noise_fade(fy);
|
|
|
|
float w = noise_fade(fz);
|
|
|
|
|
|
|
|
float result;
|
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
result = noise_nerp(w, noise_nerp(v, noise_nerp(u, noise_grad(hash(X, Y, Z), fx, fy, fz),
|
|
|
|
noise_grad(hash(X + 1, Y, Z), fx - 1.0, fy, fz)),
|
|
|
|
noise_nerp(u, noise_grad(hash(X, Y + 1, Z), fx, fy - 1.0, fz),
|
|
|
|
noise_grad(hash(X + 1, Y + 1, Z), fx - 1.0, fy - 1.0, fz))),
|
|
|
|
noise_nerp(v, noise_nerp(u, noise_grad(hash(X, Y, Z + 1), fx, fy, fz - 1.0),
|
|
|
|
noise_grad(hash(X + 1, Y, Z + 1), fx - 1.0, fy, fz - 1.0)),
|
|
|
|
noise_nerp(u, noise_grad(hash(X, Y + 1, Z + 1), fx, fy - 1.0, fz - 1.0),
|
|
|
|
noise_grad(hash(X + 1, Y + 1, Z + 1), fx - 1.0, fy - 1.0, fz - 1.0))));
|
2016-05-20 18:58:56 +02:00
|
|
|
return noise_scale3(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
float noise(vec3 p)
|
|
|
|
{
|
|
|
|
return 0.5 * noise_perlin(p.x, p.y, p.z) + 0.5;
|
|
|
|
}
|
|
|
|
|
2016-05-22 19:09:42 +02:00
|
|
|
float snoise(vec3 p)
|
|
|
|
{
|
|
|
|
return noise_perlin(p.x, p.y, p.z);
|
|
|
|
}
|
|
|
|
|
2016-05-20 18:58:56 +02:00
|
|
|
float noise_turbulence(vec3 p, float octaves, int hard)
|
|
|
|
{
|
|
|
|
float fscale = 1.0;
|
|
|
|
float amp = 1.0;
|
|
|
|
float sum = 0.0;
|
|
|
|
octaves = clamp(octaves, 0.0, 16.0);
|
2017-05-19 14:20:08 -04:00
|
|
|
int n = int(octaves);
|
|
|
|
for (int i = 0; i <= n; i++) {
|
2016-05-26 18:46:12 +10:00
|
|
|
float t = noise(fscale * p);
|
2016-05-20 18:58:56 +02:00
|
|
|
if (hard != 0) {
|
2016-05-26 18:46:12 +10:00
|
|
|
t = abs(2.0 * t - 1.0);
|
2016-05-20 18:58:56 +02:00
|
|
|
}
|
2016-05-26 18:46:12 +10:00
|
|
|
sum += t * amp;
|
2016-05-20 18:58:56 +02:00
|
|
|
amp *= 0.5;
|
|
|
|
fscale *= 2.0;
|
|
|
|
}
|
|
|
|
float rmd = octaves - floor(octaves);
|
2017-05-19 14:20:08 -04:00
|
|
|
if (rmd != 0.0) {
|
2016-05-26 18:46:12 +10:00
|
|
|
float t = noise(fscale * p);
|
2016-05-20 18:58:56 +02:00
|
|
|
if (hard != 0) {
|
2016-05-26 18:46:12 +10:00
|
|
|
t = abs(2.0 * t - 1.0);
|
2016-05-20 18:58:56 +02:00
|
|
|
}
|
2016-05-26 18:46:12 +10:00
|
|
|
float sum2 = sum + t * amp;
|
|
|
|
sum *= (float(1 << n) / float((1 << (n + 1)) - 1));
|
|
|
|
sum2 *= (float(1 << (n + 1)) / float((1 << (n + 2)) - 1));
|
|
|
|
return (1.0 - rmd) * sum + rmd * sum2;
|
2016-05-20 18:58:56 +02:00
|
|
|
}
|
|
|
|
else {
|
2016-05-26 18:46:12 +10:00
|
|
|
sum *= (float(1 << n) / float((1 << (n + 1)) - 1));
|
2016-05-20 18:58:56 +02:00
|
|
|
return sum;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-08 16:48:26 +00:00
|
|
|
void node_tex_noise(vec3 co, float scale, float detail, float distortion, out vec4 color, out float fac)
|
2011-11-08 11:38:16 +00:00
|
|
|
{
|
2016-05-20 18:58:56 +02:00
|
|
|
vec3 p = co * scale;
|
|
|
|
int hard = 0;
|
|
|
|
if (distortion != 0.0) {
|
|
|
|
vec3 r, offset = vec3(13.5, 13.5, 13.5);
|
|
|
|
r.x = noise(p + offset) * distortion;
|
|
|
|
r.y = noise(p) * distortion;
|
|
|
|
r.z = noise(p - offset) * distortion;
|
|
|
|
p += r;
|
|
|
|
}
|
|
|
|
|
|
|
|
fac = noise_turbulence(p, detail, hard);
|
|
|
|
color = vec4(fac,
|
|
|
|
noise_turbulence(vec3(p.y, p.x, p.z), detail, hard),
|
|
|
|
noise_turbulence(vec3(p.y, p.z, p.x), detail, hard),
|
|
|
|
1);
|
2011-11-08 11:38:16 +00:00
|
|
|
}
|
|
|
|
|
2016-05-22 19:09:42 +02:00
|
|
|
/* Musgrave fBm
|
|
|
|
*
|
|
|
|
* H: fractal increment parameter
|
|
|
|
* lacunarity: gap between successive frequencies
|
|
|
|
* octaves: number of frequencies in the fBm
|
|
|
|
*
|
|
|
|
* from "Texturing and Modelling: A procedural approach"
|
|
|
|
*/
|
|
|
|
|
|
|
|
float noise_musgrave_fBm(vec3 p, float H, float lacunarity, float octaves)
|
|
|
|
{
|
|
|
|
float rmd;
|
|
|
|
float value = 0.0;
|
|
|
|
float pwr = 1.0;
|
|
|
|
float pwHL = pow(lacunarity, -H);
|
|
|
|
|
2017-05-19 14:20:08 -04:00
|
|
|
for (int i = 0; i < int(octaves); i++) {
|
2016-05-22 19:09:42 +02:00
|
|
|
value += snoise(p) * pwr;
|
|
|
|
pwr *= pwHL;
|
|
|
|
p *= lacunarity;
|
|
|
|
}
|
|
|
|
|
|
|
|
rmd = octaves - floor(octaves);
|
2016-05-23 10:31:36 +02:00
|
|
|
if (rmd != 0.0)
|
2016-05-22 19:09:42 +02:00
|
|
|
value += rmd * snoise(p) * pwr;
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Musgrave Multifractal
|
|
|
|
*
|
|
|
|
* H: highest fractal dimension
|
|
|
|
* lacunarity: gap between successive frequencies
|
|
|
|
* octaves: number of frequencies in the fBm
|
|
|
|
*/
|
|
|
|
|
|
|
|
float noise_musgrave_multi_fractal(vec3 p, float H, float lacunarity, float octaves)
|
|
|
|
{
|
|
|
|
float rmd;
|
|
|
|
float value = 1.0;
|
|
|
|
float pwr = 1.0;
|
|
|
|
float pwHL = pow(lacunarity, -H);
|
|
|
|
|
2017-05-19 14:20:08 -04:00
|
|
|
for (int i = 0; i < int(octaves); i++) {
|
2016-05-22 19:09:42 +02:00
|
|
|
value *= (pwr * snoise(p) + 1.0);
|
|
|
|
pwr *= pwHL;
|
|
|
|
p *= lacunarity;
|
|
|
|
}
|
|
|
|
|
|
|
|
rmd = octaves - floor(octaves);
|
2016-05-23 10:31:36 +02:00
|
|
|
if (rmd != 0.0)
|
2016-05-22 19:09:42 +02:00
|
|
|
value *= (rmd * pwr * snoise(p) + 1.0); /* correct? */
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Musgrave Heterogeneous Terrain
|
|
|
|
*
|
|
|
|
* H: fractal dimension of the roughest area
|
|
|
|
* lacunarity: gap between successive frequencies
|
|
|
|
* octaves: number of frequencies in the fBm
|
|
|
|
* offset: raises the terrain from `sea level'
|
|
|
|
*/
|
|
|
|
|
|
|
|
float noise_musgrave_hetero_terrain(vec3 p, float H, float lacunarity, float octaves, float offset)
|
|
|
|
{
|
|
|
|
float value, increment, rmd;
|
|
|
|
float pwHL = pow(lacunarity, -H);
|
|
|
|
float pwr = pwHL;
|
|
|
|
|
|
|
|
/* first unscaled octave of function; later octaves are scaled */
|
|
|
|
value = offset + snoise(p);
|
|
|
|
p *= lacunarity;
|
|
|
|
|
2017-05-19 14:20:08 -04:00
|
|
|
for (int i = 1; i < int(octaves); i++) {
|
2016-05-22 19:09:42 +02:00
|
|
|
increment = (snoise(p) + offset) * pwr * value;
|
|
|
|
value += increment;
|
|
|
|
pwr *= pwHL;
|
|
|
|
p *= lacunarity;
|
|
|
|
}
|
|
|
|
|
|
|
|
rmd = octaves - floor(octaves);
|
2016-05-23 10:31:36 +02:00
|
|
|
if (rmd != 0.0) {
|
2016-05-22 19:09:42 +02:00
|
|
|
increment = (snoise(p) + offset) * pwr * value;
|
|
|
|
value += rmd * increment;
|
|
|
|
}
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Hybrid Additive/Multiplicative Multifractal Terrain
|
|
|
|
*
|
|
|
|
* H: fractal dimension of the roughest area
|
|
|
|
* lacunarity: gap between successive frequencies
|
|
|
|
* octaves: number of frequencies in the fBm
|
|
|
|
* offset: raises the terrain from `sea level'
|
|
|
|
*/
|
|
|
|
|
|
|
|
float noise_musgrave_hybrid_multi_fractal(vec3 p, float H, float lacunarity, float octaves, float offset, float gain)
|
|
|
|
{
|
|
|
|
float result, signal, weight, rmd;
|
|
|
|
float pwHL = pow(lacunarity, -H);
|
|
|
|
float pwr = pwHL;
|
|
|
|
|
|
|
|
result = snoise(p) + offset;
|
|
|
|
weight = gain * result;
|
|
|
|
p *= lacunarity;
|
|
|
|
|
2017-05-19 14:20:08 -04:00
|
|
|
for (int i = 1; (weight > 0.001f) && (i < int(octaves)); i++) {
|
2016-05-23 10:31:36 +02:00
|
|
|
if (weight > 1.0)
|
2016-05-22 19:09:42 +02:00
|
|
|
weight = 1.0;
|
|
|
|
|
|
|
|
signal = (snoise(p) + offset) * pwr;
|
|
|
|
pwr *= pwHL;
|
|
|
|
result += weight * signal;
|
|
|
|
weight *= gain * signal;
|
|
|
|
p *= lacunarity;
|
|
|
|
}
|
|
|
|
|
|
|
|
rmd = octaves - floor(octaves);
|
2016-05-23 10:31:36 +02:00
|
|
|
if (rmd != 0.0)
|
2016-05-22 19:09:42 +02:00
|
|
|
result += rmd * ((snoise(p) + offset) * pwr);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Ridged Multifractal Terrain
|
|
|
|
*
|
|
|
|
* H: fractal dimension of the roughest area
|
|
|
|
* lacunarity: gap between successive frequencies
|
|
|
|
* octaves: number of frequencies in the fBm
|
|
|
|
* offset: raises the terrain from `sea level'
|
|
|
|
*/
|
|
|
|
|
|
|
|
float noise_musgrave_ridged_multi_fractal(vec3 p, float H, float lacunarity, float octaves, float offset, float gain)
|
|
|
|
{
|
|
|
|
float result, signal, weight;
|
|
|
|
float pwHL = pow(lacunarity, -H);
|
|
|
|
float pwr = pwHL;
|
|
|
|
|
|
|
|
signal = offset - abs(snoise(p));
|
|
|
|
signal *= signal;
|
|
|
|
result = signal;
|
|
|
|
weight = 1.0;
|
|
|
|
|
2017-05-19 14:20:08 -04:00
|
|
|
for (int i = 1; i < int(octaves); i++) {
|
2016-05-22 19:09:42 +02:00
|
|
|
p *= lacunarity;
|
|
|
|
weight = clamp(signal * gain, 0.0, 1.0);
|
|
|
|
signal = offset - abs(snoise(p));
|
|
|
|
signal *= signal;
|
|
|
|
signal *= weight;
|
|
|
|
result += signal * pwr;
|
|
|
|
pwr *= pwHL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
float svm_musgrave(int type,
|
|
|
|
float dimension,
|
|
|
|
float lacunarity,
|
|
|
|
float octaves,
|
|
|
|
float offset,
|
|
|
|
float intensity,
|
|
|
|
float gain,
|
|
|
|
vec3 p)
|
|
|
|
{
|
2017-05-19 14:20:08 -04:00
|
|
|
if (type == 0 /* NODE_MUSGRAVE_MULTIFRACTAL */)
|
2016-05-26 18:46:12 +10:00
|
|
|
return intensity * noise_musgrave_multi_fractal(p, dimension, lacunarity, octaves);
|
2017-05-19 14:20:08 -04:00
|
|
|
else if (type == 1 /* NODE_MUSGRAVE_FBM */)
|
2016-05-26 18:46:12 +10:00
|
|
|
return intensity * noise_musgrave_fBm(p, dimension, lacunarity, octaves);
|
2017-05-19 14:20:08 -04:00
|
|
|
else if (type == 2 /* NODE_MUSGRAVE_HYBRID_MULTIFRACTAL */)
|
2016-05-26 18:46:12 +10:00
|
|
|
return intensity * noise_musgrave_hybrid_multi_fractal(p, dimension, lacunarity, octaves, offset, gain);
|
2017-05-19 14:20:08 -04:00
|
|
|
else if (type == 3 /* NODE_MUSGRAVE_RIDGED_MULTIFRACTAL */)
|
2016-05-26 18:46:12 +10:00
|
|
|
return intensity * noise_musgrave_ridged_multi_fractal(p, dimension, lacunarity, octaves, offset, gain);
|
2017-05-19 14:20:08 -04:00
|
|
|
else if (type == 4 /* NODE_MUSGRAVE_HETERO_TERRAIN */)
|
2016-05-26 18:46:12 +10:00
|
|
|
return intensity * noise_musgrave_hetero_terrain(p, dimension, lacunarity, octaves, offset);
|
2016-05-22 19:09:42 +02:00
|
|
|
return 0.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void node_tex_musgrave(vec3 co,
|
|
|
|
float scale,
|
|
|
|
float detail,
|
|
|
|
float dimension,
|
|
|
|
float lacunarity,
|
|
|
|
float offset,
|
|
|
|
float gain,
|
|
|
|
float type,
|
|
|
|
out vec4 color,
|
|
|
|
out float fac)
|
|
|
|
{
|
|
|
|
fac = svm_musgrave(int(type),
|
|
|
|
dimension,
|
|
|
|
lacunarity,
|
|
|
|
detail,
|
|
|
|
offset,
|
|
|
|
1.0,
|
|
|
|
gain,
|
2016-05-26 18:46:12 +10:00
|
|
|
co * scale);
|
2016-05-22 19:09:42 +02:00
|
|
|
|
|
|
|
color = vec4(fac, fac, fac, 1.0);
|
|
|
|
}
|
|
|
|
|
2011-11-08 11:38:16 +00:00
|
|
|
void node_tex_sky(vec3 co, out vec4 color)
|
|
|
|
{
|
|
|
|
color = vec4(1.0);
|
|
|
|
}
|
|
|
|
|
2016-05-20 18:05:29 +02:00
|
|
|
void node_tex_voronoi(vec3 co, float scale, float coloring, out vec4 color, out float fac)
|
2011-11-08 11:38:16 +00:00
|
|
|
{
|
2016-05-20 18:05:29 +02:00
|
|
|
vec3 p = co * scale;
|
|
|
|
int xx, yy, zz, xi, yi, zi;
|
|
|
|
float da[4];
|
|
|
|
vec3 pa[4];
|
|
|
|
|
|
|
|
xi = floor_to_int(p[0]);
|
|
|
|
yi = floor_to_int(p[1]);
|
|
|
|
zi = floor_to_int(p[2]);
|
|
|
|
|
|
|
|
da[0] = 1e+10;
|
|
|
|
da[1] = 1e+10;
|
|
|
|
da[2] = 1e+10;
|
|
|
|
da[3] = 1e+10;
|
|
|
|
|
|
|
|
for (xx = xi - 1; xx <= xi + 1; xx++) {
|
|
|
|
for (yy = yi - 1; yy <= yi + 1; yy++) {
|
|
|
|
for (zz = zi - 1; zz <= zi + 1; zz++) {
|
|
|
|
vec3 ip = vec3(xx, yy, zz);
|
|
|
|
vec3 vp = cellnoise_color(ip);
|
|
|
|
vec3 pd = p - (vp + ip);
|
|
|
|
float d = dot(pd, pd);
|
|
|
|
vp += vec3(xx, yy, zz);
|
|
|
|
if (d < da[0]) {
|
|
|
|
da[3] = da[2];
|
|
|
|
da[2] = da[1];
|
|
|
|
da[1] = da[0];
|
|
|
|
da[0] = d;
|
|
|
|
pa[3] = pa[2];
|
|
|
|
pa[2] = pa[1];
|
|
|
|
pa[1] = pa[0];
|
|
|
|
pa[0] = vp;
|
|
|
|
}
|
|
|
|
else if (d < da[1]) {
|
|
|
|
da[3] = da[2];
|
|
|
|
da[2] = da[1];
|
|
|
|
da[1] = d;
|
|
|
|
|
|
|
|
pa[3] = pa[2];
|
|
|
|
pa[2] = pa[1];
|
|
|
|
pa[1] = vp;
|
|
|
|
}
|
|
|
|
else if (d < da[2]) {
|
|
|
|
da[3] = da[2];
|
|
|
|
da[2] = d;
|
|
|
|
|
|
|
|
pa[3] = pa[2];
|
|
|
|
pa[2] = vp;
|
|
|
|
}
|
|
|
|
else if (d < da[3]) {
|
|
|
|
da[3] = d;
|
|
|
|
pa[3] = vp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (coloring == 0.0) {
|
|
|
|
fac = abs(da[0]);
|
|
|
|
color = vec4(fac, fac, fac, 1);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
color = vec4(cellnoise_color(pa[0]), 1);
|
|
|
|
fac = (color.x + color.y + color.z) * (1.0 / 3.0);
|
|
|
|
}
|
2011-11-08 11:38:16 +00:00
|
|
|
}
|
|
|
|
|
2016-05-20 21:21:57 +02:00
|
|
|
float calc_wave(vec3 p, float distortion, float detail, float detail_scale, int wave_type, int wave_profile)
|
2011-11-08 11:38:16 +00:00
|
|
|
{
|
2016-05-20 21:21:57 +02:00
|
|
|
float n;
|
|
|
|
|
2016-05-23 10:31:36 +02:00
|
|
|
if (wave_type == 0) /* type bands */
|
2016-05-20 21:21:57 +02:00
|
|
|
n = (p.x + p.y + p.z) * 10.0;
|
|
|
|
else /* type rings */
|
|
|
|
n = length(p) * 20.0;
|
|
|
|
|
2016-05-23 10:31:36 +02:00
|
|
|
if (distortion != 0.0)
|
2016-05-26 18:46:12 +10:00
|
|
|
n += distortion * noise_turbulence(p * detail_scale, detail, 0);
|
2016-05-20 21:21:57 +02:00
|
|
|
|
2016-05-23 10:31:36 +02:00
|
|
|
if (wave_profile == 0) { /* profile sin */
|
2016-05-20 21:21:57 +02:00
|
|
|
return 0.5 + 0.5 * sin(n);
|
|
|
|
}
|
|
|
|
else { /* profile saw */
|
|
|
|
n /= 2.0 * M_PI;
|
|
|
|
n -= int(n);
|
2016-05-26 18:46:12 +10:00
|
|
|
return (n < 0.0) ? n + 1.0 : n;
|
2016-05-20 21:21:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-23 19:56:50 +10:00
|
|
|
void node_tex_wave(
|
|
|
|
vec3 co, float scale, float distortion, float detail, float detail_scale, float wave_type, float wave_profile,
|
|
|
|
out vec4 color, out float fac)
|
2016-05-20 21:21:57 +02:00
|
|
|
{
|
|
|
|
float f;
|
2016-05-26 18:46:12 +10:00
|
|
|
f = calc_wave(co * scale, distortion, detail, detail_scale, int(wave_type), int(wave_profile));
|
2016-05-20 21:21:57 +02:00
|
|
|
|
|
|
|
color = vec4(f, f, f, 1.0);
|
|
|
|
fac = f;
|
2011-11-08 11:38:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* light path */
|
|
|
|
|
|
|
|
void node_light_path(
|
|
|
|
out float is_camera_ray,
|
|
|
|
out float is_shadow_ray,
|
|
|
|
out float is_diffuse_ray,
|
|
|
|
out float is_glossy_ray,
|
2011-12-01 19:31:36 +00:00
|
|
|
out float is_singular_ray,
|
2011-11-08 11:38:16 +00:00
|
|
|
out float is_reflection_ray,
|
2012-10-18 12:37:51 +00:00
|
|
|
out float is_transmission_ray,
|
2014-03-06 09:06:20 +01:00
|
|
|
out float ray_length,
|
2014-04-21 16:31:46 +02:00
|
|
|
out float ray_depth,
|
2017-01-29 16:00:14 +01:00
|
|
|
out float diffuse_depth,
|
|
|
|
out float glossy_depth,
|
2016-01-06 23:38:13 +01:00
|
|
|
out float transparent_depth,
|
|
|
|
out float transmission_depth)
|
2011-11-08 11:38:16 +00:00
|
|
|
{
|
2017-05-10 10:32:22 +02:00
|
|
|
#ifndef PROBE_CAPTURE
|
2011-11-08 11:38:16 +00:00
|
|
|
is_camera_ray = 1.0;
|
|
|
|
is_glossy_ray = 0.0;
|
2017-05-10 10:32:22 +02:00
|
|
|
is_diffuse_ray = 0.0;
|
2011-11-08 11:38:16 +00:00
|
|
|
is_reflection_ray = 0.0;
|
|
|
|
is_transmission_ray = 0.0;
|
2017-05-10 10:32:22 +02:00
|
|
|
#else
|
|
|
|
is_camera_ray = 0.0;
|
|
|
|
is_glossy_ray = 1.0;
|
|
|
|
is_diffuse_ray = 1.0;
|
|
|
|
is_reflection_ray = 1.0;
|
|
|
|
is_transmission_ray = 1.0;
|
|
|
|
#endif
|
|
|
|
is_shadow_ray = 0.0;
|
|
|
|
is_singular_ray = 0.0;
|
2012-10-18 12:37:51 +00:00
|
|
|
ray_length = 1.0;
|
2014-03-06 09:06:20 +01:00
|
|
|
ray_depth = 1.0;
|
2017-01-29 16:00:14 +01:00
|
|
|
diffuse_depth = 1.0;
|
|
|
|
glossy_depth = 1.0;
|
2014-04-21 16:31:46 +02:00
|
|
|
transparent_depth = 1.0;
|
2016-01-06 23:38:13 +01:00
|
|
|
transmission_depth = 1.0;
|
2011-11-08 11:38:16 +00:00
|
|
|
}
|
|
|
|
|
2012-05-09 10:14:01 +00:00
|
|
|
void node_light_falloff(float strength, float tsmooth, out float quadratic, out float linear, out float constant)
|
2012-05-07 20:24:38 +00:00
|
|
|
{
|
|
|
|
quadratic = strength;
|
|
|
|
linear = strength;
|
|
|
|
constant = strength;
|
|
|
|
}
|
|
|
|
|
2017-04-14 18:13:44 +03:00
|
|
|
void node_object_info(mat4 obmat, vec3 info, out vec3 location, out float object_index, out float material_index, out float random)
|
2012-05-21 12:52:28 +00:00
|
|
|
{
|
2017-04-14 18:13:44 +03:00
|
|
|
location = obmat[3].xyz;
|
|
|
|
object_index = info.x;
|
|
|
|
material_index = info.y;
|
|
|
|
random = info.z;
|
2012-05-21 12:52:28 +00:00
|
|
|
}
|
|
|
|
|
2016-04-26 18:43:02 +10:00
|
|
|
void node_normal_map(vec4 tangent, vec3 normal, vec3 texnormal, out vec3 outnormal)
|
2013-05-27 17:48:02 +00:00
|
|
|
{
|
2016-04-26 18:43:02 +10:00
|
|
|
vec3 B = tangent.w * cross(normal, tangent.xyz);
|
|
|
|
|
|
|
|
outnormal = texnormal.x * tangent.xyz + texnormal.y * B + texnormal.z * normal;
|
|
|
|
outnormal = normalize(outnormal);
|
2013-05-27 17:48:02 +00:00
|
|
|
}
|
|
|
|
|
2016-05-22 16:47:06 +02:00
|
|
|
void node_bump(float strength, float dist, float height, vec3 N, vec3 surf_pos, float invert, out vec3 result)
|
2012-10-18 12:37:51 +00:00
|
|
|
{
|
2016-05-22 16:47:06 +02:00
|
|
|
if (invert != 0.0) {
|
|
|
|
dist *= -1.0;
|
|
|
|
}
|
2016-05-20 14:16:54 +02:00
|
|
|
vec3 dPdx = dFdx(surf_pos);
|
|
|
|
vec3 dPdy = dFdy(surf_pos);
|
|
|
|
|
|
|
|
/* Get surface tangents from normal. */
|
|
|
|
vec3 Rx = cross(dPdy, N);
|
|
|
|
vec3 Ry = cross(N, dPdx);
|
|
|
|
|
|
|
|
/* Compute surface gradient and determinant. */
|
|
|
|
float det = dot(dPdx, Rx);
|
|
|
|
float absdet = abs(det);
|
|
|
|
|
|
|
|
float dHdx = dFdx(height);
|
|
|
|
float dHdy = dFdy(height);
|
2016-05-26 18:46:12 +10:00
|
|
|
vec3 surfgrad = dHdx * Rx + dHdy * Ry;
|
2016-05-20 14:16:54 +02:00
|
|
|
|
|
|
|
strength = max(strength, 0.0);
|
|
|
|
|
2016-05-26 18:46:12 +10:00
|
|
|
result = normalize(absdet * N - dist * sign(det) * surfgrad);
|
|
|
|
result = normalize(strength * result + (1.0 - strength) * N);
|
2012-10-18 12:37:51 +00:00
|
|
|
}
|
2012-05-21 12:52:28 +00:00
|
|
|
|
2011-11-08 11:38:16 +00:00
|
|
|
/* output */
|
|
|
|
|
2017-07-03 21:39:52 +02:00
|
|
|
void node_output_material(Closure surface, Closure volume, float displacement, out Closure result)
|
2011-11-08 11:38:16 +00:00
|
|
|
{
|
|
|
|
result = surface;
|
|
|
|
}
|
|
|
|
|
2017-06-24 05:24:59 +02:00
|
|
|
uniform float backgroundAlpha;
|
|
|
|
|
2017-07-03 21:39:52 +02:00
|
|
|
void node_output_world(Closure surface, Closure volume, out Closure result)
|
2014-11-24 17:18:56 +01:00
|
|
|
{
|
2017-07-03 22:08:07 +02:00
|
|
|
#ifndef VOLUMETRICS
|
2017-07-16 23:49:25 +02:00
|
|
|
#ifdef EEVEE_ENGINE
|
|
|
|
result = Closure(surface.radiance, backgroundAlpha, vec4(0.0), vec2(0.0), -1);
|
|
|
|
#else
|
2017-07-03 21:39:52 +02:00
|
|
|
result = Closure(surface.radiance, backgroundAlpha);
|
2017-07-16 23:49:25 +02:00
|
|
|
#endif
|
2017-07-03 22:08:07 +02:00
|
|
|
#else
|
|
|
|
result = volume;
|
|
|
|
#endif /* VOLUMETRICS */
|
2014-11-24 17:18:56 +01:00
|
|
|
}
|
|
|
|
|
2017-07-03 22:08:07 +02:00
|
|
|
#ifndef VOLUMETRICS
|
2017-05-10 10:31:17 +02:00
|
|
|
/* TODO : clean this ifdef mess */
|
|
|
|
/* EEVEE output */
|
2017-05-17 19:40:21 +02:00
|
|
|
#ifdef EEVEE_ENGINE
|
2017-05-02 19:25:25 +02:00
|
|
|
void world_normals_get(out vec3 N)
|
|
|
|
{
|
|
|
|
N = gl_FrontFacing ? worldNormal : -worldNormal;
|
|
|
|
}
|
|
|
|
|
2017-06-20 14:33:13 +02:00
|
|
|
void node_eevee_metallic(
|
2017-05-02 19:25:25 +02:00
|
|
|
vec4 basecol, float metallic, float specular, float roughness, vec4 emissive, float transp, vec3 normal,
|
|
|
|
float clearcoat, float clearcoat_roughness, vec3 clearcoat_normal,
|
2017-07-15 16:09:44 +02:00
|
|
|
float occlusion, float ssr_id, out Closure result)
|
2017-05-02 19:25:25 +02:00
|
|
|
{
|
2017-07-16 23:49:25 +02:00
|
|
|
vec3 diffuse, f0, ssr_spec;
|
2017-06-30 14:12:25 +02:00
|
|
|
convert_metallic_to_specular(basecol.rgb, metallic, specular, diffuse, f0);
|
2017-05-02 19:25:25 +02:00
|
|
|
|
2017-07-16 23:49:25 +02:00
|
|
|
vec3 L = eevee_surface_lit(normal, diffuse, f0, roughness, occlusion, int(ssr_id), ssr_spec);
|
2017-07-17 13:39:03 +02:00
|
|
|
vec3 vN = normalize(mat3(ViewMatrix) * normal);
|
|
|
|
result = Closure(L + emissive.rgb, 1.0 - transp, vec4(ssr_spec, roughness), normal_encode(vN, viewCameraVec), int(ssr_id));
|
2017-05-02 19:25:25 +02:00
|
|
|
}
|
|
|
|
|
2017-06-20 14:33:13 +02:00
|
|
|
void node_eevee_specular(
|
2017-05-02 19:25:25 +02:00
|
|
|
vec4 diffuse, vec4 specular, float roughness, vec4 emissive, float transp, vec3 normal,
|
|
|
|
float clearcoat, float clearcoat_roughness, vec3 clearcoat_normal,
|
2017-07-15 16:09:44 +02:00
|
|
|
float occlusion, float ssr_id, out Closure result)
|
2017-05-02 19:25:25 +02:00
|
|
|
{
|
2017-07-16 23:49:25 +02:00
|
|
|
vec3 ssr_spec;
|
|
|
|
|
|
|
|
vec3 L = eevee_surface_lit(normal, diffuse.rgb, specular.rgb, roughness, occlusion, int(ssr_id), ssr_spec);
|
2017-07-17 13:39:03 +02:00
|
|
|
vec3 vN = normalize(mat3(ViewMatrix) * normal);
|
|
|
|
result = Closure(L + emissive.rgb, 1.0 - transp, vec4(ssr_spec, roughness), normal_encode(vN, viewCameraVec), int(ssr_id));
|
2017-05-02 19:25:25 +02:00
|
|
|
}
|
2017-06-19 16:31:10 +02:00
|
|
|
|
2017-07-03 21:39:52 +02:00
|
|
|
void node_output_eevee_material(Closure surface, out Closure result)
|
2017-06-19 16:31:10 +02:00
|
|
|
{
|
2017-07-09 12:01:29 +02:00
|
|
|
result = surface;
|
2017-06-19 16:31:10 +02:00
|
|
|
}
|
|
|
|
|
2017-07-03 22:08:07 +02:00
|
|
|
#endif /* EEVEE_ENGINE */
|
|
|
|
#endif /* VOLUMETRICS */
|
2017-05-02 19:25:25 +02:00
|
|
|
|
2013-01-22 11:18:41 +00:00
|
|
|
/* ********************** matcap style render ******************** */
|
|
|
|
|
2014-03-29 11:40:26 +02:00
|
|
|
void material_preview_matcap(vec4 color, sampler2D ima, vec4 N, vec4 mask, out vec4 result)
|
2013-01-22 11:18:41 +00:00
|
|
|
{
|
2014-03-29 11:40:26 +02:00
|
|
|
vec3 normal;
|
|
|
|
|
2015-07-20 16:08:06 +02:00
|
|
|
#ifndef USE_OPENSUBDIV
|
2016-05-26 18:46:12 +10:00
|
|
|
/* remap to 0.0 - 1.0 range. This is done because OpenGL 2.0 clamps colors
|
2014-03-29 11:40:26 +02:00
|
|
|
* between shader stages and we want the full range of the normal */
|
2017-05-19 14:20:08 -04:00
|
|
|
normal = 2.0 * N.xyz - vec3(1.0);
|
|
|
|
normal.z = max(normal.z, 0.0);
|
2014-03-29 11:40:26 +02:00
|
|
|
normal = normalize(normal);
|
2015-07-20 16:08:06 +02:00
|
|
|
#else
|
|
|
|
normal = inpt.v.normal;
|
2017-05-19 14:20:08 -04:00
|
|
|
mask = vec4(1.0);
|
2015-07-20 16:08:06 +02:00
|
|
|
#endif
|
2013-01-22 11:18:41 +00:00
|
|
|
|
2017-05-19 14:20:08 -04:00
|
|
|
vec2 tex = 0.49 * normal.xy + vec2(0.5);
|
|
|
|
|
2017-05-19 10:23:07 -04:00
|
|
|
result = texture(ima, tex) * mask;
|
2013-01-22 11:18:41 +00:00
|
|
|
}
|