-
I want to make a rain effect but having trouble with rotating the image in shader... i think i'm close but just don't see it for the most part. his my codepen https://codepen.io/L2L2L/pen/vYdExmM?editors=1010 and on the webgl website they have a rotation example. https://webglfundamentals.org/webgl/lessons/webgl-2d-rotation.html i tried to incorporate that into the shader but having trouble figuring out how. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 4 replies
-
First off, it looks like you copied the first example instead of the last example (with the most features) including rotation of the texture. https://webglfundamentals.org/webgl/webgl-2d-drawimage-06.html And 2nd off, the next article adds rotation of the quads. |
Beta Was this translation helpful? Give feedback.
-
Your change isn't setting the correct size for the textures. It's setting a 1x1 texture, then loading cross origin images. It's not setting the Further, it's choosing a random non-square size for each quad https://codepen.io/greggman/pen/jOZEJgE?editors=1010 BTW: If you go to the article page and click "Export" on a live sample it will export a version on codepen that runs with the images. |
Beta Was this translation helpful? Give feedback.
-
The code is rotating the texture [inside the destination quad]. If you want to rotate the quad the texture is drawn too use the code from the following article |
Beta Was this translation helpful? Give feedback.
-
You're basically asking for a Canvas 2D tutorial since that example is emulating the canvas 2D API. The examples on the page show rotation https://webglfundamentals.org/webgl/webgl-2d-matrixstack-02.html https://codepen.io/greggman/pen/QWQweev?editors=101 https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Transformations https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/rotate |
Beta Was this translation helpful? Give feedback.
You're basically asking for a Canvas 2D tutorial since that example is emulating the canvas 2D API. The examples on the page show rotation
https://webglfundamentals.org/webgl/webgl-2d-matrixstack-02.html
https://codepen.io/greggman/pen/QWQweev?editors=101
https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Transformations
https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/rotate