Skip to content

Commit 1092d16

Browse files
committed
pxlNav v0.0.17
Fully updated three and adjusted shaders that needed gamma adjustment Implementation of three's old color system needs to happen in pxlNav, This gamma adjustment is too manual.
1 parent c4c97c2 commit 1092d16

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+16888
-57923
lines changed

Public/js/pxlNavLoader_basic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const antiAliasing = pxlEnums.ANTI_ALIASING.LOW;
5353
// Default is `BASIC` - a simple shadow edge
5454
// Options are - OFF, BASIC, SOFT
5555
// *Mobile devices are limited to `OFF` or `BASIC` automatically
56-
const shadowMapBiasing = pxlEnums.SHADOW_MAP.SOFT;
56+
const shadowMapBiasing = pxlEnums.SHADOW_MAP.OFF;
5757

5858
// Set camera to static Camera Positions
5959
// Locations pulled from the 'Camera' group in the pxlRoom's FBX file

Source/js/pxlNav/RoomClass.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import {
3030
UniformsUtils,
3131
UniformsLib
3232
} from "../libs/three/three.module.min.js";
33-
//import { ShaderPass } from 'three/examples/jsm/postprocessing/EffectComposer.js';
3433
import { pxlPrincipledVert, pxlPrincipledFrag } from "./shaders/objects/PxlPrincipled.js";
3534

3635
class RoomEnvironment{

Source/js/pxlNav/core/FileIO.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,20 @@ export class FileIO{
9090
}
9191
}
9292

