Pryme8 Posted March 5, 2018 Share Posted March 5, 2018 http://www.babylonjs-playground.com/#YSZ7YV#29 I feel like I am doing this wrong... getVertexColor = function(pick){ var indices = pick.pickedMesh.getIndices(); var vdc = pick.pickedMesh.getVertexBuffer(BABYLON.VertexBuffer.ColorKind); //console.log(vdc, indices); var p1,p2,p3; p1 = indices[(pick.faceId*3)]; //p2 = indices[(pick.faceId*3)+1]; //p3 = indices[(pick.faceId*3)+2]; var pc = new BABYLON.Vector3(vdc._buffer._data[p1],vdc._buffer._data[p1+1],vdc._buffer._data[p1+2]); shader.setVector3("selectedChannel", pc); }; I want to get the Color Vertex Data at point of click. Quote Link to comment Share on other sites More sharing options...
RaananW Posted March 6, 2018 Share Posted March 6, 2018 I am not sure what should be the result, but one thing for sure - p1 will not be enough. you will need p2 and p3. also, highly recommended not to use native js events in the playground (you have canvas.addEventListener). those functions will not be unregistered if you press run again, and will actually run N times (N being the number of times you pressed run + 1). you can use scene.onPointerMove instead. Pryme8 1 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted March 6, 2018 Author Share Posted March 6, 2018 Hmm so I need to average the color information of the three points then to get the face color then? That might make it so when a face is on the border to anouther color, that I get a different response then what anticipated because it will blend those points. http://www.babylonjs-playground.com/#YSZ7YV#33 >_< yeah this is not working. Quote Link to comment Share on other sites More sharing options...
babbleon Posted March 7, 2018 Share Posted March 7, 2018 This seems to work - logs R, G & B to console: http://www.babylonjs-playground.com/#YSZ7YV#35 p1A = indices[pick.faceId*3]*4; Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted March 7, 2018 Author Share Posted March 7, 2018 http://www.babylonjs-playground.com/#YSZ7YV#36 Nice ^+^ forward progress! Quote Link to comment Share on other sites More sharing options...
babbleon Posted March 7, 2018 Share Posted March 7, 2018 You see that though on the door panels, b = 0.8, but when you hover over them... anything with +ve B colour highlights which isn't correct. I ran out of time earlier to look into this. Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted March 7, 2018 Author Share Posted March 7, 2018 that sounds like the model buffer data, we could just round for now to fix it. http://www.babylonjs-playground.com/#YSZ7YV#37 I just adjusted the shader to use > on the selected channel instead of == Quote Link to comment Share on other sites More sharing options...
babbleon Posted March 7, 2018 Share Posted March 7, 2018 This is what I intended: http://www.babylonjs-playground.com/#YSZ7YV#39 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted March 7, 2018 Author Share Posted March 7, 2018 What did you change there? I'm not sure how that is even working... cause that seems like more then 3 channels. http://www.babylonjs-playground.com/#YSZ7YV#40 Quote Link to comment Share on other sites More sharing options...
babbleon Posted March 7, 2018 Share Posted March 7, 2018 We have three basic channels; Red: r=1, g=0, b=0 Green: r=0, g=1, b=0 Blue: r=0, g=0, b=1 Some faces though have less intense, R, G or B as these are intended to be areas that can have their texture altered. Looking through the PG, I'm not sure though how this could be accomplished. My intention originally was that each of the separately selectable vertices could be 'detached' from the mesh to make a new one... but I suspect this may be tons of work which I want to avoid. I am thinking with my Blender head on. Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted March 7, 2018 Author Share Posted March 7, 2018 It would be possible but would add tons more script. This is working off the assumption that there will ever only be 3 channels, you are effectively making it an infinite amount by doing that. 17 minutes ago, babbleon said: I am thinking with my Blender head on. Ideally you would just split the mesh up before exporting it, and then this shader would be way way simpler. I know you said that would mess with your workflow, but honestly should make thing easier for you. Just select the faces on the model you want to be a separate modifiable section split it out and then add all the parts to a null object/parent. That would honestly be faster then assigning vertex colors and would be way way more robust. Then when we import the model, we assign new instances of the shader to each of the submeshs/regions. It will make your and my life way easier and should accomplish what you really want. Quote Link to comment Share on other sites More sharing options...
babbleon Posted March 7, 2018 Share Posted March 7, 2018 yup, agreed! Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted March 7, 2018 Author Share Posted March 7, 2018 Do me a favor and split up that model into what like 5 submeshs group them under a null and export that. Let me know what the link is for it and Ill go from there. Quote Link to comment Share on other sites More sharing options...
babbleon Posted March 8, 2018 Share Posted March 8, 2018 Hi @Pryme8 - here you go: https://raw.githubusercontent.com/babbleon/babylon/master/RGB-Mapping7.babylon Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted March 8, 2018 Author Share Posted March 8, 2018 Thank you sir! Just saw this. I will give this a go here and get back to you. 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.