- Home /
highlight a portion of a mesh in runtime
I am making a voxel-based game, that uses Marching Cubes to generate the chunks, and the terrain is editable at runtime, allows to place or destroy "blocks", and exist a pointer to show which cube will be edited, but this is not nice to preview what really will be modified, I want a highlight in the position which is to be edited.
image that represents what I want :
and a video of voxel farm engine thats represents the idea ( skip to 3:00 ) : Voxel Farm Engine: July 2013
what is the approach needed to achieve this?
(sorry for my too bad English,I from Brazil)
Capture the material.color to temp, change the material.color to add some red on the cube that's currently active, when the widget moves off the cube set original color back to temp and do it again on the new cube. Have you tried something like that?
change the material.color to add some red on the cube that's currently active getyour411 this not works, if I change the material.color, all the chunk will be painted into red, which chunk contains 10x10x10 cubes; and each cube I place, is modified not one single chunk, but in some times( at the corners) 8 chunks!; I need something which works similar a shadow, or lighting, but only in the limits of the pointer;Capture the material.color to temp,
Why would you change all the 'chunk' - when your pointer is on top of a cube, can't you access just that one cube's material.color?
the terrain is not made of single cubes with yours single meshs and each ones with yours material color to edit,is made of various chunks,containing 10x10x10 cubes!, see this image: your aproach not works!
Answer by erick_weil · Feb 15, 2014 at 07:44 PM
ok, I solved for myself this problem, I Imported the projectors assets, and created a custom material using the asset multiply shader and asigned this material ( red ) in a ortographic projector, with your dimensions ( near cliping plane, far cliping plane, ortographic size) resized to agree the cube scale, the projector is child of the pointer.
Works very fine and the result is the same I expect, like the images above in the question.