2017-03-26 21:19:23 -04:00
|
|
|
|
|
|
|
|
uniform mat4 ModelViewMatrix;
|
|
|
|
|
uniform mat4 ProjectionMatrix;
|
|
|
|
|
uniform mat3 NormalMatrix;
|
|
|
|
|
|
2015-07-20 16:08:06 +02:00
|
|
|
#ifdef USE_OPENSUBDIV
|
|
|
|
|
in vec3 normal;
|
|
|
|
|
in vec4 position;
|
|
|
|
|
|
|
|
|
|
out block {
|
|
|
|
|
VertexData v;
|
|
|
|
|
} outpt;
|
|
|
|
|
#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
|
|
|
|
2017-05-17 10:46:42 +10:00
|
|
|
out vec3 varposition;
|
|
|
|
|
out vec3 varnormal;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An 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-07-11 19:17:29 +03:00
|
|
|
#ifdef CLIP_WORKAROUND
|
|
|
|
|
varying float gl_ClipDistance[6];
|
|
|
|
|
#endif
|
|
|
|
|
|
2016-06-27 15:32:52 +10:00
|
|
|
|
|
|
|
|
/* Color, keep in sync with: gpu_shader_vertex_world.glsl */
|
|
|
|
|
|
2016-05-31 14:39:49 +02:00
|
|
|
float srgb_to_linearrgb(float c)
|
|
|
|
|
{
|
|
|
|
|
if (c < 0.04045)
|
|
|
|
|
return (c < 0.0) ? 0.0 : c * (1.0 / 12.92);
|
|
|
|
|
else
|
|
|
|
|
return pow((c + 0.055) * (1.0 / 1.055), 2.4);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void srgb_to_linearrgb(vec3 col_from, out vec3 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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool is_srgb(int info)
|
|
|
|
|
{
|
|
|
|
|
return (info == 1)? true: false;
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-01 10:26:18 +02:00
|
|
|
void set_var_from_attr(float attr, int info, out float var)
|
|
|
|
|
{
|
|
|
|
|
var = attr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void set_var_from_attr(vec2 attr, int info, out vec2 var)
|
|
|
|
|
{
|
|
|
|
|
var = attr;
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-31 14:39:49 +02:00
|
|
|
void set_var_from_attr(vec3 attr, int info, out vec3 var)
|
|
|
|
|
{
|
|
|
|
|
if (is_srgb(info)) {
|
|
|
|
|
srgb_to_linearrgb(attr, var);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
var = attr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void set_var_from_attr(vec4 attr, int info, out vec4 var)
|
|
|
|
|
{
|
|
|
|
|
if (is_srgb(info)) {
|
|
|
|
|
srgb_to_linearrgb(attr, var);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
var = attr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-27 15:32:52 +10:00
|
|
|
/* end color code */
|
|
|
|
|
|
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An 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 main()
|
|
|
|
|
{
|
2015-07-20 16:08:06 +02:00
|
|
|
#ifndef USE_OPENSUBDIV
|
|
|
|
|
vec4 position = gl_Vertex;
|
|
|
|
|
vec3 normal = gl_Normal;
|
|
|
|
|
#endif
|
|
|
|
|
|
2017-03-26 21:19:23 -04:00
|
|
|
vec4 co = ModelViewMatrix * position;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
|
varposition = co.xyz;
|
2017-03-26 21:19:23 -04:00
|
|
|
varnormal = normalize(NormalMatrix * normal);
|
|
|
|
|
gl_Position = ProjectionMatrix * 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
|
|
|
|
2014-07-11 19:17:29 +03:00
|
|
|
#ifdef CLIP_WORKAROUND
|
|
|
|
|
int i;
|
2016-05-23 10:31:36 +02:00
|
|
|
for (i = 0; i < 6; i++)
|
2014-07-11 19:17:29 +03:00
|
|
|
gl_ClipDistance[i] = dot(co, gl_ClipPlane[i]);
|
2014-08-27 11:23:10 +02:00
|
|
|
#elif !defined(GPU_ATI)
|
2013-03-13 18:00:13 +00:00
|
|
|
// Setting gl_ClipVertex is necessary to get glClipPlane working on NVIDIA
|
|
|
|
|
// graphic cards, while on ATI it can cause a software fallback.
|
2014-07-11 19:17:29 +03:00
|
|
|
gl_ClipVertex = co;
|
2013-02-26 00:49:42 +00:00
|
|
|
#endif
|
2015-02-12 19:39:10 +01:00
|
|
|
|
2015-07-20 16:08:06 +02:00
|
|
|
#ifdef USE_OPENSUBDIV
|
|
|
|
|
outpt.v.position = co;
|
|
|
|
|
outpt.v.normal = varnormal;
|
|
|
|
|
#endif
|