Jump to content

Using UV Map on New Material


DopeBiscuit
 Share

Recommended Posts

Hello guys, I was wondering if there is a way to keep using a mesh's UV map after changing it's material.

My game currently uses a cell shader, so I have been giving meshes ShaderMaterials and then calling ShaderMaterial.setTexture() to give it the same texture as before.

This successfully applies the cell shader and texture, but the UV map is lost in the process so the texture no longer lines up.

I've looked through the mesh, material, submaterials, and texture's attributes and all i can find are u/v offset, scale, and Ang (which are 0, 1, 0 respectively), but in the .babylon file for the model I see an attribute caled "uvs" which I'm assuming is what I need to copy. Thanks in advance!

Link to comment
Share on other sites

Ok so the only difference I can find between the old diffuseTexture and newMaterial._textures.textureSampler is invertY

changing invertY doesn't fix the problem though. Considering it's named _invertY I'm assuming I can't change it?

 

I call newMaterial.setTexture(...).setVector3().setFloats() etc but I don't see a setBool function for invertY.

 

Link to comment
Share on other sites

Ah, I see. I should have checked the parameters i was giving to the new texture, i was calling

newMaterial.setTexture("textureSampler", new BABYLON.Texture(diffuseUrl, scene, false, false, 2))

when it should have been 

newMaterial.setTexture("textureSampler", new BABYLON.Texture(diffuseUrl, scene, false, invertY, 2))

Sigh, I feel dumb lol. Thanks for the help Deltakosh!

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...