Jump to content

Object Outline Shader


photo

Recommended Posts

Posted

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

post-1501-0-59126600-1438590207_thumb.png

Posted

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:

  • 1 month later...
Posted

Hi.

This type of selection can generate 1 selection type(color).
what can i do to make several objects selected different colors?

Posted

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:

Posted

Hi silent.

Ok but when i do so and select several objects with differend colors 
color of selection changes where objects eclips each other. 

post-1525-0-56173300-1441699878_thumb.png

seems like they subtract.
and i need selection of front object cover up selection of back object.

Thanks

Posted

Yes, we need several independent selection groups merged in one post-texture at the end. Not the intersection.

Posted

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:

×
×
  • Create New...