render_stencil

StencilMap

Ziel des Stencil-Buffers für einen View. Ist diesem Pointer eine Bitmap zugewiesen, wird der Inhalt des Stencil-Buffers nach dem Rendern in diese Bitmap kopiert und nicht über den Bildschirm gezeichnet. Auf diese Weise lassen sich solche Postprocessing-Effekte wie verschwommene Stencil-Schatten auf den Stencil-Buffer anwenden. Die Stencil-Zieltextur steht Shadern durch die Variable StencilMap zur verfügung.

Typ:

BMAP* (lite-c)
texture (shader code)

Bemerkungen:

Edition:

 C   LC 

Beispiele:

function main()
{
  ...
  shadow_stencil = 4; // activate z-fail accelerated stencil shadows
  effect_load(mtl_shadow,"st_stencilblur.fx"); // autogenerate render_stencil by assigning a stencil shader  
...
// st_stencilblur.fx - Poisson blur shader

texture StencilMap; // stencil buffer image in the alpha channel
sampler smpStencil = sampler_state { texture = <StencilMap> }; 
float4 vecViewPort; // contains viewport pixel size in zw components

static const float fDist = 4.0;   // blur factor
static const float fStrength = 0.15;  // shadow darkness

static const float2 fTaps_Poisson[12] = {
	{-.326,-.406},{-.840,-.074},{-.696, .457},{-.203, .621},
	{ .962,-.195},{ .473,-.480},{ .519, .767},{ .185,-.893},
	{ .507, .064},{ .896, .412},{-.322,-.933},{-.792,-.598}
};

float4 blurPoissonPS( float2 Tex : TEXCOORD0) : COLOR0 
{
   float4 Stencil = 0;
   for (int i=0; i < NUM_TAPS; i++)
     Stencil += tex2D(smpStencil,Tex.xy + fTaps_Poisson[i]*fDist*vecViewPort.zw);
   return Stencil * fStrength;
}

technique stencilblur { 
  pass one { 
     PixelShader = compile ps_2_0 blurPoissonPS(); 
  }
} 

Siehe auch:

VIEW, BMAP, view.bmap, view.stage, view.material, render_target, render_zbuffer, PROCESS_SCREEN, shadow_stencil

► Aktuelle Version Online