Skip to content

Commit 30eb1db

Browse files
committed
Reworked RabbitDruidA & Blinking
Reworked the RabbitDruidA rig, the weighting needs work, but - Modeling, UV, Texturing fixes Diffuse texture and ARE texture, Ambient Occlusion, Reflective/Shiny, Eye Mask Isolated the Skeleton shader important parts as well, Campfire flicker on Rabbit Druid in scene
1 parent bc81ef1 commit 30eb1db

File tree

15 files changed

+348
-14
lines changed

15 files changed

+348
-14
lines changed

Public/js/blog/blogEntries.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
// But that's likely overkill for a blog I'll rarely update anyway
77

88

9-
import { blogEntryObj as blogEntry_20241207_A } from "./2024-12-07_A.js";
10-
import { blogEntryObj as blogEntry_20241208_A } from "./2024-12-08_A.js";
9+
import { blogEntryObj as blogEntry_20241207_A } from "./2024-12-08_A.js";
10+
import { blogEntryObj as blogEntry_20241208_A } from "./2024-12-07_A.js";
1111

1212

1313
export const blogEntries = {

Source/js/pxlNav/core/FileIO.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ export class FileIO{
6868
// mesh = Current Object To Check For UserData Entries
6969
checkForUserData( envObj, envScene, mesh ){
7070
if( mesh.hasOwnProperty("userData") ){
71+
if( mesh.hasOwnProperty("material") ){
72+
if( mesh.userData.hasOwnProperty("doubleSided") && mesh.userData.doubleSided ){
73+
mesh.material.side=THREE.DoubleSide;
74+
}else{
75+
mesh.material.side=THREE.FrontSide;
76+
}
77+
}
78+
7179
// Add to Glow render pass; ran by blurComposer
7280
if( mesh.userData.hasOwnProperty("GlowPass") && mesh.userData.GlowPass ){
7381
if( !envObj.geoList['GlowPass'] ){
@@ -1476,6 +1484,10 @@ export class FileIO{
14761484

14771485
curFbx.traverse((c)=>{
14781486
this.checkForUserData( envObj, envScene, c );
1487+
1488+
if(c.userData.hasOwnProperty("doubleSided") && c.userData.doubleSided){
1489+
c.material.side=THREE.DoubleSide;
1490+
}
14791491
});
14801492

14811493
this.pxlAnim.initObject( meshKey, curFbx );

Source/js/pxlNav/core/Utils.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,15 @@ export class Utils{
122122
strip=strip.innerText;
123123
return strip;
124124
}
125-
125+
126+
// -- -- -- //
127+
128+
randomFloat(min,max){
129+
return Math.random()*(max-min)+min;
130+
}
131+
132+
// -- -- -- //
133+
126134
componentToHex(c) {
127135
var hex = c.toString(16);
128136
return hex.padStart(2,'0');
384 KB
Loading
Binary file not shown.
Binary file not shown.
477 KB
Loading
Binary file not shown.

Source/pxlRooms/CampfireEnvironment/CampfireEnvironment.js

Lines changed: 70 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as THREE from "../../js/libs/three/three.module.js";
2-
import { campfireLogVert, campfireLogFrag,
2+
import { rabbitDruidVert, rabbitDruidFrag,
3+
campfireLogVert, campfireLogFrag,
34
campfireVert, campfireFrag,
45
envGroundVert, envGroundFrag } from "./Shaders.js";
56
import RoomEnvironment from "../../js/pxlNav/RoomClass.js";
@@ -54,6 +55,13 @@ export class CampfireEnvironment extends RoomEnvironment{
5455
this.fog=new THREE.FogExp2( this.fogColor, this.fogExp);
5556

5657
this.perspectiveInstances = 160;
58+
59+
this.eyeBlinkInf = new THREE.Vector2(0,0);
60+
this.eyeBlinkMinMaxDelay = [1.0,8.0];
61+
this.eyeBlinkMinMaxRate = [ .035, 0.06 ];
62+
this.eyeBlinkNext = 0;
63+
this.eyeBlinkAnim = 0;
64+
this.eyeBlinkRate = 0;
5765
}
5866
init(){
5967
super.init();
@@ -95,11 +103,34 @@ export class CampfireEnvironment extends RoomEnvironment{
95103
// Cycle changes occur here as well.
96104
if(this.animMixer){
97105
this.pxlAnim.step( this.animRigName );
106+
this.checkEyeBlink();
98107
}
99108

100109
//this.pxlEnv.pxlCamera.setStats( this.pxlCamFOV, this.pxlCamZoom, this.pxlCamAspect, this.pxlCamNearClipping );
101110
}
102111

112+
checkEyeBlink(){
113+
if( this.eyeBlinkAnim > 0 ){
114+
// Decrease the eye blink animation 1 to 0
115+
this.eyeBlinkAnim -= this.eyeBlinkRate;
116+
// Map 0-1 to 0-1-0
117+
let sawAnim = (Math.min(.5,this.eyeBlinkAnim) - Math.max(0,this.eyeBlinkAnim-.5)) * 2;
118+
this.eyeBlinkInf.x = sawAnim;
119+
if( this.eyeBlinkAnim <= 0 ){
120+
// Add a random time until the next eye blink
121+
this.eyeBlinkNext = this.msRunner.x + this.pxlUtils.randomFloat( this.eyeBlinkMinMaxDelay[0], this.eyeBlinkMinMaxDelay[1] );
122+
}
123+
}else{
124+
this.eyeBlinkInf.x = 0;
125+
if(this.msRunner.x > this.eyeBlinkNext ){
126+
// Set the next blink rate, how quickly the animation goes from 1 to 0
127+
this.eyeBlinkRate = this.pxlUtils.randomFloat( this.eyeBlinkMinMaxRate[0], this.eyeBlinkMinMaxRate[1] );
128+
this.eyeBlinkAnim = 1;
129+
}
130+
}
131+
this.textureList[ "RabbitDruidA" ].uniforms.eyeBlink.value = this.eyeBlinkInf;
132+
}
133+
103134
// -- -- --
104135

105136

@@ -207,9 +238,6 @@ export class CampfireEnvironment extends RoomEnvironment{
207238
this.textureList["CampfireLogs"]=logMat;
208239
}
209240

210-
// Asign Campfire Log material
211-
//console.log(x)
212-
//console.log(x.material)
213241
this.geoList['InstancesObjects'][x].material=logMat;
214242
}
215243
}
@@ -219,7 +247,6 @@ export class CampfireEnvironment extends RoomEnvironment{
219247
this.setUserHeight( this.camInitPos.y );
220248

221249

222-
//console.log(this.geoList);
223250

224251
this.booted=true;
225252
}
@@ -238,7 +265,6 @@ export class CampfireEnvironment extends RoomEnvironment{
238265
this.animInitCycle = fallback;
239266
this.log("No animation cycle '"+this.animInitCycle+"' found; Using '"+fallback+"' instead");
240267
}
241-
242268

243269
// To view the skeleton of Mr. Rabbit Druid
244270
// Uncomment the following 2 lines --
@@ -249,11 +275,47 @@ export class CampfireEnvironment extends RoomEnvironment{
249275
let curMesh = this.pxlAnim.getMesh( animKey );
250276
if(curMesh){
251277
let curMtl = curMesh.material;
278+
curMtl.side = THREE.DoubleSide;
279+
let vert = curMtl.vertexShader;
280+
let frag = curMtl.fragmentShader;
281+
let newSkinnedMtl = this.setSkinnedMaterial( curMesh, rabbitDruidVert(), rabbitDruidFrag() );
282+
this.textureList[ "RabbitDruidA" ] = newSkinnedMtl;
252283
}
253284

254-
285+
if( this.geoList["Scripted"].hasOwnProperty("pokinStick_geo") ){
286+
let stickMtl = this.geoList["Scripted"]["pokinStick_geo"].material;
287+
stickMtl.shininess = 0;
288+
}
289+
}
290+
291+
setSkinnedMaterial( bindObj, vertShader=null, fragShader=null ){
292+
293+
let skinnedMtlUniforms = THREE.UniformsUtils.merge(
294+
[
295+
THREE.UniformsLib['common'],
296+
THREE.UniformsLib['lights'],
297+
{
298+
'diffuseTexture' : { type:'t', value: null },
299+
'areTexture' : { type:'t', value: null },
300+
'noiseTexture' : { type:'t', value: null },
301+
'eyeBlink' : { type:'v2', value: this.eyeBlinkInf },
302+
'mult': { type:'f', value:1 },
303+
}
304+
]
305+
);
306+
307+
skinnedMtlUniforms.diffuseTexture.value = bindObj.material.map;
308+
skinnedMtlUniforms.areTexture.value = this.pxlUtils.loadTexture( this.assetPath+"RabbitDruidA/RabbitDruidA_lowRes_ARE.jpg" );
309+
skinnedMtlUniforms.noiseTexture.value = this.cloud3dTexture;
310+
311+
let skinnedMaterial = this.pxlFile.pxlShaderBuilder( skinnedMtlUniforms, vertShader, fragShader );
312+
skinnedMaterial.skinning = true;
313+
skinnedMaterial.side = THREE.DoubleSide;
314+
skinnedMaterial.lights = true;
315+
316+
bindObj.material = skinnedMaterial;
317+
return skinnedMaterial;
255318
}
256-
257319

258320
// -- -- -- -- -- -- -- -- -- -- -- -- -- //
259321

@@ -333,8 +395,6 @@ export class CampfireEnvironment extends RoomEnvironment{
333395
this.textureList[ "CampfireFlame_geo" ]=campfireMtl;
334396

335397

336-
337-
338398
//
339399
// -- -- --
340400

@@ -344,5 +404,4 @@ export class CampfireEnvironment extends RoomEnvironment{
344404

345405
}
346406

347-
348407
}

0 commit comments

Comments
 (0)