{"action":"created","issue":{"url":"https://api.github.com/repos/photonstorm/phaser/issues/3823","repository_url":"https://api.github.com/repos/photonstorm/phaser","labels_url":"https://api.github.com/repos/photonstorm/phaser/issues/3823/labels{/name}","comments_url":"https://api.github.com/repos/photonstorm/phaser/issues/3823/comments","events_url":"https://api.github.com/repos/photonstorm/phaser/issues/3823/events","html_url":"https://github.com/photonstorm/phaser/issues/3823","id":339264173,"node_id":"MDU6SXNzdWUzMzkyNjQxNzM=","number":3823,"title":"Render Texture issues","user":{"login":"SBCGames","id":8962889,"node_id":"MDQ6VXNlcjg5NjI4ODk=","avatar_url":"https://avatars0.githubusercontent.com/u/8962889?v=4","gravatar_id":"","url":"https://api.github.com/users/SBCGames","html_url":"https://github.com/SBCGames","followers_url":"https://api.github.com/users/SBCGames/followers","following_url":"https://api.github.com/users/SBCGames/following{/other_user}","gists_url":"https://api.github.com/users/SBCGames/gists{/gist_id}","starred_url":"https://api.github.com/users/SBCGames/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SBCGames/subscriptions","organizations_url":"https://api.github.com/users/SBCGames/orgs","repos_url":"https://api.github.com/users/SBCGames/repos","events_url":"https://api.github.com/users/SBCGames/events{/privacy}","received_events_url":"https://api.github.com/users/SBCGames/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2018-07-08T22:36:04Z","updated_at":"2018-07-31T23:57:44Z","closed_at":null,"author_association":"NONE","body":"Hi, this is sum of issues I found when working with Render Texture (WebGL). This is current setup:\r\n - game 640x1024 pixels,\r\n - render texture in scene 300x300 pixels\r\n(I use render texture to prerender 9-image for menu)\r\n\r\n![game](https://user-images.githubusercontent.com/8962889/42424394-ebac026a-830b-11e8-8fa7-7389ffb5a778.jpg)\r\n\r\n\r\n1] when using FireFox, erorr / warning is thrown: \"Error: WebGL warning: drawArrays: Drawing to a destination rect smaller than the viewport rect. (This warning will only be given once)\":\r\n\r\n![glerror](https://user-images.githubusercontent.com/8962889/42424399-0afb724a-830c-11e8-88b6-d1224d0e586a.png)\r\n\r\n It is related to size of viewport and size of render texture. In this case, render texture is only 300x300, while viewport is 640x1024.\r\n\r\nOriginal code in file RenderTextureWebGL.js can be changed to following and error then does not show (and everything else still seems to work...). Here I am using exact numbers from my game as I am not sure what is correct source for them in code.\r\n```javascript\r\n    draw: function (texture, frame, x, y)\r\n    {\r\n        // add this line to change viewport size to size of render texture\r\n        this.gl.viewport(0, 0, 300, 300);\r\n\r\n        var glTexture = texture.source[frame.sourceIndex].glTexture;\r\n        var tint = (this.globalTint >> 16) + (this.globalTint & 0xff00) + ((this.globalTint & 0xff) << 16);\r\n        this.renderer.setFramebuffer(this.framebuffer);\r\n\r\n        // set projection to size of render texture, not size of the game\r\n        this.renderer.pipelines.TextureTintPipeline.projOrtho(0, 300 /* this.renderer.pipelines.TextureTintPipeline.width */ ,\r\n                0, 300 /* this.renderer.pipelines.TextureTintPipeline.height */, -1000.0, 1000.0);\r\n\r\n        this.renderer.pipelines.TextureTintPipeline.drawTexture(glTexture, x, y, tint, this.globalAlpha, frame.cutX, frame.cutY, frame.cutWidth, frame.cutHeight, this.currentMatrix, null, this);\r\n        this.renderer.setFramebuffer(null);\r\n        this.renderer.pipelines.TextureTintPipeline.projOrtho(0, this.renderer.pipelines.TextureTintPipeline.width, this.renderer.pipelines.TextureTintPipeline.height, 0, -1000.0, 1000.0);\r\n\r\n        // add this line to change viewport size back to game viewport\r\n        this.gl.viewport(0, 0, 640, 1024);\r\n\r\n        return this;\r\n    }\r\n```\r\n\r\n2] second issue comes from fact, that methods clear(), fill() and draw() of Render Texture are missing in TS defs (they are not present at RenderTexture.js - implementation is in RenderTextureWebGL.js and RenderTextureCanvas.js). Also type of first parametr of draw method in RenderTexture.js is not correct (string - key of texture). Method(s) uses texture (Phaser.Textures.Texture)\r\n\r\n3] this is kind of feature request: It would be great if not only single frames could be rendered into render texture (as it is not possible to scale/rotate/... them ). More, currently rendering is not batched. It is ok, if prerendering something in create() method, but it can fire lot of draw calls if someone rendered something complex every frame.\r\n It would be great if gameobject or whole displaylist/scene (or combination like container) could be rendered into render texture. Would it be possible if it used the same rendering as whole game uses, but only targeting render texture instead of main game texture?\r\n\r\n<bountysource-plugin>\r\n\r\n---\r\nWant to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/60630691-render-texture-issues?utm_campaign=plugin&utm_content=tracker%2F283654&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F283654&utm_medium=issues&utm_source=github).\r\n</bountysource-plugin>"},"comment":{"url":"https://api.github.com/repos/photonstorm/phaser/issues/comments/409405071","html_url":"https://github.com/photonstorm/phaser/issues/3823#issuecomment-409405071","issue_url":"https://api.github.com/repos/photonstorm/phaser/issues/3823","id":409405071,"node_id":"MDEyOklzc3VlQ29tbWVudDQwOTQwNTA3MQ==","user":{"login":"iamchristopher","id":5909516,"node_id":"MDQ6VXNlcjU5MDk1MTY=","avatar_url":"https://avatars2.githubusercontent.com/u/5909516?v=4","gravatar_id":"","url":"https://api.github.com/users/iamchristopher","html_url":"https://github.com/iamchristopher","followers_url":"https://api.github.com/users/iamchristopher/followers","following_url":"https://api.github.com/users/iamchristopher/following{/other_user}","gists_url":"https://api.github.com/users/iamchristopher/gists{/gist_id}","starred_url":"https://api.github.com/users/iamchristopher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iamchristopher/subscriptions","organizations_url":"https://api.github.com/users/iamchristopher/orgs","repos_url":"https://api.github.com/users/iamchristopher/repos","events_url":"https://api.github.com/users/iamchristopher/events{/privacy}","received_events_url":"https://api.github.com/users/iamchristopher/received_events","type":"User","site_admin":false},"created_at":"2018-07-31T23:57:44Z","updated_at":"2018-07-31T23:57:44Z","author_association":"CONTRIBUTOR","body":"Just to say that I'm using those RT transform methods (although that feature has been disabled in my game for a few weeks at this point) and I would much rather use GO transforms."}}
{"actor":{"display_login":"iamchristopher"}}