mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-30 22:19:50 +01:00
feat: closer tank models
This commit is contained in:
1 parent
4da4cf5259
commit
428a0bbad5
5 files changed
+45
-25
No files matched your search
@@ -10,7 +10,7 @@ import { buildScratchedFlags } from './scratchedFlags';
|
|||||||
import { buildShellIcons } from './shellIcons';
|
import { buildShellIcons } from './shellIcons';
|
||||||
import { buildTankArmors } from './tankArmors';
|
import { buildTankArmors } from './tankArmors';
|
||||||
import { buildTankIcons } from './tankIcons';
|
import { buildTankIcons } from './tankIcons';
|
||||||
import { buildTankModels } from './tankModels';
|
import { tankModels } from './tankModels';
|
||||||
|
|
||||||
config();
|
config();
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@ const production = argv.includes('--production');
|
|||||||
if (!targets && !allTargets) throw new Error('No target(s) specified');
|
if (!targets && !allTargets) throw new Error('No target(s) specified');
|
||||||
|
|
||||||
const methods = [
|
const methods = [
|
||||||
buildTankModels,
|
tankModels,
|
||||||
buildTankArmors,
|
buildTankArmors,
|
||||||
definitions,
|
definitions,
|
||||||
buildTankIcons,
|
buildTankIcons,
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ interface VehicleCustomization {
|
|||||||
armorColor: string;
|
armorColor: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function buildTankModels(production: boolean) {
|
export async function tankModels(production: boolean) {
|
||||||
console.log('Building tank models...');
|
console.log('Building tank models...');
|
||||||
|
|
||||||
const nodeIO = new NodeIO();
|
const nodeIO = new NodeIO();
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { Environment } from '@react-three/drei';
|
||||||
import { useModel } from '../../../../../hooks/useModel';
|
import { useModel } from '../../../../../hooks/useModel';
|
||||||
import { useDuel } from '../../../../../stores/duel';
|
import { useDuel } from '../../../../../stores/duel';
|
||||||
|
|
||||||
@@ -7,7 +8,8 @@ export function Lighting() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<directionalLight
|
<Environment preset="dawn" />
|
||||||
|
{/* <directionalLight
|
||||||
position={[1, 1, -1]}
|
position={[1, 1, -1]}
|
||||||
intensity={hasPbr ? 3 : 5}
|
intensity={hasPbr ? 3 : 5}
|
||||||
castShadow
|
castShadow
|
||||||
@@ -18,8 +20,7 @@ export function Lighting() {
|
|||||||
intensity={hasPbr ? 2 : 4}
|
intensity={hasPbr ? 2 : 4}
|
||||||
castShadow
|
castShadow
|
||||||
color={'rgb(240, 255, 240)'}
|
color={'rgb(240, 255, 240)'}
|
||||||
/>
|
/> */}
|
||||||
<ambientLight intensity={0.25} />
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -124,6 +124,20 @@ export async function extractModel(
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (textures.miscMap) {
|
||||||
|
material.setOcclusionTexture(
|
||||||
|
document
|
||||||
|
.createTexture(node.materialName)
|
||||||
|
.setMimeType('image/png')
|
||||||
|
.setImage(
|
||||||
|
await readTexture(
|
||||||
|
`${data}/3d/${dirname(path)}/${textures.miscMap}`,
|
||||||
|
{ mutation: TextureMutation.Miscellaneous },
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
materials.set(node['#id'].readBigUInt64LE(), material);
|
materials.set(node['#id'].readBigUInt64LE(), material);
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { existsSync } from 'fs';
|
import { existsSync } from 'fs';
|
||||||
import { clamp } from 'lodash';
|
|
||||||
import sharp from 'sharp';
|
import sharp from 'sharp';
|
||||||
import { Vector3Tuple } from 'three';
|
import { Vector3Tuple } from 'three';
|
||||||
import { readDVPLFile } from '../blitz/readDVPLFile';
|
import { readDVPLFile } from '../blitz/readDVPLFile';
|
||||||
@@ -10,11 +9,15 @@ export enum TextureMutation {
|
|||||||
Normal,
|
Normal,
|
||||||
RoughnessMetallicness,
|
RoughnessMetallicness,
|
||||||
BaseColor,
|
BaseColor,
|
||||||
|
Miscellaneous,
|
||||||
}
|
}
|
||||||
|
|
||||||
type ReadTextureOptions =
|
type ReadTextureOptions =
|
||||||
| {
|
| {
|
||||||
mutation: TextureMutation.Normal | TextureMutation.RoughnessMetallicness;
|
mutation:
|
||||||
|
| TextureMutation.Normal
|
||||||
|
| TextureMutation.RoughnessMetallicness
|
||||||
|
| TextureMutation.Miscellaneous;
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
mutation: TextureMutation.BaseColor;
|
mutation: TextureMutation.BaseColor;
|
||||||
@@ -75,25 +78,27 @@ export async function readTexture(path: string, options?: ReadTextureOptions) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case TextureMutation.RoughnessMetallicness: {
|
||||||
|
for (let index = 0; index < channels; index += 4) {
|
||||||
|
/**
|
||||||
|
* Green is ambient occlusion and alpha is emissive. But very few tanks
|
||||||
|
* use emissive so I am ignoring it for now.
|
||||||
|
*/
|
||||||
|
const occlusion = raw.data[index + 1];
|
||||||
|
// const emissive = raw.data[index + 3];
|
||||||
|
|
||||||
|
raw.data[index] = occlusion;
|
||||||
|
raw.data[index + 1] = 0;
|
||||||
|
raw.data[index + 2] = 0;
|
||||||
|
raw.data[index + 3] = 255;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case TextureMutation.BaseColor: {
|
case TextureMutation.BaseColor: {
|
||||||
for (let index = 0; index < channels; index += 4) {
|
for (let index = 0; index < channels; index += 4) {
|
||||||
// treating as pre multiplied but I can't fully confirm
|
// alpha map is specularity but I am ignoring it for now
|
||||||
|
|
||||||
const r = raw.data[index] / 255;
|
|
||||||
const g = raw.data[index + 1] / 255;
|
|
||||||
const b = raw.data[index + 2] / 255;
|
|
||||||
const a = raw.data[index + 3] / 255;
|
|
||||||
|
|
||||||
if (a === 0) continue;
|
|
||||||
|
|
||||||
const invA = 1 - a;
|
|
||||||
const rPrime = r + invA * options.baseColor[0];
|
|
||||||
const gPrime = g + invA * options.baseColor[1];
|
|
||||||
const bPrime = b + invA * options.baseColor[2];
|
|
||||||
|
|
||||||
raw.data[index] = Math.round(clamp(rPrime * 255, 0, 255));
|
|
||||||
raw.data[index + 1] = Math.round(clamp(gPrime * 255, 0, 255));
|
|
||||||
raw.data[index + 2] = Math.round(clamp(bPrime * 255, 0, 255));
|
|
||||||
raw.data[index + 3] = 255;
|
raw.data[index + 3] = 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user