Skip to content
This repository was archived by the owner on Mar 23, 2019. It is now read-only.

Extrusion shaders - #25

Merged
lbud merged 47 commits into
masterfrom
js-buildings
Oct 7, 2016
Merged

lbud merged 47 commits into
masterfrom
js-buildings

Conversation

@lbud

@lbud lbud commented Sep 19, 2016 •

Copy link
Copy Markdown
Contributor

Companion PR to mapbox/mapbox-gl-js#3223.

Adds

  • extrusion shader: used to draw solid colored extruded features
  • extrusion pattern shader: used to draw patterned extruded features
  • extrusion texture shader: used to render the entire extrusion framebuffer back to the map at a desired opacity

cc @nickidlugash @ansis @lucaswoj @jfirebaugh

Comment thread index.js Outdated
fragmentSource: fs.readFileSync(path.join(__dirname, 'src/extrusionpattern.fragment.glsl'), 'utf8'),
vertexSource: fs.readFileSync(path.join(__dirname, 'src/extrusionpattern.vertex.glsl'), 'utf8')
},
extrusiontexture: {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It took me a few moments to understand what extrusiontexture is. A name that captures the second-pass-ness of this shader would be ideal. I'll sleep on it.

void main() {
#ifdef MAPBOX_GL_JS
#pragma mapbox: initialize lowp float minH
#pragma mapbox: initialize lowp float maxH

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does the H stand for?

void main() {
#ifdef MAPBOX_GL_JS
#pragma mapbox: initialize lowp float minH
#pragma mapbox: initialize lowp float maxH

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our naming convention for identifiers in shaders is lower_underscore_case

Comment thread src/extrusion.vertex.glsl
v_color.r += clamp(color.r * directional * u_lightcolor.r, mix(0.0, 0.3, 1.0 - u_lightcolor.r), 1.0);
v_color.g += clamp(color.g * directional * u_lightcolor.g, mix(0.0, 0.3, 1.0 - u_lightcolor.g), 1.0);
v_color.b += clamp(color.b * directional * u_lightcolor.b, mix(0.0, 0.3, 1.0 - u_lightcolor.b), 1.0);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I take it from the // TODOs and commented-out code that this file is still somewhat a WIP 😄


// the following offset calculation is duplicated from the regular pattern shader:
vec2 offset_a = mod(mod(mod(u_pixel_coord_upper, scaled_size_a) * 256.0, scaled_size_a) * 256.0 + u_pixel_coord_lower, scaled_size_a);
vec2 offset_b = mod(mod(mod(u_pixel_coord_upper, scaled_size_b) * 256.0, scaled_size_b) * 256.0 + u_pixel_coord_lower, scaled_size_b);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can factor this shared out into util.glsl

@jfirebaugh jfirebaugh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@lbud
lbud merged commit 44b65f8 into master Oct 7, 2016
@lbud
lbud deleted the js-buildings branch October 7, 2016 23:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants