Skip to content

Instantly share code, notes, and snippets.

@chandlerprall
Created August 17, 2012 21:53
Show Gist options
  • Select an option

  • Save chandlerprall/3383018 to your computer and use it in GitHub Desktop.

Select an option

Save chandlerprall/3383018 to your computer and use it in GitHub Desktop.
usage
terrain_shader = new TerraFrame.TerrainShader({
uniforms: [
{ name: 'sunlight_dir', type: 'v3', value: new THREE.Vector3( -.5, .8, .7 ) }
],
textures: [
{ name: 'grass', asset: 'terrain.grass', repeat: new THREE.Vector2( 2, 2 ) },
{ name: 'rock', asset: 'terrain.rock', repeat: new THREE.Vector2( 3, 3 ) },
{ name: 'sand', asset: 'terrain.sand', repeat: new THREE.Vector2( 2, 2 ) }
],
pieces: [
'vec4 fogofwar = vec4(0.0, 0.0, 0.0, 1.0);',
'gl_FragColor = vec4(rock.rgb, 1.0);',
TerraFrame.TerrainShader.Chunks.strata({
texture: 'sand',
elevation: {
max: -1,
fade: 2
},
slope: {
max: Math.PI/4,
fade: Math.PI/8
},
}),
TerraFrame.TerrainShader.Chunks.strata({
texture: 'grass',
elevation: {
min: -3,
fade: 2
},
slope: {
max: Math.PI/4,
fade: Math.PI/8
},
}),
TerraFrame.TerrainShader.Chunks.pervertexTextures(['fogofwar']),
TerraFrame.TerrainShader.Chunks.sunlight,
],
pervertex_textures: ['fogofwar']
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment