Jump to content

Texture Mapping when using CreateBox


jacquesr
 Share

Recommended Posts

Hi guys,

I am trying to get a dynamic text texture on my mesh. The texture including dynamic sizing works pretty well, yet each face draws the texture in a different direction. Regarding front,left,right and back sides, I don't really understand why.

I don't want to use submeshes/submaterials for performance reasons (i am going to have a lot of meshes in my scene probably) if I can avoid it. Also, I read that updatable meshes are more expensive, too, so if I can, updating the UVMaps afterwards is also something I would like to avoid.

Any ideas?

http://www.babylonjs-playground.com/#YDO1F#0

 

Link to comment
Share on other sites

hi you can do it with shader :)

because the box is special mesh and have special normal

you can set 6 textures

and use a simple condition like this

if(normal.x > 0) {  gl_FragColor =  texture2D(txt1 ,uv ); }

if(normal.x < 0) {  gl_FragColor =  texture2D(txt2 ,uv ); }

if(normal.z > 0) {  gl_FragColor =  texture2D(txt3 ,uv ); }

if(normal.z < 0) {  gl_FragColor =  texture2D(txt4 ,uv ); }

if(normal.y > 0) {  gl_FragColor =  texture2D(txt5 ,uv ); }

if(normal.y < 0) {  gl_FragColor =  texture2D(txt6 ,uv ); }

 

and it possible with one texture too but have some more  code 

 

 

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...