-
Notifications
You must be signed in to change notification settings - Fork 271
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add demo for tile texture overlays (#528)
* Add initial texture skinning * Updates * Small fixes * before compile functino * Add support for image bitmap loader * Add texture overlay test demo * file rename * small fixes * Uniform fixes * Update demo * Remove cache * Load textures * slope update * remove unused lines * Limit the data that can be downloaded at once with a priority queue * Update textures result * Unset zoom point when tiles change * Move material application to demo page * Clean up material handling * Reorganize foldrs * update * Stable loading * Re-add parse tile adjustments
- Loading branch information
Showing
14 changed files
with
794 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
example/src/FadeTilesRenderer.js → ...ple/src/plugins/fade/FadeTilesRenderer.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
export const TextureOverlayMaterialMixin = base => class extends base { | ||
|
||
constructor( ...args ) { | ||
|
||
super( ...args ); | ||
this.textures = []; | ||
|
||
} | ||
|
||
onBeforeCompile( shader ) { | ||
|
||
const textures = this.textures; | ||
const material = this; | ||
|
||
shader.uniforms.textures = { | ||
get value() { | ||
|
||
return material.textures; | ||
|
||
}, | ||
}; | ||
|
||
// WebGL does not seem to like empty texture arrays | ||
if ( textures.length !== 0 ) { | ||
|
||
shader.fragmentShader = shader.fragmentShader | ||
.replace( /void main/, m => /* glsl */` | ||
uniform sampler2D textures[ ${ textures.length } ]; | ||
${ m } | ||
` ) | ||
.replace( /#include <color_fragment>/, m => /* glsl */` | ||
${ m } | ||
vec4 col; | ||
#pragma unroll_loop_start | ||
for ( int i = 0; i < ${ textures.length }; i ++ ) { | ||
col = texture( textures[ i ], vMapUv ); | ||
col = vec4( 0, 0, 1, col.r ); | ||
diffuseColor = mix( diffuseColor, vec4( 0.35, 0.65, 1, 1 ), col.a ); | ||
} | ||
#pragma unroll_loop_end | ||
` ); | ||
|
||
} | ||
|
||
} | ||
|
||
customProgramCacheKey() { | ||
|
||
return this.textures.length + this.onBeforeCompile.toString(); | ||
|
||
} | ||
|
||
}; |
Oops, something went wrong.