Knight Posted June 14, 2017 Share Posted June 14, 2017 I want to draw a texture on the line that user draws on the screen. Like a mouse trail, so I follow this tutorial. . The only thing that doesn't answer me is sending the custom uv to the shaders. I vaguely remember that in C++, I can create struct or something and the shader will know how to handle it. It seems that is not the case here. I can't even figure out how does "index" property in vertex shader gets there. Even so, I can't use the "index" approach as the line won't be full rectangle as in the example. Right now, I copied & pasted the entire lines2d classes and try to customize to be able to draw texture on there, but I don't know how to send the custom uv that I've calculated to the shader. Anyone can explain that to me? Or am I looking at this a wrong way? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 14, 2017 Share Posted June 14, 2017 Do you mind sharing a PG to repro what you are doing? Perhaps have a look to this one as well: http://doc.babylonjs.com/overviews/gui Quote Link to comment Share on other sites More sharing options...
Knight Posted June 15, 2017 Author Share Posted June 15, 2017 14 hours ago, Deltakosh said: Do you mind sharing a PG to repro what you are doing? Perhaps have a look to this one as well: http://doc.babylonjs.com/overviews/gui http://playground.babylonjs.com/#9AHTEG I want to draw the texture on the line at the bottom left, and make it curve along with the line too. GUI is nice, and I may change to it in the future, but that still doesn't give me what I want. And from what I see, I won't have access to shaders that way too Aside from adding extra variable (_texture and _fillUV), I haven't changed any process from lines2d at all Wingnut 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted June 15, 2017 Share Posted June 15, 2017 Hi again. This is over my head, but... might need to hack the Lines2D shader code... https://github.com/BabylonJS/Extensions/tree/master/canvas2D/src/shaders Not sure how to add texture feature to the lines2d shader. But heck, let's ask @NasimiAsl if he has comments. He is a GPU GOD! Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted June 15, 2017 Share Posted June 15, 2017 varying vec4 vColor; void main(void) { gl_FragColor = vColor; } with this? i think that need have some customizable function for access to control shader after that i can help varying vec4 vColor; uniform sampler2D txt1; uniform vec2 screen; void main(void) { vec3 txt = texture2D(txt1, vec2(gl_FragCoord.x/screen.x ,gl_FragCoord.y / screen.y ).rgb; gl_FragColor = vColor*0.5 +0.5 * vec4(txt,1.); } Quote Link to comment Share on other sites More sharing options...
Knight Posted June 16, 2017 Author Share Posted June 16, 2017 8 hours ago, NasimiAsl said: varying vec4 vColor; void main(void) { gl_FragColor = vColor; } with this? i think that need have some customizable function for access to control shader after that i can help varying vec4 vColor; uniform sampler2D txt1; uniform vec2 screen; void main(void) { vec3 txt = texture2D(txt1, vec2(gl_FragCoord.x/screen.x ,gl_FragCoord.y / screen.y ).rgb; gl_FragColor = vColor*0.5 +0.5 * vec4(txt,1.); } I have not gone to fragment shader part yet, because I am now figuring out how to sent the uv to the vertex shader. In the PG, I use the lines2d shaders because I don't know how to upload my slightly edited version of it and use in PG. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.