Sign in to follow this  

vColor over textures

Recommended Posts

Hi - I just ran across BJS today but it's great fun so far!


My question is, how can I get vertex colors to show up even when a material has a (diffuse) texture?


After poking around I'm guessing this could be done with a custom shader, by multiplying by 'vColor' after the texture is sampled. I couldn't get this to work in CYOS though - I tried added color data to the scene's mesh but 'vColor' didn't get passed into the shader.


Is this the right way to go about this, or is there an easy way built into the engine?


Share this post

Link to post
Share on other sites

By default StandardMaterial supports vertex color:)

Just let Babylon.js knows that you want it: mesh.useVertexColors = true


Thanks, but is this intended to work even when there's a diffuse texture?


I'm testing in the "Material Editor" demo, after applying vertex colors and verifying that 'useVertexColors' is true, and can't get the vertex colors to show up if there's a diffuse texture enabled. (They show up with emissive or ambient textures, just not diffuse.)


Edit: graphics to show what I mean:



Share this post

Link to post
Share on other sites

Actually you're right but you can then use the ambient channel


Yes, as I mentioned I noticed that, and I will try it out. (The motivation here is to simulate AO by baking occlusion into the vertex colors.)


Just to finish with my question though, would it also be possible to get vertex colors over the diffuse texture by using a custom shader that multiplied the texture by vColor?

Share this post

Link to post
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.

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.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.