@@ -387,7 +387,16 @@ function renderElement (world: World, cursor: Vec3, element: BlockElement, doAO:
387387 const aos : number [ ] = [ ]
388388 const neighborPos = position . plus ( new Vec3 ( ...dir ) )
389389 // 10%
390- const baseLight = world . getLight ( neighborPos , undefined , undefined , block . name ) / 15
390+ const { smoothLighting, shadingTheme, cardinalLight } = world . config
391+ const faceLight = world . getLight ( neighborPos , undefined , undefined , block . name )
392+ const sideShading = ( shadingTheme === 'high-contrast' ) ?
393+ ( 0.8 + 0.5 * Math . max ( 0 , 0.66 * dir [ 0 ] + 0.66 * dir [ 1 ] + 0.33 * dir [ 2 ] ) ) : //old directional light behavior
394+ (
395+ cardinalLight === 'nether' ?
396+ ( 0.5 + Math . abs ( 0.1 * dir [ 0 ] + 0.4 * dir [ 1 ] + 0.3 * dir [ 2 ] ) ) :
397+ ( 0.75 + 0.25 * dir [ 1 ] + 0.05 * ( Math . abs ( dir [ 2 ] ) - 3 * Math . abs ( dir [ 0 ] ) ) )
398+ )
399+ const baseLight = sideShading * faceLight / 15
391400 for ( const pos of corners ) {
392401 let vertex = [
393402 ( pos [ 0 ] ? maxx : minx ) ,
@@ -414,7 +423,7 @@ function renderElement (world: World, cursor: Vec3, element: BlockElement, doAO:
414423 }
415424
416425 let light = 1
417- const { smoothLighting } = world . config
426+
418427 // const smoothLighting = true
419428 if ( doAO ) {
420429 const dx = pos [ 0 ] * 2 - 1
@@ -427,7 +436,7 @@ function renderElement (world: World, cursor: Vec3, element: BlockElement, doAO:
427436 const side2 = world . getBlock ( cursor . offset ( ...side2Dir ) )
428437 const corner = world . getBlock ( cursor . offset ( ...cornerDir ) )
429438
430- let cornerLightResult = baseLight * 15
439+ let cornerLightResult = faceLight
431440
432441 if ( smoothLighting ) {
433442 const dirVec = new Vec3 ( ...dir )
@@ -444,7 +453,7 @@ function renderElement (world: World, cursor: Vec3, element: BlockElement, doAO:
444453 const cornerLightDir = getVec ( new Vec3 ( ...cornerDir ) )
445454 const cornerLight = world . getLight ( cursor . plus ( cornerLightDir ) )
446455 // interpolate
447- const lights = [ side1Light , side2Light , cornerLight , baseLight * 15 ]
456+ const lights = [ side1Light , side2Light , cornerLight , faceLight ]
448457 cornerLightResult = lights . reduce ( ( acc , cur ) => acc + cur , 0 ) / lights . length
449458 }
450459
@@ -455,8 +464,11 @@ function renderElement (world: World, cursor: Vec3, element: BlockElement, doAO:
455464 // TODO: correctly interpolate ao light based on pos (evaluate once for each corner of the block)
456465
457466 const ao = ( side1Block && side2Block ) ? 0 : ( 3 - ( side1Block + side2Block + cornerBlock ) )
467+ const ao_bias = ( shadingTheme === 'high-contrast' ) ? 0.25 : 0.4
468+ const ao_scale = ( shadingTheme === 'high-contrast' ) ? 0.25 : 0.2
469+
458470 // todo light should go upper on lower blocks
459- light = ( ao + 1 ) / 4 * ( cornerLightResult / 15 )
471+ light = sideShading * ( ao * ao_scale + ao_bias ) * ( cornerLightResult / 15 )
460472 aos . push ( ao )
461473 }
462474
0 commit comments