Simon.Anderson Posted August 3, 2015 Posted August 3, 2015 Hi All, I've started looking into creating a shader that allows the user to highlight a selected object in a scene (see attached). Has anyone found a nice solution to this? If you could point me in the right direction it would be much appreciated. Cheers, Simon
silent Posted August 3, 2015 Posted August 3, 2015 Hi Simon, I would recommend to check the data/samples/shaders/post_selection_00 sample. With a help of auxiliary buffer it is quite easy to achieve similar effect. Thanks! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN
a.koryakin Posted September 7, 2015 Posted September 7, 2015 Hi.This type of selection can generate 1 selection type(color).what can i do to make several objects selected different colors?
silent Posted September 8, 2015 Posted September 8, 2015 Hi Alexander, You will need to fill auxiliry buffer for two objects with different color. You can modify post_selection_00 sample to see the two objects selected: void update_scene() { int num = 0; while(1) { meshes[num].setMaterialState("auxiliary",0,0); meshes[num].setMaterialParameter("auxiliary_color",vec4_one,0); meshes[num+1].setMaterialState("auxiliary",0,0); meshes[num+1].setMaterialParameter("auxiliary_color",vec4_one,0); num = engine.game.getRandom(0,meshes.size()); if (num >= meshes.size()-1) num = meshes.size()-2; meshes[num].setMaterialState("auxiliary",1,0); meshes[num].setMaterialParameter("auxiliary_color",engine.game.getRandom(vec4(0.0f),vec4(1.0f,1.0f,1.0f,0.0f)),0); meshes[num+1].setMaterialState("auxiliary",1,0); meshes[num+1].setMaterialParameter("auxiliary_color",engine.game.getRandom(vec4(0.0f),vec4(1.0f,1.0f,1.0f,0.0f)),0); sleep(0.25f); } } Thanks! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN
a.koryakin Posted September 8, 2015 Posted September 8, 2015 Hi silent.Ok but when i do so and select several objects with differend colors color of selection changes where objects eclips each other. seems like they subtract.and i need selection of front object cover up selection of back object.Thanks
grayfox3000 Posted September 9, 2015 Posted September 9, 2015 Yes, we need several independent selection groups merged in one post-texture at the end. Not the intersection.
silent Posted September 9, 2015 Posted September 9, 2015 Hi, I'm afraid for multi-color selection a different approach will be required. You can write your custom shader to cover your needs. This new shader should perform some additional calculations (depth test, and so on) to generate a correct outline for multiple selected objects. Our devs currently have no solution for this task. Current shader example will work correctly only if single object is selected or the selection color will be the same. Probably, in the newer releases we will add another selection shader algorithm into the Editor, but not right now (maybe not in this year also), sorry. How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN
Recommended Posts