mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-12 23:24:41 +00:00
* Adjustment: Update Bullet version to 3.24.
This commit is contained in:
parent
35de012ee7
commit
4a3f31df2a
6148 changed files with 2112532 additions and 56873 deletions
|
|
@ -0,0 +1,10 @@
|
|||
#version 330
|
||||
precision highp float;
|
||||
|
||||
|
||||
layout(location = 0) out float fragmentdepth;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
fragmentdepth = gl_FragCoord.z;
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
//this file is autogenerated using stringify.bat (premake --stringify) in the build folder of this project
|
||||
static const char* createShadowMapInstancingFragmentShader= \
|
||||
"#version 330\n"
|
||||
"precision highp float;\n"
|
||||
"layout(location = 0) out float fragmentdepth;\n"
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
" fragmentdepth = gl_FragCoord.z;\n"
|
||||
"}\n"
|
||||
;
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
#version 330
|
||||
precision highp float;
|
||||
|
||||
|
||||
layout (location = 0) in vec4 position;
|
||||
layout (location = 1) in vec4 instance_position;
|
||||
layout (location = 2) in vec4 instance_quaternion;
|
||||
layout (location = 3) in vec2 uvcoords;
|
||||
layout (location = 4) in vec3 vertexnormal;
|
||||
layout (location = 5) in vec4 instance_color;
|
||||
layout (location = 6) in vec4 instance_scale_obUid;
|
||||
|
||||
|
||||
uniform mat4 depthMVP;
|
||||
|
||||
|
||||
vec4 quatMul ( in vec4 q1, in vec4 q2 )
|
||||
{
|
||||
vec3 im = q1.w * q2.xyz + q1.xyz * q2.w + cross ( q1.xyz, q2.xyz );
|
||||
vec4 dt = q1 * q2;
|
||||
float re = dot ( dt, vec4 ( -1.0, -1.0, -1.0, 1.0 ) );
|
||||
return vec4 ( im, re );
|
||||
}
|
||||
|
||||
vec4 quatFromAxisAngle(vec4 axis, in float angle)
|
||||
{
|
||||
float cah = cos(angle*0.5);
|
||||
float sah = sin(angle*0.5);
|
||||
float d = inversesqrt(dot(axis,axis));
|
||||
vec4 q = vec4(axis.x*sah*d,axis.y*sah*d,axis.z*sah*d,cah);
|
||||
return q;
|
||||
}
|
||||
//
|
||||
// vector rotation via quaternion
|
||||
//
|
||||
vec4 quatRotate3 ( in vec3 p, in vec4 q )
|
||||
{
|
||||
vec4 temp = quatMul ( q, vec4 ( p, 0.0 ) );
|
||||
return quatMul ( temp, vec4 ( -q.x, -q.y, -q.z, q.w ) );
|
||||
}
|
||||
vec4 quatRotate ( in vec4 p, in vec4 q )
|
||||
{
|
||||
vec4 temp = quatMul ( q, p );
|
||||
return quatMul ( temp, vec4 ( -q.x, -q.y, -q.z, q.w ) );
|
||||
}
|
||||
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec4 q = instance_quaternion;
|
||||
vec4 localcoord = quatRotate3( position.xyz*instance_scale_obUid.xyz,q);
|
||||
vec4 vertexPos = depthMVP * vec4( (instance_position+localcoord).xyz,1);
|
||||
gl_Position = vertexPos;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
//this file is autogenerated using stringify.bat (premake --stringify) in the build folder of this project
|
||||
static const char* createShadowMapInstancingVertexShader= \
|
||||
"#version 330\n"
|
||||
"precision highp float;\n"
|
||||
"layout (location = 0) in vec4 position;\n"
|
||||
"layout (location = 1) in vec4 instance_position;\n"
|
||||
"layout (location = 2) in vec4 instance_quaternion;\n"
|
||||
"layout (location = 3) in vec2 uvcoords;\n"
|
||||
"layout (location = 4) in vec3 vertexnormal;\n"
|
||||
"layout (location = 5) in vec4 instance_color;\n"
|
||||
"layout (location = 6) in vec4 instance_scale_obUid;\n"
|
||||
"uniform mat4 depthMVP;\n"
|
||||
"vec4 quatMul ( in vec4 q1, in vec4 q2 )\n"
|
||||
"{\n"
|
||||
" vec3 im = q1.w * q2.xyz + q1.xyz * q2.w + cross ( q1.xyz, q2.xyz );\n"
|
||||
" vec4 dt = q1 * q2;\n"
|
||||
" float re = dot ( dt, vec4 ( -1.0, -1.0, -1.0, 1.0 ) );\n"
|
||||
" return vec4 ( im, re );\n"
|
||||
"}\n"
|
||||
"vec4 quatFromAxisAngle(vec4 axis, in float angle)\n"
|
||||
"{\n"
|
||||
" float cah = cos(angle*0.5);\n"
|
||||
" float sah = sin(angle*0.5);\n"
|
||||
" float d = inversesqrt(dot(axis,axis));\n"
|
||||
" vec4 q = vec4(axis.x*sah*d,axis.y*sah*d,axis.z*sah*d,cah);\n"
|
||||
" return q;\n"
|
||||
"}\n"
|
||||
"//\n"
|
||||
"// vector rotation via quaternion\n"
|
||||
"//\n"
|
||||
"vec4 quatRotate3 ( in vec3 p, in vec4 q )\n"
|
||||
"{\n"
|
||||
" vec4 temp = quatMul ( q, vec4 ( p, 0.0 ) );\n"
|
||||
" return quatMul ( temp, vec4 ( -q.x, -q.y, -q.z, q.w ) );\n"
|
||||
"}\n"
|
||||
"vec4 quatRotate ( in vec4 p, in vec4 q )\n"
|
||||
"{\n"
|
||||
" vec4 temp = quatMul ( q, p );\n"
|
||||
" return quatMul ( temp, vec4 ( -q.x, -q.y, -q.z, q.w ) );\n"
|
||||
"}\n"
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
" vec4 q = instance_quaternion;\n"
|
||||
" vec4 localcoord = quatRotate3( position.xyz*instance_scale_obUid.xyz,q);\n"
|
||||
" vec4 vertexPos = depthMVP * vec4( (instance_position+localcoord).xyz,1);\n"
|
||||
" gl_Position = vertexPos;\n"
|
||||
"}\n"
|
||||
;
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
#version 330
|
||||
precision highp float;
|
||||
|
||||
in Fragment
|
||||
{
|
||||
vec4 color;
|
||||
} fragment;
|
||||
|
||||
in Vert
|
||||
{
|
||||
vec2 texcoord;
|
||||
} vert;
|
||||
|
||||
uniform sampler2D Diffuse;
|
||||
in vec3 lightDir,normal,ambient;
|
||||
out vec4 color;
|
||||
|
||||
void main_textured(void)
|
||||
{
|
||||
color = vec4(0.1,0.2,0.3,0.3);
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec4 texel = fragment.color*texture(Diffuse,vert.texcoord);//fragment.color;
|
||||
vec3 ct,cf;
|
||||
float intensity,at,af;
|
||||
|
||||
intensity = 0.5+0.5*clamp( dot( normalize(normal),lightDir ), -1,1 );
|
||||
cf = intensity*(vec3(1.0,1.0,1.0)-ambient)+ambient;
|
||||
af = 1.0;
|
||||
|
||||
ct = texel.rgb;
|
||||
at = texel.a;
|
||||
|
||||
color = vec4(ct * cf, at * af);
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
//this file is autogenerated using stringify.bat (premake --stringify) in the build folder of this project
|
||||
static const char* instancingFragmentShader= \
|
||||
"#version 330\n"
|
||||
"precision highp float;\n"
|
||||
"in Fragment\n"
|
||||
"{\n"
|
||||
" vec4 color;\n"
|
||||
"} fragment;\n"
|
||||
"in Vert\n"
|
||||
"{\n"
|
||||
" vec2 texcoord;\n"
|
||||
"} vert;\n"
|
||||
"uniform sampler2D Diffuse;\n"
|
||||
"in vec3 lightDir,normal,ambient;\n"
|
||||
"out vec4 color;\n"
|
||||
"void main_textured(void)\n"
|
||||
"{\n"
|
||||
" color = vec4(0.1,0.2,0.3,0.3);\n"
|
||||
"}\n"
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
" vec4 texel = fragment.color*texture(Diffuse,vert.texcoord);//fragment.color;\n"
|
||||
" vec3 ct,cf;\n"
|
||||
" float intensity,at,af;\n"
|
||||
" \n"
|
||||
" intensity = 0.5+0.5*clamp( dot( normalize(normal),lightDir ), -1,1 );\n"
|
||||
" cf = intensity*(vec3(1.0,1.0,1.0)-ambient)+ambient;\n"
|
||||
" af = 1.0;\n"
|
||||
" \n"
|
||||
" ct = texel.rgb;\n"
|
||||
" at = texel.a;\n"
|
||||
" \n"
|
||||
" color = vec4(ct * cf, at * af); \n"
|
||||
"}\n"
|
||||
;
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
#version 330
|
||||
precision highp float;
|
||||
|
||||
|
||||
layout (location = 0) in vec4 position;
|
||||
layout (location = 1) in vec4 instance_position;
|
||||
layout (location = 2) in vec4 instance_quaternion;
|
||||
layout (location = 3) in vec2 uvcoords;
|
||||
layout (location = 4) in vec3 vertexnormal;
|
||||
layout (location = 5) in vec4 instance_color;
|
||||
layout (location = 6) in vec4 instance_scale_obUid;
|
||||
|
||||
|
||||
uniform mat4 ModelViewMatrix;
|
||||
uniform mat4 ProjectionMatrix;
|
||||
uniform vec3 lightDirIn;
|
||||
|
||||
out Fragment
|
||||
{
|
||||
vec4 color;
|
||||
} fragment;
|
||||
|
||||
out Vert
|
||||
{
|
||||
vec2 texcoord;
|
||||
} vert;
|
||||
|
||||
|
||||
vec4 quatMul ( in vec4 q1, in vec4 q2 )
|
||||
{
|
||||
vec3 im = q1.w * q2.xyz + q1.xyz * q2.w + cross ( q1.xyz, q2.xyz );
|
||||
vec4 dt = q1 * q2;
|
||||
float re = dot ( dt, vec4 ( -1.0, -1.0, -1.0, 1.0 ) );
|
||||
return vec4 ( im, re );
|
||||
}
|
||||
|
||||
vec4 quatFromAxisAngle(vec4 axis, in float angle)
|
||||
{
|
||||
float cah = cos(angle*0.5);
|
||||
float sah = sin(angle*0.5);
|
||||
float d = inversesqrt(dot(axis,axis));
|
||||
vec4 q = vec4(axis.x*sah*d,axis.y*sah*d,axis.z*sah*d,cah);
|
||||
return q;
|
||||
}
|
||||
//
|
||||
// vector rotation via quaternion
|
||||
//
|
||||
vec4 quatRotate3 ( in vec3 p, in vec4 q )
|
||||
{
|
||||
vec4 temp = quatMul ( q, vec4 ( p, 0.0 ) );
|
||||
return quatMul ( temp, vec4 ( -q.x, -q.y, -q.z, q.w ) );
|
||||
}
|
||||
vec4 quatRotate ( in vec4 p, in vec4 q )
|
||||
{
|
||||
vec4 temp = quatMul ( q, p );
|
||||
return quatMul ( temp, vec4 ( -q.x, -q.y, -q.z, q.w ) );
|
||||
}
|
||||
|
||||
out vec3 lightDir,normal,ambient;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec4 q = instance_quaternion;
|
||||
ambient = vec3(0.5,.5,0.5);
|
||||
|
||||
vec4 worldNormal = (quatRotate3( vertexnormal,q));
|
||||
normal = normalize(worldNormal).xyz;
|
||||
|
||||
lightDir = lightDirIn;
|
||||
|
||||
vec4 localcoord = quatRotate3( position.xyz*instance_scale_obUid.xyz,q);
|
||||
vec4 vertexPos = ProjectionMatrix * ModelViewMatrix *(instance_position+localcoord);
|
||||
|
||||
gl_Position = vertexPos;
|
||||
|
||||
fragment.color = instance_color;
|
||||
vert.texcoord = uvcoords;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
//this file is autogenerated using stringify.bat (premake --stringify) in the build folder of this project
|
||||
static const char* instancingVertexShader= \
|
||||
"#version 330\n"
|
||||
"precision highp float;\n"
|
||||
"layout (location = 0) in vec4 position;\n"
|
||||
"layout (location = 1) in vec4 instance_position;\n"
|
||||
"layout (location = 2) in vec4 instance_quaternion;\n"
|
||||
"layout (location = 3) in vec2 uvcoords;\n"
|
||||
"layout (location = 4) in vec3 vertexnormal;\n"
|
||||
"layout (location = 5) in vec4 instance_color;\n"
|
||||
"layout (location = 6) in vec4 instance_scale_obUid;\n"
|
||||
"uniform mat4 ModelViewMatrix;\n"
|
||||
"uniform mat4 ProjectionMatrix;\n"
|
||||
"uniform vec3 lightDirIn;\n"
|
||||
"out Fragment\n"
|
||||
"{\n"
|
||||
" vec4 color;\n"
|
||||
"} fragment;\n"
|
||||
"out Vert\n"
|
||||
"{\n"
|
||||
" vec2 texcoord;\n"
|
||||
"} vert;\n"
|
||||
"vec4 quatMul ( in vec4 q1, in vec4 q2 )\n"
|
||||
"{\n"
|
||||
" vec3 im = q1.w * q2.xyz + q1.xyz * q2.w + cross ( q1.xyz, q2.xyz );\n"
|
||||
" vec4 dt = q1 * q2;\n"
|
||||
" float re = dot ( dt, vec4 ( -1.0, -1.0, -1.0, 1.0 ) );\n"
|
||||
" return vec4 ( im, re );\n"
|
||||
"}\n"
|
||||
"vec4 quatFromAxisAngle(vec4 axis, in float angle)\n"
|
||||
"{\n"
|
||||
" float cah = cos(angle*0.5);\n"
|
||||
" float sah = sin(angle*0.5);\n"
|
||||
" float d = inversesqrt(dot(axis,axis));\n"
|
||||
" vec4 q = vec4(axis.x*sah*d,axis.y*sah*d,axis.z*sah*d,cah);\n"
|
||||
" return q;\n"
|
||||
"}\n"
|
||||
"//\n"
|
||||
"// vector rotation via quaternion\n"
|
||||
"//\n"
|
||||
"vec4 quatRotate3 ( in vec3 p, in vec4 q )\n"
|
||||
"{\n"
|
||||
" vec4 temp = quatMul ( q, vec4 ( p, 0.0 ) );\n"
|
||||
" return quatMul ( temp, vec4 ( -q.x, -q.y, -q.z, q.w ) );\n"
|
||||
"}\n"
|
||||
"vec4 quatRotate ( in vec4 p, in vec4 q )\n"
|
||||
"{\n"
|
||||
" vec4 temp = quatMul ( q, p );\n"
|
||||
" return quatMul ( temp, vec4 ( -q.x, -q.y, -q.z, q.w ) );\n"
|
||||
"}\n"
|
||||
"out vec3 lightDir,normal,ambient;\n"
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
" vec4 q = instance_quaternion;\n"
|
||||
" ambient = vec3(0.5,.5,0.5);\n"
|
||||
" \n"
|
||||
" vec4 worldNormal = (quatRotate3( vertexnormal,q));\n"
|
||||
" normal = normalize(worldNormal).xyz;\n"
|
||||
" \n"
|
||||
" lightDir = lightDirIn;\n"
|
||||
" \n"
|
||||
" vec4 localcoord = quatRotate3( position.xyz*instance_scale_obUid.xyz,q);\n"
|
||||
" vec4 vertexPos = ProjectionMatrix * ModelViewMatrix *(instance_position+localcoord);\n"
|
||||
" gl_Position = vertexPos;\n"
|
||||
" \n"
|
||||
" fragment.color = instance_color;\n"
|
||||
" vert.texcoord = uvcoords;\n"
|
||||
"}\n"
|
||||
;
|
||||
10
Engine/lib/bullet/examples/OpenGLWindow/Shaders/linesPS.glsl
Normal file
10
Engine/lib/bullet/examples/OpenGLWindow/Shaders/linesPS.glsl
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
|
||||
#version 150
|
||||
|
||||
in vec4 colourV;
|
||||
out vec4 fragColour;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
fragColour = colourV;
|
||||
}
|
||||
10
Engine/lib/bullet/examples/OpenGLWindow/Shaders/linesPS.h
Normal file
10
Engine/lib/bullet/examples/OpenGLWindow/Shaders/linesPS.h
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
//this file is autogenerated using stringify.bat (premake --stringify) in the build folder of this project
|
||||
static const char* linesFragmentShader= \
|
||||
"#version 150\n"
|
||||
"in vec4 colourV;\n"
|
||||
"out vec4 fragColour;\n"
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
" fragColour = colourV;\n"
|
||||
"}\n"
|
||||
;
|
||||
17
Engine/lib/bullet/examples/OpenGLWindow/Shaders/linesVS.glsl
Normal file
17
Engine/lib/bullet/examples/OpenGLWindow/Shaders/linesVS.glsl
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#version 150
|
||||
|
||||
uniform mat4 ModelViewMatrix;
|
||||
uniform mat4 ProjectionMatrix;
|
||||
uniform vec4 colour;
|
||||
|
||||
in vec4 position;
|
||||
|
||||
|
||||
out vec4 colourV;
|
||||
|
||||
void main (void)
|
||||
{
|
||||
colourV = colour;
|
||||
gl_Position = ProjectionMatrix * ModelViewMatrix * position;
|
||||
|
||||
}
|
||||
15
Engine/lib/bullet/examples/OpenGLWindow/Shaders/linesVS.h
Normal file
15
Engine/lib/bullet/examples/OpenGLWindow/Shaders/linesVS.h
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
//this file is autogenerated using stringify.bat (premake --stringify) in the build folder of this project
|
||||
static const char* linesVertexShader= \
|
||||
"#version 150 \n"
|
||||
"uniform mat4 ModelViewMatrix;\n"
|
||||
"uniform mat4 ProjectionMatrix;\n"
|
||||
"uniform vec4 colour;\n"
|
||||
"in vec4 position;\n"
|
||||
"out vec4 colourV;\n"
|
||||
"void main (void)\n"
|
||||
"{\n"
|
||||
" colourV = colour;\n"
|
||||
" gl_Position = ProjectionMatrix * ModelViewMatrix * position;\n"
|
||||
" \n"
|
||||
"}\n"
|
||||
;
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
|
||||
#version 330
|
||||
precision highp float;
|
||||
|
||||
in Fragment
|
||||
{
|
||||
vec4 color;
|
||||
} fragment;
|
||||
|
||||
|
||||
in vec3 ambient;
|
||||
|
||||
out vec4 color;
|
||||
|
||||
void main_textured(void)
|
||||
{
|
||||
color = fragment.color;//texture2D(Diffuse,vert.texcoord);//fragment.color;
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec3 N;
|
||||
N.xy = gl_PointCoord.st*vec2(2.0, -2.0) + vec2(-1.0, 1.0);
|
||||
float mag = dot(N.xy, N.xy);
|
||||
if (mag > 1.0) discard;
|
||||
vec4 texel = fragment.color;//vec4(1,0,0,1);//fragment.color*texture(Diffuse,vert.texcoord);//fragment.color;
|
||||
vec3 ct;
|
||||
float at,af;
|
||||
af = 1.0;
|
||||
|
||||
ct = texel.rgb;
|
||||
at = texel.a;
|
||||
|
||||
vec3 lightDir= vec3(1,0,0);
|
||||
float diffuse = max(0.0, dot(lightDir, N));
|
||||
color = vec4(ct * diffuse, at * af);
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
//this file is autogenerated using stringify.bat (premake --stringify) in the build folder of this project
|
||||
static const char* pointSpriteFragmentShader= \
|
||||
"#version 330\n"
|
||||
"precision highp float;\n"
|
||||
"in Fragment\n"
|
||||
"{\n"
|
||||
" vec4 color;\n"
|
||||
"} fragment;\n"
|
||||
"in vec3 ambient;\n"
|
||||
"out vec4 color;\n"
|
||||
"void main_textured(void)\n"
|
||||
"{\n"
|
||||
" color = fragment.color;//texture2D(Diffuse,vert.texcoord);//fragment.color;\n"
|
||||
"}\n"
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
" vec3 N;\n"
|
||||
" N.xy = gl_PointCoord.st*vec2(2.0, -2.0) + vec2(-1.0, 1.0);\n"
|
||||
" float mag = dot(N.xy, N.xy);\n"
|
||||
" if (mag > 1.0) discard; \n"
|
||||
" vec4 texel = fragment.color;//vec4(1,0,0,1);//fragment.color*texture(Diffuse,vert.texcoord);//fragment.color;\n"
|
||||
" vec3 ct;\n"
|
||||
" float at,af;\n"
|
||||
" af = 1.0;\n"
|
||||
" \n"
|
||||
" ct = texel.rgb;\n"
|
||||
" at = texel.a;\n"
|
||||
" \n"
|
||||
" vec3 lightDir= vec3(1,0,0);\n"
|
||||
" float diffuse = max(0.0, dot(lightDir, N));\n"
|
||||
" color = vec4(ct * diffuse, at * af); \n"
|
||||
"}\n"
|
||||
;
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
#version 330
|
||||
precision highp float;
|
||||
|
||||
|
||||
|
||||
layout (location = 0) in vec4 position;
|
||||
layout (location = 1) in vec4 instance_position;
|
||||
layout (location = 3) in vec2 uvcoords;
|
||||
layout (location = 4) in vec3 vertexnormal;
|
||||
layout (location = 5) in vec4 instance_color;
|
||||
layout (location = 6) in vec4 instance_scale_obUid;
|
||||
|
||||
|
||||
uniform float screenWidth = 700.f;
|
||||
uniform mat4 ModelViewMatrix;
|
||||
uniform mat4 ProjectionMatrix;
|
||||
|
||||
out Fragment
|
||||
{
|
||||
vec4 color;
|
||||
} fragment;
|
||||
|
||||
|
||||
|
||||
//
|
||||
// vector rotation via quaternion
|
||||
//
|
||||
|
||||
out vec3 ambient;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
ambient = vec3(0.3,.3,0.3);
|
||||
|
||||
|
||||
vec4 axis = vec4(1,1,1,0);
|
||||
vec4 vertexPos = ProjectionMatrix * ModelViewMatrix *(instance_position);
|
||||
vec3 posEye = vec3(ModelViewMatrix * vec4(instance_position.xyz, 1.0));
|
||||
float dist = length(posEye);
|
||||
float pointRadius = 1.f;
|
||||
gl_PointSize = instance_scale_obUid.x * pointRadius * (screenWidth / dist);
|
||||
|
||||
gl_Position = vertexPos;
|
||||
|
||||
fragment.color = instance_color;
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
//this file is autogenerated using stringify.bat (premake --stringify) in the build folder of this project
|
||||
static const char* pointSpriteVertexShader= \
|
||||
"#version 330\n"
|
||||
"precision highp float;\n"
|
||||
"layout (location = 0) in vec4 position;\n"
|
||||
"layout (location = 1) in vec4 instance_position;\n"
|
||||
"layout (location = 3) in vec2 uvcoords;\n"
|
||||
"layout (location = 4) in vec3 vertexnormal;\n"
|
||||
"layout (location = 5) in vec4 instance_color;\n"
|
||||
"layout (location = 6) in vec4 instance_scale_obUid;\n"
|
||||
"uniform float screenWidth = 700.f;\n"
|
||||
"uniform mat4 ModelViewMatrix;\n"
|
||||
"uniform mat4 ProjectionMatrix;\n"
|
||||
"out Fragment\n"
|
||||
"{\n"
|
||||
" vec4 color;\n"
|
||||
"} fragment;\n"
|
||||
"//\n"
|
||||
"// vector rotation via quaternion\n"
|
||||
"//\n"
|
||||
"out vec3 ambient;\n"
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
" ambient = vec3(0.3,.3,0.3);\n"
|
||||
" \n"
|
||||
" \n"
|
||||
" vec4 axis = vec4(1,1,1,0);\n"
|
||||
" vec4 vertexPos = ProjectionMatrix * ModelViewMatrix *(instance_position);\n"
|
||||
" vec3 posEye = vec3(ModelViewMatrix * vec4(instance_position.xyz, 1.0));\n"
|
||||
" float dist = length(posEye);\n"
|
||||
" float pointRadius = 1.f;\n"
|
||||
" gl_PointSize = instance_scale_obUid.x * pointRadius * (screenWidth / dist);\n"
|
||||
" gl_Position = vertexPos;\n"
|
||||
" \n"
|
||||
" fragment.color = instance_color;\n"
|
||||
"}\n"
|
||||
;
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
|
||||
#version 150
|
||||
|
||||
in vec4 colourV;
|
||||
out vec4 fragColour;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
fragColour = colourV;
|
||||
}
|
||||
10
Engine/lib/bullet/examples/OpenGLWindow/Shaders/pointsPS.h
Normal file
10
Engine/lib/bullet/examples/OpenGLWindow/Shaders/pointsPS.h
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
//this file is autogenerated using stringify.bat (premake --stringify) in the build folder of this project
|
||||
static const char* pointsFragmentShader= \
|
||||
"#version 150\n"
|
||||
"in vec4 colourV;\n"
|
||||
"out vec4 fragColour;\n"
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
" fragColour = colourV;\n"
|
||||
"}\n"
|
||||
;
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
#version 150
|
||||
|
||||
uniform mat4 ModelViewMatrix;
|
||||
uniform mat4 ProjectionMatrix;
|
||||
uniform vec4 colour;
|
||||
in vec4 position;
|
||||
in vec4 colourIn;
|
||||
out vec4 colourV;
|
||||
|
||||
void main (void)
|
||||
{
|
||||
colourV = (colour[3] == -1) ? colourIn : colour;
|
||||
gl_Position = ProjectionMatrix * ModelViewMatrix * position;
|
||||
|
||||
}
|
||||
16
Engine/lib/bullet/examples/OpenGLWindow/Shaders/pointsVS.h
Normal file
16
Engine/lib/bullet/examples/OpenGLWindow/Shaders/pointsVS.h
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
//this file is autogenerated using stringify.bat (premake --stringify) in the build folder of this project
|
||||
static const char* pointsVertexShader= \
|
||||
"#version 150 \n"
|
||||
"uniform mat4 ModelViewMatrix;\n"
|
||||
"uniform mat4 ProjectionMatrix;\n"
|
||||
"uniform vec4 colour;\n"
|
||||
"in vec4 position;\n"
|
||||
"in vec4 colourIn;\n"
|
||||
"out vec4 colourV;\n"
|
||||
"void main (void)\n"
|
||||
"{\n"
|
||||
" colourV = (colour[3] == -1) ? colourIn : colour;\n"
|
||||
" gl_Position = ProjectionMatrix * ModelViewMatrix * position;\n"
|
||||
" \n"
|
||||
"}\n"
|
||||
;
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
#version 330 core
|
||||
//precision highp float;
|
||||
|
||||
in Fragment
|
||||
{
|
||||
vec4 color;
|
||||
} fragment;
|
||||
|
||||
uniform sampler2D Diffuse;
|
||||
uniform mat4 ViewMatrixInverse;
|
||||
uniform mat4 TextureMVP;
|
||||
|
||||
in vec3 lightPos,cameraPosition, normal,ambient;
|
||||
in vec4 vertexPos;
|
||||
in float materialShininess;
|
||||
in vec3 lightSpecularIntensity;
|
||||
in vec3 materialSpecularColor;
|
||||
|
||||
out vec4 color;
|
||||
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec4 projcoords = TextureMVP * vertexPos;
|
||||
vec2 texturecoords = projcoords.xy/projcoords.w;
|
||||
vec4 texel = fragment.color*texture(Diffuse,texturecoords);
|
||||
vec3 ct,cf;
|
||||
float intensity,at,af;
|
||||
if (fragment.color.w==0)
|
||||
discard;
|
||||
vec3 lightDir = normalize(lightPos);
|
||||
|
||||
vec3 normalDir = normalize(normal);
|
||||
|
||||
intensity = 0.5+0.5*clamp( dot( normalDir,lightDir ), -1,1 );
|
||||
|
||||
af = 1.0;
|
||||
|
||||
ct = texel.rgb;
|
||||
at = texel.a;
|
||||
|
||||
//float bias = 0.005f;
|
||||
|
||||
vec3 specularReflection;
|
||||
|
||||
if (dot(normalDir, lightDir) < 0.0)
|
||||
{
|
||||
specularReflection = vec3(0.0, 0.0, 0.0);
|
||||
}
|
||||
else // light source on the right side
|
||||
{
|
||||
vec3 surfaceToLight = normalize(lightPos - vertexPos.xyz);
|
||||
vec3 surfaceToCamera = normalize(cameraPosition - vertexPos.xyz);
|
||||
|
||||
|
||||
float specularCoefficient = 0.0;
|
||||
specularCoefficient = pow(max(0.0, dot(surfaceToCamera, reflect(-surfaceToLight, normalDir))), materialShininess);
|
||||
specularReflection = specularCoefficient * materialSpecularColor * lightSpecularIntensity;
|
||||
|
||||
}
|
||||
|
||||
|
||||
float visibility = 1.0;
|
||||
|
||||
intensity = 0.7*intensity + 0.3*intensity*visibility;
|
||||
|
||||
cf = intensity*(vec3(1.0,1.0,1.0)-ambient)+ambient+specularReflection*visibility;
|
||||
color = vec4(ct * cf, fragment.color.w);
|
||||
}
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
//this file is autogenerated using stringify.bat (premake --stringify) in the build folder of this project
|
||||
static const char* projectiveTextureInstancingFragmentShader= \
|
||||
"#version 330 core\n"
|
||||
"//precision highp float;\n"
|
||||
"in Fragment\n"
|
||||
"{\n"
|
||||
" vec4 color;\n"
|
||||
"} fragment;\n"
|
||||
"uniform sampler2D Diffuse;\n"
|
||||
"uniform mat4 ViewMatrixInverse;\n"
|
||||
"uniform mat4 TextureMVP;\n"
|
||||
"in vec3 lightPos,cameraPosition, normal,ambient;\n"
|
||||
"in vec4 vertexPos;\n"
|
||||
"in float materialShininess;\n"
|
||||
"in vec3 lightSpecularIntensity;\n"
|
||||
"in vec3 materialSpecularColor;\n"
|
||||
"out vec4 color;\n"
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
" vec4 projcoords = TextureMVP * vertexPos;\n"
|
||||
" vec2 texturecoords = projcoords.xy/projcoords.w;\n"
|
||||
" vec4 texel = fragment.color*texture(Diffuse,texturecoords);\n"
|
||||
" vec3 ct,cf;\n"
|
||||
" float intensity,at,af;\n"
|
||||
" if (fragment.color.w==0)\n"
|
||||
" discard;\n"
|
||||
" vec3 lightDir = normalize(lightPos);\n"
|
||||
" \n"
|
||||
" vec3 normalDir = normalize(normal);\n"
|
||||
" \n"
|
||||
" intensity = 0.5+0.5*clamp( dot( normalDir,lightDir ), -1,1 );\n"
|
||||
" \n"
|
||||
" af = 1.0;\n"
|
||||
" \n"
|
||||
" ct = texel.rgb;\n"
|
||||
" at = texel.a;\n"
|
||||
" \n"
|
||||
" //float bias = 0.005f;\n"
|
||||
" \n"
|
||||
" vec3 specularReflection;\n"
|
||||
" \n"
|
||||
" if (dot(normalDir, lightDir) < 0.0) \n"
|
||||
" {\n"
|
||||
" specularReflection = vec3(0.0, 0.0, 0.0);\n"
|
||||
" }\n"
|
||||
" else // light source on the right side\n"
|
||||
" {\n"
|
||||
" vec3 surfaceToLight = normalize(lightPos - vertexPos.xyz);\n"
|
||||
" vec3 surfaceToCamera = normalize(cameraPosition - vertexPos.xyz);\n"
|
||||
" \n"
|
||||
" \n"
|
||||
" float specularCoefficient = 0.0;\n"
|
||||
" specularCoefficient = pow(max(0.0, dot(surfaceToCamera, reflect(-surfaceToLight, normalDir))), materialShininess);\n"
|
||||
" specularReflection = specularCoefficient * materialSpecularColor * lightSpecularIntensity;\n"
|
||||
" \n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" float visibility = 1.0;\n"
|
||||
" intensity = 0.7*intensity + 0.3*intensity*visibility;\n"
|
||||
" \n"
|
||||
" cf = intensity*(vec3(1.0,1.0,1.0)-ambient)+ambient+specularReflection*visibility;\n"
|
||||
" color = vec4(ct * cf, fragment.color.w);\n"
|
||||
"}\n"
|
||||
;
|
||||
|
|
@ -0,0 +1,97 @@
|
|||
#version 330
|
||||
precision highp float;
|
||||
|
||||
|
||||
layout (location = 0) in vec4 position;
|
||||
layout (location = 1) in vec4 instance_position;
|
||||
layout (location = 2) in vec4 instance_quaternion;
|
||||
layout (location = 3) in vec2 uvcoords;
|
||||
layout (location = 4) in vec3 vertexnormal;
|
||||
layout (location = 5) in vec4 instance_color;
|
||||
layout (location = 6) in vec4 instance_scale_obUid;
|
||||
|
||||
|
||||
uniform mat4 TextureMVP;
|
||||
uniform mat4 MVP;
|
||||
uniform vec3 lightPosIn;
|
||||
uniform vec3 cameraPositionIn;
|
||||
uniform mat4 ViewMatrixInverse;
|
||||
uniform float materialShininessIn;
|
||||
uniform vec3 lightSpecularIntensityIn;
|
||||
uniform vec3 materialSpecularColorIn;
|
||||
|
||||
out vec4 ShadowCoord;
|
||||
|
||||
out Fragment
|
||||
{
|
||||
vec4 color;
|
||||
} fragment;
|
||||
|
||||
out Vert
|
||||
{
|
||||
vec2 texcoord;
|
||||
} vert;
|
||||
|
||||
|
||||
vec4 quatMul ( in vec4 q1, in vec4 q2 )
|
||||
{
|
||||
vec3 im = q1.w * q2.xyz + q1.xyz * q2.w + cross ( q1.xyz, q2.xyz );
|
||||
vec4 dt = q1 * q2;
|
||||
float re = dot ( dt, vec4 ( -1.0, -1.0, -1.0, 1.0 ) );
|
||||
return vec4 ( im, re );
|
||||
}
|
||||
|
||||
vec4 quatFromAxisAngle(vec4 axis, in float angle)
|
||||
{
|
||||
float cah = cos(angle*0.5);
|
||||
float sah = sin(angle*0.5);
|
||||
float d = inversesqrt(dot(axis,axis));
|
||||
vec4 q = vec4(axis.x*sah*d,axis.y*sah*d,axis.z*sah*d,cah);
|
||||
return q;
|
||||
}
|
||||
//
|
||||
// vector rotation via quaternion
|
||||
//
|
||||
vec4 quatRotate3 ( in vec3 p, in vec4 q )
|
||||
{
|
||||
vec4 temp = quatMul ( q, vec4 ( p, 0.0 ) );
|
||||
return quatMul ( temp, vec4 ( -q.x, -q.y, -q.z, q.w ) );
|
||||
}
|
||||
vec4 quatRotate ( in vec4 p, in vec4 q )
|
||||
{
|
||||
vec4 temp = quatMul ( q, p );
|
||||
return quatMul ( temp, vec4 ( -q.x, -q.y, -q.z, q.w ) );
|
||||
}
|
||||
|
||||
out vec3 lightPos,normal,ambient;
|
||||
out vec4 vertexPos;
|
||||
out vec3 cameraPosition;
|
||||
out float materialShininess;
|
||||
out vec3 lightSpecularIntensity;
|
||||
out vec3 materialSpecularColor;
|
||||
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec4 q = instance_quaternion;
|
||||
ambient = vec3(0.5,.5,0.5);
|
||||
|
||||
vec4 worldNormal = (quatRotate3( vertexnormal,q));
|
||||
|
||||
normal = worldNormal.xyz;
|
||||
|
||||
lightPos = lightPosIn;
|
||||
cameraPosition = cameraPositionIn;
|
||||
materialShininess = materialShininessIn;
|
||||
lightSpecularIntensity = lightSpecularIntensityIn;
|
||||
materialSpecularColor = materialSpecularColorIn;
|
||||
|
||||
vec4 localcoord = quatRotate3( position.xyz*instance_scale_obUid.xyz,q);
|
||||
vertexPos = vec4((instance_position+localcoord).xyz,1);
|
||||
|
||||
vec4 vertexLoc = MVP* vec4((instance_position+localcoord).xyz,1);
|
||||
gl_Position = vertexLoc;
|
||||
|
||||
fragment.color = instance_color;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
//this file is autogenerated using stringify.bat (premake --stringify) in the build folder of this project
|
||||
static const char* projectiveTextureInstancingVertexShader= \
|
||||
"#version 330 \n"
|
||||
"precision highp float;\n"
|
||||
"layout (location = 0) in vec4 position;\n"
|
||||
"layout (location = 1) in vec4 instance_position;\n"
|
||||
"layout (location = 2) in vec4 instance_quaternion;\n"
|
||||
"layout (location = 3) in vec2 uvcoords;\n"
|
||||
"layout (location = 4) in vec3 vertexnormal;\n"
|
||||
"layout (location = 5) in vec4 instance_color;\n"
|
||||
"layout (location = 6) in vec4 instance_scale_obUid;\n"
|
||||
"uniform mat4 TextureMVP;\n"
|
||||
"uniform mat4 MVP;\n"
|
||||
"uniform vec3 lightPosIn;\n"
|
||||
"uniform vec3 cameraPositionIn;\n"
|
||||
"uniform mat4 ViewMatrixInverse;\n"
|
||||
"uniform float materialShininessIn;\n"
|
||||
"uniform vec3 lightSpecularIntensityIn;\n"
|
||||
"uniform vec3 materialSpecularColorIn;\n"
|
||||
"out vec4 ShadowCoord;\n"
|
||||
"out Fragment\n"
|
||||
"{\n"
|
||||
" vec4 color;\n"
|
||||
"} fragment;\n"
|
||||
"out Vert\n"
|
||||
"{\n"
|
||||
" vec2 texcoord;\n"
|
||||
"} vert;\n"
|
||||
"vec4 quatMul ( in vec4 q1, in vec4 q2 )\n"
|
||||
"{\n"
|
||||
" vec3 im = q1.w * q2.xyz + q1.xyz * q2.w + cross ( q1.xyz, q2.xyz );\n"
|
||||
" vec4 dt = q1 * q2;\n"
|
||||
" float re = dot ( dt, vec4 ( -1.0, -1.0, -1.0, 1.0 ) );\n"
|
||||
" return vec4 ( im, re );\n"
|
||||
"}\n"
|
||||
"vec4 quatFromAxisAngle(vec4 axis, in float angle)\n"
|
||||
"{\n"
|
||||
" float cah = cos(angle*0.5);\n"
|
||||
" float sah = sin(angle*0.5);\n"
|
||||
" float d = inversesqrt(dot(axis,axis));\n"
|
||||
" vec4 q = vec4(axis.x*sah*d,axis.y*sah*d,axis.z*sah*d,cah);\n"
|
||||
" return q;\n"
|
||||
"}\n"
|
||||
"//\n"
|
||||
"// vector rotation via quaternion\n"
|
||||
"//\n"
|
||||
"vec4 quatRotate3 ( in vec3 p, in vec4 q )\n"
|
||||
"{\n"
|
||||
" vec4 temp = quatMul ( q, vec4 ( p, 0.0 ) );\n"
|
||||
" return quatMul ( temp, vec4 ( -q.x, -q.y, -q.z, q.w ) );\n"
|
||||
"}\n"
|
||||
"vec4 quatRotate ( in vec4 p, in vec4 q )\n"
|
||||
"{\n"
|
||||
" vec4 temp = quatMul ( q, p );\n"
|
||||
" return quatMul ( temp, vec4 ( -q.x, -q.y, -q.z, q.w ) );\n"
|
||||
"}\n"
|
||||
"out vec3 lightPos,normal,ambient;\n"
|
||||
"out vec4 vertexPos;\n"
|
||||
"out vec3 cameraPosition;\n"
|
||||
"out float materialShininess;\n"
|
||||
"out vec3 lightSpecularIntensity;\n"
|
||||
"out vec3 materialSpecularColor;\n"
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
" vec4 q = instance_quaternion;\n"
|
||||
" ambient = vec3(0.5,.5,0.5);\n"
|
||||
" \n"
|
||||
" vec4 worldNormal = (quatRotate3( vertexnormal,q));\n"
|
||||
" \n"
|
||||
" normal = worldNormal.xyz;\n"
|
||||
" lightPos = lightPosIn;\n"
|
||||
" cameraPosition = cameraPositionIn;\n"
|
||||
" materialShininess = materialShininessIn;\n"
|
||||
" lightSpecularIntensity = lightSpecularIntensityIn;\n"
|
||||
" materialSpecularColor = materialSpecularColorIn;\n"
|
||||
" \n"
|
||||
" vec4 localcoord = quatRotate3( position.xyz*instance_scale_obUid.xyz,q);\n"
|
||||
" vertexPos = vec4((instance_position+localcoord).xyz,1);\n"
|
||||
" \n"
|
||||
" vec4 vertexLoc = MVP* vec4((instance_position+localcoord).xyz,1);\n"
|
||||
" gl_Position = vertexLoc;\n"
|
||||
" fragment.color = instance_color;\n"
|
||||
"}\n"
|
||||
;
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
#version 330
|
||||
precision highp float;
|
||||
in vec4 scale_obuid;
|
||||
out vec4 color;
|
||||
|
||||
|
||||
|
||||
void main(void)
|
||||
{
|
||||
highp int obuid = int(scale_obuid.w);
|
||||
float r = ((obuid>>0 )&0xff)*(1./255.f);
|
||||
float g = ((obuid>>8 )&0xff)*(1./255.f);
|
||||
float b = ((obuid>>16)&0xff)*(1./255.f);
|
||||
float a = ((obuid>>24)&0xff)*(1./255.f);
|
||||
color = vec4(r,g,b,a);
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
//this file is autogenerated using stringify.bat (premake --stringify) in the build folder of this project
|
||||
static const char* segmentationMaskInstancingFragmentShader= \
|
||||
"#version 330\n"
|
||||
"precision highp float;\n"
|
||||
"in vec4 scale_obuid;\n"
|
||||
"out vec4 color;\n"
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
" highp int obuid = int(scale_obuid.w);\n"
|
||||
" float r = ((obuid>>0 )&0xff)*(1./255.f);\n"
|
||||
" float g = ((obuid>>8 )&0xff)*(1./255.f);\n"
|
||||
" float b = ((obuid>>16)&0xff)*(1./255.f);\n"
|
||||
" float a = ((obuid>>24)&0xff)*(1./255.f);\n"
|
||||
" color = vec4(r,g,b,a);\n"
|
||||
"}\n"
|
||||
;
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
#version 330
|
||||
precision highp float;
|
||||
|
||||
|
||||
layout (location = 0) in vec4 position;
|
||||
layout (location = 1) in vec4 instance_position;
|
||||
layout (location = 2) in vec4 instance_quaternion;
|
||||
layout (location = 5) in vec4 instance_color;
|
||||
layout (location = 6) in vec4 instance_scale_obUid;
|
||||
|
||||
uniform mat4 ModelViewMatrix;
|
||||
uniform mat4 ProjectionMatrix;
|
||||
|
||||
out vec4 scale_obuid;
|
||||
|
||||
out Fragment
|
||||
{
|
||||
vec4 color;
|
||||
} fragment;
|
||||
|
||||
vec4 quatMul ( in vec4 q1, in vec4 q2 )
|
||||
{
|
||||
vec3 im = q1.w * q2.xyz + q1.xyz * q2.w + cross ( q1.xyz, q2.xyz );
|
||||
vec4 dt = q1 * q2;
|
||||
float re = dot ( dt, vec4 ( -1.0, -1.0, -1.0, 1.0 ) );
|
||||
return vec4 ( im, re );
|
||||
}
|
||||
|
||||
vec4 quatFromAxisAngle(vec4 axis, in float angle)
|
||||
{
|
||||
float cah = cos(angle*0.5);
|
||||
float sah = sin(angle*0.5);
|
||||
float d = inversesqrt(dot(axis,axis));
|
||||
vec4 q = vec4(axis.x*sah*d,axis.y*sah*d,axis.z*sah*d,cah);
|
||||
return q;
|
||||
}
|
||||
//
|
||||
// vector rotation via quaternion
|
||||
//
|
||||
vec4 quatRotate3 ( in vec3 p, in vec4 q )
|
||||
{
|
||||
vec4 temp = quatMul ( q, vec4 ( p, 0.0 ) );
|
||||
return quatMul ( temp, vec4 ( -q.x, -q.y, -q.z, q.w ) );
|
||||
}
|
||||
vec4 quatRotate ( in vec4 p, in vec4 q )
|
||||
{
|
||||
vec4 temp = quatMul ( q, p );
|
||||
return quatMul ( temp, vec4 ( -q.x, -q.y, -q.z, q.w ) );
|
||||
}
|
||||
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec4 q = instance_quaternion;
|
||||
vec4 localcoord = quatRotate3( position.xyz*instance_scale_obUid.xyz,q);
|
||||
vec4 vertexPos = ProjectionMatrix * ModelViewMatrix *(instance_position+localcoord);
|
||||
scale_obuid = instance_scale_obUid;
|
||||
gl_Position = vertexPos;
|
||||
fragment.color = instance_color;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
//this file is autogenerated using stringify.bat (premake --stringify) in the build folder of this project
|
||||
static const char* segmentationMaskInstancingVertexShader= \
|
||||
"#version 330\n"
|
||||
"precision highp float;\n"
|
||||
"layout (location = 0) in vec4 position;\n"
|
||||
"layout (location = 1) in vec4 instance_position;\n"
|
||||
"layout (location = 2) in vec4 instance_quaternion;\n"
|
||||
"layout (location = 5) in vec4 instance_color;\n"
|
||||
"layout (location = 6) in vec4 instance_scale_obUid;\n"
|
||||
"uniform mat4 ModelViewMatrix;\n"
|
||||
"uniform mat4 ProjectionMatrix;\n"
|
||||
"out vec4 scale_obuid;\n"
|
||||
"out Fragment\n"
|
||||
"{\n"
|
||||
" vec4 color;\n"
|
||||
"} fragment;\n"
|
||||
"vec4 quatMul ( in vec4 q1, in vec4 q2 )\n"
|
||||
"{\n"
|
||||
" vec3 im = q1.w * q2.xyz + q1.xyz * q2.w + cross ( q1.xyz, q2.xyz );\n"
|
||||
" vec4 dt = q1 * q2;\n"
|
||||
" float re = dot ( dt, vec4 ( -1.0, -1.0, -1.0, 1.0 ) );\n"
|
||||
" return vec4 ( im, re );\n"
|
||||
"}\n"
|
||||
"vec4 quatFromAxisAngle(vec4 axis, in float angle)\n"
|
||||
"{\n"
|
||||
" float cah = cos(angle*0.5);\n"
|
||||
" float sah = sin(angle*0.5);\n"
|
||||
" float d = inversesqrt(dot(axis,axis));\n"
|
||||
" vec4 q = vec4(axis.x*sah*d,axis.y*sah*d,axis.z*sah*d,cah);\n"
|
||||
" return q;\n"
|
||||
"}\n"
|
||||
"//\n"
|
||||
"// vector rotation via quaternion\n"
|
||||
"//\n"
|
||||
"vec4 quatRotate3 ( in vec3 p, in vec4 q )\n"
|
||||
"{\n"
|
||||
" vec4 temp = quatMul ( q, vec4 ( p, 0.0 ) );\n"
|
||||
" return quatMul ( temp, vec4 ( -q.x, -q.y, -q.z, q.w ) );\n"
|
||||
"}\n"
|
||||
"vec4 quatRotate ( in vec4 p, in vec4 q )\n"
|
||||
"{\n"
|
||||
" vec4 temp = quatMul ( q, p );\n"
|
||||
" return quatMul ( temp, vec4 ( -q.x, -q.y, -q.z, q.w ) );\n"
|
||||
"}\n"
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
" vec4 q = instance_quaternion;\n"
|
||||
" vec4 localcoord = quatRotate3( position.xyz*instance_scale_obUid.xyz,q);\n"
|
||||
" vec4 vertexPos = ProjectionMatrix * ModelViewMatrix *(instance_position+localcoord);\n"
|
||||
" scale_obuid = instance_scale_obUid;\n"
|
||||
" gl_Position = vertexPos;\n"
|
||||
" fragment.color = instance_color;\n"
|
||||
"}\n"
|
||||
;
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
#version 330 core
|
||||
//precision highp float;
|
||||
|
||||
in Fragment
|
||||
{
|
||||
vec4 color;
|
||||
} fragment;
|
||||
|
||||
in Vert
|
||||
{
|
||||
vec2 texcoord;
|
||||
} vert;
|
||||
|
||||
uniform sampler2D Diffuse;
|
||||
uniform sampler2DShadow shadowMap;
|
||||
uniform mat4 ViewMatrixInverse;
|
||||
|
||||
in vec3 lightPos,cameraPosition, normal,ambient;
|
||||
in vec4 ShadowCoord;
|
||||
in vec4 vertexPos;
|
||||
in float materialShininess;
|
||||
in float shadowmapIntensity;
|
||||
in vec3 lightSpecularIntensity;
|
||||
in vec3 materialSpecularColor;
|
||||
|
||||
out vec4 color;
|
||||
|
||||
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec4 texel = fragment.color*texture(Diffuse,vert.texcoord);
|
||||
vec3 ct,cf;
|
||||
float intensity,at,af;
|
||||
if (fragment.color.w==0)
|
||||
discard;
|
||||
vec3 lightDir = normalize(lightPos);
|
||||
|
||||
vec3 normalDir = normalize(normal);
|
||||
|
||||
intensity = 0.5+0.5*clamp( dot( normalDir,lightDir ), -1,1 );
|
||||
|
||||
af = 1.0;
|
||||
|
||||
ct = texel.rgb;
|
||||
at = texel.a;
|
||||
|
||||
//float bias = 0.005f;
|
||||
|
||||
vec3 specularReflection;
|
||||
|
||||
if (dot(normalDir, lightDir) < 0.0)
|
||||
{
|
||||
specularReflection = vec3(0.0, 0.0, 0.0);
|
||||
}
|
||||
else // light source on the right side
|
||||
{
|
||||
vec3 surfaceToLight = normalize(lightPos - vertexPos.xyz);
|
||||
vec3 surfaceToCamera = normalize(cameraPosition - vertexPos.xyz);
|
||||
|
||||
|
||||
float specularCoefficient = 0.0;
|
||||
specularCoefficient = pow(max(0.0, dot(surfaceToCamera, reflect(-surfaceToLight, normalDir))), materialShininess);
|
||||
specularReflection = specularCoefficient * materialSpecularColor * lightSpecularIntensity;
|
||||
|
||||
}
|
||||
|
||||
|
||||
float visibility = texture(shadowMap, vec3(ShadowCoord.xy,(ShadowCoord.z)/ShadowCoord.w));
|
||||
if (intensity<0.5)
|
||||
visibility = 0;
|
||||
|
||||
intensity = (1.0-shadowmapIntensity)*intensity + shadowmapIntensity*intensity*visibility;
|
||||
|
||||
cf = intensity*(vec3(1.0,1.0,1.0)-ambient)+ambient+specularReflection*visibility;
|
||||
color = vec4(ct * cf, fragment.color.w);
|
||||
}
|
||||
70
Engine/lib/bullet/examples/OpenGLWindow/Shaders/useShadowMapInstancingPS.h
Executable file
70
Engine/lib/bullet/examples/OpenGLWindow/Shaders/useShadowMapInstancingPS.h
Executable file
|
|
@ -0,0 +1,70 @@
|
|||
//this file is autogenerated using stringify.bat (premake --stringify) in the build folder of this project
|
||||
static const char* useShadowMapInstancingFragmentShader= \
|
||||
"#version 330 core\n"
|
||||
"//precision highp float;\n"
|
||||
"in Fragment\n"
|
||||
"{\n"
|
||||
" vec4 color;\n"
|
||||
"} fragment;\n"
|
||||
"in Vert\n"
|
||||
"{\n"
|
||||
" vec2 texcoord;\n"
|
||||
"} vert;\n"
|
||||
"uniform sampler2D Diffuse;\n"
|
||||
"uniform sampler2DShadow shadowMap;\n"
|
||||
"uniform mat4 ViewMatrixInverse;\n"
|
||||
"in vec3 lightPos,cameraPosition, normal,ambient;\n"
|
||||
"in vec4 ShadowCoord;\n"
|
||||
"in vec4 vertexPos;\n"
|
||||
"in float materialShininess;\n"
|
||||
"in float shadowmapIntensity;\n"
|
||||
"in vec3 lightSpecularIntensity;\n"
|
||||
"in vec3 materialSpecularColor;\n"
|
||||
"out vec4 color;\n"
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
" vec4 texel = fragment.color*texture(Diffuse,vert.texcoord);\n"
|
||||
" vec3 ct,cf;\n"
|
||||
" float intensity,at,af;\n"
|
||||
" if (fragment.color.w==0)\n"
|
||||
" discard;\n"
|
||||
" vec3 lightDir = normalize(lightPos);\n"
|
||||
" \n"
|
||||
" vec3 normalDir = normalize(normal);\n"
|
||||
" \n"
|
||||
" intensity = 0.5+0.5*clamp( dot( normalDir,lightDir ), -1,1 );\n"
|
||||
" \n"
|
||||
" af = 1.0;\n"
|
||||
" \n"
|
||||
" ct = texel.rgb;\n"
|
||||
" at = texel.a;\n"
|
||||
" \n"
|
||||
" //float bias = 0.005f;\n"
|
||||
" \n"
|
||||
" vec3 specularReflection;\n"
|
||||
" \n"
|
||||
" if (dot(normalDir, lightDir) < 0.0) \n"
|
||||
" {\n"
|
||||
" specularReflection = vec3(0.0, 0.0, 0.0);\n"
|
||||
" }\n"
|
||||
" else // light source on the right side\n"
|
||||
" {\n"
|
||||
" vec3 surfaceToLight = normalize(lightPos - vertexPos.xyz);\n"
|
||||
" vec3 surfaceToCamera = normalize(cameraPosition - vertexPos.xyz);\n"
|
||||
" \n"
|
||||
" \n"
|
||||
" float specularCoefficient = 0.0;\n"
|
||||
" specularCoefficient = pow(max(0.0, dot(surfaceToCamera, reflect(-surfaceToLight, normalDir))), materialShininess);\n"
|
||||
" specularReflection = specularCoefficient * materialSpecularColor * lightSpecularIntensity;\n"
|
||||
" \n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" float visibility = texture(shadowMap, vec3(ShadowCoord.xy,(ShadowCoord.z)/ShadowCoord.w));\n"
|
||||
" if (intensity<0.5)\n"
|
||||
" visibility = 0;\n"
|
||||
" intensity = (1.0-shadowmapIntensity)*intensity + shadowmapIntensity*intensity*visibility;\n"
|
||||
" \n"
|
||||
" cf = intensity*(vec3(1.0,1.0,1.0)-ambient)+ambient+specularReflection*visibility;\n"
|
||||
" color = vec4(ct * cf, fragment.color.w);\n"
|
||||
"}\n"
|
||||
;
|
||||
105
Engine/lib/bullet/examples/OpenGLWindow/Shaders/useShadowMapInstancingVS.glsl
Executable file
105
Engine/lib/bullet/examples/OpenGLWindow/Shaders/useShadowMapInstancingVS.glsl
Executable file
|
|
@ -0,0 +1,105 @@
|
|||
#version 330
|
||||
precision highp float;
|
||||
|
||||
|
||||
layout (location = 0) in vec4 position;
|
||||
layout (location = 1) in vec4 instance_position;
|
||||
layout (location = 2) in vec4 instance_quaternion;
|
||||
layout (location = 3) in vec2 uvcoords;
|
||||
layout (location = 4) in vec3 vertexnormal;
|
||||
layout (location = 5) in vec4 instance_color;
|
||||
layout (location = 6) in vec4 instance_scale_obUid;
|
||||
|
||||
|
||||
uniform mat4 ModelViewMatrix;
|
||||
uniform mat4 ProjectionMatrix;
|
||||
uniform mat4 DepthBiasModelViewProjectionMatrix;
|
||||
uniform mat4 MVP;
|
||||
uniform vec3 lightPosIn;
|
||||
uniform vec3 cameraPositionIn;
|
||||
uniform mat4 ViewMatrixInverse;
|
||||
uniform float materialShininessIn;
|
||||
uniform float shadowmapIntensityIn;
|
||||
uniform vec3 lightSpecularIntensityIn;
|
||||
uniform vec3 materialSpecularColorIn;
|
||||
|
||||
out vec4 ShadowCoord;
|
||||
|
||||
out Fragment
|
||||
{
|
||||
vec4 color;
|
||||
} fragment;
|
||||
|
||||
out Vert
|
||||
{
|
||||
vec2 texcoord;
|
||||
} vert;
|
||||
|
||||
|
||||
vec4 quatMul ( in vec4 q1, in vec4 q2 )
|
||||
{
|
||||
vec3 im = q1.w * q2.xyz + q1.xyz * q2.w + cross ( q1.xyz, q2.xyz );
|
||||
vec4 dt = q1 * q2;
|
||||
float re = dot ( dt, vec4 ( -1.0, -1.0, -1.0, 1.0 ) );
|
||||
return vec4 ( im, re );
|
||||
}
|
||||
|
||||
vec4 quatFromAxisAngle(vec4 axis, in float angle)
|
||||
{
|
||||
float cah = cos(angle*0.5);
|
||||
float sah = sin(angle*0.5);
|
||||
float d = inversesqrt(dot(axis,axis));
|
||||
vec4 q = vec4(axis.x*sah*d,axis.y*sah*d,axis.z*sah*d,cah);
|
||||
return q;
|
||||
}
|
||||
//
|
||||
// vector rotation via quaternion
|
||||
//
|
||||
vec4 quatRotate3 ( in vec3 p, in vec4 q )
|
||||
{
|
||||
vec4 temp = quatMul ( q, vec4 ( p, 0.0 ) );
|
||||
return quatMul ( temp, vec4 ( -q.x, -q.y, -q.z, q.w ) );
|
||||
}
|
||||
vec4 quatRotate ( in vec4 p, in vec4 q )
|
||||
{
|
||||
vec4 temp = quatMul ( q, p );
|
||||
return quatMul ( temp, vec4 ( -q.x, -q.y, -q.z, q.w ) );
|
||||
}
|
||||
|
||||
out vec3 lightPos,normal,ambient;
|
||||
out vec4 vertexPos;
|
||||
out vec3 cameraPosition;
|
||||
out float materialShininess;
|
||||
out float shadowmapIntensity;
|
||||
out vec3 lightSpecularIntensity;
|
||||
out vec3 materialSpecularColor;
|
||||
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec4 q = instance_quaternion;
|
||||
ambient = vec3(0.5,.5,0.5);
|
||||
|
||||
vec4 worldNormal = (quatRotate3( vertexnormal,q));
|
||||
|
||||
normal = worldNormal.xyz;
|
||||
|
||||
lightPos = lightPosIn;
|
||||
cameraPosition = cameraPositionIn;
|
||||
materialShininess = materialShininessIn;
|
||||
|
||||
shadowmapIntensity = shadowmapIntensityIn;
|
||||
lightSpecularIntensity = lightSpecularIntensityIn;
|
||||
materialSpecularColor = materialSpecularColorIn;
|
||||
|
||||
vec4 localcoord = quatRotate3( position.xyz*instance_scale_obUid.xyz,q);
|
||||
vertexPos = vec4((instance_position+localcoord).xyz,1);
|
||||
|
||||
vec4 vertexLoc = MVP* vec4((instance_position+localcoord).xyz,1);
|
||||
gl_Position = vertexLoc;
|
||||
ShadowCoord = DepthBiasModelViewProjectionMatrix * vec4((instance_position+localcoord).xyz,1);
|
||||
|
||||
fragment.color = instance_color;
|
||||
vert.texcoord = uvcoords;
|
||||
}
|
||||
|
||||
92
Engine/lib/bullet/examples/OpenGLWindow/Shaders/useShadowMapInstancingVS.h
Executable file
92
Engine/lib/bullet/examples/OpenGLWindow/Shaders/useShadowMapInstancingVS.h
Executable file
|
|
@ -0,0 +1,92 @@
|
|||
//this file is autogenerated using stringify.bat (premake --stringify) in the build folder of this project
|
||||
static const char* useShadowMapInstancingVertexShader= \
|
||||
"#version 330 \n"
|
||||
"precision highp float;\n"
|
||||
"layout (location = 0) in vec4 position;\n"
|
||||
"layout (location = 1) in vec4 instance_position;\n"
|
||||
"layout (location = 2) in vec4 instance_quaternion;\n"
|
||||
"layout (location = 3) in vec2 uvcoords;\n"
|
||||
"layout (location = 4) in vec3 vertexnormal;\n"
|
||||
"layout (location = 5) in vec4 instance_color;\n"
|
||||
"layout (location = 6) in vec4 instance_scale_obUid;\n"
|
||||
"uniform mat4 ModelViewMatrix;\n"
|
||||
"uniform mat4 ProjectionMatrix;\n"
|
||||
"uniform mat4 DepthBiasModelViewProjectionMatrix;\n"
|
||||
"uniform mat4 MVP;\n"
|
||||
"uniform vec3 lightPosIn;\n"
|
||||
"uniform vec3 cameraPositionIn;\n"
|
||||
"uniform mat4 ViewMatrixInverse;\n"
|
||||
"uniform float materialShininessIn;\n"
|
||||
"uniform float shadowmapIntensityIn;\n"
|
||||
"uniform vec3 lightSpecularIntensityIn;\n"
|
||||
"uniform vec3 materialSpecularColorIn;\n"
|
||||
"out vec4 ShadowCoord;\n"
|
||||
"out Fragment\n"
|
||||
"{\n"
|
||||
" vec4 color;\n"
|
||||
"} fragment;\n"
|
||||
"out Vert\n"
|
||||
"{\n"
|
||||
" vec2 texcoord;\n"
|
||||
"} vert;\n"
|
||||
"vec4 quatMul ( in vec4 q1, in vec4 q2 )\n"
|
||||
"{\n"
|
||||
" vec3 im = q1.w * q2.xyz + q1.xyz * q2.w + cross ( q1.xyz, q2.xyz );\n"
|
||||
" vec4 dt = q1 * q2;\n"
|
||||
" float re = dot ( dt, vec4 ( -1.0, -1.0, -1.0, 1.0 ) );\n"
|
||||
" return vec4 ( im, re );\n"
|
||||
"}\n"
|
||||
"vec4 quatFromAxisAngle(vec4 axis, in float angle)\n"
|
||||
"{\n"
|
||||
" float cah = cos(angle*0.5);\n"
|
||||
" float sah = sin(angle*0.5);\n"
|
||||
" float d = inversesqrt(dot(axis,axis));\n"
|
||||
" vec4 q = vec4(axis.x*sah*d,axis.y*sah*d,axis.z*sah*d,cah);\n"
|
||||
" return q;\n"
|
||||
"}\n"
|
||||
"//\n"
|
||||
"// vector rotation via quaternion\n"
|
||||
"//\n"
|
||||
"vec4 quatRotate3 ( in vec3 p, in vec4 q )\n"
|
||||
"{\n"
|
||||
" vec4 temp = quatMul ( q, vec4 ( p, 0.0 ) );\n"
|
||||
" return quatMul ( temp, vec4 ( -q.x, -q.y, -q.z, q.w ) );\n"
|
||||
"}\n"
|
||||
"vec4 quatRotate ( in vec4 p, in vec4 q )\n"
|
||||
"{\n"
|
||||
" vec4 temp = quatMul ( q, p );\n"
|
||||
" return quatMul ( temp, vec4 ( -q.x, -q.y, -q.z, q.w ) );\n"
|
||||
"}\n"
|
||||
"out vec3 lightPos,normal,ambient;\n"
|
||||
"out vec4 vertexPos;\n"
|
||||
"out vec3 cameraPosition;\n"
|
||||
"out float materialShininess;\n"
|
||||
"out float shadowmapIntensity;\n"
|
||||
"out vec3 lightSpecularIntensity;\n"
|
||||
"out vec3 materialSpecularColor;\n"
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
" vec4 q = instance_quaternion;\n"
|
||||
" ambient = vec3(0.5,.5,0.5);\n"
|
||||
" \n"
|
||||
" vec4 worldNormal = (quatRotate3( vertexnormal,q));\n"
|
||||
" \n"
|
||||
" normal = worldNormal.xyz;\n"
|
||||
" lightPos = lightPosIn;\n"
|
||||
" cameraPosition = cameraPositionIn;\n"
|
||||
" materialShininess = materialShininessIn;\n"
|
||||
" \n"
|
||||
" shadowmapIntensity = shadowmapIntensityIn;\n"
|
||||
" lightSpecularIntensity = lightSpecularIntensityIn;\n"
|
||||
" materialSpecularColor = materialSpecularColorIn;\n"
|
||||
" \n"
|
||||
" vec4 localcoord = quatRotate3( position.xyz*instance_scale_obUid.xyz,q);\n"
|
||||
" vertexPos = vec4((instance_position+localcoord).xyz,1);\n"
|
||||
" \n"
|
||||
" vec4 vertexLoc = MVP* vec4((instance_position+localcoord).xyz,1);\n"
|
||||
" gl_Position = vertexLoc;\n"
|
||||
" ShadowCoord = DepthBiasModelViewProjectionMatrix * vec4((instance_position+localcoord).xyz,1);\n"
|
||||
" fragment.color = instance_color;\n"
|
||||
" vert.texcoord = uvcoords;\n"
|
||||
"}\n"
|
||||
;
|
||||
Loading…
Add table
Add a link
Reference in a new issue