valepu Posted September 9, 2015 Share Posted September 9, 2015 Hello,I have started using Babylon.js yesterday and i was playing around a bit, i wanted to make a cube with different textures for each face (well, to be precise it will have a different texture for top and bottom, then the same texture for all the sides) but when i do that with some code i found on this forum ( http://www.html5gamedevs.com/topic/12392-having-different-textures-for-each-face-on-a-cube/ ), the textures are rotated into different directions for each couple of faces (top-bottom, front-back, left-right). You can see that here: http://www.babylonjs-playground.com/index.html#1QKKTU#2 the texture is supposed to have the yellow lines at the sides, the black thingie on the left and the blue dot in the bottom-right corner http://www.babylonjs-playground.com/textures/misc.jpg (used the one from materials playground sample).I have also noticed that when using the the "invertY" parameter on front and back this happens: - No parameters setFront flipped horizonatlly and vertically, back normal - Front: false Back: falseFront flipped horizontally, back flipped vertically - Front: true Back: falseFront flipped horizonatlly and vertically, back normal - Front: false Back: trueFront flipped horizonatlly, back flipped vertically - Front: true Back: trueFront flipped horizonatlly and vertically, back normal Now, did I do something wrong/didn't understand how it works (I admit i just copy/pasted the code for multimaterial texture) or is this the expected behavior? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 9, 2015 Share Posted September 9, 2015 Hello this is correct but if you want to completely control the way texture is applied you have to:- either change UV for every vertex- play with texture.uScale / vScale Quote Link to comment Share on other sites More sharing options...
valepu Posted September 9, 2015 Author Share Posted September 9, 2015 Hello this is correct but if you want to completely control the way texture is applied you have to:- either change UV for every vertex- play with texture.uScale / vScale I see, thanks Quote Link to comment Share on other sites More sharing options...
valepu Posted September 9, 2015 Author Share Posted September 9, 2015 While it wasn't hard to change uScale/vScale, i have found nothing about changing vertex UV (this is all new for me so i don't know if i'm looking for the wrong things on google), is it possible to have a sample/tutorial on how to do that? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 9, 2015 Share Posted September 9, 2015 Changing the UV is a little bit harder as you have to update the internal buffers.See here how to get access to internal data: https://github.com/BabylonJS/Babylon.js/blob/master/src/Mesh/babylon.mesh.ts#L2123 Quote Link to comment Share on other sites More sharing options...
valepu Posted September 9, 2015 Author Share Posted September 9, 2015 Well i guess it's time to study!thanks again! Quote Link to comment Share on other sites More sharing options...
valepu Posted September 10, 2015 Author Share Posted September 10, 2015 Other than changing UV for every vertex you can also use the wAng property to rotate a texture. This is an example where all the textures are shown to the camera in the same direction as if you were watching the 2d image from which the texture is generated (black thingie on the left, blue dot bottom right) : http://www.babylonjs-playground.com/index.html#1QKKTU#4 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.