basilisk-engine 0.0.7__py3-none-any.whl → 0.0.9__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of basilisk-engine might be problematic. Click here for more details.
- basilisk/bsk_assets/Roboto-Regular.ttf +0 -0
- basilisk/bsk_assets/basilisk.png +0 -0
- basilisk/bsk_assets/cube.obj +49 -0
- basilisk/bsk_assets/skybox.png +0 -0
- basilisk/render/frame.py +2 -2
- basilisk/shaders/batch.frag +248 -0
- basilisk/shaders/batch.vert +109 -0
- basilisk/shaders/draw.frag +22 -0
- basilisk/shaders/draw.vert +22 -0
- basilisk/shaders/filter.frag +23 -0
- basilisk/shaders/frame.frag +13 -0
- basilisk/shaders/frame.vert +14 -0
- basilisk/shaders/image.png +0 -0
- basilisk/shaders/sky.frag +10 -0
- basilisk/shaders/sky.vert +14 -0
- {basilisk_engine-0.0.7.dist-info → basilisk_engine-0.0.9.dist-info}/METADATA +1 -1
- {basilisk_engine-0.0.7.dist-info → basilisk_engine-0.0.9.dist-info}/RECORD +19 -5
- {basilisk_engine-0.0.7.dist-info → basilisk_engine-0.0.9.dist-info}/WHEEL +0 -0
- {basilisk_engine-0.0.7.dist-info → basilisk_engine-0.0.9.dist-info}/top_level.txt +0 -0
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Blender 4.1.0
|
|
2
|
+
# www.blender.org
|
|
3
|
+
mtllib cube.mtl
|
|
4
|
+
o Cube
|
|
5
|
+
v -1.000000 -1.000000 1.000000
|
|
6
|
+
v -1.000000 1.000000 1.000000
|
|
7
|
+
v -1.000000 -1.000000 -1.000000
|
|
8
|
+
v -1.000000 1.000000 -1.000000
|
|
9
|
+
v 1.000000 -1.000000 1.000000
|
|
10
|
+
v 1.000000 1.000000 1.000000
|
|
11
|
+
v 1.000000 -1.000000 -1.000000
|
|
12
|
+
v 1.000000 1.000000 -1.000000
|
|
13
|
+
vn -1.0000 -0.0000 -0.0000
|
|
14
|
+
vn -0.0000 -0.0000 -1.0000
|
|
15
|
+
vn 1.0000 -0.0000 -0.0000
|
|
16
|
+
vn -0.0000 -0.0000 1.0000
|
|
17
|
+
vn -0.0000 -1.0000 -0.0000
|
|
18
|
+
vn -0.0000 1.0000 -0.0000
|
|
19
|
+
vt 0.002191 0.000000
|
|
20
|
+
vt 0.997809 0.002461
|
|
21
|
+
vt 0.996578 0.998078
|
|
22
|
+
vt 0.002191 0.994387
|
|
23
|
+
vt 0.002191 0.005152
|
|
24
|
+
vt 1.000269 0.001461
|
|
25
|
+
vt 0.996578 0.999539
|
|
26
|
+
vt 0.003422 0.998309
|
|
27
|
+
vt 0.000961 0.000461
|
|
28
|
+
vt 0.999039 -0.004461
|
|
29
|
+
vt 0.996578 0.996078
|
|
30
|
+
vt 0.002191 0.993618
|
|
31
|
+
vt 0.003422 -0.001769
|
|
32
|
+
vt 1.001500 0.001922
|
|
33
|
+
vt 0.996578 0.997539
|
|
34
|
+
vt 0.002191 1.001230
|
|
35
|
+
vt 0.005652 0.000461
|
|
36
|
+
vt 0.997578 0.000461
|
|
37
|
+
vt 0.995117 1.001000
|
|
38
|
+
vt 0.000730 0.998539
|
|
39
|
+
vt 0.001191 -0.000769
|
|
40
|
+
vt 1.000000 0.000000
|
|
41
|
+
vt 0.997479 0.997489
|
|
42
|
+
vt 0.006113 0.997309
|
|
43
|
+
s 0
|
|
44
|
+
f 1/1/1 2/2/1 4/3/1 3/4/1
|
|
45
|
+
f 3/5/2 4/6/2 8/7/2 7/8/2
|
|
46
|
+
f 7/9/3 8/10/3 6/11/3 5/12/3
|
|
47
|
+
f 5/13/4 6/14/4 2/15/4 1/16/4
|
|
48
|
+
f 3/17/5 7/18/5 5/19/5 1/20/5
|
|
49
|
+
f 8/21/6 4/22/6 2/23/6 6/24/6
|
|
Binary file
|
basilisk/render/frame.py
CHANGED
|
@@ -88,9 +88,9 @@ class Frame:
|
|
|
88
88
|
"""
|
|
89
89
|
|
|
90
90
|
# Read the shaders
|
|
91
|
-
with open(f'
|
|
91
|
+
with open(self.engine.root + f'/shaders/{vert}.vert') as file:
|
|
92
92
|
vertex_shader = file.read()
|
|
93
|
-
with open(f'
|
|
93
|
+
with open(self.engine.root + f'/shaders/{frag}.frag') as file:
|
|
94
94
|
fragment_shader = file.read()
|
|
95
95
|
|
|
96
96
|
# Create the program
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
#version 330 core
|
|
2
|
+
|
|
3
|
+
layout (location = 0) out vec4 fragColor;
|
|
4
|
+
|
|
5
|
+
// Structs needed for the shader
|
|
6
|
+
struct textArray {
|
|
7
|
+
sampler2DArray array;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
struct DirectionalLight {
|
|
11
|
+
vec3 direction;
|
|
12
|
+
float intensity;
|
|
13
|
+
vec3 color;
|
|
14
|
+
float ambient;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
struct Material {
|
|
18
|
+
vec3 color;
|
|
19
|
+
float roughness;
|
|
20
|
+
float subsurface;
|
|
21
|
+
float sheen;
|
|
22
|
+
float sheenTint;
|
|
23
|
+
float anisotropic;
|
|
24
|
+
float specular;
|
|
25
|
+
float metallicness;
|
|
26
|
+
float specularTint;
|
|
27
|
+
float clearcoat;
|
|
28
|
+
float clearcoatGloss;
|
|
29
|
+
|
|
30
|
+
int hasAlbedoMap;
|
|
31
|
+
vec2 albedoMap;
|
|
32
|
+
int hasNormalMap;
|
|
33
|
+
vec2 normalMap;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
struct LightResult {
|
|
37
|
+
vec3 diffuse;
|
|
38
|
+
vec3 specular;
|
|
39
|
+
vec3 clearcoat;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
in vec2 uv;
|
|
43
|
+
in vec3 position;
|
|
44
|
+
in mat3 TBN;
|
|
45
|
+
|
|
46
|
+
// Material attributes
|
|
47
|
+
flat in Material mtl;
|
|
48
|
+
|
|
49
|
+
// Uniforms
|
|
50
|
+
uniform vec3 cameraPosition;
|
|
51
|
+
const int maxDirLights = 5;
|
|
52
|
+
uniform DirectionalLight dirLights[maxDirLights];
|
|
53
|
+
uniform int numDirLights;
|
|
54
|
+
uniform textArray textureArrays[5];
|
|
55
|
+
uniform samplerCube skyboxTexture;
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
float luminance(vec3 color) {
|
|
59
|
+
return dot(color, vec3(0.299, 0.587, 0.114));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
float sqr(float x) {
|
|
63
|
+
return x * x;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
float SchlickFresnel(float x) {
|
|
67
|
+
x = clamp(1.0 - x, 0.0, 1.0);
|
|
68
|
+
float x2 = x * x;
|
|
69
|
+
return x2 * x2 * x;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
float GTR1(float ndoth, float a) {
|
|
73
|
+
float a2 = a * a;
|
|
74
|
+
float t = 1.0 + (a2 - 1.0) * ndoth * ndoth;
|
|
75
|
+
return (a2 - 1.0) / (3.1415 * log(a2) * t);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
float AnisotropicGTR2(float ndoth, float hdotx, float hdoty, float ax, float ay) {
|
|
79
|
+
return 1 / (3.1415 * ax * ay * sqr(sqr(hdotx / ax) + sqr(hdoty / ay) + sqr(ndoth)));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
float SmithGGX(float alpha, float ndotl, float ndotv) {
|
|
83
|
+
float a = ndotv * sqrt(alpha + ndotl * (ndotl - alpha * ndotl));
|
|
84
|
+
float b = ndotl * sqrt(alpha + ndotv * (ndotv - alpha * ndotv));
|
|
85
|
+
|
|
86
|
+
return 0.5 / (a + b);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
float AnisotropicSmithGGX(float ndots, float sdotx, float sdoty, float ax, float ay) {
|
|
90
|
+
return 1 / (ndots + sqrt(pow(sdotx * ax, 2) + pow(sdoty * ay, 2) + pow(ndots, 2)));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Diffuse model as outlined by Burley: https://media.disneyanimation.com/uploads/production/publication_asset/48/asset/s2012_pbs_disney_brdf_notes_v3.pdf
|
|
94
|
+
// Much help from Acerola's video on the topic: https://www.youtube.com/watch?v=KkOkx0FiHDA&t=570s
|
|
95
|
+
LightResult PrincipledDiffuse(DirectionalLight light, Material mtl, vec3 albedo, vec3 N, vec3 V, vec3 X, vec3 Y) {
|
|
96
|
+
|
|
97
|
+
LightResult result;
|
|
98
|
+
|
|
99
|
+
vec3 L = normalize(-light.direction); // light direction
|
|
100
|
+
vec3 H = normalize(L + V); // half vector
|
|
101
|
+
|
|
102
|
+
// Commonly used values
|
|
103
|
+
float cos_theta_l = clamp(dot(N, L), 0.0, 1.0);
|
|
104
|
+
float cos_theta_V = clamp(dot(N, V), 0.0, 1.0);
|
|
105
|
+
float cos_theta_D = clamp(dot(L, H), 0.0, 1.0); // Also equal to dot(V, H) by symetry
|
|
106
|
+
|
|
107
|
+
float ndoth = dot(N, H);
|
|
108
|
+
float hdotx = dot(H, X);
|
|
109
|
+
float hdoty = dot(H, Y);
|
|
110
|
+
float ldotx = dot(L, X);
|
|
111
|
+
float ldoty = dot(L, Y);
|
|
112
|
+
float vdotx = dot(V, X);
|
|
113
|
+
float vdoty = dot(V, Y);
|
|
114
|
+
|
|
115
|
+
// Color Values
|
|
116
|
+
vec3 surfaceColor = albedo;
|
|
117
|
+
float Cdlum = luminance(surfaceColor);
|
|
118
|
+
|
|
119
|
+
vec3 Ctint = Cdlum > 0.0 ? surfaceColor / Cdlum : vec3(1.0, 1.0, 1.0);
|
|
120
|
+
vec3 Cspec0 = mix(mtl.specular * 0.08 * mix(vec3(1.0, 1.0, 1.0), Ctint, mtl.specularTint), surfaceColor, mtl.metallicness);
|
|
121
|
+
vec3 Csheen = mix(vec3(1.0, 1.0, 1.0), Ctint, mtl.sheenTint);
|
|
122
|
+
|
|
123
|
+
// Diffuse
|
|
124
|
+
float FL = SchlickFresnel(cos_theta_l);
|
|
125
|
+
float FV = SchlickFresnel(cos_theta_V);
|
|
126
|
+
float Fss90 = cos_theta_D * cos_theta_D * mtl.roughness;
|
|
127
|
+
float Fd90 = 0.5 + 2.0 * Fss90;
|
|
128
|
+
|
|
129
|
+
float Fd = mix(1.0, Fd90, FL) * mix(1.0, Fd90, FV);
|
|
130
|
+
|
|
131
|
+
// Subsurface
|
|
132
|
+
float Fss = mix(1.0, Fss90, FL) * mix(1.0, Fss90, FV);
|
|
133
|
+
float ss = 1.25 * (Fss * ((1 / (cos_theta_l + cos_theta_V)) - 0.5) + 0.5);
|
|
134
|
+
|
|
135
|
+
// Specular
|
|
136
|
+
float alpha = mtl.roughness * mtl.roughness;
|
|
137
|
+
float aspect = sqrt(1.0 - 0.9 * mtl.anisotropic);
|
|
138
|
+
float alpha_x = max(0.001, alpha / aspect);
|
|
139
|
+
float alpha_y = max(0.001, alpha * aspect);
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
// Anisotropic Microfacet Normal Distribution
|
|
143
|
+
float Ds = AnisotropicGTR2(ndoth, hdotx, hdoty, alpha_x, alpha_y);
|
|
144
|
+
|
|
145
|
+
// Geometric Attenuation
|
|
146
|
+
float GalphaSquared = pow(0.5 + mtl.roughness * 0.5, 2);
|
|
147
|
+
float GalphaX = max(0.001, GalphaSquared / aspect);
|
|
148
|
+
float GalphaY = max(0.001, GalphaSquared * aspect);
|
|
149
|
+
float G = AnisotropicSmithGGX(cos_theta_l, ldotx, ldoty, GalphaX, GalphaY);
|
|
150
|
+
G = sqrt(G);
|
|
151
|
+
G *= AnisotropicSmithGGX(cos_theta_V, vdotx, vdoty, GalphaX, GalphaY);
|
|
152
|
+
|
|
153
|
+
// Fresnel Reflectance
|
|
154
|
+
float FH = SchlickFresnel(cos_theta_D);
|
|
155
|
+
vec3 F = mix(Cspec0, vec3(1.0, 1.0, 1.0), FH);
|
|
156
|
+
|
|
157
|
+
// Sheen lobe
|
|
158
|
+
vec3 Fsheen = FH * mtl.sheen * Csheen;
|
|
159
|
+
|
|
160
|
+
// Clearcoat
|
|
161
|
+
float Dr = GTR1(ndoth, mix(0.1, 0.001, mtl.clearcoatGloss)); // Normalized Isotropic GTR Gamma == 1
|
|
162
|
+
float Fr = mix(0.04, 1.0, FH);
|
|
163
|
+
float Gr = SmithGGX(cos_theta_l, cos_theta_V, 0.25);
|
|
164
|
+
|
|
165
|
+
// Result for all lobes
|
|
166
|
+
|
|
167
|
+
result.diffuse = max(vec3(0.0), (1 / 3.1415) * albedo * (mix(Fd, ss, mtl.subsurface) + Fsheen) * (1.0 - mtl.metallicness) * cos_theta_l);
|
|
168
|
+
result.specular = max(vec3(0.0), vec3(Ds * F * G) * cos_theta_l);
|
|
169
|
+
result.clearcoat = max(vec3(0.0), vec3(0.25 * mtl.clearcoat * Gr * Fr * Dr) * cos_theta_l);
|
|
170
|
+
|
|
171
|
+
// Combine lobes and multiply weakening factor and light attributes
|
|
172
|
+
return result;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
vec3 getAlbedo(Material mtl, vec2 uv, float gamma) {
|
|
176
|
+
vec3 albedo = mtl.color;
|
|
177
|
+
if (bool(mtl.hasAlbedoMap)){
|
|
178
|
+
albedo *= pow(texture(textureArrays[int(round(mtl.albedoMap.x))].array, vec3(uv, round(mtl.albedoMap.y))).rgb, vec3(gamma));
|
|
179
|
+
}
|
|
180
|
+
return albedo;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
vec3 getNormal(Material mtl, mat3 TBN){
|
|
184
|
+
// Isolate the normal vector from the TBN basis
|
|
185
|
+
vec3 normal = TBN[2];
|
|
186
|
+
// Apply normal map if the material has one
|
|
187
|
+
if (bool(mtl.hasNormalMap)) {
|
|
188
|
+
normal = texture(textureArrays[int(round(mtl.normalMap.x))].array, vec3(uv, round(mtl.normalMap.y))).rgb * 2.0 - 1.0;
|
|
189
|
+
normal = normalize(TBN * normal);
|
|
190
|
+
}
|
|
191
|
+
// Return vector
|
|
192
|
+
return normal;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
void main() {
|
|
196
|
+
float gamma = 2.2;
|
|
197
|
+
vec3 viewDir = vec3(normalize(cameraPosition - position));
|
|
198
|
+
|
|
199
|
+
// Get lighting vectors
|
|
200
|
+
vec3 albedo = getAlbedo(mtl, uv, gamma);
|
|
201
|
+
vec3 normal = getNormal(mtl, TBN);
|
|
202
|
+
vec3 tangent = TBN[0];
|
|
203
|
+
vec3 bitangent = TBN[1];
|
|
204
|
+
|
|
205
|
+
// Orthogonalize the tangent and bitangent according to the mapped normal vector
|
|
206
|
+
tangent = tangent - dot(normal, tangent) * normal;
|
|
207
|
+
bitangent = bitangent - dot(normal, bitangent) * normal - dot(tangent, bitangent) * tangent;
|
|
208
|
+
|
|
209
|
+
// Lighting variables
|
|
210
|
+
vec3 N = normalize(normal); // normal
|
|
211
|
+
vec3 V = normalize(cameraPosition - position); // view vector
|
|
212
|
+
vec3 X = normalize(tangent); // Tangent Vector
|
|
213
|
+
vec3 Y = normalize(bitangent); // Bitangent Vector
|
|
214
|
+
|
|
215
|
+
// Indirect lighting
|
|
216
|
+
vec3 ambient_sky = texture(skyboxTexture, N).rgb;
|
|
217
|
+
vec3 reflect_sky = texture(skyboxTexture, reflect(-V, N)).rgb;
|
|
218
|
+
|
|
219
|
+
LightResult lightResult;
|
|
220
|
+
lightResult.diffuse = vec3(0.0);
|
|
221
|
+
lightResult.specular = vec3(0.0);
|
|
222
|
+
lightResult.clearcoat = vec3(0.0);
|
|
223
|
+
|
|
224
|
+
// Add result from each directional light in the scene
|
|
225
|
+
for (int i = 0; i < numDirLights; i++) {
|
|
226
|
+
// Caculate the light for the directional light
|
|
227
|
+
LightResult dirLightResult = PrincipledDiffuse(dirLights[i], mtl, albedo, N, V, X, Y);
|
|
228
|
+
vec3 lightFactor = dirLights[i].intensity * dirLights[i].color;
|
|
229
|
+
// Add each lobe
|
|
230
|
+
lightResult.diffuse += dirLightResult.diffuse * lightFactor;
|
|
231
|
+
lightResult.specular += dirLightResult.specular * lightFactor;
|
|
232
|
+
lightResult.clearcoat += dirLightResult.clearcoat * lightFactor;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
lightResult.specular = min(vec3(1.0), lightResult.specular);
|
|
236
|
+
lightResult.specular *= mix(vec3(1.0), reflect_sky, mtl.metallicness) * luminance(reflect_sky);
|
|
237
|
+
lightResult.diffuse *= mix(vec3(1.0), ambient_sky, 0.25);
|
|
238
|
+
|
|
239
|
+
vec3 finalColor = albedo * 0.3 * mix(vec3(1.0), reflect_sky, mtl.metallicness);
|
|
240
|
+
finalColor += (lightResult.diffuse + lightResult.specular + lightResult.clearcoat);
|
|
241
|
+
|
|
242
|
+
// light_result *= mix(vec3(1.0), texture(skyboxTexture, reflect(-V, N)).rgb, mtl.metallicness);
|
|
243
|
+
// Gamma correction
|
|
244
|
+
finalColor = pow(finalColor, vec3(1.0/gamma));
|
|
245
|
+
|
|
246
|
+
// Output fragment color
|
|
247
|
+
fragColor = vec4(finalColor, 1.0);
|
|
248
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
#version 330 core
|
|
2
|
+
|
|
3
|
+
layout (location = 0) in vec3 in_position;
|
|
4
|
+
layout (location = 1) in vec2 in_uv;
|
|
5
|
+
layout (location = 2) in vec3 in_normal;
|
|
6
|
+
layout (location = 3) in vec3 in_tangent;
|
|
7
|
+
layout (location = 4) in vec3 in_bitangent;
|
|
8
|
+
|
|
9
|
+
layout (location = 5) in vec3 obj_position;
|
|
10
|
+
layout (location = 6) in vec4 obj_rotation;
|
|
11
|
+
layout (location = 7) in vec3 obj_scale;
|
|
12
|
+
layout (location = 8) in float obj_material;
|
|
13
|
+
|
|
14
|
+
// Variables passed on to the fragment shader
|
|
15
|
+
out vec2 uv;
|
|
16
|
+
out vec3 position;
|
|
17
|
+
out mat3 TBN;
|
|
18
|
+
|
|
19
|
+
// Material struct sent to fragment shader
|
|
20
|
+
struct Material {
|
|
21
|
+
vec3 color;
|
|
22
|
+
float roughness;
|
|
23
|
+
float subsurface;
|
|
24
|
+
float sheen;
|
|
25
|
+
float sheenTint;
|
|
26
|
+
float anisotropic;
|
|
27
|
+
float specular;
|
|
28
|
+
float metallicness;
|
|
29
|
+
float specularTint;
|
|
30
|
+
float clearcoat;
|
|
31
|
+
float clearcoatGloss;
|
|
32
|
+
|
|
33
|
+
int hasAlbedoMap;
|
|
34
|
+
vec2 albedoMap;
|
|
35
|
+
int hasNormalMap;
|
|
36
|
+
vec2 normalMap;
|
|
37
|
+
};
|
|
38
|
+
flat out Material mtl;
|
|
39
|
+
|
|
40
|
+
// Uniforms
|
|
41
|
+
uniform mat4 projectionMatrix;
|
|
42
|
+
uniform mat4 viewMatrix;
|
|
43
|
+
uniform sampler2D materialsTexture;
|
|
44
|
+
|
|
45
|
+
// Function to get the model matrix from node position, rotation, and scale
|
|
46
|
+
mat4 getModelMatrix(vec3 pos, vec4 rot, vec3 scl) {
|
|
47
|
+
mat4 translation = mat4(
|
|
48
|
+
1 , 0 , 0 , 0,
|
|
49
|
+
0 , 1 , 0 , 0,
|
|
50
|
+
0 , 0 , 1 , 0,
|
|
51
|
+
pos.x, pos.y, pos.z, 1
|
|
52
|
+
);
|
|
53
|
+
mat4 rotation = mat4(
|
|
54
|
+
1 - 2 * (rot.z * rot.z + rot.w * rot.w), 2 * (rot.y * rot.z - rot.w * rot.x), 2 * (rot.y * rot.w + rot.z * rot.x), 0,
|
|
55
|
+
2 * (rot.y * rot.z + rot.w * rot.x), 1 - 2 * (rot.y * rot.y + rot.w * rot.w), 2 * (rot.z * rot.w - rot.y * rot.x), 0,
|
|
56
|
+
2 * (rot.y * rot.w - rot.z * rot.x), 2 * (rot.z * rot.w + rot.y * rot.x), 1 - 2 * (rot.y * rot.y + rot.z * rot.z), 0,
|
|
57
|
+
0, 0, 0, 1
|
|
58
|
+
);
|
|
59
|
+
mat4 scale = mat4(
|
|
60
|
+
scl.x, 0 , 0 , 0,
|
|
61
|
+
0 , scl.y, 0 , 0,
|
|
62
|
+
0 , 0 , scl.z, 0,
|
|
63
|
+
0 , 0 , 0 , 1
|
|
64
|
+
);
|
|
65
|
+
return translation * rotation * scale;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Function to get the TBN matrix for normal mapping
|
|
69
|
+
mat3 getTBN(mat4 modelMatrix, vec3 normal, vec3 tangent, vec3 bitangent){
|
|
70
|
+
vec3 T = normalize(vec3(modelMatrix * vec4(tangent, 0.0)));
|
|
71
|
+
vec3 B = normalize(vec3(modelMatrix * vec4(bitangent, 0.0)));
|
|
72
|
+
vec3 N = normalize(vec3(modelMatrix * vec4(normal, 0.0)));
|
|
73
|
+
return mat3(T, B, N);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
void main() {
|
|
77
|
+
// Set the model matrix
|
|
78
|
+
mat4 modelMatrix = getModelMatrix(obj_position, obj_rotation, obj_scale);
|
|
79
|
+
|
|
80
|
+
// Set out variables
|
|
81
|
+
position = (modelMatrix * vec4(in_position, 1.0)).xyz;
|
|
82
|
+
TBN = getTBN(modelMatrix, in_normal, in_tangent, in_bitangent);
|
|
83
|
+
uv = in_uv;
|
|
84
|
+
|
|
85
|
+
// Get the material
|
|
86
|
+
int mtl_size = 19;
|
|
87
|
+
int materialID = int(obj_material);
|
|
88
|
+
mtl.color = vec3(texelFetch(materialsTexture, ivec2(0, 0 + materialID * mtl_size), 0).r, texelFetch(materialsTexture, ivec2(0, 1 + materialID * mtl_size), 0).r, texelFetch(materialsTexture, ivec2(0, 2 + materialID * mtl_size), 0).r);
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
mtl.roughness = texelFetch(materialsTexture, ivec2(0, 3 + materialID * mtl_size), 0).r;
|
|
92
|
+
mtl.subsurface = texelFetch(materialsTexture, ivec2(0, 4 + materialID * mtl_size), 0).r;
|
|
93
|
+
mtl.sheen = texelFetch(materialsTexture, ivec2(0, 5 + materialID * mtl_size), 0).r;
|
|
94
|
+
mtl.sheenTint = texelFetch(materialsTexture, ivec2(0, 6 + materialID * mtl_size), 0).r;
|
|
95
|
+
mtl.anisotropic = texelFetch(materialsTexture, ivec2(0, 7 + materialID * mtl_size), 0).r;
|
|
96
|
+
mtl.specular = texelFetch(materialsTexture, ivec2(0, 8 + materialID * mtl_size), 0).r;
|
|
97
|
+
mtl.metallicness = texelFetch(materialsTexture, ivec2(0, 9 + materialID * mtl_size), 0).r;
|
|
98
|
+
mtl.specularTint = texelFetch(materialsTexture, ivec2(0, 10 + materialID * mtl_size), 0).r;
|
|
99
|
+
mtl.clearcoat = texelFetch(materialsTexture, ivec2(0, 11 + materialID * mtl_size), 0).r;
|
|
100
|
+
mtl.clearcoatGloss = texelFetch(materialsTexture, ivec2(0, 12 + materialID * mtl_size), 0).r;
|
|
101
|
+
|
|
102
|
+
mtl.hasAlbedoMap = int(texelFetch(materialsTexture, ivec2(0, 13 + materialID * mtl_size), 0).r);
|
|
103
|
+
mtl.albedoMap = vec2(texelFetch(materialsTexture, ivec2(0, 14 + materialID * mtl_size), 0).r, texelFetch(materialsTexture, ivec2(0, 15 + materialID * mtl_size), 0).r);
|
|
104
|
+
mtl.hasNormalMap = int(texelFetch(materialsTexture, ivec2(0, 16 + materialID * mtl_size), 0).r);
|
|
105
|
+
mtl.normalMap = vec2(texelFetch(materialsTexture, ivec2(0, 17 + materialID * mtl_size), 0).r, texelFetch(materialsTexture, ivec2(0, 18 + materialID * mtl_size), 0).r);
|
|
106
|
+
|
|
107
|
+
// Set the fragment position
|
|
108
|
+
gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(in_position, 1.0);
|
|
109
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#version 330 core
|
|
2
|
+
|
|
3
|
+
layout (location = 0) out vec4 fragColor;
|
|
4
|
+
|
|
5
|
+
in vec4 color;
|
|
6
|
+
in vec2 imageIndex;
|
|
7
|
+
in vec2 uv;
|
|
8
|
+
flat in int usesImage;
|
|
9
|
+
|
|
10
|
+
struct textArray {
|
|
11
|
+
sampler2DArray array;
|
|
12
|
+
};
|
|
13
|
+
uniform textArray textureArrays[5];
|
|
14
|
+
|
|
15
|
+
void main() {
|
|
16
|
+
if (bool(usesImage)) {
|
|
17
|
+
fragColor = texture(textureArrays[int(round(imageIndex.x))].array, vec3(uv, round(imageIndex.y)));
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
fragColor = color;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#version 330 core
|
|
2
|
+
|
|
3
|
+
layout (location = 0) in vec2 in_position;
|
|
4
|
+
layout (location = 1) in vec4 in_color;
|
|
5
|
+
layout (location = 2) in int in_uses_image;
|
|
6
|
+
|
|
7
|
+
out vec4 color;
|
|
8
|
+
out vec2 imageIndex;
|
|
9
|
+
out vec2 uv;
|
|
10
|
+
flat out int usesImage;
|
|
11
|
+
|
|
12
|
+
void main() {
|
|
13
|
+
usesImage = in_uses_image;
|
|
14
|
+
if (bool(in_uses_image)) {
|
|
15
|
+
imageIndex = in_color.xy;
|
|
16
|
+
uv = in_color.zw;
|
|
17
|
+
}
|
|
18
|
+
else{
|
|
19
|
+
color = in_color;
|
|
20
|
+
}
|
|
21
|
+
gl_Position = vec4(in_position.x, -in_position.y, 0.0, 1.0);
|
|
22
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#version 330 core
|
|
2
|
+
|
|
3
|
+
out vec4 fragColor;
|
|
4
|
+
|
|
5
|
+
in vec2 uv;
|
|
6
|
+
|
|
7
|
+
uniform sampler2D screenTexture;
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
void main()
|
|
11
|
+
{
|
|
12
|
+
vec2 direction = normalize(vec2(1.0, 1.0));
|
|
13
|
+
float magnitude = 0.6;
|
|
14
|
+
float redOffset = 0.009 * magnitude;
|
|
15
|
+
float greenOffset = 0.006 * magnitude;
|
|
16
|
+
float blueOffset = -0.006 * magnitude;
|
|
17
|
+
|
|
18
|
+
float r = texture(screenTexture, uv + direction * redOffset).r;
|
|
19
|
+
float g = texture(screenTexture, uv + direction * greenOffset).g;
|
|
20
|
+
float b = texture(screenTexture, uv + direction * blueOffset).b;
|
|
21
|
+
|
|
22
|
+
fragColor = vec4(r, g, b, 1.0);
|
|
23
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#version 330 core
|
|
2
|
+
layout (location = 0) in vec3 in_position;
|
|
3
|
+
|
|
4
|
+
out vec3 texCubeCoords;
|
|
5
|
+
|
|
6
|
+
uniform mat4 projectionMatrix;
|
|
7
|
+
uniform mat4 viewMatrix;
|
|
8
|
+
|
|
9
|
+
void main() {
|
|
10
|
+
texCubeCoords = in_position;
|
|
11
|
+
vec4 pos = projectionMatrix * mat4(mat3(viewMatrix)) * vec4(in_position, 1.0);
|
|
12
|
+
gl_Position = pos.xyww;
|
|
13
|
+
gl_Position.z -= 0.0001;
|
|
14
|
+
}
|
|
@@ -2,7 +2,11 @@ basilisk/__init__.py,sha256=g1picXHoGTf2Oo0cc7XfMZr58QW8sPO7Gubsvlfmj_E,339
|
|
|
2
2
|
basilisk/config.py,sha256=ynTRlX633DGoEtZOeAK8KNJF6offV3k3XFD7cia3Keg,61
|
|
3
3
|
basilisk/engine.py,sha256=lGDJtSf6Z4mgJ014AWqHXOUz5iM4aJd18A0k_48gH7o,5805
|
|
4
4
|
basilisk/scene.py,sha256=ow3w2ZouBdn7E1xw39-aMu7_gbsnDxzeNi1mqbYqa-M,4452
|
|
5
|
+
basilisk/bsk_assets/Roboto-Regular.ttf,sha256=kqYnZjMRQMpbyLulIChCLSdgYa1XF8GsUIoRi2Gcauw,168260
|
|
5
6
|
basilisk/bsk_assets/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
+
basilisk/bsk_assets/basilisk.png,sha256=1xePD8qDycxlRQ7hjEmfuw900BRykhRyumJePi6hxi8,21299
|
|
8
|
+
basilisk/bsk_assets/cube.obj,sha256=rLm2nNcfj1zPZUx-VSF5CxqnToteHjzXQNxfRNq5iKU,1189
|
|
9
|
+
basilisk/bsk_assets/skybox.png,sha256=0C9MvWUwNzewyiMtWLKrZJzAcLC1Ce72T3-Lq4hJZu0,1206153
|
|
6
10
|
basilisk/collisions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
11
|
basilisk/collisions/collider.py,sha256=-bWTt5s_cO2Nmn9lG3igFQulYw5M19B9xoEEiGRCAzM,3469
|
|
8
12
|
basilisk/collisions/collider_handler.py,sha256=S1TsBd8S3s_U5vozodTxIxRrAUMcYP6dIe2uf_42zaM,7372
|
|
@@ -48,7 +52,7 @@ basilisk/render/batch.py,sha256=YGhmTIY3SHWft6ESuFJc1WluZNh8_w2TMNdRK6wTJjM,2950
|
|
|
48
52
|
basilisk/render/camera.py,sha256=nTlp48fhtSo9cc0dLIwPyx6lW3o595FhZM2r1iBCjEQ,6056
|
|
49
53
|
basilisk/render/chunk.py,sha256=hU1xjy_ibQO40YDeWULNMofLsI4EfOYGmtxN6FqhwfE,2246
|
|
50
54
|
basilisk/render/chunk_handler.py,sha256=2ZsUiLw9SA_YzBQXtTZMMQ6-Lc1oJVo_VENZDWXXHh0,5652
|
|
51
|
-
basilisk/render/frame.py,sha256=
|
|
55
|
+
basilisk/render/frame.py,sha256=OwgDtBK3EtXTD8e6o8chAl0Wu3fg-KwTEYQg1-r21y8,6728
|
|
52
56
|
basilisk/render/image.py,sha256=27Jg8LuLjJ-NhSgbueFHc8RC8WmTOJOf2R6k1SLzI6I,2628
|
|
53
57
|
basilisk/render/image_handler.py,sha256=giebUrgf9OpJ0vwljyJe1YdDtmB5oUisYmCL-t0kIRY,4119
|
|
54
58
|
basilisk/render/light.py,sha256=hFqODv9iK4GEDZeDyBHxOWwwd4v8Pm089_xoScBMjVY,3879
|
|
@@ -58,7 +62,17 @@ basilisk/render/material_handler.py,sha256=pYgDBFFJw9TASVBQ33F4eO7SEh4vpVIHIDoVf
|
|
|
58
62
|
basilisk/render/shader_handler.py,sha256=DBpW_Dx4GAaR_YHAslu4ZuXk35mL4iZaEIGMCpBQX7U,3557
|
|
59
63
|
basilisk/render/sky.py,sha256=aYC8W_RehC084OcJK22HQnViu_wFPWqHv8lMzSwBJMw,4725
|
|
60
64
|
basilisk/shaders/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
+
basilisk/shaders/batch.frag,sha256=w0t98k3Zp5v4qmg2ou7pnrselyIufIlQst61LkZXvjM,8544
|
|
66
|
+
basilisk/shaders/batch.vert,sha256=qYjN0YIJI_70jpDSiMt7kn5F1XEReqqKdjDp_nCd8KI,4735
|
|
67
|
+
basilisk/shaders/draw.frag,sha256=XV7dcVm-RhZXs6e6ddJhesR6BAmVWEHZqQgEJQEA77Q,450
|
|
68
|
+
basilisk/shaders/draw.vert,sha256=UQtceYDIUfrluXZSb_Y_L8_-Ky_bjAj9Uyvuu8KkpeE,509
|
|
69
|
+
basilisk/shaders/filter.frag,sha256=m_egR4yiFRmIHGwCCfpcdvGXQi1w1Ago_iABlbnX80c,584
|
|
70
|
+
basilisk/shaders/frame.frag,sha256=rs_AA1u7DL3CxtqpTqvhgQjYYthl_l_Dg7RXpU9_5Ks,160
|
|
71
|
+
basilisk/shaders/frame.vert,sha256=KPB-Q3-Rix9-JxSj5tBHbZOu7QCdFgCzHwiZKEYIbFc,227
|
|
72
|
+
basilisk/shaders/image.png,sha256=nZRs38y_Ze8sKVuUWuYDnf9y35v2TOX_L6Ae0nJ7Ilc,13906
|
|
73
|
+
basilisk/shaders/sky.frag,sha256=vTmZ1Xsd601_gmeBRfLYodHuBoBDI-M_1IybRt0ZDFk,178
|
|
74
|
+
basilisk/shaders/sky.vert,sha256=v_BSdnMiljSJGPqno-J_apAiom38IrBzbDoxM7pIgwI,345
|
|
75
|
+
basilisk_engine-0.0.9.dist-info/METADATA,sha256=dBinxZxclHiFPD-5IA2rwqXNhwrZV-qNWNSFnnosTeA,1118
|
|
76
|
+
basilisk_engine-0.0.9.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
|
|
77
|
+
basilisk_engine-0.0.9.dist-info/top_level.txt,sha256=enlSYSf7CUyAly1jmUCNNGInTbaFUjGk4SKwyckZQkw,9
|
|
78
|
+
basilisk_engine-0.0.9.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|