93+
// -- -- --
94+
95+
// Convert Linear to sRGB
96+
tosRGB( val ){
97+
if( val <= 0.0031308 ){
98+
val *= 12.92;
99+
}else{
100+
val = 1.055 * Math.pow(val, 1.0/2.4) - 0.055;
101+
}
102+
return val;
103+
}
104+
105+
// -- -- --
106+
93107
// Check for UserData on the Mesh
94108
// envObj = Environment Class Object
95109
// envScene = Environment ThreeJS Scene Object
@@ -368,6 +382,7 @@ export class FileIO{
368382
let curScale = scale;
369383
if( hasColor ){
370384
let curScalar = mesh.geometry.attributes.color.getX(x);
385+
curScalar = this.tosRGB(curScalar);
371386
curScale = new Vector3(curScalar, curScalar, curScalar);
372387
}
373388
matrix.compose(position, quaternion, curScale);
@@ -448,6 +463,7 @@ export class FileIO{
448463
}
449464

450465

466+
451467
// -- -- -- -- -- -- -- -- -- -- -- -- -- //
452468
// -- -- -- -- -- -- -- -- -- -- -- -- -- //
453469
// -- -- -- -- -- -- -- -- -- -- -- -- -- //

Source/js/pxlNav/shaders/objects/PxlPrincipled.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,10 @@ export function pxlPrincipledFrag( ShaderParms, useColor, useFog, lights, shadow
356356
}
357357
ret+=`
358358
Cd*=cdMult;
359+
360+
// Convert to sRGB
361+
Cd.rgb = mix( 12.92 * Cd.rgb, 1.055 * pow(Cd.rgb, vec3(1.0 / 2.4)) - 0.055, step(0.0031308, Cd.rgb) );
362+
359363
gl_FragColor=Cd;
360364
}`;
361365
return ret;

Source/js/pxlNav/shaders/scene/SkyObject.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,15 @@ export function skyObjectFrag( skyHazeValue=SKY_HAZE.OFF ){
6262
if( skyHazeValue == SKY_HAZE.VAPOR ){
6363
ret+=`
6464
65+
66+
vec3 lPos = vLocalPos;
67+
lPos.y = abs(lPos.y)*0.05;
68+
6569
float t = time.x*.6;
6670
67-
vec2 nUv = ( vec2(vUv.x*0.230, vUv.y*.85 - t*.0065) );
71+
vec2 nUv = vec2(vUv.x*0.20, vUv.y - t*.0065 - lPos.y );
6872
vec3 noiseCd = texture2D( noiseTexture, nUv ).rgb;
69-
nUv = ( nUv+noiseCd.rg*(noiseCd.b));
70-
//nUv.y *= .5;
73+
nUv = ( nUv+noiseCd.rg*(noiseCd.b) + t*.02);
7174
noiseCd = texture2D( noiseTexture, nUv ).rgb;
7275
noiseCd.rg = noiseCd.rg*2.0-1.0;
7376
@@ -87,8 +90,8 @@ export function skyObjectFrag( skyHazeValue=SKY_HAZE.OFF ){
8790
float blend = 0.0;
8891
float uvShift=0.0;
8992
for(int s=0; s<5; ++s){
90-
uvShift = mix(noiseCd.r, noiseCd.g, fract(noiseCd.b+float(s)*193.5247))*15.0;
91-
curUV = baseUV+vec2(0.0,resUV.y*-(dist+uvShift) );
93+
uvShift = mix(noiseCd.r, noiseCd.g, (noiseCd.b+float(s)*193.5247))*15.0;
94+
curUV = baseUV+vec2(0.0,resUV.y*-(dist+uvShift) - t*.005 );
9295
curDepth = texture2D(envDiffuse,curUV).x ;
9396
curDepth = fitDepth( curDepth );
9497
curPerc = step( .3, (1.0-curDepth)*7.00 );
@@ -103,10 +106,11 @@ export function skyObjectFrag( skyHazeValue=SKY_HAZE.OFF ){
103106
normPos.y = normPos.y*normPos.y*normPos.y;
104107
depth = clamp(reachDepth+normPos.y, 0.0, 1.0)*.02;
105108
106-
float fogMixer = (Cd.r+Cd.g+Cd.b)*10.5 - (fogColor.r+fogColor.g+fogColor.b) ;
109+
float fogMixer = (Cd.r+Cd.g+Cd.b) - (fogColor.r+fogColor.g+fogColor.b) ;
107110
vec3 toFogColor = mix( fogColor, Cd.rgb, step(0.0, fogMixer) );
108-
float blender = (sin(noiseCd.r*PI+t+uv.x))*max(0.0,1.0-(depth+fogMixer))*.15;
109-
vec3 baseColor = (toFogColor+(blender) - depth*3.0);
111+
float blender = (sin(noiseCd.r*PI+t+uv.x))*max(0.0,1.0-(depth+fogMixer))*.1 ;
112+
vec3 baseColor = (toFogColor-min(1.0,blender+ depth*10.0)) ;
113+
110114
111115
Cd.rgb = mix(Cd.rgb, baseColor, depth);
112116

Source/js/pxlRooms/CampfireEnvironment/CampfireEnvironment.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import {
55
LinearFilter, AdditiveBlending,
66
DoubleSide, FrontSide,
77
UniformsUtils, UniformsLib,
8-
SRGBColorSpace, LinearSRGBColorSpace
9-
8+
SRGBColorSpace, LinearSRGBColorSpace,
9+
AmbientLight
1010
} from "../../libs/three/three.module.min.js";
1111

1212
import { RoomEnvironment, pxlEffects } from "../../pxlNav.js";
@@ -156,6 +156,11 @@ export class CampfireEnvironment extends RoomEnvironment{
156156
let particleSource = this.geoList['Scripted']['ParticleSource_loc'];
157157
let particleSourcePos = particleSource.position;
158158

159+
160+
var ambientLight = new AmbientLight( 0x101010 ); // soft white light
161+
this.scene.add( ambientLight );
162+
163+
159164
let campefireOrder = 0;
160165

161166
if( this.geoList.hasOwnProperty("InstanceObjects") ){

Source/js/pxlRooms/CampfireEnvironment/Shaders.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ export function rabbitDruidVert(){
140140
vec4 areCd=texture2D(areTexture,vUv);
141141
outCd = diffCd;
142142
143+
// Convert to sRGB
144+
outCd.rgb = mix( 12.92 * outCd.rgb, 1.055 * pow(outCd.rgb, vec3(1.0 / 2.4)) - 0.055, step(0.0031308, outCd.rgb) );
145+
143146
vec2 animUv = vUv*.01;
144147
animUv.y -= time.x*.1;
145148
vec4 nCd=texture2D(noiseTexture,animUv);
Binary file not shown.

Source/js/pxlRooms/FieldEnvironment/FieldEnvironment.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export class FieldEnvironment extends RoomEnvironment{
5252
this.pxlCamFarClipping = 10000;
5353

5454
// this.fogColor=new Color(.3,.3,.3);
55-
this.fogColor=new Color(.01,.02,.05);
55+
this.fogColor=new Color(.005,.01,.025);
5656
this.fogExp=.0007;
5757
this.fog=new FogExp2( this.fogColor, this.fogExp);
5858

@@ -102,18 +102,18 @@ export class FieldEnvironment extends RoomEnvironment{
102102
this.warpPortalTexture=null;
103103
this.warpZoneRenderTarget=null;
104104

105-
this.worldPosMaterial=null;
105+
this.worldPosMaterial=null;
106106
this.worldPosRenderTarget=null;
107107
this.spiralizerPass=null;
108108

109-
this.bloomPreState=false;
109+
this.bloomPreState=false;
110110

111111
this.cloud3dTexture=null;
112112
this.smoothNoiseTexture=null;
113113

114-
//%=
115-
this.currentShader=null;
116-
//%
114+
//%=
115+
this.currentShader=null;
116+
//%
117117
}
118118
init(){
119119
this.scene.fog=this.fog;
@@ -361,6 +361,7 @@ export class FieldEnvironment extends RoomEnvironment{
361361
let ShaderParms = {};
362362
let useLights = true
363363
let useShadows = curObj.userData.castShadow == true || curObj.userData.receiveShadow == true
364+
useShadows = false
364365
let useFog = true;
365366

366367
let useColor = false;
@@ -382,7 +383,7 @@ export class FieldEnvironment extends RoomEnvironment{
382383
}
383384
});
384385
}
385-
386+
pointShadowLightCount=0;
386387
let mat=this.pxlFile.pxlShaderBuilder(
387388
shaderUniforms,
388389
pxlPrincipledVert( useShadows ),
@@ -421,7 +422,7 @@ export class FieldEnvironment extends RoomEnvironment{
421422
[
422423
UniformsLib[ "common" ],
423424
UniformsLib[ "lights" ],
424-
UniformsLib[ "shadowmap" ],
425+
/*UniformsLib[ "shadowmap" ],*/
425426
{
426427
'diffuse' : { type:'t', value: null },
427428
'dirtDiffuse' : { type:'t', value: null },
@@ -446,6 +447,7 @@ export class FieldEnvironment extends RoomEnvironment{
446447

447448
let environmentGroundMat=this.pxlFile.pxlShaderBuilder( envGroundUniforms, envGroundVert(), envGroundFrag(1) );
448449
environmentGroundMat.lights= true;
450+
console.log(environmentGroundMat)
449451

450452
envGroundUniforms.uniformNoise.value.wrapS = RepeatWrapping;
451453
envGroundUniforms.uniformNoise.value.wrapT = RepeatWrapping;
@@ -466,7 +468,7 @@ export class FieldEnvironment extends RoomEnvironment{
466468
let grassClusterUniforms = UniformsUtils.merge(
467469
[
468470
UniformsLib[ "lights" ],
469-
UniformsLib[ "shadowmap" ],
471+
/*UniformsLib[ "shadowmap" ],*/
470472
{
471473
'noiseTexture' : { type:'t', value: null },
472474
'fogColor' : { type: "c", value: this.fogColor },

0 commit comments

Comments
 (0)