{"action":"created","issue":{"url":"https://api.github.com/repos/GoodBoyDigital/pixi.js/issues/1883","labels_url":"https://api.github.com/repos/GoodBoyDigital/pixi.js/issues/1883/labels{/name}","comments_url":"https://api.github.com/repos/GoodBoyDigital/pixi.js/issues/1883/comments","events_url":"https://api.github.com/repos/GoodBoyDigital/pixi.js/issues/1883/events","html_url":"https://github.com/GoodBoyDigital/pixi.js/issues/1883","id":87036622,"number":1883,"title":"Possible error in the Filter's dimensions uniform","user":{"login":"jagi","id":1051229,"avatar_url":"https://avatars.githubusercontent.com/u/1051229?v=3","gravatar_id":"","url":"https://api.github.com/users/jagi","html_url":"https://github.com/jagi","followers_url":"https://api.github.com/users/jagi/followers","following_url":"https://api.github.com/users/jagi/following{/other_user}","gists_url":"https://api.github.com/users/jagi/gists{/gist_id}","starred_url":"https://api.github.com/users/jagi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jagi/subscriptions","organizations_url":"https://api.github.com/users/jagi/orgs","repos_url":"https://api.github.com/users/jagi/repos","events_url":"https://api.github.com/users/jagi/events{/privacy}","received_events_url":"https://api.github.com/users/jagi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-06-10T16:58:31Z","updated_at":"2015-07-07T16:53:48Z","closed_at":null,"body":"Hi I think that there is an error in this line: https://github.com/GoodBoyDigital/pixi.js/blob/master/src/core/renderers/webgl/managers/FilterManager.js#L192\r\n\r\nIt should be changed from:\r\n\r\n```js\r\nfilters[0].uniforms.dimensions.value[0] = this.renderer.width;\r\nfilters[0].uniforms.dimensions.value[1] = this.renderer.height;\r\nfilters[0].uniforms.dimensions.value[2] = this.quad.vertices[0];\r\nfilters[0].uniforms.dimensions.value[3] = this.quad.vertices[5];\r\n```\r\n\r\nto\r\n\r\n```js\r\nfilters[0].uniforms.dimensions.value[0] = this.renderer.width;\r\nfilters[0].uniforms.dimensions.value[1] = this.renderer.height;\r\nfilters[0].uniforms.dimensions.value[2] = this.quad.vertices[4];\r\nfilters[0].uniforms.dimensions.value[3] = this.quad.vertices[5];\r\n```\r\n\r\nAs far as I understand the dimensions' values under indexes 2 and 3 are the width and the height of the sprite. My sprite has the size 400 x 200 and my canvas has size 600 x 600 but in the dimensions array I get `[600, 600, 0, 200]`. I don't know exactly what values stores `this.quad.vertices` but after investigating its values I assume that there should be 4th index taken instead of 0.\r\n\r\nHere is an example filter that I've made. And everything works but only in the Y axis not in the X axis, because of that error. The filter just offsets sprite's texture and wraps it around.\r\n\r\n```js\r\nfunction OffsetFilter() {\r\n  var vertexShader = null;\r\n  var fragmentShader = [\r\n    'precision mediump float;',\r\n    '',\r\n    'varying vec2 vTextureCoord;',\r\n    '',\r\n    'uniform vec4 dimensions;',\r\n    'uniform vec2 offset;',\r\n    'uniform sampler2D uSampler;',\r\n    '',\r\n    'void main(void)',\r\n    '{',\r\n    '    vec2 pixelSize = vec2(1.0) / dimensions.xy;',\r\n    '    vec2 spriteSize = dimensions.zw / dimensions.xy;',\r\n    '    vec2 coord = vTextureCoord.xy - pixelSize.xy * offset;',\r\n    '',\r\n    '    if (coord.x < 0.0) {',\r\n    '        coord.x = coord.x + spriteSize.x;',\r\n    '    }',\r\n    '',\r\n    '    if (coord.y < 0.0) {',\r\n    '        coord.y = coord.y + spriteSize.y;',\r\n    '    ',\r\n    '    }',\r\n    '',\r\n    '    gl_FragColor = texture2D(uSampler, coord);',\r\n    '}'\r\n  ].join('\\n');\r\n\r\n  PIXI.filters.AbstractFilter.call(this,\r\n    null,\r\n    fragmentShader,\r\n    {\r\n      dimensions: {\r\n        type: '4fv',\r\n        value: new Float32Array([0, 0, 0, 0])\r\n      },\r\n      offset: {\r\n        type: 'v2',\r\n        value: {\r\n          x: 50,\r\n          y: 50\r\n        }\r\n      }\r\n    }\r\n  );\r\n}\r\n\r\nOffsetFilter.prototype = Object.create(PIXI.filters.AbstractFilter.prototype);\r\nOffsetFilter.prototype.constructor = OffsetFilter;\r\n\r\nObject.defineProperties(OffsetFilter.prototype, {\r\n  offset: {\r\n    get: function() {\r\n      return this.uniforms.offset.value;\r\n    },\r\n    set: function(value) {\r\n      this.uniforms.offset.value = value;\r\n    }\r\n  }\r\n});\r\n```"},"comment":{"url":"https://api.github.com/repos/GoodBoyDigital/pixi.js/issues/comments/119266520","html_url":"https://github.com/GoodBoyDigital/pixi.js/issues/1883#issuecomment-119266520","issue_url":"https://api.github.com/repos/GoodBoyDigital/pixi.js/issues/1883","id":119266520,"user":{"login":"englercj","id":944497,"avatar_url":"https://avatars.githubusercontent.com/u/944497?v=3","gravatar_id":"","url":"https://api.github.com/users/englercj","html_url":"https://github.com/englercj","followers_url":"https://api.github.com/users/englercj/followers","following_url":"https://api.github.com/users/englercj/following{/other_user}","gists_url":"https://api.github.com/users/englercj/gists{/gist_id}","starred_url":"https://api.github.com/users/englercj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/englercj/subscriptions","organizations_url":"https://api.github.com/users/englercj/orgs","repos_url":"https://api.github.com/users/englercj/repos","events_url":"https://api.github.com/users/englercj/events{/privacy}","received_events_url":"https://api.github.com/users/englercj/received_events","type":"User","site_admin":false},"created_at":"2015-07-07T16:53:48Z","updated_at":"2015-07-07T16:53:48Z","body":"@jagi Rotation information is passed in the transform matrix, it shouldn't be in dimensions. The dimensions are not about the sprite but about geometry. Using a `vec4` means a single uniform upload instead of 2."}}