private void InitShadowStencilPass() { Material matStencil = MaterialManager.Instance.GetByName(STENCIL_SHADOW_VOLUMES_MATERIAL); if(matStencil == null) { // Create matStencil = (Material)MaterialManager.Instance.Create(STENCIL_SHADOW_VOLUMES_MATERIAL); shadowStencilPass = matStencil.GetTechnique(0).GetPass(0); if(targetRenderSystem.Caps.CheckCap(Capabilities.VertexPrograms)) { // Enable the finite point light extruder for now, just to get some params shadowStencilPass.SetVertexProgram( ShadowVolumeExtrudeProgram.GetProgramName(ShadowVolumeExtrudeProgram.Programs.PointLightFinite)); finiteExtrusionParams = shadowStencilPass.VertexProgramParameters; finiteExtrusionParams.SetAutoConstant(0, AutoConstants.WorldViewProjMatrix); finiteExtrusionParams.SetAutoConstant(4, AutoConstants.LightPositionObjectSpace); finiteExtrusionParams.SetAutoConstant(5, AutoConstants.ShadowExtrusionDistance); } matStencil.Compile(); // Nothing else, we don't use this like a 'real' pass anyway, // it's more of a placeholder } else { shadowStencilPass = matStencil.GetTechnique(0).GetPass(0); } }
private void InitShadowDebugPass() { Material matDebug = MaterialManager.Instance.GetByName(SHADOW_VOLUMES_MATERIAL); if(matDebug == null) { // Create matDebug = (Material)MaterialManager.Instance.Create(SHADOW_VOLUMES_MATERIAL); shadowDebugPass = matDebug.GetTechnique(0).GetPass(0); shadowDebugPass.SetSceneBlending(SceneBlendType.Add); shadowDebugPass.LightingEnabled = false; shadowDebugPass.DepthWrite = false; TextureUnitState t = shadowDebugPass.CreateTextureUnitState(); t.SetColorOperationEx( LayerBlendOperationEx.Modulate, LayerBlendSource.Manual, LayerBlendSource.Current, new ColorEx(0.7f, 0.0f, 0.2f)); shadowDebugPass.CullMode = CullingMode.None; if(targetRenderSystem.Caps.CheckCap(Capabilities.VertexPrograms)) { ShadowVolumeExtrudeProgram.Initialize(); // Enable the (infinite) point light extruder for now, just to get some params shadowDebugPass.SetVertexProgram( ShadowVolumeExtrudeProgram.GetProgramName(ShadowVolumeExtrudeProgram.Programs.PointLight)); infiniteExtrusionParams = shadowDebugPass.VertexProgramParameters; infiniteExtrusionParams.SetAutoConstant(0, AutoConstants.WorldViewProjMatrix); infiniteExtrusionParams.SetAutoConstant(4, AutoConstants.LightPositionObjectSpace); } matDebug.Compile(); } else { shadowDebugPass = matDebug.GetTechnique(0).GetPass(0); } }