quake2ts 0.0.234 → 0.0.235
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.
- package/package.json +1 -1
- package/packages/client/dist/browser/index.global.js +31 -3
- package/packages/client/dist/browser/index.global.js.map +1 -1
- package/packages/client/dist/cjs/index.cjs +31 -3
- package/packages/client/dist/cjs/index.cjs.map +1 -1
- package/packages/client/dist/esm/index.js +31 -3
- package/packages/client/dist/esm/index.js.map +1 -1
- package/packages/client/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/engine/dist/browser/index.global.js +44 -13
- package/packages/engine/dist/browser/index.global.js.map +1 -1
- package/packages/engine/dist/cjs/index.cjs +39 -4
- package/packages/engine/dist/cjs/index.cjs.map +1 -1
- package/packages/engine/dist/esm/index.js +39 -4
- package/packages/engine/dist/esm/index.js.map +1 -1
- package/packages/engine/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/engine/dist/types/render/bsp/geometry.d.ts +1 -0
- package/packages/engine/dist/types/render/bsp/geometry.d.ts.map +1 -1
- package/packages/engine/dist/types/render/bsp/renderer.d.ts.map +1 -1
- package/packages/engine/dist/types/render/bsp/surface.d.ts.map +1 -1
- package/packages/engine/dist/types/render/bspPipeline.d.ts +4 -2
- package/packages/engine/dist/types/render/bspPipeline.d.ts.map +1 -1
- package/packages/game/dist/tsconfig.tsbuildinfo +1 -1
|
@@ -5119,6 +5119,7 @@ precision highp float;
|
|
|
5119
5119
|
layout(location = 0) in vec3 a_position;
|
|
5120
5120
|
layout(location = 1) in vec2 a_texCoord;
|
|
5121
5121
|
layout(location = 2) in vec2 a_lightmapCoord;
|
|
5122
|
+
layout(location = 3) in float a_lightmapStep;
|
|
5122
5123
|
|
|
5123
5124
|
uniform mat4 u_modelViewProjection;
|
|
5124
5125
|
uniform vec2 u_texScroll;
|
|
@@ -5126,6 +5127,7 @@ uniform vec2 u_lightmapScroll;
|
|
|
5126
5127
|
|
|
5127
5128
|
out vec2 v_texCoord;
|
|
5128
5129
|
out vec2 v_lightmapCoord;
|
|
5130
|
+
out float v_lightmapStep;
|
|
5129
5131
|
out vec3 v_position;
|
|
5130
5132
|
|
|
5131
5133
|
vec2 applyScroll(vec2 uv, vec2 scroll) {
|
|
@@ -5135,6 +5137,7 @@ vec2 applyScroll(vec2 uv, vec2 scroll) {
|
|
|
5135
5137
|
void main() {
|
|
5136
5138
|
v_texCoord = applyScroll(a_texCoord, u_texScroll);
|
|
5137
5139
|
v_lightmapCoord = applyScroll(a_lightmapCoord, u_lightmapScroll);
|
|
5140
|
+
v_lightmapStep = a_lightmapStep;
|
|
5138
5141
|
v_position = a_position;
|
|
5139
5142
|
gl_Position = u_modelViewProjection * vec4(a_position, 1.0);
|
|
5140
5143
|
}`;
|
|
@@ -5151,11 +5154,13 @@ const int MAX_DLIGHTS = ${MAX_DLIGHTS};
|
|
|
5151
5154
|
|
|
5152
5155
|
in vec2 v_texCoord;
|
|
5153
5156
|
in vec2 v_lightmapCoord;
|
|
5157
|
+
in float v_lightmapStep;
|
|
5154
5158
|
in vec3 v_position;
|
|
5155
5159
|
|
|
5156
5160
|
uniform sampler2D u_diffuseMap;
|
|
5157
5161
|
uniform sampler2D u_lightmapAtlas;
|
|
5158
5162
|
uniform vec4 u_lightStyleFactors;
|
|
5163
|
+
uniform vec4 u_styleLayerMapping; // 0, 1, 2... or -1 if invalid
|
|
5159
5164
|
uniform float u_alpha;
|
|
5160
5165
|
uniform bool u_applyLightmap;
|
|
5161
5166
|
uniform bool u_warp;
|
|
@@ -5189,9 +5194,35 @@ void main() {
|
|
|
5189
5194
|
vec3 totalLight = vec3(1.0);
|
|
5190
5195
|
|
|
5191
5196
|
if (u_applyLightmap) {
|
|
5192
|
-
|
|
5193
|
-
|
|
5194
|
-
|
|
5197
|
+
// Multi-style lightmap accumulation
|
|
5198
|
+
vec3 light = vec3(0.0);
|
|
5199
|
+
bool hasLight = false;
|
|
5200
|
+
|
|
5201
|
+
vec2 lmBase = warpCoords(v_lightmapCoord);
|
|
5202
|
+
|
|
5203
|
+
// Loop unrolled-ish
|
|
5204
|
+
for (int i = 0; i < 4; i++) {
|
|
5205
|
+
// We can access vec4 components by index in newer GLSL ES, or use direct access
|
|
5206
|
+
float layer = u_styleLayerMapping[i];
|
|
5207
|
+
float factor = u_lightStyleFactors[i];
|
|
5208
|
+
|
|
5209
|
+
if (layer >= -0.5) { // Valid layer (check >= 0 approx)
|
|
5210
|
+
// Offset V by layer * step
|
|
5211
|
+
// Since we packed vertically
|
|
5212
|
+
vec2 offset = vec2(0.0, layer * v_lightmapStep);
|
|
5213
|
+
light += texture(u_lightmapAtlas, lmBase + offset).rgb * factor;
|
|
5214
|
+
hasLight = true;
|
|
5215
|
+
}
|
|
5216
|
+
}
|
|
5217
|
+
|
|
5218
|
+
// If no valid lightmaps found (e.g. unlit surface?), default to full bright?
|
|
5219
|
+
// Or if u_applyLightmap is true, there should be at least one style.
|
|
5220
|
+
// Fallback to 1.0 if accumulator is empty?
|
|
5221
|
+
// In Q2, unlit surfs are fullbright (or use minlight).
|
|
5222
|
+
// If hasLight is false, it means no styles are active.
|
|
5223
|
+
if (!hasLight) light = vec3(1.0);
|
|
5224
|
+
|
|
5225
|
+
totalLight = light; // Dynamic lights add on top or multiply? Q2 adds.
|
|
5195
5226
|
|
|
5196
5227
|
// Add dynamic lights
|
|
5197
5228
|
for (int i = 0; i < MAX_DLIGHTS; i++) {
|
|
@@ -5228,6 +5259,7 @@ void main() {
|
|
|
5228
5259
|
o_color = finalColor;
|
|
5229
5260
|
}`;
|
|
5230
5261
|
var DEFAULT_STYLE_INDICES = [0, 255, 255, 255];
|
|
5262
|
+
var DEFAULT_STYLE_LAYERS = [0, -1, -1, -1];
|
|
5231
5263
|
function resolveLightStyles(styleIndices = DEFAULT_STYLE_INDICES, styleValues = []) {
|
|
5232
5264
|
const factors = new Float32Array(4);
|
|
5233
5265
|
for (let i = 0; i < 4; i += 1) {
|
|
@@ -5271,12 +5303,13 @@ var BspSurfacePipeline = class {
|
|
|
5271
5303
|
this.program = ShaderProgram.create(
|
|
5272
5304
|
gl,
|
|
5273
5305
|
{ vertex: BSP_SURFACE_VERTEX_SOURCE, fragment: BSP_SURFACE_FRAGMENT_SOURCE },
|
|
5274
|
-
{ a_position: 0, a_texCoord: 1, a_lightmapCoord: 2 }
|
|
5306
|
+
{ a_position: 0, a_texCoord: 1, a_lightmapCoord: 2, a_lightmapStep: 3 }
|
|
5275
5307
|
);
|
|
5276
5308
|
this.uniformMvp = this.program.getUniformLocation("u_modelViewProjection");
|
|
5277
5309
|
this.uniformTexScroll = this.program.getUniformLocation("u_texScroll");
|
|
5278
5310
|
this.uniformLmScroll = this.program.getUniformLocation("u_lightmapScroll");
|
|
5279
5311
|
this.uniformLightStyles = this.program.getUniformLocation("u_lightStyleFactors");
|
|
5312
|
+
this.uniformStyleLayerMapping = this.program.getUniformLocation("u_styleLayerMapping");
|
|
5280
5313
|
this.uniformAlpha = this.program.getUniformLocation("u_alpha");
|
|
5281
5314
|
this.uniformApplyLightmap = this.program.getUniformLocation("u_applyLightmap");
|
|
5282
5315
|
this.uniformWarp = this.program.getUniformLocation("u_warp");
|
|
@@ -5298,6 +5331,7 @@ var BspSurfacePipeline = class {
|
|
|
5298
5331
|
const {
|
|
5299
5332
|
modelViewProjection,
|
|
5300
5333
|
styleIndices = DEFAULT_STYLE_INDICES,
|
|
5334
|
+
styleLayers = DEFAULT_STYLE_LAYERS,
|
|
5301
5335
|
styleValues = [],
|
|
5302
5336
|
diffuseSampler = 0,
|
|
5303
5337
|
lightmapSampler,
|
|
@@ -5320,6 +5354,7 @@ var BspSurfacePipeline = class {
|
|
|
5320
5354
|
this.gl.uniform2f(this.uniformTexScroll, finalScrollX, finalScrollY);
|
|
5321
5355
|
this.gl.uniform2f(this.uniformLmScroll, state.flowOffset[0], state.flowOffset[1]);
|
|
5322
5356
|
this.gl.uniform4fv(this.uniformLightStyles, styles);
|
|
5357
|
+
this.gl.uniform4fv(this.uniformStyleLayerMapping, styleLayers);
|
|
5323
5358
|
this.gl.uniform1f(this.uniformAlpha, finalAlpha);
|
|
5324
5359
|
const applyLightmap = !state.sky && lightmapSampler !== void 0;
|
|
5325
5360
|
this.gl.uniform1i(this.uniformApplyLightmap, applyLightmap ? 1 : 0);
|