public static int ConvertEnum( SceneBlendFactor blend ) { switch ( blend ) { case SceneBlendFactor.One: return Gl.GL_ONE; case SceneBlendFactor.Zero: return Gl.GL_ZERO; case SceneBlendFactor.DestColor: return Gl.GL_DST_COLOR; case SceneBlendFactor.SourceColor: return Gl.GL_SRC_COLOR; case SceneBlendFactor.OneMinusDestColor: return Gl.GL_ONE_MINUS_DST_COLOR; case SceneBlendFactor.OneMinusSourceColor: return Gl.GL_ONE_MINUS_SRC_COLOR; case SceneBlendFactor.DestAlpha: return Gl.GL_DST_ALPHA; case SceneBlendFactor.SourceAlpha: return Gl.GL_SRC_ALPHA; case SceneBlendFactor.OneMinusDestAlpha: return Gl.GL_ONE_MINUS_DST_ALPHA; case SceneBlendFactor.OneMinusSourceAlpha: return Gl.GL_ONE_MINUS_SRC_ALPHA; } ; // to keep compiler happy return Gl.GL_ONE; }
public void SetSeparateSceneBlending( SceneBlendFactor sourceFactor, SceneBlendFactor destFactor, SceneBlendFactor sourceFactorAlpha, SceneBlendFactor destFactorAlpha ) { for ( var i = 0; i < this._passes.Count; i++ ) { this._passes[ i ].SetSeparateSceneBlending( sourceFactor, destFactor, sourceFactorAlpha, destFactorAlpha ); } }
/* public static XFG.TextureArgument Convert( LayerBlendSource blendSource ) { XFG.TextureArgument d3dTexArg = 0; switch ( blendSource ) { case LayerBlendSource.Current: d3dTexArg = XFG.TextureArgument.Current; break; case LayerBlendSource.Texture: d3dTexArg = XFG.TextureArgument.TextureColor; break; case LayerBlendSource.Diffuse: d3dTexArg = XFG.TextureArgument.Diffuse; break; case LayerBlendSource.Specular: d3dTexArg = XFG.TextureArgument.Specular; break; case LayerBlendSource.Manual: d3dTexArg = XFG.TextureArgument.TFactor; break; } // end switch return d3dTexArg; }*/ /// <summary> /// Helper method to convert Axiom scene blend factors to Xna /// </summary> /// <param name="factor"></param> /// <returns></returns> public static XFG.Blend Convert( SceneBlendFactor factor ) { XFG.Blend xnaBlend = 0; switch ( factor ) { case SceneBlendFactor.One: xnaBlend = XFG.Blend.One; break; case SceneBlendFactor.Zero: xnaBlend = XFG.Blend.Zero; break; case SceneBlendFactor.DestColor: xnaBlend = XFG.Blend.DestinationColor; break; case SceneBlendFactor.SourceColor: xnaBlend = XFG.Blend.SourceColor; break; case SceneBlendFactor.OneMinusDestColor: xnaBlend = XFG.Blend.InverseDestinationColor; break; case SceneBlendFactor.OneMinusSourceColor: xnaBlend = XFG.Blend.InverseSourceColor; break; case SceneBlendFactor.DestAlpha: xnaBlend = XFG.Blend.DestinationAlpha; break; case SceneBlendFactor.SourceAlpha: xnaBlend = XFG.Blend.SourceAlpha; break; case SceneBlendFactor.OneMinusDestAlpha: xnaBlend = XFG.Blend.InverseDestinationAlpha; break; case SceneBlendFactor.OneMinusSourceAlpha: xnaBlend = XFG.Blend.InverseSourceAlpha; break; } return xnaBlend; }
/// <summary> /// Helper method to convert Axiom scene blend factors to D3D /// </summary> /// <param name="factor"></param> /// <returns></returns> public static D3D.Blend ConvertEnum( SceneBlendFactor factor ) { D3D.Blend d3dBlend = 0; switch ( factor ) { case SceneBlendFactor.One: d3dBlend = D3D.Blend.One; break; case SceneBlendFactor.Zero: d3dBlend = D3D.Blend.Zero; break; case SceneBlendFactor.DestColor: d3dBlend = D3D.Blend.DestinationColor; break; case SceneBlendFactor.SourceColor: d3dBlend = D3D.Blend.SourceColor; break; case SceneBlendFactor.OneMinusDestColor: d3dBlend = D3D.Blend.InverseDestinationColor; break; case SceneBlendFactor.OneMinusSourceColor: d3dBlend = D3D.Blend.InverseSourceColor; break; case SceneBlendFactor.DestAlpha: d3dBlend = D3D.Blend.DestinationAlpha; break; case SceneBlendFactor.SourceAlpha: d3dBlend = D3D.Blend.SourceAlpha; break; case SceneBlendFactor.OneMinusDestAlpha: d3dBlend = D3D.Blend.InverseDestinationAlpha; break; case SceneBlendFactor.OneMinusSourceAlpha: d3dBlend = D3D.Blend.InverseSourceAlpha; break; } return d3dBlend; }
/// <summary> /// Allows very fine control of blending this Pass with the existing contents of the scene. /// </summary> /// <remarks> /// Wheras the texture blending operations seen in the TextureUnitState class are concerned with /// blending between texture layers, this blending is about combining the output of the material /// as a whole with the existing contents of the rendering target. This blending therefore allows /// object transparency and other special effects. /// <p/> /// This version of the method allows complete control over the blending operation, by specifying the /// source and destination blending factors. The result of the blending operation is: /// <span align="center"> /// final = (texture * sourceFactor) + (pixel * destFactor) /// </span> /// <p/> /// Each of the factors is specified as one of a number of options, as specified in the SceneBlendFactor /// enumerated type. /// <p/> /// This method is applicable for both the fixed-function and programmable pipelines. /// </remarks> /// <param name="src">The source factor in the above calculation, i.e. multiplied by the texture color components.</param> /// <param name="dest">The destination factor in the above calculation, i.e. multiplied by the pixel color components.</param> public void SetSceneBlending(SceneBlendFactor src, SceneBlendFactor dest) { // copy settings sourceBlendFactor = src; destBlendFactor = dest; }
public override void SetSceneBlending( SceneBlendFactor src, SceneBlendFactor dest, SceneBlendOperation op) { int srcFactor = GLHelper.ConvertEnum( src ); int destFactor = GLHelper.ConvertEnum( dest ); if ( src == SceneBlendFactor.One && dest == SceneBlendFactor.Zero ) { Gl.glDisable( Gl.GL_BLEND ); } else { // enable blending and set the blend function Gl.glEnable( Gl.GL_BLEND ); Gl.glBlendFunc( srcFactor, destFactor ); } var func = Gl.GL_FUNC_ADD; switch (op) { case SceneBlendOperation.Add: func = Gl.GL_FUNC_ADD; break; case SceneBlendOperation.Subtract: func = Gl.GL_FUNC_SUBTRACT; break; case SceneBlendOperation.ReverseSubtract: func = Gl.GL_FUNC_REVERSE_SUBTRACT; break; case SceneBlendOperation.Min: func = Gl.GL_MIN; break; case SceneBlendOperation.Max: func = Gl.GL_MAX; break; } if (GLEW_VERSION_1_4 || GLEW_ARB_imaging) { Gl.glBlendEquation(func); } else if (GLEW_EXT_blend_minmax && (func == Gl.GL_MIN || func == Gl.GL_MAX)) { Gl.glBlendEquationEXT(func); } }
/// <summary> /// Default constructor. /// </summary> /// <param name="parent">Technique that owns this Pass.</param> /// <param name="index">Index of this pass.</param> public Pass( Technique parent, int index ) { this._parent = parent; this._index = index; lock ( passLock ) { this.passId = nextPassId++; } // color defaults _ambient = ColorEx.White; _diffuse = ColorEx.White; _specular = ColorEx.Black; _emissive = ColorEx.Black; // by default, don't override the scene's fog settings _fogOverride = false; _fogMode = FogMode.None; _fogColor = ColorEx.White; _fogStart = 0; _fogEnd = 1; _fogDensity = 0.001f; // default blending (overwrite) _sourceBlendFactor = SceneBlendFactor.One; _destinationBlendFactor = SceneBlendFactor.Zero; // depth buffer settings _depthCheck = true; _depthWrite = true; _colorWriteEnabled = true; _depthFunction = CompareFunction.LessEqual; // cull settings _cullingMode = CullingMode.Clockwise; _manualCullingMode = ManualCullingMode.Back; // light settings _lightingEnabled = true; _runOnlyForOneLightType = true; _onlyLightType = LightType.Point; _shadingMode = Shading.Gouraud; // Default max lights to the global max _maxSimultaneousLights = Config.MaxSimultaneousLights; _name = index.ToString(); IterationCount = 1; DirtyHash(); }
public override void SetSceneBlending( SceneBlendFactor src, SceneBlendFactor dest, SceneBlendOperation op ) { var sourceBlend = this.GetBlendMode( src ); var destBlend = this.GetBlendMode( dest ); if ( src == SceneBlendFactor.One && dest == SceneBlendFactor.Zero ) { GL.Disable( All.Blend ); GLES2Config.GlCheckError( this ); } else { GL.Enable( All.Blend ); GLES2Config.GlCheckError( this ); GL.BlendFunc( sourceBlend, destBlend ); GLES2Config.GlCheckError( this ); } var func = All.FuncAdd; switch ( op ) { case SceneBlendOperation.Add: func = All.FuncAdd; break; case SceneBlendOperation.Subtract: func = All.FuncSubtract; break; case SceneBlendOperation.ReverseSubtract: func = All.FuncReverseSubtract; break; case SceneBlendOperation.Min: //#if GL_EXT_blend_minmax //func = Alll.MinExt; //#endif break; case SceneBlendOperation.Max: //#if GL_EXT_blend_minmax //func = Alll.MaxExt; //#endif break; } GL.BlendEquation( func ); GLES2Config.GlCheckError( this ); }
public static D3D9.Blend ConvertEnum( SceneBlendFactor factor ) { switch ( factor ) { case SceneBlendFactor.One: return D3D9.Blend.One; case SceneBlendFactor.Zero: return D3D9.Blend.Zero; case SceneBlendFactor.DestColor: return D3D9.Blend.DestinationColor; case SceneBlendFactor.SourceColor: return D3D9.Blend.SourceColor; case SceneBlendFactor.OneMinusDestColor: return D3D9.Blend.InverseDestinationColor; case SceneBlendFactor.OneMinusSourceColor: return D3D9.Blend.InverseSourceColor; case SceneBlendFactor.DestAlpha: return D3D9.Blend.DestinationAlpha; case SceneBlendFactor.SourceAlpha: return D3D9.Blend.SourceAlpha; case SceneBlendFactor.OneMinusDestAlpha: return D3D9.Blend.InverseDestinationAlpha; case SceneBlendFactor.OneMinusSourceAlpha: return D3D9.Blend.InverseSourceAlpha; } ; return (D3D9.Blend)0x7fffffff; //D3DBLEND_FORCE_DWORD }
/// <summary> /// Private method to convert our blend factors to that of Open GL /// </summary> /// <param name="factor"></param> /// <returns></returns> private int ConvertBlendFactor(SceneBlendFactor factor) { int glFactor = 0; switch(factor) { case SceneBlendFactor.One: glFactor = Gl.GL_ONE; break; case SceneBlendFactor.Zero: glFactor = Gl.GL_ZERO; break; case SceneBlendFactor.DestColor: glFactor = Gl.GL_DST_COLOR; break; case SceneBlendFactor.SourceColor: glFactor = Gl.GL_SRC_COLOR; break; case SceneBlendFactor.OneMinusDestColor: glFactor = Gl.GL_ONE_MINUS_DST_COLOR; break; case SceneBlendFactor.OneMinusSourceColor: glFactor = Gl.GL_ONE_MINUS_SRC_COLOR; break; case SceneBlendFactor.DestAlpha: glFactor = Gl.GL_DST_ALPHA; break; case SceneBlendFactor.SourceAlpha: glFactor = Gl.GL_SRC_ALPHA; break; case SceneBlendFactor.OneMinusDestAlpha: glFactor = Gl.GL_ONE_MINUS_DST_ALPHA; break; case SceneBlendFactor.OneMinusSourceAlpha: glFactor = Gl.GL_ONE_MINUS_SRC_ALPHA; break; } // return the GL equivalent return glFactor; }
/// <summary> /// /// </summary> /// <param name="src"></param> /// <param name="dest"></param> public override void SetSceneBlending(SceneBlendFactor src, SceneBlendFactor dest) { if(src == lastBlendSrc && dest == lastBlendDest) { return; } int srcFactor = ConvertBlendFactor(src); int destFactor = ConvertBlendFactor(dest); // enable blending and set the blend function Gl.glEnable(Gl.GL_BLEND); Gl.glBlendFunc(srcFactor, destFactor); lastBlendSrc = src; lastBlendDest = dest; }
public void SetSeparateSceneBlending( SceneBlendFactor sourceFactor, SceneBlendFactor destFactor, SceneBlendFactor sourceFactorAlpha, SceneBlendFactor destFactorAlpha ) { this._sourceBlendFactor = sourceFactor; this._destinationBlendFactor = destFactor; this._sourceBlendFactorAlpha = sourceFactorAlpha; this._destinationBlendFactorAlpha = destFactorAlpha; this.separateBlend = true; }
public void SetSceneBlending( SceneBlendFactor src, SceneBlendFactor dest ) { // copy settings this._sourceBlendFactor = src; this._destinationBlendFactor = dest; this.separateBlend = false; }
protected void GetBlendFlags( SceneBlendType type, out SceneBlendFactor source, out SceneBlendFactor dest ) { switch ( type ) { case SceneBlendType.TransparentAlpha: source = SceneBlendFactor.SourceAlpha; dest = SceneBlendFactor.OneMinusSourceAlpha; break; case SceneBlendType.TransparentColor: source = SceneBlendFactor.SourceColor; dest = SceneBlendFactor.OneMinusSourceColor; break; case SceneBlendType.Modulate: source = SceneBlendFactor.DestColor; dest = SceneBlendFactor.Zero; break; case SceneBlendType.Add: source = SceneBlendFactor.One; dest = SceneBlendFactor.One; break; case SceneBlendType.Replace: source = SceneBlendFactor.One; dest = SceneBlendFactor.Zero; break; default: throw new AxiomException( "Invalid SceneBlendType {0}", type ); } }
public override void SetSeparateSceneBlending( SceneBlendFactor sourceFactor, SceneBlendFactor destFactor, SceneBlendFactor sourceFactorAlpha, SceneBlendFactor destFactorAlpha ) { throw new NotImplementedException(); }
/// <summary> /// Sets the global blending factors for combining subsequent renders with the existing frame contents. /// The result of the blending operation is: /// <p align="center">final = (texture * src) + (pixel * dest)</p> /// Each of the factors is specified as one of a number of options, as specified in the SceneBlendFactor /// enumerated type. /// </summary> /// <param name="src">The source factor in the above calculation, i.e. multiplied by the texture color components.</param> /// <param name="dest">The destination factor in the above calculation, i.e. multiplied by the pixel color components.</param> /// <param name="op">The blend operation mode for combining pixels</param> public override void SetSceneBlending(SceneBlendFactor src, SceneBlendFactor dest, SceneBlendOperation op) { StateManager.BlendState.AlphaSourceBlend = XnaHelper.Convert(src); StateManager.BlendState.AlphaDestinationBlend = XnaHelper.Convert(dest); StateManager.BlendState.AlphaBlendFunction = XnaHelper.Convert(op); /**/ StateManager.BlendState.ColorSourceBlend = XnaHelper.Convert( src ); StateManager.BlendState.ColorDestinationBlend = XnaHelper.Convert( dest ); /**/ StateManager.BlendState.ColorSourceBlend = StateManager.BlendState.AlphaSourceBlend; StateManager.BlendState.ColorDestinationBlend = StateManager.BlendState.AlphaDestinationBlend; /**/ //TODO use SceneBlendOperation StateManager.BlendState.ColorBlendFunction = StateManager.BlendState.AlphaBlendFunction; } #endregion #region SetSeparateSceneBlending /// <summary> /// Sets the global blending factors for combining subsequent renders with the existing frame contents. /// The result of the blending operation is: /// final = (texture * sourceFactor) + (pixel * destFactor). /// Each of the factors is specified as one of a number of options, as specified in the SceneBlendFactor /// enumerated type. /// </summary> /// <param name="sourceFactor">The source factor in the above calculation, i.e. multiplied by the texture color components.</param> /// <param name="destFactor">The destination factor in the above calculation, i.e. multiplied by the pixel color components.</param> /// <param name="sourceFactorAlpha">The source factor in the above calculation for the alpha channel, i.e. multiplied by the texture alpha components.</param> /// <param name="destFactorAlpha">The destination factor in the above calculation for the alpha channel, i.e. multiplied by the pixel alpha components.</param> /// <param name="op">The blend operation mode for combining pixels</param> /// <param name="alphaOp">The blend operation mode for combining pixel alpha values</param> public override void SetSeparateSceneBlending(SceneBlendFactor sourceFactor, SceneBlendFactor destFactor, SceneBlendFactor sourceFactorAlpha, SceneBlendFactor destFactorAlpha, SceneBlendOperation op, SceneBlendOperation alphaOp) { StateManager.BlendState.ColorSourceBlend = XnaHelper.Convert(sourceFactor); StateManager.BlendState.ColorDestinationBlend = XnaHelper.Convert(destFactor); StateManager.BlendState.AlphaSourceBlend = XnaHelper.Convert(sourceFactorAlpha); StateManager.BlendState.AlphaDestinationBlend = XnaHelper.Convert(destFactorAlpha); StateManager.BlendState.ColorBlendFunction = XnaHelper.Convert(op); StateManager.BlendState.AlphaBlendFunction = XnaHelper.Convert(alphaOp); } #endregion #region SetScissorTest /// <summary> /// Sets the 'scissor region' ie the region of the target in which rendering can take place. /// </summary> /// <remarks> /// This method allows you to 'mask off' rendering in all but a given rectangular area /// as identified by the parameters to this method. /// <p/> /// Not all systems support this method. Check the <see cref="Capabilities"/> enum for the /// ScissorTest capability to see if it is supported. /// </remarks> /// <param name="enable">True to enable the scissor test, false to disable it.</param> /// <param name="left">Left corner (in pixels).</param> /// <param name="top">Top corner (in pixels).</param> /// <param name="right">Right corner (in pixels).</param> /// <param name="bottom">Bottom corner (in pixels).</param> public override void SetScissorTest(bool enable, int left, int top, int right, int bottom) { if (enable) { _device.ScissorRectangle = new Rectangle(left, top, right - left, bottom - top); StateManager.RasterizerState.ScissorTestEnable = true; } else { StateManager.RasterizerState.ScissorTestEnable = false; } } #endregion #region SetStencilBufferParams /// <summary> /// This method allows you to set all the stencil buffer parameters in one call. /// </summary> /// <remarks> /// <para> /// The stencil buffer is used to mask out pixels in the render target, allowing /// you to do effects like mirrors, cut-outs, stencil shadows and more. Each of /// your batches of rendering is likely to ignore the stencil buffer, /// update it with new values, or apply it to mask the output of the render. /// The stencil test is:<PRE> /// (Reference Value & Mask) CompareFunction (Stencil Buffer Value & Mask)</PRE> /// The result of this will cause one of 3 actions depending on whether the test fails, /// succeeds but with the depth buffer check still failing, or succeeds with the /// depth buffer check passing too.</para> /// <para> /// Unlike other render states, stencilling is left for the application to turn /// on and off when it requires. This is because you are likely to want to change /// parameters between batches of arbitrary objects and control the ordering yourself. /// In order to batch things this way, you'll want to use OGRE's separate render queue /// groups (see RenderQueue) and register a RenderQueueListener to get notifications /// between batches.</para> /// <para> /// There are individual state change methods for each of the parameters set using /// this method. /// Note that the default values in this method represent the defaults at system /// start up too.</para> /// </remarks> /// <param name="function">The comparison function applied.</param> /// <param name="refValue">The reference value used in the comparison.</param> /// <param name="mask"> /// The bitmask applied to both the stencil value and the reference value /// before comparison. /// </param> /// <param name="stencilFailOp">The action to perform when the stencil check fails.</param> /// <param name="depthFailOp"> /// The action to perform when the stencil check passes, but the depth buffer check still fails. /// </param> /// <param name="passOp">The action to take when both the stencil and depth check pass.</param> /// <param name="twoSidedOperation"> /// If set to true, then if you render both back and front faces /// (you'll have to turn off culling) then these parameters will apply for front faces, /// and the inverse of them will happen for back faces (keep remains the same). /// </param> public override void SetStencilBufferParams(CompareFunction function, int refValue, int mask, StencilOperation stencilFailOp, StencilOperation depthFailOp, StencilOperation passOp, bool twoSidedOperation) { bool flip; // 2 sided operation? if (twoSidedOperation) { //if ( !HardwareCapabilities.HasCapability( Capabilities.TwoSidedStencil ) ) //{ // throw new AxiomException( "2-sided stencils are not supported on this hardware!" ); //} StateManager.DepthStencilState.TwoSidedStencilMode = true; flip = (invertVertexWinding && activeRenderTarget.RequiresTextureFlipping) || (!invertVertexWinding && !activeRenderTarget.RequiresTextureFlipping); StateManager.DepthStencilState.StencilFail = XnaHelper.Convert(stencilFailOp, !flip); StateManager.DepthStencilState.StencilDepthBufferFail = XnaHelper.Convert(depthFailOp, !flip); StateManager.DepthStencilState.StencilPass = XnaHelper.Convert(passOp, !flip); } else { StateManager.DepthStencilState.TwoSidedStencilMode = false; flip = false; } // configure standard version of the stencil operations StateManager.DepthStencilState.StencilFunction = XnaHelper.Convert(function); StateManager.DepthStencilState.ReferenceStencil = refValue; StateManager.DepthStencilState.StencilMask = mask; StateManager.DepthStencilState.StencilFail = XnaHelper.Convert(stencilFailOp, flip); StateManager.DepthStencilState.StencilDepthBufferFail = XnaHelper.Convert(depthFailOp, flip); StateManager.DepthStencilState.StencilPass = XnaHelper.Convert(passOp, flip); StateManager.BlendState.ColorWriteChannels = ColorWriteChannels.None; } #endregion #region SetSurfaceParams /// <summary> /// Sets the surface properties to be used for future rendering. /// /// This method sets the the properties of the surfaces of objects /// to be rendered after it. In this context these surface properties /// are the amount of each type of light the object reflects (determining /// it's color under different types of light), whether it emits light /// itself, and how shiny it is. Textures are not dealt with here, /// <see cref="SetTexture(int, bool, Texture)"/> method for details. /// This method is used by SetMaterial so does not need to be called /// direct if that method is being used. /// </summary> /// <param name="ambient"> /// The amount of ambient (sourceless and directionless) /// light an object reflects. Affected by the color/amount of ambient light in the scene. /// </param> /// <param name="diffuse"> /// The amount of light from directed sources that is /// reflected (affected by color/amount of point, directed and spot light sources) /// </param> /// <param name="specular"> /// The amount of specular light reflected. This is also /// affected by directed light sources but represents the color at the /// highlights of the object. /// </param> /// <param name="emissive"> /// The color of light emitted from the object. Note that /// this will make an object seem brighter and not dependent on lights in /// the scene, but it will not act as a light, so will not illuminate other /// objects. Use a light attached to the same SceneNode as the object for this purpose. /// </param> /// <param name="shininess"> /// A value which only has an effect on specular highlights (so /// specular must be non-black). The higher this value, the smaller and crisper the /// specular highlights will be, imitating a more highly polished surface. /// This value is not constrained to 0.0-1.0, in fact it is likely to /// be more (10.0 gives a modest sheen to an object). /// </param> /// <param name="tracking"> /// A bit field that describes which of the ambient, diffuse, specular /// and emissive colors follow the vertex color of the primitive. When a bit in this field is set /// its colorValue is ignored. This is a combination of TVC_AMBIENT, TVC_DIFFUSE, TVC_SPECULAR(note that the shininess value is still /// taken from shininess) and TVC_EMISSIVE. TVC_NONE means that there will be no material property /// tracking the vertex colors. /// </param> public override void SetSurfaceParams(ColorEx ambient, ColorEx diffuse, ColorEx specular, ColorEx emissive, Real shininess, TrackVertexColor tracking) { /*/ //basicEffect.Alpha; //basicEffect.AmbientLightColor; //basicEffect.DiffuseColor; basicEffect.DirectionalLight0; basicEffect.DirectionalLight1; basicEffect.DirectionalLight2; //basicEffect.EmissiveColor; basicEffect.EnableDefaultLighting(); //basicEffect.FogColor; //basicEffect.FogEnabled; //basicEffect.FogEnd; //basicEffect.FogStart; //basicEffect.LightingEnabled; basicEffect.PreferPerPixelLighting; //basicEffect.Projection; //basicEffect.SpecularColor; //basicEffect.SpecularPower; //basicEffect.Texture; //basicEffect.TextureEnabled; //basicEffect.VertexColorEnabled; //basicEffect.View; //basicEffect.World; /**/ //basicEffect.EnableDefaultLighting(); //basicEffect.PreferPerPixelLighting = true; if (ambient == ColorEx.White && diffuse == ColorEx.Black && emissive == ColorEx.Black && specular == ColorEx.Black && shininess == 0 ) { //_fixedFunctionState.MaterialEnabled = false; basicEffect.AmbientLightColor = Color.White.ToVector3(); basicEffect.DiffuseColor = Color.White.ToVector3(); } else { //_fixedFunctionState.MaterialEnabled = true; basicEffect.AmbientLightColor = XnaHelper.Convert( ambient ).ToVector3(); basicEffect.DiffuseColor = XnaHelper.Convert( diffuse ).ToVector3(); } basicEffect.SpecularColor = XnaHelper.Convert(specular).ToVector3(); basicEffect.EmissiveColor = XnaHelper.Convert(emissive).ToVector3(); basicEffect.SpecularPower = shininess; try { skinnedEffect.AmbientLightColor = basicEffect.AmbientLightColor; skinnedEffect.DiffuseColor = basicEffect.DiffuseColor; skinnedEffect.SpecularColor = basicEffect.SpecularColor; skinnedEffect.EmissiveColor = basicEffect.EmissiveColor; skinnedEffect.SpecularPower = basicEffect.SpecularPower; } catch ( Exception ex ) { } #if AXIOM_FF_EMULATION if (//ambient == ColorEx.White && diffuse == ColorEx.Black //&& //emissive == ColorEx.Black && //specular == ColorEx.Black && //shininess == 0 ) { //_fixedFunctionState.MaterialEnabled = false; _ffProgramParameters.MaterialAmbient = new ColorEx( 0, 1, 1, 1 ); _ffProgramParameters.MaterialDiffuse = ColorEx.White; _ffProgramParameters.MaterialSpecular = ColorEx.Black; } else { //_fixedFunctionState.MaterialEnabled = true; _ffProgramParameters.MaterialAmbient = ambient; _ffProgramParameters.MaterialDiffuse = diffuse; _ffProgramParameters.MaterialSpecular = specular; //_ffProgramParameters.MaterialEmissive = emissive; //_ffProgramParameters.MaterialShininess = shininess; } #endif } #endregion #region SetPointParameters /// <summary> /// Sets the size of points and how they are attenuated with distance. /// <remarks> /// When performing point rendering or point sprite rendering, /// point size can be attenuated with distance. The equation for /// doing this is attenuation = 1 / (constant + linear * dist + quadratic * d^2) . /// </remarks> /// </summary> public override void SetPointParameters(Real size, bool attenuationEnabled, Real constant, Real linear, Real quadratic, Real minSize, Real maxSize) { throw new AxiomException("XNA does not support PointSprites."); } #endregion #region SetTexture /// <summary> /// Sets the texture to bind to a given texture unit. /// /// User processes would not normally call this direct unless rendering /// primitives themselves. /// </summary> /// <param name="unit"> /// The index of the texture unit to modify. Multitexturing /// hardware can support multiple units <see cref="RenderSystemCapabilities.TextureUnitCount"/> /// </param> /// <param name="enabled"></param> /// <param name="texture"></param> public override void SetTexture(int stage, bool enabled, Texture texture) { var xnaTexture = (XnaTexture)texture; var compensateNPOT = false; if ((texture != null) && (!Bitwise.IsPow2(texture.Width) || !Bitwise.IsPow2(texture.Height))) { if (Capabilities.HasCapability(Graphics.Capabilities.NonPowerOf2Textures)) { if (Capabilities.NonPOW2TexturesLimited) compensateNPOT = true; } else compensateNPOT = true; if (compensateNPOT) { SetTextureAddressingMode(stage, new UVWAddressing(TextureAddressing.Clamp)); } } texStageDesc[stage].Enabled = enabled; if (enabled && xnaTexture != null) { _device.Textures[stage] = xnaTexture.DXTexture; // TODO: NRSC: Solve cast problem for non Texture2D basicEffect.Texture = xnaTexture.DXTexture as Texture2D; try { basicEffect.TextureEnabled = basicEffect.Texture != null; } catch ( Exception ex ) { SetTextureAddressingMode( stage, new UVWAddressing( TextureAddressing.Clamp ) ); } finally { basicEffect.TextureEnabled = basicEffect.Texture != null; } skinnedEffect.Texture = basicEffect.Texture; // set stage description texStageDesc[stage].tex = xnaTexture.DXTexture; texStageDesc[stage].texType = xnaTexture.TextureType; var state = StateManager.SamplerStates[stage]; if ( #if !SILVERLIGHT _device.GraphicsProfile == GraphicsProfile.Reach && #endif !( (XnaTexture)texture ).IsPowerOfTwo ) { state.AddressU = TextureAddressMode.Clamp; state.AddressV = TextureAddressMode.Clamp; state.AddressW = TextureAddressMode.Clamp; } else { state.AddressU = TextureAddressMode.Wrap; state.AddressV = TextureAddressMode.Wrap; state.AddressW = TextureAddressMode.Wrap; } } else { if (texStageDesc[stage].tex != null) { _device.Textures[stage] = null; } // set stage description to defaults texStageDesc[stage].tex = null; texStageDesc[stage].autoTexCoordType = TexCoordCalcMethod.None; texStageDesc[stage].coordIndex = 0; texStageDesc[stage].texType = TextureType.OneD; } #if AXIOM_FF_EMULATION _ffProgramParameters.SetTextureEnabled( stage, enabled ); #endif } #endregion #region SetTextureAddressingMode /// <summary> /// Tells the hardware how to treat texture coordinates. /// </summary> public override void SetTextureAddressingMode(int stage, UVWAddressing uvw) { if (_device.GetVertexBuffers().Length == 0) { return; } if ( !(from VertexElement vde in _device.GetVertexBuffers()[0].VertexBuffer.VertexDeclaration.GetVertexElements() where vde.VertexElementUsage == VertexElementUsage.Normal select vde).Any()) { return; } var xnaTexture = _device.Textures[stage] as Texture2D; var compensateNPOT = false; if ((xnaTexture != null) && (!Bitwise.IsPow2(xnaTexture.Width) || !Bitwise.IsPow2(xnaTexture.Height))) { if (Capabilities.HasCapability(Graphics.Capabilities.NonPowerOf2Textures)) { if (Capabilities.NonPOW2TexturesLimited) compensateNPOT = true; } else compensateNPOT = true; if (compensateNPOT) { uvw = new UVWAddressing( TextureAddressing.Clamp ); } } // set the device sampler states accordingly StateManager.SamplerStates[ stage ].AddressU = XnaHelper.Convert( uvw.U ); StateManager.SamplerStates[ stage ].AddressV = XnaHelper.Convert( uvw.V ); StateManager.SamplerStates[ stage ].AddressW = XnaHelper.Convert( uvw.W ); } #endregion #region SetTextureMipmapBias /// <summary> /// Sets the mipmap bias value for a given texture unit. /// </summary> /// <remarks> /// This allows you to adjust the mipmap calculation up or down for a /// given texture unit. Negative values force a larger mipmap to be used, /// positive values force a smaller mipmap to be used. Units are in numbers /// of levels, so +1 forces the mipmaps to one smaller level. /// </remarks> /// <note>Only does something if render system has capability RSC_MIPMAP_LOD_BIAS.</note> public override void SetTextureMipmapBias(int unit, float bias) { if (currentCapabilities.HasCapability(Graphics.Capabilities.MipmapLODBias)) { var ss = _device.SamplerStates[unit]; _device.SamplerStates[unit] = new SamplerState { MipMapLevelOfDetailBias = bias, MaxMipLevel = ss.MaxMipLevel, MaxAnisotropy = ss.MaxAnisotropy, #if ! SILVERLIGHT AddressW = ss.AddressW, #endif AddressV = ss.AddressV, AddressU = ss.AddressU, Filter = ss.Filter, }; } } #endregion #region SetTextureBorderColor /// <summary> /// Tells the hardware what border color to use when texture addressing mode is set to Border /// </summary> /// <param name="unit"></param> /// <param name="borderColor"></param> public override void SetTextureBorderColor(int stage, ColorEx borderColor) { //texStageDesc[ stage ].borderColor = borderColor; } #endregion #region SetTextureBlendMode /// <summary> /// Sets the texture blend modes from a TextureLayer record. /// Meant for use internally only - apps should use the Material /// and TextureLayer classes. /// </summary> /// <param name="unit">Texture unit.</param> /// <param name="bm">Details of the blending modes.</param> public override void SetTextureBlendMode(int stage, LayerBlendModeEx blendMode) { basicEffect.Alpha = 1.0f; skinnedEffect.Alpha = 1.0f; if (blendMode.blendType == LayerBlendType.Color) { texStageDesc[stage].layerBlendMode = blendMode; } /* TODO: use StateManager.BlendState */ if (blendMode.operation == LayerBlendOperationEx.BlendManual) { StateManager.BlendState.BlendFactor = new Color(blendMode.blendFactor, 0, 0, 0); } if (blendMode.blendType == LayerBlendType.Color) { //_device.RenderState.AlphaBlendEnable = false; } else if (blendMode.blendType == LayerBlendType.Alpha) { //_device.RenderState.AlphaBlendEnable = true; } var manualD3D = XnaHelper.Convert(StateManager.BlendState.BlendFactor); if (blendMode.blendType == LayerBlendType.Color) { manualD3D = new ColorEx(blendMode.blendFactor, blendMode.colorArg1.r, blendMode.colorArg1.g, blendMode.colorArg1.b); } else if (blendMode.blendType == LayerBlendType.Alpha) { manualD3D = new ColorEx(blendMode.alphaArg1, blendMode.blendFactor, blendMode.blendFactor, blendMode.blendFactor); } var blendSource = blendMode.source1; for (var i = 0; i < 2; i++) { // set the texture blend factor if this is manual blending if (blendSource == LayerBlendSource.Manual) { StateManager.BlendState.BlendFactor = XnaHelper.Convert(manualD3D); } // pick proper argument settings if (blendMode.blendType == LayerBlendType.Color) { if (i == 0) { texStageDesc[stage].layerBlendMode.colorArg1 = blendMode.colorArg1; } else if (i == 1) { texStageDesc[stage].layerBlendMode.colorArg2 = blendMode.colorArg2; } } else if (blendMode.blendType == LayerBlendType.Alpha) { if (i == 0) { texStageDesc[stage].layerBlendMode.alphaArg1 = blendMode.alphaArg1; basicEffect.Alpha = blendMode.alphaArg1; } else if (i == 1) { texStageDesc[stage].layerBlendMode.alphaArg2 = blendMode.alphaArg2; basicEffect.Alpha = blendMode.alphaArg2; } skinnedEffect.Alpha = basicEffect.Alpha; } // Source2 blendSource = blendMode.source2; if (blendMode.blendType == LayerBlendType.Color) { manualD3D = new ColorEx(manualD3D.a, blendMode.colorArg2.r, blendMode.colorArg2.g, blendMode.colorArg2.b); } else if (blendMode.blendType == LayerBlendType.Alpha) { manualD3D = new ColorEx(blendMode.alphaArg2, manualD3D.r, manualD3D.g, manualD3D.b); } } }
public override void SetSceneBlending(SceneBlendFactor src, SceneBlendFactor dest) { // set the render states after converting the incoming values to D3D.Blend if (src == SceneBlendFactor.One && dest == SceneBlendFactor.Zero) SetRenderState(ref cache.alphaBlendEnable, RenderStates.AlphaBlendEnable, false); else { SetRenderState(ref cache.alphaBlendEnable, RenderStates.AlphaBlendEnable, true); if (cache.sourceBlend != src) { cache.sourceBlend = src; device.RenderState.SourceBlend = D3DHelper.ConvertEnum(src); } if (cache.destinationBlend != dest) { cache.destinationBlend = dest; device.RenderState.DestinationBlend = D3DHelper.ConvertEnum(dest); } } }
public override void SetSceneBlending(SceneBlendFactor src, SceneBlendFactor dest, SceneBlendOperation op = SceneBlendOperation.Add) { // set the render states after converting the incoming values to D3D.Blend if ( src == SceneBlendFactor.One && dest == SceneBlendFactor.Zero ) { SetRenderState( RenderState.AlphaBlendEnable, false ); } else { SetRenderState( RenderState.AlphaBlendEnable, true ); SetRenderState( RenderState.SeparateAlphaBlendEnable, false ); SetRenderState( RenderState.SourceBlend, (int)D3DHelper.ConvertEnum( src ) ); SetRenderState( RenderState.DestinationBlend, (int)D3DHelper.ConvertEnum( dest ) ); } SetRenderState( RenderState.BlendOperation, (int)D3DHelper.ConvertEnum( op ) ); SetRenderState( RenderState.BlendOperationAlpha, (int)D3DHelper.ConvertEnum( op ) ); }
public void setSceneBlending(SceneBlendFactor sourceFactor, SceneBlendFactor destFactor) { Technique_setSceneBlending2(technique, sourceFactor, destFactor); }
public void setSeparateSceneBlending(SceneBlendFactor sourceFactor, SceneBlendFactor destFactor, SceneBlendFactor sourceFactorAlpha, SceneBlendFactor destFactorAlpha) { OgrePINVOKE.Material_setSeparateSceneBlending__SWIG_1(swigCPtr, (int)sourceFactor, (int)destFactor, (int)sourceFactorAlpha, (int)destFactorAlpha); if (OgrePINVOKE.SWIGPendingException.Pending) { throw OgrePINVOKE.SWIGPendingException.Retrieve(); } }
public void setSeparateSceneBlending(SceneBlendFactor sourceFactor, SceneBlendFactor destFactor, SceneBlendFactor sourceFactorAlpha, SceneBlendFactor destFactorAlpha) { Technique_setSeparateSceneBlending2(technique, sourceFactor, destFactor, sourceFactorAlpha, destFactorAlpha); }
public override void SetSeparateSceneBlending( SceneBlendFactor sourceFactor, SceneBlendFactor destFactor, SceneBlendFactor sourceFactorAlpha, SceneBlendFactor destFactorAlpha, SceneBlendOperation op, SceneBlendOperation alphaOp) { int sourceBlend = GLHelper.ConvertEnum( sourceFactor ); int destBlend = GLHelper.ConvertEnum( destFactor ); int sourceBlendAlpha = GLHelper.ConvertEnum( sourceFactorAlpha ); int destBlendAlpha = GLHelper.ConvertEnum( destFactorAlpha ); if ( sourceFactor == SceneBlendFactor.One && destFactor == SceneBlendFactor.Zero && sourceFactorAlpha == SceneBlendFactor.One && destFactorAlpha == SceneBlendFactor.Zero ) { Gl.glDisable( Gl.GL_BLEND ); } else { Gl.glEnable( Gl.GL_BLEND ); Gl.glBlendFuncSeparate( sourceBlend, destBlend, sourceBlendAlpha, destBlendAlpha ); } var func = Gl.GL_FUNC_ADD; var alphaFunc = Gl.GL_FUNC_ADD; switch (op) { case SceneBlendOperation.Add: func = Gl.GL_FUNC_ADD; break; case SceneBlendOperation.Subtract: func = Gl.GL_FUNC_SUBTRACT; break; case SceneBlendOperation.ReverseSubtract: func = Gl.GL_FUNC_REVERSE_SUBTRACT; break; case SceneBlendOperation.Min: func = Gl.GL_MIN; break; case SceneBlendOperation.Max: func = Gl.GL_MAX; break; } switch (alphaOp) { case SceneBlendOperation.Add: alphaFunc = Gl.GL_FUNC_ADD; break; case SceneBlendOperation.Subtract: alphaFunc = Gl.GL_FUNC_SUBTRACT; break; case SceneBlendOperation.ReverseSubtract: alphaFunc = Gl.GL_FUNC_REVERSE_SUBTRACT; break; case SceneBlendOperation.Min: alphaFunc = Gl.GL_MIN; break; case SceneBlendOperation.Max: alphaFunc = Gl.GL_MAX; break; } if (GLEW_VERSION_2_0) { Gl.glBlendEquationSeparate(func, alphaFunc); } else if (GLEW_EXT_blend_equation_separate) { Gl.glBlendEquationSeparateEXT(func, alphaFunc); } }
private static extern void Technique_setSeparateSceneBlending2(IntPtr technique, SceneBlendFactor sourceFactor, SceneBlendFactor destFactor, SceneBlendFactor sourceFactorAlpha, SceneBlendFactor destFactorAlpha);
/// <summary> /// Default constructor. /// </summary> /// <param name="parent">Technique that owns this Pass.</param> /// <param name="index">Index of this pass.</param> public Pass(Technique parent, int index) { this.parent = parent; this.index = index; lock (passLock) { this.passId = nextPassId++; } // color defaults ambient = ColorEx.White; diffuse = ColorEx.White; specular = ColorEx.Black; emissive = ColorEx.Black; // by default, don't override the scene's fog settings fogOverride = false; fogMode = FogMode.None; fogColor = ColorEx.White; fogStart = 0; fogEnd = 1; fogDensity = 0.001f; // default blending (overwrite) sourceBlendFactor = SceneBlendFactor.One; destBlendFactor = SceneBlendFactor.Zero; // depth buffer settings depthCheck = true; depthWrite = true; colorWrite = true; alphaRejectFunction = CompareFunction.AlwaysPass; alphaRejectValue = 0; depthFunc = CompareFunction.LessEqual; depthBiasConstant = 0f; depthBiasSlopeScale = 0f; // cull settings cullMode = CullingMode.Clockwise; manualCullMode = ManualCullingMode.Back; // light settings lightingEnabled = true; runOnlyForOneLightType = true; lightsPerIteration = 1; runOncePerLight = false; onlyLightType = LightType.Point; shadeOptions = Shading.Gouraud; // Default max lights to the global max maxLights = Config.MaxSimultaneousLights; // Starting light index startLight = 0; // Default to solid sceneDetail = SceneDetailLevel.Solid; // Iteration count of 1 passIterationCount = 1; // pointSize, etc. pointSize = 1.0f; pointMinSize = 0f; pointMaxSize = 0f; pointSpritesEnabled = false; pointAttenuationEnabled = false; pointAttenuationConstant = 1.0f; pointAttenuationLinear = 0f; pointAttenuationQuadratic = 0f; contentTypeLookupBuilt = false; name = index.ToString(); DirtyHash(); }
public void setSceneBlending(SceneBlendFactor sourceFactor, SceneBlendFactor destFactor) { Pass_setSceneBlending2(pass, sourceFactor, destFactor); }
/// <summary> /// Sets the global blending factors for combining subsequent renders with the existing frame contents. /// The result of the blending operation is:</p> /// <p align="center">final = (texture * src) + (pixel * dest)</p> /// Each of the factors is specified as one of a number of options, as specified in the SceneBlendFactor /// enumerated type. /// </summary> /// <param name="src">The source factor in the above calculation, i.e. multiplied by the texture color components.</param> /// <param name="dest">The destination factor in the above calculation, i.e. multiplied by the pixel color components.</param> public abstract void SetSceneBlending(SceneBlendFactor src, SceneBlendFactor dest);
public void setSeparateSceneBlending(SceneBlendFactor sourceFactor, SceneBlendFactor destFactor, SceneBlendFactor sourceFactorAlpha, SceneBlendFactor destFactorAlpha) { Pass_setSeparateSceneBlending2(pass, sourceFactor, destFactor, sourceFactorAlpha, destFactorAlpha); }
public void SetSceneBlending( SceneBlendFactor src, SceneBlendFactor dest ) { // load each pass for ( var i = 0; i < this._passes.Count; i++ ) { this._passes[ i ].SetSceneBlending( src, dest ); } }
private static extern void Pass_setSceneBlending2(IntPtr pass, SceneBlendFactor sourceFactor, SceneBlendFactor destFactor);
/// <summary> /// /// </summary> /// <param name="src"></param> /// <param name="dest"></param> public override void SetSceneBlending( SceneBlendFactor src, SceneBlendFactor dest ) { GLESConfig.GlCheckError( this ); All sourceBlend = GetBlendMode( src ); All destBlend = GetBlendMode( dest ); if ( src == SceneBlendFactor.One && dest == SceneBlendFactor.Zero ) { OpenGL.Disable( All.Blend ); GLESConfig.GlCheckError( this ); } else { // SBF_SOURCE_COLOUR - not allowed for source - http://www.khronos.org/opengles/sdk/1.1/docs/man/ if ( src == SceneBlendFactor.SourceColor ) { sourceBlend = GetBlendMode( SceneBlendFactor.SourceAlpha ); } OpenGL.Enable( All.Blend ); GLESConfig.GlCheckError( this ); OpenGL.BlendFunc( sourceBlend, destBlend ); GLESConfig.GlCheckError( this ); } #if GL_OES_blend_subtract #endif }
private static extern void Pass_setSeparateSceneBlending2(IntPtr pass, SceneBlendFactor sourceFactor, SceneBlendFactor destFactor, SceneBlendFactor sourceFactorAlpha, SceneBlendFactor destFactorAlpha);
public void SetSceneBlending( SceneBlendFactor src, SceneBlendFactor dest ) { // load each pass for ( int i = 0; i < _passes.Count; i++ ) { ( (Pass)_passes[ i ] ).SetSceneBlending( src, dest ); } }
public void setSceneBlending(SceneBlendFactor sourceFactor, SceneBlendFactor destFactor) { Material_setSceneBlending2(resource, sourceFactor, destFactor); }
private All GetBlendMode( SceneBlendFactor axiomBlend ) { switch ( axiomBlend ) { case SceneBlendFactor.One: return All.One; case SceneBlendFactor.Zero: return All.Zero; case SceneBlendFactor.DestColor: return All.DstColor; case SceneBlendFactor.SourceColor: return All.SrcColor; case SceneBlendFactor.OneMinusDestColor: return All.OneMinusDstColor; case SceneBlendFactor.OneMinusSourceColor: return All.OneMinusSrcColor; case SceneBlendFactor.DestAlpha: return All.DstAlpha; case SceneBlendFactor.SourceAlpha: return All.SrcAlpha; case SceneBlendFactor.OneMinusDestAlpha: return All.OneMinusDstAlpha; case SceneBlendFactor.OneMinusSourceAlpha: return All.OneMinusSrcAlpha; default: //To keep compiler happy return All.One; } }
public void setSeparateSceneBlending(SceneBlendFactor sourceFactor, SceneBlendFactor destFactor, SceneBlendFactor sourceFactorAlpha, SceneBlendFactor destFactorAlpha) { Material_setSeparateSceneBlending2(resource, sourceFactor, destFactor, sourceFactorAlpha, destFactorAlpha); }
public override void SetSeparateSceneBlending( SceneBlendFactor sourceFactor, SceneBlendFactor destFactor, SceneBlendFactor sourceFactorAlpha, SceneBlendFactor destFactorAlpha, SceneBlendOperation op, SceneBlendOperation alphaOp ) { var sourceBlend = this.GetBlendMode( sourceFactor ); var destBlend = this.GetBlendMode( destFactor ); var sourceBlendAlpha = this.GetBlendMode( sourceFactorAlpha ); var destBlendAlpha = this.GetBlendMode( destFactorAlpha ); if ( sourceFactor == SceneBlendFactor.One && destFactor == SceneBlendFactor.Zero && sourceFactorAlpha == SceneBlendFactor.One && destFactorAlpha == SceneBlendFactor.Zero ) { GL.Disable( All.Blend ); GLES2Config.GlCheckError( this ); } else { GL.Enable( All.Blend ); GLES2Config.GlCheckError( this ); GL.BlendFuncSeparate( sourceBlend, destBlend, sourceBlendAlpha, destBlendAlpha ); GLES2Config.GlCheckError( this ); } All func = All.FuncAdd, alphaFunc = All.FuncAdd; switch ( op ) { case SceneBlendOperation.Add: func = All.FuncAdd; break; case SceneBlendOperation.Subtract: func = All.FuncSubtract; break; case SceneBlendOperation.ReverseSubtract: func = All.FuncReverseSubtract; break; case SceneBlendOperation.Min: //#if GL_EXT_blend_minmax //func = Alll.MinExt; //#endif break; case SceneBlendOperation.Max: //#if GL_EXT_blend_minmax //func = Alll.MaxExt; //#endif break; } switch ( alphaOp ) { case SceneBlendOperation.Add: alphaFunc = All.FuncAdd; break; case SceneBlendOperation.Subtract: alphaFunc = All.FuncSubtract; break; case SceneBlendOperation.ReverseSubtract: alphaFunc = All.FuncReverseSubtract; break; case SceneBlendOperation.Min: //#if GL_EXT_blend_minmax //func = Alll.MinExt; //#endif break; case SceneBlendOperation.Max: //#if GL_EXT_blend_minmax //func = Alll.MaxExt; //#endif break; default: break; } GL.BlendEquationSeparate( func, alphaFunc ); GLES2Config.GlCheckError( this ); }
private static extern void Material_setSceneBlending2(IntPtr material, SceneBlendFactor sourceFactor, SceneBlendFactor destFactor);
public override void SetSeparateSceneBlending( SceneBlendFactor sourceFactor, SceneBlendFactor destFactor, SceneBlendFactor sourceFactorAlpha, SceneBlendFactor destFactorAlpha, SceneBlendOperation op = SceneBlendOperation.Add, SceneBlendOperation alphaOp = SceneBlendOperation.Add ) { if ( sourceFactor == SceneBlendFactor.One && destFactor == SceneBlendFactor.Zero && sourceFactorAlpha == SceneBlendFactor.One && destFactorAlpha == SceneBlendFactor.Zero ) { SetRenderState( RenderState.AlphaBlendEnable, false ); } else { SetRenderState( RenderState.AlphaBlendEnable, true ); SetRenderState( RenderState.SeparateAlphaBlendEnable, true ); SetRenderState( RenderState.SourceBlend, (int)D3DHelper.ConvertEnum( sourceFactor ) ); SetRenderState( RenderState.DestinationBlend, (int)D3DHelper.ConvertEnum( destFactor ) ); SetRenderState( RenderState.SourceBlendAlpha, (int)D3DHelper.ConvertEnum( sourceFactorAlpha ) ); SetRenderState( RenderState.DestinationBlendAlpha, (int)D3DHelper.ConvertEnum( destFactorAlpha ) ); } SetRenderState(RenderState.BlendOperation, (int)D3DHelper.ConvertEnum(op)); SetRenderState(RenderState.BlendOperationAlpha, (int)D3DHelper.ConvertEnum(alphaOp)); }
/// <summary> /// Sets the multipass fallback operation for this layer, if you used TextureUnitState.SetColorOperationEx /// and not enough multitexturing hardware is available. /// </summary> /// <remarks> /// Because some effects exposed using TextureUnitState.SetColorOperationEx are only supported under /// multitexturing hardware, if the hardware is lacking the system must fallback on multipass rendering, /// which unfortunately doesn't support as many effects. This method is for you to specify the fallback /// operation which most suits you. /// <p/> /// You'll notice that the interface is the same as the Material.SetSceneBlending method; this is /// because multipass rendering IS effectively scene blending, since each layer is rendered on top /// of the last using the same mechanism as making an object transparent, it's just being rendered /// in the same place repeatedly to get the multitexture effect. /// <p/> /// If you use the simpler (and hence less flexible) TextureUnitState.SetColorOperation method you /// don't need to call this as the system sets up the fallback for you. /// <p/> /// This option has no effect in the programmable pipeline, because there is no multipass fallback /// and multitexture blending is handled by the fragment shader. /// </remarks> /// <param name="src">How to apply the source color during blending.</param> /// <param name="dest">How to affect the destination color during blending.</param> public void SetColorOpMultipassFallback( SceneBlendFactor src, SceneBlendFactor dest ) { this.colorBlendFallbackSrc = src; this.colorBlendFallbackDest = dest; }
/// <summary> /// Allows very fine control of blending this Pass with the existing contents of the scene. /// </summary> /// <remarks> /// Wheras the texture blending operations seen in the TextureUnitState class are concerned with /// blending between texture layers, this blending is about combining the output of the material /// as a whole with the existing contents of the rendering target. This blending therefore allows /// object transparency and other special effects. /// <p/> /// This version of the method allows complete control over the blending operation, by specifying the /// source and destination blending factors. The result of the blending operation is: /// <span align="center"> /// final = (texture * sourceFactor) + (pixel * destFactor) /// </span> /// <p/> /// Each of the factors is specified as one of a number of options, as specified in the SceneBlendFactor /// enumerated type. /// <p/> /// This method is applicable for both the fixed-function and programmable pipelines. /// </remarks> /// <param name="src">The source factor in the above calculation, i.e. multiplied by the texture color components.</param> /// <param name="dest">The destination factor in the above calculation, i.e. multiplied by the pixel color components.</param> public void SetSceneBlending( SceneBlendFactor src, SceneBlendFactor dest ) { // copy settings _sourceBlendFactor = src; _destinationBlendFactor = dest; }
public void SetSceneBlending(SceneBlendFactor src, SceneBlendFactor dest) { // load each technique for(int i = 0; i < techniques.Count; i++) { ((Technique)techniques[i]).SetSceneBlending(src, dest); } }