hit2501 Posted July 1, 2018 Share Posted July 1, 2018 I can apply a texture to a complete exported model (lets say a dodecahedron) from Blender and change its size with vScale and uScale. But now I'm trying change the size of only 1 face of the dodecahedron, is there a way or sample to achieve this? It would be necessary to apply the texture for each mesh by separated? Thank you all. Quote Link to comment Share on other sites More sharing options...
Wingnut Posted July 1, 2018 Share Posted July 1, 2018 Hi hit, good to see you again. I can TRY to answer this... probably wrong... but I will tell some things. Let's playground-up and do some thinkin'. https://www.babylonjs-playground.com/#2GXQ13#11 Ok, that's all the further I'M going. The rest... scares me. FaceUV's. Phew. http://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors#polyhedra http://doc.babylonjs.com/playground/?code=CreatePolyhedron Flat. Flat is important... which is one parameter of the possible options of a CreatePolyhedron() call, I think. Look at console. After convert-to-flat, our dodec has many more verts. I THINK... a flat-shaded mesh has THREE available UV's at EACH corner/vert-position. This is because their are actually 3 verts at each corner-point, on a flat-shaded mesh. And that... is what YOU need, I believe. You want to affect the texture on ONE face of the dodec, but not affect other faces. Without flat-shaded... adjusting the UV at ONE vert-point... would affect the texture of all faces that intersected at that vert-point. You just want to affect one face, so you need a "private uv", right? heh. No affecting the neighbors. Understand the difference between faceUVs adjusting scale/size of a face texture AT CREATION TIME, versus adjusting it later, "live". I think one way is easy, the other way, not so easy. Let's ping @jerome, just because I know he LOVES being pinged. That guy drives faceUV's amazingly well. He sort-of invented them for BJS, I think. JackFalcon 1 Quote Link to comment Share on other sites More sharing options...
dbawel Posted July 1, 2018 Share Posted July 1, 2018 @hit2501 This is not necessarily simple in your code. If it were me, I would unwrap your texture, and modify the texture and or most likely the UV mapping in your application. Then export, which is far faster and far less calculations - if doable at all for your needs. DB Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted July 2, 2018 Share Posted July 2, 2018 hi @hit2501 i have one solution https://www.babylonjs-playground.com/#UXCB15#45 step 1 make png and select your selected face on this and cut it make custom shader and read texture 2 ways diffuseColor = texture2D(mainTexture,vDiffuseUV).rgb; // main texture float specialFart = texture2D(colorpatern,vDiffuseUV).a; // special face condition vec3 def2 = texture2D(mainTexture,vDiffuseUV*20.).rgb; // read new texture by scale 20 and in final mix them diffuseColor = diffuseColor*(specialFart)+def2*(1.-specialFart) ; dbawel 1 Quote Link to comment Share on other sites More sharing options...
hit2501 Posted July 2, 2018 Author Share Posted July 2, 2018 Thank you Nasimi I'll try it. NasimiAsl 1 Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted July 2, 2018 Share Posted July 2, 2018 ** just notice CustomMaterial Have special bug when you wanna update lights or something we can't fix it yet Quote Link to comment Share on other sites More sharing options...
Wingnut Posted July 2, 2018 Share Posted July 2, 2018 13 hours ago, dbawel said: This is not necessarily simple in your code. If it were me, I would unwrap your texture, and modify the texture and or most likely the UV mapping in your application. Then export, which is far faster and far less calculations - if doable at all for your needs. Hi guys. This, and some of the other ideas... are "done at creation time" ideas. Hit2501... you haven't yet told us if/not you need to resize a face texture... AFTER creation/first-render (later, during game-play). If you DO need to resize a face's texture... later... after creation, that requires a different kind of solution, I think. *shrug* 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.