Shader Builder / use vertex context to parse the symbol rotation expression

Previously the expression was parsed in the fragment shader context, which
meant in case the expression used an attributes the resulting GLSL code
would be wrong.

Fragment shader context:
`float angle = v_heading; // we're using the varying: not OK`

Vertex shader context:
`float angle = a_heading; // we're using the attribute: OK`
This commit is contained in:
Olivier Guyot
2020-03-03 09:45:57 +01:00
parent 5ea0b52ba8
commit 40d44db85e
2 changed files with 15 additions and 1 deletions

View File

@@ -511,6 +511,20 @@ void main(void) {
expect(result.uniforms).to.have.property('u_ratio');
});
it('parses a style with a rotation expression using an attribute', function() {
const result = parseLiteralStyle({
symbol: {
symbolType: 'square',
size: 6,
rotation: ['get', 'heading']
}
});
expect(result.builder.attributes).to.eql(['float a_heading']);
expect(result.builder.varyings).to.eql([]);
expect(result.builder.rotationExpression).to.eql('a_heading');
});
it('correctly adds string variables to the string literals mapping', function() {
const result = parseLiteralStyle({
variables: {