public XMaterial(ref XMain X, Texture2D Texture, bool EnableTextureMapping, Texture2D NormalMap, bool EnableNormalMapping, Vector4?DiffuseColor, bool AlphaBlendable, float Specularity) { if (Texture != null) { texture = Texture; } if (NormalMap != null) { normalmap = NormalMap; } if (DiffuseColor != null) { diffuse = DiffuseColor; } else { diffuse = new Vector4(1f, 1f, 1f, 1); } VertexWinding = CullMode.CullCounterClockwiseFace; this.AlphaBlendable = AlphaBlendable; this.EnableTexureMapping = EnableTextureMapping; this.EnableNormalMapping = EnableNormalMapping; this.Specularity = Specularity; }
void DrawBlock( UndoParentNode owner, CullMode cullMode ) { bool guiEnabled = GUI.enabled: GUI.enabled = m_active: EditorGUI.BeginChangeCheck(): { m_reference.IntSlider( ref owner, ReferenceValueContent, 0, 255 ): m_readMask.IntSlider( ref owner, ReadMaskContent, 0, 255 ): m_writeMask.IntSlider( ref owner, WriteMaskContent, 0, 255 ): if( cullMode == CullMode.Off ) { m_comparisonFunctionFrontIdx.EnumTypePopup( ref owner, ComparisonFrontStr, StencilBufferOpHelper.StencilComparisonLabels ): m_passStencilOpFrontIdx.EnumTypePopup( ref owner, PassFrontStr, StencilBufferOpHelper.StencilOpsLabels ): m_failStencilOpFrontIdx.EnumTypePopup( ref owner, FailFrontStr, StencilBufferOpHelper.StencilOpsLabels ): m_zFailStencilOpFrontIdx.EnumTypePopup( ref owner, ZFailFrontStr, StencilBufferOpHelper.StencilOpsLabels ): EditorGUILayout.Separator(): m_comparisonFunctionBackIdx.EnumTypePopup( ref owner, ComparisonBackStr, StencilBufferOpHelper.StencilComparisonLabels ): m_passStencilOpBackIdx.EnumTypePopup( ref owner, PassBackStr, StencilBufferOpHelper.StencilOpsLabels ): m_failStencilOpBackIdx.EnumTypePopup( ref owner, FailBackStr, StencilBufferOpHelper.StencilOpsLabels ): m_zFailStencilOpBackIdx.EnumTypePopup( ref owner, ZFailBackStr, StencilBufferOpHelper.StencilOpsLabels ): } else { m_comparisonFunctionFrontIdx.EnumTypePopup( ref owner, ComparisonStr, StencilBufferOpHelper.StencilComparisonLabels ): m_passStencilOpFrontIdx.EnumTypePopup( ref owner, PassFrontStr, StencilBufferOpHelper.StencilOpsLabels ): m_failStencilOpFrontIdx.EnumTypePopup( ref owner, FailFrontStr, StencilBufferOpHelper.StencilOpsLabels ): m_zFailStencilOpFrontIdx.EnumTypePopup( ref owner, ZFailFrontStr, StencilBufferOpHelper.StencilOpsLabels ): } } if( EditorGUI.EndChangeCheck() ) { m_isDirty = true: } GUI.enabled = guiEnabled: }
/* Private Hashing Functions */ private static StateHash GetRasterizerHash( CullMode cullMode, FillMode fillMode, float depthBias, bool msaa, bool scissor, float slopeScaleDepthBias ) { // Bool -> Int32 conversion int multiSampleAntiAlias = (msaa ? 1 : 0); int scissorTestEnable = (scissor ? 1 : 0); int packedProperties = ((int)multiSampleAntiAlias << 4) | ((int)scissorTestEnable << 3) | ((int)cullMode << 1) | ((int)fillMode); unchecked { return(new StateHash( (ulong)packedProperties, (FloatToULong(slopeScaleDepthBias) << 32) | FloatToULong(depthBias) )); } }
// 这里是在MVP坐标系空间做 public static bool Is_MVP_Culled(CullMode mode, Triangle tri) { if (mode == CullMode.none) { return(false); } Vector3 v1 = tri.p3 - tri.p2; Vector3 v2 = tri.p2 - tri.p1; Vector3 n = Vector3.Cross(v2, v1); Vector3 lookAt = new Vector3(0, 0, 1f); bool isFront = Vector3.Dot(lookAt, n) < 0; switch (mode) { case CullMode.front: { return(isFront); } case CullMode.back: { return(!isFront); } } return(false); }
// Update is called once per frame private IEnumerator ChangeCulling() { UpdateCullMode(); while (true) { yield return(new WaitForSeconds(changeDelay)); switch (cullMode) { case CullMode.Off: cullMode = CullMode.Front; break; case CullMode.Front: cullMode = CullMode.Back; break; case CullMode.Back: cullMode = CullMode.Off; break; } UpdateCullMode(); } }
private void BindCullMode(bool force) { if (force || cullMode != boundCullMode) { var enabled = boundCullMode != CullMode.None; var required = cullMode != CullMode.None; if (force || required != enabled) { if (required) { GL.Enable(EnableCap.CullFace); GLHelper.CheckGLErrors(); } else { GL.Disable(EnableCap.CullFace); GLHelper.CheckGLErrors(); } } if (required) { GL.CullFace((CullFaceMode)GLHelper.GetGLCullFaceMode(cullMode)); GLHelper.CheckGLErrors(); } boundCullMode = cullMode; } }
//Setup all the material properties protected override void SetTexture(Material material, int i) { material.SetTexture("_Texture1", textures[Model.TextureLookup[Model.Skin.Textures[i].Texture]]); if (Model.Skin.Textures[i].TextureCount > 1) { material.SetTexture("_Texture2", textures[Model.TextureLookup[Model.Skin.Textures[i].Texture + 1]]); } if (Model.Skin.Textures[i].TextureCount > 2) { material.SetTexture("_Emission", textures[Model.TextureLookup[Model.Skin.Textures[i].Texture + 2]]); } material.SetInt("_SrcBlend", (int)SrcBlend(Model.Materials[Model.Skin.Textures[i].Material].Blend)); material.SetInt("_DstBlend", (int)DstBlend(Model.Materials[Model.Skin.Textures[i].Material].Blend)); material.SetFloat("_AlphaCut", Model.Materials[Model.Skin.Textures[i].Material].Blend == 1 ? 0.1f : 0f); Color color = Color.white; if (Model.Skin.Textures[i].Color != -1) { color = colors[Model.Skin.Textures[i].Color]; } CullMode cull = (Model.Materials[Model.Skin.Textures[i].Material].Flags & 0x04) != 0 ? CullMode.Off : CullMode.Front; material.SetInt("_Cull", (int)cull); float depth = (Model.Materials[Model.Skin.Textures[i].Material].Flags & 0x10) != 0 ? 0f : 1f; material.SetFloat("_DepthTest", depth); color.a = Model.Transparencies[Model.TransparencyLookup[Model.Skin.Textures[i].Transparency]]; material.SetColor("_Color", color); }
public override void Draw() { GraphicsDevice device = GameContainer.Graphics.GraphicsDevice; Camera cam = Cameras.Current; CullMode previousCullMode = device.RenderState.CullMode; device.RenderState.CullMode = CullMode.CullClockwiseFace; effect.View = cam.View; effect.Projection = cam.Projection; effect.World = transform.World; effect.DiffuseColor = color.ToVector3(); effect.Begin(); foreach (EffectPass pass in effect.CurrentTechnique.Passes) { pass.Begin(); device.VertexDeclaration = vertexDeclaration; device.DrawUserPrimitives(PrimitiveType.TriangleList, vertices, 0, vertices.Length / 3); pass.End(); } effect.End(); device.RenderState.CullMode = previousCullMode; }
/// <summary> /// Dibuja la geometría usando una lista de vértices /// </summary> /// <param name="device">Dispositivo</param> /// <param name="world">Matriz mundo del objeto</param> /// <param name="view">Matriz vista</param> /// <param name="projection">Matriz proyección</param> private void DrawVertexBuffer(GraphicsDevice device, Matrix world, Matrix view, Matrix projection) { FillMode prevFill = device.RenderState.FillMode; device.RenderState.FillMode = fillMode; CullMode prevCull = device.RenderState.CullMode; device.RenderState.CullMode = cullMode; this.SetEffectParams(basicEffect); basicEffect.World = world; basicEffect.View = view; basicEffect.Projection = projection; basicEffect.Begin(); foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes) { pass.Begin(); this.DrawGeometry(device); pass.End(); } basicEffect.End(); device.VertexDeclaration = null; device.RenderState.FillMode = prevFill; device.RenderState.CullMode = prevCull; }
void DrawBlock(UndoParentNode owner, CullMode cullMode) { EditorGUI.BeginChangeCheck(); { m_reference = owner.EditorGUILayoutIntSlider(ReferenceValueContent, m_reference, 0, 255); m_readMask = owner.EditorGUILayoutIntSlider(ReadMaskContent, m_readMask, 0, 255); m_writeMask = owner.EditorGUILayoutIntSlider(WriteMaskContent, m_writeMask, 0, 255); if (cullMode == CullMode.Off) { m_comparisonFunctionIdx = owner.EditorGUILayoutPopup(ComparisonFrontStr, m_comparisonFunctionIdx, StencilBufferOpHelper.StencilComparisonLabels); m_passStencilOpIdx = owner.EditorGUILayoutPopup(PassFrontStr, m_passStencilOpIdx, StencilBufferOpHelper.StencilOpsLabels); m_failStencilOpIdx = owner.EditorGUILayoutPopup(FailFrontStr, m_failStencilOpIdx, StencilBufferOpHelper.StencilOpsLabels); m_zFailStencilOpIdx = owner.EditorGUILayoutPopup(ZFailFrontStr, m_zFailStencilOpIdx, StencilBufferOpHelper.StencilOpsLabels); EditorGUILayout.Separator(); m_comparisonFunctionBackIdx = owner.EditorGUILayoutPopup(ComparisonBackStr, m_comparisonFunctionBackIdx, StencilBufferOpHelper.StencilComparisonLabels); m_passStencilOpBackIdx = owner.EditorGUILayoutPopup(PassBackStr, m_passStencilOpBackIdx, StencilBufferOpHelper.StencilOpsLabels); m_failStencilOpBackIdx = owner.EditorGUILayoutPopup(FailBackStr, m_failStencilOpBackIdx, StencilBufferOpHelper.StencilOpsLabels); m_zFailStencilOpBackIdx = owner.EditorGUILayoutPopup(ZFailBackStr, m_zFailStencilOpBackIdx, StencilBufferOpHelper.StencilOpsLabels); } else { m_comparisonFunctionIdx = owner.EditorGUILayoutPopup(ComparisonStr, m_comparisonFunctionIdx, StencilBufferOpHelper.StencilComparisonLabels); m_passStencilOpIdx = owner.EditorGUILayoutPopup(PassStr, m_passStencilOpIdx, StencilBufferOpHelper.StencilOpsLabels); m_failStencilOpIdx = owner.EditorGUILayoutPopup(FailStr, m_failStencilOpIdx, StencilBufferOpHelper.StencilOpsLabels); m_zFailStencilOpIdx = owner.EditorGUILayoutPopup(ZFailStr, m_zFailStencilOpIdx, StencilBufferOpHelper.StencilOpsLabels); } } if (EditorGUI.EndChangeCheck()) { m_isDirty = true; } }
public static void Cull(CullMode cullMode) { if (_cull != cullMode) { switch (cullMode) { case CullMode.CullClockwiseFace: GL11.FrontFace(All11.Ccw); GL11.CullFace(All11.Back); GL11.Enable(All11.CullFace); break; case CullMode.CullCounterClockwiseFace: GL11.FrontFace(All11.Cw); GL11.CullFace(All11.Back); GL11.Enable(All11.CullFace); break; case CullMode.None: GL11.Disable(All11.CullFace); break; } _cull = cullMode; } }
/// <summary> /// Sets the face culling mode. Is called before the draw call. /// </summary> /// <param name="program">The program.</param> public override void Set(ShaderProgram program) { if (!m_initialized || CullMode != m_currentCullMode) { m_currentCullMode = CullMode; m_initialized = true; switch (m_currentCullMode) { case CullMode.Back: GL.Enable(EnableCap.CullFace); GL.CullFace(CullFaceMode.Back); break; case CullMode.Front: GL.Enable(EnableCap.CullFace); GL.CullFace(CullFaceMode.Front); break; case CullMode.Off: GL.Disable(EnableCap.CullFace); break; } } }
private void processCullMode(ref CullMode mode, JsonObject jo, params string[] args) { var jv = findFirst(jo, args); if (jv.Type == JsonTypes.Number) { var num = (int)jv; switch (num) { case 0: mode = CullMode.None; break; case 1: mode = CullMode.CullClockwiseFace; break; case 2: mode = CullMode.CullCounterClockwiseFace; break; } } else if (jv.Type == JsonTypes.String) { var name = (string)jv; switch (name.ToLower()) { case "0": case "none": mode = CullMode.None; break; case "1": case "clockwise": mode = CullMode.CullClockwiseFace; break; case "2": case "counter": case "counter_clockwide": mode = CullMode.CullCounterClockwiseFace; break; } } }
//Setup all the material properties protected override void SetTexture(Material material, int i) { material.SetTexture("_Texture1", textures[Model.TextureLookup[Model.Skin.Textures[i].Texture]]); if (Model.Skin.Textures[i].TextureCount > 1) { material.SetTexture("_Texture2", textures[Model.TextureLookup[Model.Skin.Textures[i].Texture + 1]]); } if (helper.Emission == null) { material.SetTexture("_Emission", Texture2D.blackTexture); } else if (Model.Textures[Model.TextureLookup[Model.Skin.Textures[i].Texture]].Type == 1) { material.SetTexture("_Emission", helper.Emission); } material.SetInt("_SrcBlend", (int)SrcBlend(Model.Materials[Model.Skin.Textures[i].Material].Blend)); material.SetInt("_DstBlend", (int)DstBlend(Model.Materials[Model.Skin.Textures[i].Material].Blend)); material.SetFloat("_AlphaCut", Model.Materials[Model.Skin.Textures[i].Material].Blend == 1 ? 0.1f : 0f); if (Model.Skin.Textures[i].Color != -1) { material.SetColor("_Color", colors[Model.Skin.Textures[i].Color]); } CullMode cull = (Model.Materials[Model.Skin.Textures[i].Material].Flags & 0x04) != 0 ? CullMode.Off : CullMode.Front; material.SetInt("_Cull", (int)cull); float depth = (Model.Materials[Model.Skin.Textures[i].Material].Flags & 0x10) != 0 ? 0f : 1f; material.SetFloat("_DepthTest", depth); }
public void SetCullMode(CullMode cullMode) { foreach (var renderer in _renderers) { renderer.SetCullMode(cullMode); } }
public override void ReadFromString(ref string[] nodeParams) { base.ReadFromString(ref nodeParams); m_currentSelectedMode = Convert.ToInt32(GetCurrentParam(ref nodeParams)); m_noFog = Convert.ToBoolean(GetCurrentParam(ref nodeParams)); if (UIUtils.CurrentShaderVersion() > 14202) { m_currentAlphaMode = (OutlineAlphaModes)Enum.Parse(typeof(OutlineAlphaModes), GetCurrentParam(ref nodeParams)); } if (UIUtils.CurrentShaderVersion() > 14302) { m_zWriteMode = Convert.ToInt32(GetCurrentParam(ref nodeParams)); m_zTestMode = Convert.ToInt32(GetCurrentParam(ref nodeParams)); } if (UIUtils.CurrentShaderVersion() > 15304) { m_cullMode = (CullMode)Enum.Parse(typeof(CullMode), GetCurrentParam(ref nodeParams)); } SetAdditonalTitleText(string.Format(Constants.SubTitleTypeFormatStr, AvailableOutlineModes[m_currentSelectedMode])); UpdatePorts(); CheckAlphaPortVisibility(); }
private void Update(EvaluationContext context) { RasterizerState.Value?.Dispose(); var rasterizerDesc = new RasterizerStateDescription() { CullMode = CullMode.GetValue(context), DepthBias = DepthBias.GetValue(context), DepthBiasClamp = DepthBiasClamp.GetValue(context), FillMode = FillMode.GetValue(context), IsAntialiasedLineEnabled = AntialiasedLineEnabled.GetValue(context), IsDepthClipEnabled = DepthClipEnabled.GetValue(context), IsFrontCounterClockwise = FrontCounterClockwise.GetValue(context), IsMultisampleEnabled = MultiSampleEnabled.GetValue(context), IsScissorEnabled = ScissorEnabled.GetValue(context), SlopeScaledDepthBias = SlopeScaledDepthBias.GetValue(context) }; try { RasterizerState.Value = new RasterizerState(ResourceManager.Instance().Device, rasterizerDesc); // todo: put into resource manager } catch (Exception e) { Log.Error("Failed to create rasterizer state: " + e.Message); } }
public D3D11RasterizerState(D3D11GraphicsDevice graphicsDevice, CullMode cullMode, FillMode fillMode, bool isDepthEnabled, bool isScissorEnabled, bool isMultiSampleEnabled, bool isAntialiasedLineEnabled) { _graphicsDevice = graphicsDevice; CullMode = cullMode; FillMode = fillMode; _nativeRasterizerState = CreateRasterizerState(isDepthEnabled, isScissorEnabled, isMultiSampleEnabled, isAntialiasedLineEnabled); }
RenderableComponent(CullMode cullMode, PrimitiveTopology primitiveTopology, RenderTechniques technique) : this() { CullMode = cullMode; PrimitiveTopology = primitiveTopology; Technique = technique; IsRenderable = true; }
private static RasterizerState Create(Device5 device, string name, FillMode fillMode, CullMode cullMode, bool depthClipEnabled, bool scissorEnabled, bool multiSampleEnabled) { return(new RasterizerState( device, new RasterizerStateDescription { FillMode = fillMode, CullMode = cullMode, IsFrontCounterClockwise = false, DepthBias = 0, DepthBiasClamp = 0, SlopeScaledDepthBias = 0, IsDepthClipEnabled = depthClipEnabled, IsScissorEnabled = scissorEnabled, IsMultisampleEnabled = multiSampleEnabled, IsAntialiasedLineEnabled = multiSampleEnabled }) { DebugName = name }); }
public RasterState(CullMode cullingMode = CullMode.Back, int offsetUnits = 0, float offsetFactor = 0f, bool depthClip = true) { this.m_CullingMode = cullingMode; this.m_OffsetUnits = offsetUnits; this.m_OffsetFactor = offsetFactor; this.m_DepthClip = Convert.ToByte(depthClip); }
public XMaterial(ref XMain X, string Texture, bool EnableTextureMapping, string NormalMap, bool EnableNormalMapping, Vector4?DiffuseColor, bool AlphaBlendable, float Specularity) { if (!string.IsNullOrEmpty(Texture)) { texture = X.Content.Load <Texture2D>(Texture); } if (!string.IsNullOrEmpty(NormalMap)) { normalmap = X.Content.Load <Texture2D>(NormalMap); } if (DiffuseColor != null) { diffuse = DiffuseColor; } else { diffuse = new Vector4(1f, 1f, 1f, 1); } VertexWinding = CullMode.CullCounterClockwiseFace; this.AlphaBlendable = AlphaBlendable; this.EnableTexureMapping = EnableTextureMapping; this.EnableNormalMapping = EnableNormalMapping; this.Specularity = Specularity; }
public Material(Material src) { Flag = src.Flag; ColorChannelControlsCount = src.ColorChannelControlsCount; NumTevStagesCount = src.NumTevStagesCount; NumTexGensCount = src.NumTexGensCount; CullMode = src.CullMode; ZCompLoc = src.ZCompLoc; Dither = src.Dither; TextureIndices = src.TextureIndices; TextureNames = src.TextureNames; IndTexEntry = src.IndTexEntry; MaterialColors = src.MaterialColors; ChannelControls = src.ChannelControls; AmbientColors = src.AmbientColors; LightingColors = src.LightingColors; TexCoord1Gens = src.TexCoord1Gens; PostTexCoordGens = src.PostTexCoordGens; TexMatrix1 = src.TexMatrix1; PostTexMatrix = src.PostTexMatrix; TevOrders = src.TevOrders; ColorSels = src.ColorSels; AlphaSels = src.AlphaSels; TevColors = src.TevColors; KonstColors = src.KonstColors; TevStages = src.TevStages; SwapModes = src.SwapModes; SwapTables = src.SwapTables; FogInfo = src.FogInfo; AlphCompare = src.AlphCompare; BMode = src.BMode; ZMode = src.ZMode; NBTScale = src.NBTScale; }
public static void DoCull(Material material, bool twoSided) { CullMode cull = twoSided ? CullMode.Off : CullMode.Back; material.SetInt("_Cull", (int)cull); material.doubleSidedGI = twoSided; }
private RasterizerState(string name, CullMode cullMode) : this() { Name = name; _cullMode = cullMode; _defaultStateObject = true; }
/// <summary> /// /// </summary> /// <param name="cullMode">Default is CullMode.None</param> /// <param name="fillMode">Default is FillMode.WireFrame</param> /// <param name="vertexColorsEnabled">Default is true.</param> public void Draw(Matrix world, Matrix cameraView, Matrix cameraProjection, CullMode cullMode, FillMode fillMode, bool vertexColorsEnabled) { // I had to make a localRS because assigning directly to the graphicsDevice.RasterizerState.properties // didn't work. RasterizerState localRS = new RasterizerState(); localRS.CullMode = cullMode; localRS.FillMode = fillMode; graphicsDevice.RasterizerState = localRS; // Effect configuration effect.World = world; effect.View = cameraView; effect.Projection = cameraProjection; effect.VertexColorEnabled = vertexColorsEnabled; foreach (EffectPass pass in effect.CurrentTechnique.Passes) { pass.Apply(); graphicsDevice.DrawUserIndexedPrimitives <VertexPositionColor>( PrimitiveType.LineList, verts, 0, 2, vertexIndicies, 0, 1); } }
public override void Draw() { GraphicsDevice device = GameContainer.Graphics.GraphicsDevice; CullMode previousCullMode = device.RenderState.CullMode; device.RenderState.CullMode = CullMode.None; device.RenderState.AlphaBlendEnable = true; device.RenderState.SourceBlend = Blend.SourceAlpha; device.RenderState.DestinationBlend = Blend.InverseSourceAlpha; effect.View = Cameras.Current.View; effect.Projection = Cameras.Current.Projection; effect.World = transform.World; effect.DiffuseColor = color.ToVector3(); effect.Alpha = alpha; effect.Begin(); foreach (EffectPass pass in effect.CurrentTechnique.Passes) { pass.Begin(); device.VertexDeclaration = vertexDeclaration; device.DrawUserPrimitives(PrimitiveType.TriangleList, vertices, 0, vertices.Length / 3); pass.End(); } effect.End(); device.RenderState.CullMode = previousCullMode; }
public void Draw(UndoParentNode owner, CullMode cullMode) { bool foldoutValue = EditorVariablesManager.ExpandedStencilOptions.Value; NodeUtils.DrawPropertyGroup(ref foldoutValue, FoldoutLabelStr, () => { m_reference = owner.EditorGUILayoutIntSlider(ReferenceValueContent, m_reference, 0, 255); m_readMask = owner.EditorGUILayoutIntSlider(ReadMaskContent, m_readMask, 0, 255); m_writeMask = owner.EditorGUILayoutIntSlider(WriteMaskContent, m_writeMask, 0, 255); if (cullMode == CullMode.Off) { m_comparisonFunctionIdx = owner.EditorGUILayoutPopup(ComparisonFrontStr, m_comparisonFunctionIdx, StencilBufferOpHelper.StencilComparisonLabels); m_passStencilOpIdx = owner.EditorGUILayoutPopup(PassFrontStr, m_passStencilOpIdx, StencilBufferOpHelper.StencilOpsLabels); m_failStencilOpIdx = owner.EditorGUILayoutPopup(FailFrontStr, m_failStencilOpIdx, StencilBufferOpHelper.StencilOpsLabels); m_zFailStencilOpIdx = owner.EditorGUILayoutPopup(ZFailFrontStr, m_zFailStencilOpIdx, StencilBufferOpHelper.StencilOpsLabels); EditorGUILayout.Separator(); m_comparisonFunctionBackIdx = owner.EditorGUILayoutPopup(ComparisonBackStr, m_comparisonFunctionBackIdx, StencilBufferOpHelper.StencilComparisonLabels); m_passStencilOpBackIdx = owner.EditorGUILayoutPopup(PassBackStr, m_passStencilOpBackIdx, StencilBufferOpHelper.StencilOpsLabels); m_failStencilOpBackIdx = owner.EditorGUILayoutPopup(FailBackStr, m_failStencilOpBackIdx, StencilBufferOpHelper.StencilOpsLabels); m_zFailStencilOpBackIdx = owner.EditorGUILayoutPopup(ZFailBackStr, m_zFailStencilOpBackIdx, StencilBufferOpHelper.StencilOpsLabels); } else { m_comparisonFunctionIdx = owner.EditorGUILayoutPopup(ComparisonStr, m_comparisonFunctionIdx, StencilBufferOpHelper.StencilComparisonLabels); m_passStencilOpIdx = owner.EditorGUILayoutPopup(PassStr, m_passStencilOpIdx, StencilBufferOpHelper.StencilOpsLabels); m_failStencilOpIdx = owner.EditorGUILayoutPopup(FailStr, m_failStencilOpIdx, StencilBufferOpHelper.StencilOpsLabels); m_zFailStencilOpIdx = owner.EditorGUILayoutPopup(ZFailStr, m_zFailStencilOpIdx, StencilBufferOpHelper.StencilOpsLabels); } }); EditorVariablesManager.ExpandedStencilOptions.Value = foldoutValue; }
// 判断是否需要Cull(这里是世界坐标剔除) public static bool IsCulled(SoftCamera camera, CullMode mode, Triangle tri) { if (mode == CullMode.none) { return(false); } if (camera == null) { return(true); } Vector3 v1 = tri.p3 - tri.p2; Vector3 v2 = tri.p2 - tri.p1; Vector3 n = Vector3.Cross(v1, v2); Vector3 lookAt = camera.LookAt; bool isFront = Vector3.Dot(lookAt, n) < 0; switch (mode) { case CullMode.front: { return(isFront); } case CullMode.back: { return(!isFront); } } return(false); }
private RasterizerState( string name, CullMode cullMode ) : this() { Name = name; CullMode = cullMode; }
public RasterizerState GetCullBackRasterizerState(DXDevice device, CullMode cullMode) { RasterizerState state; if (rasterizerStates.TryGetValue(cullMode, out state)) return state; var newState = new RasterizerState(device, GetRasterizer(cullMode)); rasterizerStates.Add(cullMode, newState); return newState; }
private SharpDX.Direct3D11.CullMode ConvertToCullMode( CullMode value ) { switch ( value ) { case CullMode.None: return SharpDX.Direct3D11.CullMode.None; case CullMode.ClockWise: return SharpDX.Direct3D11.CullMode.Front; case CullMode.CounterClockWise: return SharpDX.Direct3D11.CullMode.Back; default: throw new ArgumentException (); } }
public static All OpenGL11(CullMode cull) { switch (cull) { case CullMode.CullClockwiseFace: return All.Cw; case CullMode.CullCounterClockwiseFace: return All.Ccw; default: throw new NotImplementedException(); } }
/// <summary> /// Creates a new instance of the rasterizer state. /// </summary> /// <param name="cullMode"></param> /// <param name="fillMode"></param> /// <param name="depthBias"></param> /// <param name="slopeDepthBias"></param> /// <returns></returns> public static RasterizerState Create ( CullMode cullMode, FillMode fillMode = FillMode.Solid, int depthBias = 0, float slopeDepthBias = 0 ) { var rs = new RasterizerState(); rs.CullMode = cullMode; rs.DepthBias = depthBias; rs.SlopeDepthBias = slopeDepthBias; rs.MsaaEnabled = true; rs.FillMode = fillMode; rs.DepthClipEnabled = true; rs.ScissorEnabled = false; return rs; }
public Spatial () { // TODO: This should have a unique number suffic across all of the same types. name = this.GetType ().Name; parent = null; localTransformation = new Transformation (); worldTransformation = new Transformation (); spatialState = State.UPDATE_LOCAL_BOUND; cullMode = CullMode.INHERIT; }
public static CullFaceMode GetCullMode(CullMode cullMode) { switch (cullMode) { case CullMode.Front: return CullFaceMode.Front; case CullMode.Back: return CullFaceMode.Back; case CullMode.None: default: return CullFaceMode.FrontAndBack; } }
/// <summary> /// Sets default values for this instance. /// </summary> public void SetDefault() { CullMode = CullMode.Back; FillMode = FillMode.Solid; DepthClipEnable = true; FrontFaceCounterClockwise = false; ScissorTestEnable = false; MultiSampleAntiAlias = false; MultiSampleAntiAliasLine = false; DepthBias = 0; DepthBiasClamp = 0f; SlopeScaleDepthBias = 0f; }
public static Cull MapFrom(CullMode cullMode) { switch (cullMode) { case CullMode.None: return Cull.None; case CullMode.CW: return Cull.Clockwise; case CullMode.CCW: return Cull.Counterclockwise; default: throw new ArgumentOutOfRangeException("cullMode"); } }
public void VisualTestCullMode(CullMode cullMode) { Game.Components.Add(new Colored3DCubeComponent(Game)); Game.PreDrawWith += (sender, e) => { Game.GraphicsDevice.RasterizerState = new RasterizerState { CullMode = cullMode }; }; RunSingleFrameTest(); }
public static CullModeFlags ConvertCullMode(CullMode cullMode) { // NOTE: Vulkan's CullModeFlags.FrontAndBack is not exposed switch (cullMode) { case CullMode.Back: return CullModeFlags.Back; case CullMode.Front: return CullModeFlags.Front; case CullMode.None: return CullModeFlags.None; default: throw new ArgumentOutOfRangeException(nameof(cullMode)); } }
private static RasterizerStateDescription GetRasterizer(CullMode cullMode) { var rasterizerDescription = new RasterizerStateDescription { CullMode = cullMode, FillMode = FillMode.Solid, IsFrontCounterClockwise = true, DepthBias = 0, DepthBiasClamp = 0.0f, SlopeScaledDepthBias = 0.0f, IsDepthClipEnabled = true, IsScissorEnabled = false, //IsMultisampleEnabled = true, //IsAntialiasedLineEnabled = false }; return rasterizerDescription; }
public static void Cull(CullMode cullMode) { if (_cull != cullMode) { switch(cullMode) { case CullMode.CullClockwiseFace: GL11.FrontFace(All11.Ccw); GL11.CullFace(All11.Back); GL11.Enable(All11.CullFace); break; case CullMode.CullCounterClockwiseFace: GL11.FrontFace(All11.Cw); GL11.CullFace(All11.Back); GL11.Enable(All11.CullFace); break; case CullMode.None: GL11.Disable(All11.CullFace); break; } _cull = cullMode; } }
/// <summary> /// specify whether front- or back-facing facets can be culled /// </summary> /// <param name="mode">Specifies whether front- or back-facing facets are candidates for culling. Symbolic constants GL_FRONT, GL_BACK, and GL_FRONT_AND_BACK are accepted. The initial value is GL_BACK.</param> /// <remarks> /// glCullFace specifies whether front- or back-facing facets are culled (as specified by mode) when facet culling is enabled. Facet culling is initially disabled. To enable and disable facet culling, call the glEnable and glDisable commands with the argument GL_CULL_FACE. Facets include triangles, quadrilaterals, polygons, and rectangles. /// glFrontFace specifies which of the clockwise and counterclockwise facets are front-facing and back-facing. See glFrontFace. /// </remarks> public static void CullFace(CullMode mode) { Delegates.glCullFace(mode); }
internal static RasterizerState New(GraphicsDevice device, string name, CullMode mode) { var description = RasterizerStateDescription.Default(); description.CullMode = mode; var state = New(device, description); state.Name = name; return state; }
public void SetSceneCullMode(CullMode mode) { sceneCullMode = mode; }
private RasterizerState(RasterizerState cloneSource) { Name = cloneSource.Name; _cullMode = cloneSource._cullMode; _fillMode = cloneSource._fillMode; _depthBias = cloneSource._depthBias; _multiSampleAntiAlias = cloneSource._multiSampleAntiAlias; _scissorTestEnable = cloneSource._scissorTestEnable; _slopeScaleDepthBias = cloneSource._slopeScaleDepthBias; _depthClipEnable = cloneSource._depthClipEnable; }
public override bool OnInitialize() { MDL0Material* header = Header; _initVersion = header->_pad != 0 && _replaced ? header->_pad : Model._version; if ((_name == null) && (header->_stringOffset != 0)) _name = header->ResourceString; XFCmds.Clear(); //Get XF Commands byte* pData = (byte*)header->DisplayLists(Model._version) + 0xE0; Top: if (*pData++ == 0x10) { XFData dat = new XFData(); int count = (ushort)*(bushort*)pData; pData += 2; dat.addr = (XFMemoryAddr)(ushort)*(bushort*)pData; pData += 2; dat.values = new List<uint>(); for (int i = 0; i < count + 1; i++) { dat.values.Add(*(buint*)pData); pData += 4; } XFCmds.Add(dat); goto Top; } _mdl0Offset = header->_mdl0Offset; _stringOffset = header->_stringOffset; _userDataOffset = header->UserDataOffset(_initVersion); _shaderOffset = header->_shaderOffset; _dlOffset = header->DisplayListOffset(_initVersion); _furDataOffset = header->FurDataOffset(_initVersion); _matRefOffset = header->_matRefOffset; _pad = header->_pad; _dataLen = header->_dataLen; _numTextures = header->_numTexGens; _numLights = header->_numLightChans; _usageFlags = new Bin32(header->_usageFlags); _indirectMethod1 = header->_indirectMethod1; _indirectMethod2 = header->_indirectMethod2; _indirectMethod3 = header->_indirectMethod3; _indirectMethod4 = header->_indirectMethod4; _normMapRefLight1 = header->_normMapRefLight1; _normMapRefLight2 = header->_normMapRefLight2; _normMapRefLight3 = header->_normMapRefLight3; _normMapRefLight4 = header->_normMapRefLight4; _ssc = header->_activeTEVStages; _clip = header->_numIndTexStages; _transp = header->_enableAlphaTest; _lSet = header->_lightSet; _fSet = header->_fogSet; _cull = (CullMode)(int)header->_cull; if ((-header->_mdl0Offset + (int)header->DisplayListOffset(_initVersion)) % 0x20 != 0) { Model._errors.Add("Material " + Index + " has an improper align offset."); SignalPropertyChange(); } mode = header->DisplayLists(_initVersion); _alphaFunc = mode->AlphaFunction; _zMode = mode->ZMode; _blendMode = mode->BlendMode; _constantAlpha = mode->ConstantAlpha; _tevColorBlock = *header->TevColorBlock(_initVersion); _tevKonstBlock = *header->TevKonstBlock(_initVersion); _indMtx = *header->IndMtxBlock(_initVersion); MDL0TexSRTData* TexMatrices = header->TexMatrices(_initVersion); _layerFlags = TexMatrices->_layerFlags; _texMtxFlags = TexMatrices->_mtxFlags; MDL0MaterialLighting* Light = header->Light(_initVersion); (_chan1 = Light->Channel1)._parent = this; (_chan2 = Light->Channel2)._parent = this; c1 = CReg2Color; c2 = CReg2Color; c3 = CReg2Color; k1 = KReg0Color; k2 = KReg1Color; k3 = KReg2Color; k3 = KReg3Color; clr1 = C1MaterialColor; clr2 = C2MaterialColor; amb1 = C1AmbientColor; amb2 = C2AmbientColor; (_userEntries = new UserDataCollection()).Read(header->UserData(_initVersion)); return true; }
public ShipGeometryBuffer(int numIndicies, int numVerticies, int numPrimitives, string textureName, CullMode cullMode = CullMode.None) : base(numIndicies, numVerticies, numPrimitives, textureName) { BufferRasterizer = new RasterizerState(); BufferRasterizer.CullMode = cullMode; }
public static void SetupMaterial(Material material, BlendMode blendMode, CullMode cullMode) { switch (blendMode) { case BlendMode.Opaque: material.SetOverrideTag("RenderType", ""); material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One); material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero); material.SetInt("_CullMode", (int)cullMode); material.SetInt("_ZWrite", 1); material.DisableKeyword("_ALPHATEST_ON"); material.DisableKeyword("_ALPHABLEND_ON"); material.DisableKeyword("_ALPHAPREMULTIPLY_ON"); material.renderQueue = -1; break; case BlendMode.Cutout: material.SetOverrideTag("RenderType", "TransparentCutout"); material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One); material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero); material.SetInt("_CullMode", (int)cullMode); material.SetInt("_ZWrite", 1); material.EnableKeyword("_ALPHATEST_ON"); material.DisableKeyword("_ALPHABLEND_ON"); material.DisableKeyword("_ALPHAPREMULTIPLY_ON"); material.renderQueue = 2450; break; case BlendMode.Fade: material.SetOverrideTag("RenderType", "Transparent"); material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha); material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha); material.SetInt("_CullMode", (int)cullMode); material.SetInt("_ZWrite", 0); material.DisableKeyword("_ALPHATEST_ON"); material.EnableKeyword("_ALPHABLEND_ON"); material.DisableKeyword("_ALPHAPREMULTIPLY_ON"); material.renderQueue = 3000; break; case BlendMode.Transparent: material.SetOverrideTag("RenderType", "Transparent"); material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One); material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha); material.SetInt("_CullMode", (int)cullMode); material.SetInt("_ZWrite", 0); material.DisableKeyword("_ALPHATEST_ON"); material.DisableKeyword("_ALPHABLEND_ON"); material.EnableKeyword("_ALPHAPREMULTIPLY_ON"); material.renderQueue = 3000; break; } }
private static CullFaceMode GetCullMode(CullMode cullMode) { switch (cullMode) { case CullMode.Front: return CullFaceMode.Front; case CullMode.Back: return CullFaceMode.Back; default: return CullFaceMode.Back; // not used if CullMode.None } }
//property.Expanded = EditorGUILayout.Foldout( property.Expanded, property.GetPropertyType().PropertyTypeString() ); public void Draw() { var shaderNameContent = new GUIContent( "Shader Name", "Name for shader. Includes the hierarchy listing, that is, MyShaders/Shader will be in a folder called \"MyShaders\" in the shader selection dropdown. Also used when referring to fallback shaders."); var oldColor = GUI.color; if( string.IsNullOrEmpty(_shaderName ) ) { GUI.color = Color.red; } _shaderName.Value = EditorGUILayout.TextField(shaderNameContent, _shaderName.Value); GUI.color = oldColor; var shaderFallbackContent = new GUIContent( "Shader Fallback", "Fallback shader to use in case this shader can not be used."); _shaderFallback.Value = EditorGUILayout.TextField( shaderFallbackContent, _shaderFallback.Value ); var targetContent = new GUIContent("Shader Model","Requires more recent hardware to use the shader, but allows for more instructions, texture reads, and more input information."); _shaderTarget = (ShaderTarget)EditorGUILayout.EnumPopup( targetContent, _shaderTarget ); var excludePathContent = new GUIContent("Exclude Path","Exclude a renderpath from shader generation"); _excludePath = (ExcludePath)EditorGUILayout.EnumPopup( excludePathContent, _excludePath ); GUILayout.Space(8); _showQueueSettings = EditorGUILayout.Foldout( _showQueueSettings, "Queue Settings" ); if( _showQueueSettings ) { var renderTypeContent = new GUIContent("Render Type","This is the rendertype tag inserted into the shader. Can be used for shader replace"); _renderType = (RenderType)EditorGUILayout.EnumPopup( renderTypeContent, _renderType ); if ( _renderType == RenderType.Custom ) _renderTypeCustom.Value = EditorGUILayout.TextField( "Custom Type" ,_renderTypeCustom.Value ); var queueContent = new GUIContent("Render Queue","The render queue that this material will be put in"); _queue = (Queue)EditorGUILayout.EnumPopup( queueContent, _queue ); var offContent = new GUIContent( "Queue Offset", "Offset for drawing. Used to ensure some things draw before or after others, it specifically is an offset from the given queue- That is to say, you won't have a transparent object draw before an opaque object (or similar) due to this offset."); _queueAdjust = EditorGUILayout.IntSlider(offContent, _queueAdjust.Value, -100, 100); } GUILayout.Space( 8 ); _showCullingAndDepthSettings = EditorGUILayout.Foldout( _showCullingAndDepthSettings, "Culling and Depth Settings" ); if( _showCullingAndDepthSettings ) { var zWriteContent = new GUIContent("Write Depth","Depth is considered when testing other objects. Disable for certain effects, like letting other things draw over yourself, or for speed on most overlays."); _zWrite = (ZWrite)EditorGUILayout.EnumPopup( zWriteContent, _zWrite ); var cullModeContent = new GUIContent("CullMode","Select back / forward to clip backwards facing polygons"); _cullMode = (CullMode)EditorGUILayout.EnumPopup( cullModeContent, _cullMode ); var zTestContent = new GUIContent("ZTest","Select Z-Test Value"); _zTest = (ZTest)EditorGUILayout.EnumPopup( zTestContent, _zTest ); var enableLODContent = new GUIContent("Enable LOD","Enable Shader LOD scaling"); _enableLOD = EditorGUILayout.BeginToggleGroup( enableLODContent, _enableLOD ); _lod = EditorGUILayout.IntSlider( "LOD", _lod, 0, 1000 ); EditorGUILayout.EndToggleGroup(); } GUILayout.Space( 8 ); _showBlending = EditorGUILayout.Foldout( _showBlending, "Blending Settings" ); if( _showBlending ) { var blendingTypeContent = new GUIContent("Blend Type","Use a build in blend mode or a custom blend mode"); _blending = (BlendingType)EditorGUILayout.EnumPopup( blendingTypeContent, _blending ); if( CustomBlendingEnabled() ) { var srcBlendContent = new GUIContent("Src Blend Mode","How the source channel of blending is used"); _srcBlend = (BlendingMode)EditorGUILayout.EnumPopup( srcBlendContent, _srcBlend ); var dstBlendContent = new GUIContent("Dst Blend Mode","How the destination channel of blending is used"); _dstBlend = (BlendingMode)EditorGUILayout.EnumPopup( dstBlendContent, _dstBlend ); } } GUILayout.Space( 8 ); _showColorAndLighting = EditorGUILayout.Foldout( _showColorAndLighting, "Color And Lighting Settings" ); if( _showColorAndLighting ) { GUILayout.BeginHorizontal(); GUILayout.Label( "Color Mask:", GUILayout.ExpandWidth(false) ); _colorMaskR.Value = EditorExtensions.ToggleButton( _colorMaskR.Value, "R","Mask R Channel"); _colorMaskG.Value = EditorExtensions.ToggleButton( _colorMaskG.Value, "G","Mask G Channel"); _colorMaskB.Value = EditorExtensions.ToggleButton( _colorMaskB.Value, "B","Mask B Channel"); _colorMaskA.Value = EditorExtensions.ToggleButton( _colorMaskA.Value, "A","Mask A Channel"); GUILayout.EndHorizontal(); _dualForward = GUILayout.Toggle( _dualForward, new GUIContent( "Forward Dual Lightmaps","Use dual lightmaps in the forward rendering path" )); _fullForwardShadows = GUILayout.Toggle( _fullForwardShadows, new GUIContent( "Forward Full Shadows", "Support all shadow types in Forward rendering path." )); _softVegetation = GUILayout.Toggle( _softVegetation, new GUIContent( "Soft Vegetation", "Makes the surface shader only be rendered when Soft Vegetation is on." )); _noAmbient = GUILayout.Toggle( _noAmbient, new GUIContent( "No Ambient", "Do not apply any ambient lighting or spherical harmonics lights.")); _noLightmap = GUILayout.Toggle( _noLightmap, new GUIContent( "No Lightmaps", "Disables lightmap support in this shader (makes a shader smaller)." )); _addShadow = GUILayout.Toggle( _addShadow, new GUIContent( "Advanced Shadow Pass", "Performs vertex transformations and clipping for the shadow pass, you need to use this if shadows do not display properly." )); _ignoreProjectors = GUILayout.Toggle( _ignoreProjectors, new GUIContent( "Ignore Projectors", "Ignores projector components, should be used if your doing custom vertex transformations or most transparency" )); _approxview = GUILayout.Toggle( _approxview, new GUIContent( "Approximate View", "Computes normalized view direction per-vertex instead of per-pixel, for shaders that need it. This is faster, but view direction is not entirely correct when camera gets close to surface." )); _halfasview = GUILayout.Toggle( _halfasview, new GUIContent( "Half As View", "Pass half-direction vector into the lighting function instead of view-direction. Half-direction will be computed and normalized per vertex. This is faster, but not entirely correct." )); _noForwardAdd = GUILayout.Toggle( _noForwardAdd, new GUIContent( "Disable Forward Add", "Disables Forward rendering additive pass. This makes the shader support one full directional light, with all other lights computed per-vertex/SH. Makes shaders smaller as well." )); } GUILayout.Space( 8 ); _showFogSettings = EditorGUILayout.Foldout( _showFogSettings, "Fog Settings" ); if( _showFogSettings ) { _fogModeOverride = EditorGUILayout.BeginToggleGroup( "Fog Mode Override", _fogModeOverride ); var fogModeContent = new GUIContent("Fog Mode","The type of fog to use"); _fogMode = (FogMode)EditorGUILayout.EnumPopup( fogModeContent, _fogMode ); if( _fogMode == FogMode.Linear ) { _fogNearLinear.Value = EditorGUILayout.FloatField( "Near Linear Range:", _fogNearLinear ); _fogFarLinear.Value = EditorGUILayout.FloatField( "Far Linear Range:", _fogFarLinear ); } EditorGUILayout.EndToggleGroup(); _fogColorOverride = EditorGUILayout.BeginToggleGroup( "Fog Color Override", _fogColorOverride ); _fogColor.Value = EditorGUILayout.ColorField("Fog Color:", _fogColor ); EditorGUILayout.EndToggleGroup(); _fogDensityOverride = EditorGUILayout.BeginToggleGroup( "Fog Density Override", _fogDensityOverride ); _fogDensity.Value = EditorGUILayout.FloatField( "Fog Density:", _fogDensity ); EditorGUILayout.EndToggleGroup(); } }
public void ApplyRasterizerState( RasterizerState rasterizerState, bool renderTargetBound ) { if (rasterizerState.ScissorTestEnable != scissorTestEnable) { scissorTestEnable = rasterizerState.ScissorTestEnable; ToggleGLState(GLenum.GL_SCISSOR_TEST, scissorTestEnable); } CullMode actualMode; if (renderTargetBound) { actualMode = rasterizerState.CullMode; } else { // When not rendering offscreen the faces change order. if (rasterizerState.CullMode == CullMode.None) { actualMode = rasterizerState.CullMode; } else { actualMode = ( rasterizerState.CullMode == CullMode.CullClockwiseFace ? CullMode.CullCounterClockwiseFace : CullMode.CullClockwiseFace ); } } if (actualMode != cullFrontFace) { if ((actualMode == CullMode.None) != (cullFrontFace == CullMode.None)) { ToggleGLState(GLenum.GL_CULL_FACE, actualMode != CullMode.None); } cullFrontFace = actualMode; if (cullFrontFace != CullMode.None) { glFrontFace(XNAToGL.FrontFace[(int) cullFrontFace]); } } if (rasterizerState.FillMode != fillMode) { fillMode = rasterizerState.FillMode; glPolygonMode( GLenum.GL_FRONT_AND_BACK, XNAToGL.GLFillMode[(int) fillMode] ); } // FIXME: Floating point equality comparisons used for speed -flibit float realDepthBias = rasterizerState.DepthBias * XNAToGL.DepthBiasScale[ renderTargetBound ? (int) currentDepthStencilFormat : (int) Backbuffer.DepthFormat ]; if ( realDepthBias != depthBias || rasterizerState.SlopeScaleDepthBias != slopeScaleDepthBias ) { if ( realDepthBias == 0.0f && rasterizerState.SlopeScaleDepthBias == 0.0f) { // We're changing to disabled bias, disable! glDisable(GLenum.GL_POLYGON_OFFSET_FILL); } else { if (depthBias == 0.0f && slopeScaleDepthBias == 0.0f) { // We're changing away from disabled bias, enable! glEnable(GLenum.GL_POLYGON_OFFSET_FILL); } glPolygonOffset( rasterizerState.SlopeScaleDepthBias, realDepthBias ); } depthBias = realDepthBias; slopeScaleDepthBias = rasterizerState.SlopeScaleDepthBias; } /* FIXME: This doesn't actually work on like 99% of setups! * For whatever reason people decided that they didn't have to obey * GL_MULTISAMPLE's value when it was disabled. * * If they could do it for D3D9 I fail to see why they couldn't for * OpenGL. Idiots. * * -flibit */ if (rasterizerState.MultiSampleAntiAlias != multiSampleEnable) { multiSampleEnable = rasterizerState.MultiSampleAntiAlias; ToggleGLState(GLenum.GL_MULTISAMPLE, multiSampleEnable); } }
public static extern void glCullFace(CullMode mode);
/// <summary> /// Retrieves a rasterize state by using the cull mode as a lookup /// </summary> /// <param name="cullMode">The cullmode used to lookup the rasterize state</param> /// <returns></returns> private static RasterizerState RasterizerStateGetFromCullMode(CullMode cullMode) { switch (cullMode) { case (CullMode.CullCounterClockwiseFace): return RasterizerState.CullCounterClockwise; case (CullMode.CullClockwiseFace): return RasterizerState.CullClockwise; default: return RasterizerState.CullNone; } }
/// <summary> /// Initializes a new instance of the <see cref="RasterizerStateDescription"/> class. /// </summary> /// <param name="cullMode">The cull mode.</param> public RasterizerStateDescription(CullMode cullMode) : this() { SetDefault(); CullMode = cullMode; }
public void UpdateAsMetal() { if (!isMetal) return; _updating = true; if (ShaderNode != null && ShaderNode._autoMetal && ShaderNode.texCount == Children.Count) { //ShaderNode.DefaultAsMetal(Children.Count); } else { bool found = false; foreach (MDL0ShaderNode s in Model._shadGroup.Children) { if (s._autoMetal && s.texCount == Children.Count) { ShaderNode = s; found = true; } else { if (s._stages == 4) { foreach (MDL0MaterialNode y in s._materials) if (!y.isMetal || y.Children.Count != Children.Count) goto NotFound; ShaderNode = s; found = true; goto End; NotFound: continue; } } } End: if (!found) { MDL0ShaderNode shader = new MDL0ShaderNode(); Model._shadGroup.AddChild(shader); shader.DefaultAsMetal(Children.Count); ShaderNode = shader; } } if (MetalMaterial != null) { Name = MetalMaterial.Name + "_ExtMtl"; _ssc = 4; if (Children.Count - 1 != MetalMaterial.Children.Count) { //Remove all children for (int i = 0; i < Children.Count; i++) { ((MDL0MaterialRefNode)Children[i]).TextureNode = null; ((MDL0MaterialRefNode)Children[i]).PaletteNode = null; RemoveChild(Children[i--]); } //Start over for (int i = 0; i <= MetalMaterial.Children.Count; i++) { MDL0MaterialRefNode mr = new MDL0MaterialRefNode(); AddChild(mr); mr.Texture = "metal00"; mr._index1 = mr._index2 = i; mr._texFlags.TexScale = new Vector2(1); mr._bindState._scale = new Vector3(1); mr._texMatrix.TexMtx = Matrix43.Identity; mr._texMatrix.SCNCamera = -1; mr._texMatrix.SCNLight = -1; mr._texMatrix.Identity = 1; if (i == MetalMaterial.Children.Count) { mr._minFltr = 5; mr._magFltr = 1; mr._lodBias = -2; mr.HasTextureMatrix = true; mr._projection = (int)TexProjection.STQ; mr._inputForm = (int)TexInputForm.ABC1; mr._sourceRow = (int)TexSourceRow.Normals; mr.Normalize = true; mr.MapMode = (MDL0MaterialRefNode.MappingMethod)1; } else { mr._projection = (int)TexProjection.ST; mr._inputForm = (int)TexInputForm.AB11; mr._sourceRow = (int)TexSourceRow.TexCoord0 + i; mr.Normalize = false; mr.MapMode = (MDL0MaterialRefNode.MappingMethod)0; } mr._texGenType = (int)TexTexgenType.Regular; mr._embossSource = 4; mr._embossLight = 2; mr.getTexMtxVal(); } _chan1 = new LightChannel(63, new RGBAPixel(128, 128, 128, 255), new RGBAPixel(255, 255, 255, 255), 0, 0, this); C1ColorEnabled = true; C1ColorDiffuseFunction = GXDiffuseFn.Clamped; C1ColorAttenuation = GXAttnFn.Spotlight; C1AlphaEnabled = true; C1AlphaDiffuseFunction = GXDiffuseFn.Clamped; C1AlphaAttenuation = GXAttnFn.Spotlight; _chan2 = new LightChannel(63, new RGBAPixel(255, 255, 255, 255), new RGBAPixel(), 0, 0, this); C2ColorEnabled = true; C2ColorDiffuseFunction = GXDiffuseFn.Disabled; C2ColorAttenuation = GXAttnFn.Specular; C2AlphaDiffuseFunction = GXDiffuseFn.Disabled; C2AlphaAttenuation = GXAttnFn.Specular; _lSet = MetalMaterial._lSet; _fSet = MetalMaterial._fSet; _cull = MetalMaterial._cull; _numLights = 2; ZCompareLoc = false; _normMapRefLight1 = _normMapRefLight2 = _normMapRefLight3 = _normMapRefLight4 = -1; SignalPropertyChange(); } } _updating = false; }
/****************************************************************************************/ /// <summary> /// (Void) Set how we cull our models [TIP: Default is CounterClockwise] /// </summary> /// <param name="Mode"></param> public void CullingState(CullMode Mode) { Core.Graphics.GraphicsDevice.RenderState.CullMode = Mode; }