Skip to content

Commit ef8cbd8

Browse files
author
oyvindln
committed
Readded GLSL150+ shaders
Added back GLSL150+ shaders Makes OD check shader version and select betweed version accordingly
1 parent ef5171e commit ef8cbd8

27 files changed

+3408
-3
lines changed

cmake/config/resources.cfg.in

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
[Graphics]
22
FileSystem=materials/RTShaderLib
33
FileSystem=materials/RTShaderLib/materials
4-
FileSystem=materials/RTShaderLib/Cg
5-
FileSystem=materials/RTShaderLib/GLSL
64
FileSystem=materials/scripts
75
FileSystem=materials/textures
86
FileSystem=models
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#version 150
2+
3+
mat2x4 blendTwoWeightsAntipod(vec4 blendWgt, vec4 blendIdx, mat2x4 dualQuaternions[24]);
4+
vec3 calculateBlendPosition(vec3 position, mat2x4 blendDQ);
5+
6+
in vec4 vertex;
7+
in vec4 blendIndices;
8+
in vec4 blendWeights;
9+
10+
out vec4 oColour;
11+
// Support up to 24 bones of float3x4
12+
// vs_1_1 only supports 96 params so more than this is not feasible
13+
uniform mat2x4 worldDualQuaternion2x4Array[24];
14+
uniform mat3x4 scaleM[24];
15+
uniform mat4 viewProjectionMatrix;
16+
uniform vec4 ambient;
17+
18+
//Two-phase skinning shadow caster pass
19+
void main()
20+
{
21+
//First phase - applies scaling and shearing:
22+
mat3x4 blendS = blendWeights.x*scaleM[int(blendIndices.x)];
23+
blendS += blendWeights.y*scaleM[int(blendIndices.y)];
24+
25+
vec3 pass1_position = vertex * blendS;
26+
27+
//Second phase
28+
mat2x4 blendDQ = blendTwoWeightsAntipod(blendWeights, blendIndices, worldDualQuaternion2x4Array);
29+
30+
float len = length(blendDQ[0]);
31+
blendDQ /= len;
32+
33+
vec3 blendPosition = calculateBlendPosition(pass1_position, blendDQ);
34+
35+
// view / projection
36+
gl_Position = viewProjectionMatrix * vec4(blendPosition, 1.0);
37+
38+
oColour = ambient;
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#version 150
2+
3+
mat2x4 blendTwoWeightsAntipod(vec4 blendWgt, vec4 blendIdx, mat4x2 dualQuaternions[24]);
4+
vec3 calculateBlendPosition(vec4 position, mat2x4 blendDQ);
5+
6+
uniform mat4x2 worldDualQuaternion2x4Array[24];
7+
uniform mat4x4 viewProjectionMatrix;
8+
uniform vec4 ambient;
9+
10+
in vec4 vertex;
11+
in vec4 blendIndices;
12+
in vec4 blendWeights;
13+
out vec4 oColour;
14+
15+
//Shadow caster pass
16+
void main()
17+
{
18+
mat2x4 blendDQ = blendTwoWeightsAntipod(blendWeights, blendIndices, worldDualQuaternion2x4Array);
19+
20+
float len = length(blendDQ[0]);
21+
blendDQ /= len;
22+
23+
vec3 blendPosition = calculateBlendPosition(vertex, blendDQ);
24+
25+
// view / projection
26+
gl_Position = viewProjectionMatrix * vec4(blendPosition, 1.0);
27+
28+
oColour = ambient;
29+
}
30+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#version 150
2+
3+
vec3 calculateBlendPosition(vec4 position, mat2x4 blendDQ);
4+
5+
uniform mat4x2 worldDualQuaternion2x4Array[24];
6+
uniform mat4x4 viewProjectionMatrix;
7+
uniform vec4 ambient;
8+
9+
in vec4 vertex;
10+
in vec4 blendIndices;
11+
in vec4 blendWeights;
12+
out vec4 oColour;
13+
14+
//Shadow caster pass
15+
void main()
16+
{
17+
mat2x4 blendDQ = blendWeights.x * worldDualQuaternion2x4Array[blendIndices.x];
18+
19+
float len = length(blendDQ[0]);
20+
blendDQ /= len;
21+
22+
vec3 blendPosition = calculateBlendPosition(vertex, blendDQ);
23+
24+
// view / projection
25+
gl_Position = viewProjectionMatrix * vec4(blendPosition, 1.0);
26+
27+
oColour = ambient;
28+
}
29+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#version 150
2+
3+
in vec4 oColour;
4+
out vec4 fragColour;
5+
6+
void main()
7+
{
8+
fragColour = oColour;
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#version 150
2+
3+
uniform mat4x4 viewProjectionMatrix;
4+
in vec4 vertex;
5+
6+
out vec2 oUv0;
7+
8+
void main()
9+
{
10+
// view / projection
11+
gl_Position = viewProjectionMatrix * vertex;
12+
13+
//Depth information
14+
oUv0.x = gl_Position.z;
15+
oUv0.y = gl_Position.w;
16+
}
17+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#version 150
2+
3+
mat2x4 blendTwoWeightsAntipod(vec4 blendWgt, vec4 blendIdx, mat4x2 dualQuaternions[24]);
4+
vec3 calculateBlendPosition(vec4 position, mat2x4 blendDQ);
5+
6+
uniform mat4x2 worldDualQuaternion2x4Array[24];
7+
uniform mat4x4 viewProjectionMatrix;
8+
uniform vec4 ambient;
9+
10+
in vec4 vertex;
11+
in vec4 blendIndices;
12+
in vec4 blendWeights;
13+
out vec4 oColour;
14+
15+
//Shadow caster pass
16+
void main()
17+
{
18+
mat2x4 blendDQ = blendTwoWeightsAntipod(blendWeights, blendIndices, worldDualQuaternion2x4Array);
19+
20+
float len = length(blendDQ[0]);
21+
blendDQ /= len;
22+
23+
vec3 blendPosition = calculateBlendPosition(vertex, blendDQ);
24+
25+
// view / projection
26+
gl_Position = viewProjectionMatrix * vec4(blendPosition, 1.0);
27+
28+
oColour = ambient;
29+
}
30+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#version 150
2+
3+
mat2x4 blendTwoWeightsAntipod(vec4 blendWgt, vec4 blendIdx, vec4 dualQuaternions[48]);
4+
vec3 calculateBlendPosition(vec3 position, mat2x4 blendDQ);
5+
6+
uniform vec4 worldDualQuaternion2x4Array[48];
7+
uniform mat4x4 viewProjectionMatrix;
8+
uniform vec4 ambient;
9+
10+
in vec4 vertex;
11+
in vec4 blendIndices;
12+
in vec4 blendWeights;
13+
out vec4 oColour;
14+
15+
//Shadow caster pass
16+
void main()
17+
{
18+
mat2x4 blendDQ = blendTwoWeightsAntipod(blendWeights, blendIndices, worldDualQuaternion2x4Array);
19+
20+
float len = length(blendDQ[0]);
21+
blendDQ /= len;
22+
23+
vec3 blendPosition = calculateBlendPosition(vertex.xyz, blendDQ);
24+
25+
// view / projection
26+
gl_Position = viewProjectionMatrix * vec4(blendPosition, 1.0);
27+
28+
oColour = ambient;
29+
}
30+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
#version 150
2+
3+
mat2x4 blendTwoWeights(vec4 blendWgt, vec4 blendIdx, mat2x4 dualQuaternions[24])
4+
{
5+
mat2x4 blendDQ = blendWgt.x*dualQuaternions[int(blendIdx.x)];
6+
blendDQ += blendWgt.y*dualQuaternions[int(blendIdx.y)];
7+
8+
return blendDQ;
9+
}
10+
11+
mat2x4 blendTwoWeightsAntipod(vec4 blendWgt, vec4 blendIdx, mat2x4 dualQuaternions[24])
12+
{
13+
mat2x4 dq0 = dualQuaternions[int(blendIdx.x)];
14+
mat2x4 dq1 = dualQuaternions[int(blendIdx.y)];
15+
16+
//Accurate antipodality handling. For speed increase, remove the following line,
17+
//though, the results will only be valid for rotations less than 180 degrees.
18+
if (dot(dq0[0], dq1[0]) < 0.0) dq1 *= -1.0;
19+
20+
mat2x4 blendDQ = blendWgt.x*dq0;
21+
blendDQ += blendWgt.y*dq1;
22+
23+
return blendDQ;
24+
}
25+
26+
mat2x4 blendThreeWeightsAntipod(vec4 blendWgt, vec4 blendIdx, mat2x4 dualQuaternions[24])
27+
{
28+
mat2x4 dq0 = dualQuaternions[int(blendIdx.x)];
29+
mat2x4 dq1 = dualQuaternions[int(blendIdx.y)];
30+
mat2x4 dq2 = dualQuaternions[int(blendIdx.z)];
31+
32+
//Accurate antipodality handling. For speed increase, remove the following line,
33+
//though, the results will only be valid for rotations less than 180 degrees.
34+
if (dot(dq0[0], dq1[0]) < 0.0) dq1 *= -1.0;
35+
if (dot(dq0[0], dq2[0]) < 0.0) dq2 *= -1.0;
36+
37+
mat2x4 blendDQ = blendWgt.x*dq0;
38+
blendDQ += blendWgt.y*dq1;
39+
blendDQ += blendWgt.z*dq2;
40+
41+
return blendDQ;
42+
}
43+
44+
mat2x4 blendFourWeightsAntipod(vec4 blendWgt, vec4 blendIdx, mat2x4 dualQuaternions[24])
45+
{
46+
mat2x4 dq0 = dualQuaternions[int(blendIdx.x)];
47+
mat2x4 dq1 = dualQuaternions[int(blendIdx.y)];
48+
mat2x4 dq2 = dualQuaternions[int(blendIdx.z)];
49+
mat2x4 dq3 = dualQuaternions[int(blendIdx.w)];
50+
51+
//Accurate antipodality handling. For speed increase, remove the following line,
52+
//though, the results will only be valid for rotations less than 180 degrees.
53+
if (dot(dq0[0], dq1[0]) < 0.0) dq1 *= -1.0;
54+
if (dot(dq0[0], dq2[0]) < 0.0) dq2 *= -1.0;
55+
if (dot(dq0[0], dq3[0]) < 0.0) dq3 *= -1.0;
56+
57+
mat2x4 blendDQ = blendWgt.x*dq0;
58+
blendDQ += blendWgt.y*dq1;
59+
blendDQ += blendWgt.z*dq2;
60+
blendDQ += blendWgt.w*dq3;
61+
62+
return blendDQ;
63+
}
64+
65+
vec3 calculateBlendPosition(vec3 position, mat2x4 blendDQ)
66+
{
67+
vec3 blendPosition = position + 2.0*cross(blendDQ[0].yzw, cross(blendDQ[0].yzw, position) + blendDQ[0].x*position);
68+
vec3 trans = 2.0*(blendDQ[0].x*blendDQ[1].yzw - blendDQ[1].x*blendDQ[0].yzw + cross(blendDQ[0].yzw, blendDQ[1].yzw));
69+
blendPosition += trans;
70+
71+
return blendPosition;
72+
}
73+
74+
vec3 calculateBlendNormal(vec3 normal, mat2x4 blendDQ)
75+
{
76+
return normal + 2.0*cross(blendDQ[0].yzw, cross(blendDQ[0].yzw, normal) + blendDQ[0].x*normal);
77+
}
78+
79+
mat3 adjointTransposeMatrix(mat3 M)
80+
{
81+
mat3 atM;
82+
atM[0][0] = M[2][2] * M[1][1] - M[1][2] * M[2][1];
83+
atM[0][1] = M[1][2] * M[2][0] - M[1][0] * M[2][2];
84+
atM[0][2] = M[1][0] * M[2][1] - M[2][0] * M[1][1];
85+
86+
atM[1][0] = M[0][2] * M[2][1] - M[2][2] * M[0][1];
87+
atM[1][1] = M[2][2] * M[0][0] - M[0][2] * M[2][0];
88+
atM[1][2] = M[2][0] * M[0][1] - M[0][0] * M[2][1];
89+
90+
atM[2][0] = M[1][2] * M[0][1] - M[0][2] * M[1][1];
91+
atM[2][1] = M[1][0] * M[0][2] - M[1][2] * M[0][0];
92+
atM[2][2] = M[0][0] * M[1][1] - M[1][0] * M[0][1];
93+
94+
return atM;
95+
}

0 commit comments

Comments
 (0)