fenomas Posted February 2, 2015 Share Posted February 2, 2015 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? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted February 2, 2015 Share Posted February 2, 2015 Hello! By default StandardMaterial supports vertex color:) Just let Babylon.js knows that you want it: mesh.useVertexColors = true Quote Link to comment Share on other sites More sharing options...
fenomas Posted February 3, 2015 Author Share Posted February 3, 2015 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: Quote Link to comment Share on other sites More sharing options...
fenomas Posted February 3, 2015 Author Share Posted February 3, 2015 Better yet, a playground (document.onclick toggles the diffuse texture) http://www.babylonjs-playground.com/#2EUHZW Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted February 3, 2015 Share Posted February 3, 2015 Actually you're right but you can then use the ambient channel:http://www.babylonjs-playground.com/#2EUHZW#1 Quote Link to comment Share on other sites More sharing options...
fenomas Posted February 3, 2015 Author Share Posted February 3, 2015 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? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted February 3, 2015 Share Posted February 3, 2015 Sure thing, in this case just create your own shader:http://blogs.msdn.com/b/eternalcoding/archive/2014/04/17/learning-shaders-create-your-own-shaders-with-babylon-js.aspx 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.