How use stencil for every mesh in compositor?

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
User avatar
iloseall
Gremlin
Posts: 156
Joined: Sun Sep 14, 2003 3:54 am
Location: Beijing China
Contact:

How use stencil for every mesh in compositor?

Post by iloseall »

:D
two question:

Question 1: ****????*****
I don't know how to set stencil for every object
for try to make optimize ,I want do this:
draw the light mesh back,check stencil==1, and increment stencil;
draw the light mesh front,check stencil==2, and decrement stencil,calc light color;
Can I set the stencil in the material script for every pass?

ref : http://ati.amd.com/developer/gdc/D3DTut ... hading.pdf page 22: Stencil Light Volumes

Question 2:
target_output's depth_stencil buffer is diffrence from (rt_gbuffer rt_lbuffer)'s depth_stencil buffer
How can I Do?

Code: Select all

compositor DL
{
  technique mrt
  {
		texture rt_gbuffer target_width target_height  PF_FLOAT16_GR PF_R8G8B8A8 PF_R8G8B8A8 PF_R8G8B8A8
		
		//texture rt_gbuffer target_width target_height  PF_FLOAT16_RGBA PF_FLOAT16_RGBA PF_FLOAT16_RGBA PF_FLOAT16_RGBA
		
		texture rt_lbuffer target_width target_height PF_R8G8B8A8
		
		target rt_gbuffer 
		{
			//input previous
			input none
			
			material_scheme gbuffer
			
			pass clear
			{
				buffers colour depth stencil
				colour_value 0 0 0 0
				depth_value 1.0
				stencil_value 0
			}
			
			//render scene mesh to fat buffer,and set stencil =1.
			pass stencil
			{
				check on
				ref_value 1
				pass_op replace
			}
			
			pass render_scene
			{
				first_render_queue 10
				last_render_queue 80
			}

		}
		
		target rt_lbuffer
		{
			input none

			pass clear
			{
				buffers colour
				colour_value 0 0 0 0
			}

			//check stencil ,so we need calc GlobalLight for sky box 
			pass stencil
			{
				check on
				ref_value 1
				comp_func less_equal 
				pass_op keep				
			}
			
			pass render_quad
			{
			
				material  DL/GlobalLight_PS_0
				identifier 1011
				
				//material  DL/AmbientDirectionLight
				//identifier 1011
				
				//material DL/Depth
				//identifier 1012
				
				input 0 rt_gbuffer 0
				input 1 rt_gbuffer 1
				input 2 rt_gbuffer 2
				input 3 rt_gbuffer 3
			}
		}
		
		target rt_lbuffer
		{
			input none

		//Question 1: ****????*****
		//pass for render light mesh,just like Sphere,Cone .
		//I don't know how to set stencil for every object 
		//for try to make optimize ,I want do this:
		//		draw the light mesh back,check stencil==1, and increment  stencil;
		//		draw the light mesh front,check stencil==2, and decrement  stencil,calc light color;
		//Can I set the stencil in the material script for every pass?
		
		//ref : http://ati.amd.com/developer/gdc/D3DTutorial_DeferredShading.pdf	page 22: Stencil Light Volumes
			pass render_scene
			{
				first_render_queue 90
				last_render_queue 95
			}
		}
		
		//Question 2: ****????*****
		//target_output's depth_stencil buffer is diffrence from (rt_gbuffer rt_lbuffer)'s depth_stencil buffer
		//why?
		target_output
		{
			input none

			//because question 2, we should set the stencil check off
			pass stencil
			{
				check off
			}
			
			pass render_quad
			{
				material DL/Final
				
				input 0 rt_gbuffer 0
				input 1 rt_gbuffer 1
				input 2 rt_gbuffer 2
				input 3 rt_gbuffer 3
				input 4 rt_lbuffer 0
			}
		}
	}	
}
Post Reply