pheinisch Posted July 29, 2016 Share Posted July 29, 2016 Hello everyone ! I'm having a bit of a misunderstanding with the TriPlanarMaterial of the material library. If I understand correctly, a face of a mesh looking exactly at the X axis sould be textured only with the texture assigned to the X axis, same with Y and Z, and a face with a (1, 1, 1) normal should have a blending of the three textures. Thus, a vertical face should not show any sign of the texture assigned to the Y axis. I'm having a practical issue as you can see in this playground : http://www.babylonjs-playground.com/#E6OZX#38 Here, the vertical faces of the ground mesh are textured both with the grass and the floor texture, just as if they were oriented 45°. But the side of the box is almost not textured with grass, whereas it is more facing the Y axis. What could be the origin of this issue ? Thanks in advance ! Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted July 29, 2016 Share Posted July 29, 2016 Summoning @luaacro Quote Link to comment Share on other sites More sharing options...
julien-moreau Posted August 10, 2016 Share Posted August 10, 2016 Hi pheinisch According to the material's code (vertex shader), the textures coordinates are not related to the normal of the vertices, but related to the final world position of the current vertex. The advantage of this material is that meshes don't need normals and/or uvs buffers, only positions vec4 worldPos = finalWorld * vec4(position, 1.0); #ifdef DIFFUSEX vTextureUVX = worldPos.zy / tileSize; #endif #ifdef DIFFUSEY vTextureUVY = worldPos.xz / tileSize; #endif #ifdef DIFFUSEZ vTextureUVZ = worldPos.xy / tileSize; #endif There is a very good tutorial which explains everything (better than me) here : http://www.martinpalko.com/triplanar-mapping/ Adding a new material which works with normals might be a good idea btw Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted August 11, 2016 Share Posted August 11, 2016 this could be edited to do textures, I just kept it simple and did colors for now... it needs to be finished up but once i I am done you will have 4 zones: Sand Grass Grass2 Snow or Rock With 3 angle zones in each so flat areas will have a texture then the transition from flat to vertical and beyond will have both have a texture. So you will need 12 seamless textures to reference, and then I may take it a step farther and let you put more then one in per each Range/Zone. Im thinking this is more what your looking for. Quote Link to comment Share on other sites More sharing options...
pheinisch Posted August 11, 2016 Author Share Posted August 11, 2016 Thanks to both of you for your anwsers ! 8 hours ago, Pryme8 said: Im thinking this is more what your looking for. This is indeed working with colors, but with textures you would still need to solve UV mapping issues right ? 13 hours ago, Luaacro said: According to the material's code (vertex shader), the textures coordinates are not related to the normal of the vertices, but related to the final world position of the current vertex. The advantage of this material is that meshes don't need normals and/or uvs buffers, only positions I understand that the texture coordinates are based on vertex position, but I don't see what's the difference between the ground and the box in this playground : http://www.babylonjs-playground.com/#E6OZX#49 Why is it that the box is correctly textured, but the ground have this grass texture artefact on its vertical faces ? Another thing, if you don't set normalTextures, everything fades to black : http://www.babylonjs-playground.com/#E6OZX#51, any idea why ? 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.