public override void SetEffectParameters(Effect effect) { if (effect.Parameters["Position"] != null) { effect.Parameters["Position"].SetValue(Position); } if (effect.Parameters["LightColor"] != null) { effect.Parameters["LightColor"].SetValue(LightColor); } if (effect.Parameters["Attenuation"] != null) { effect.Parameters["Attenuation"].SetValue(Attenuation); } if (effect.Parameters["DiffuseColor"] != null) { effect.Parameters["DiffuseColor"].SetValue(DiffuseColor.ToVector3()); } if (effect.Parameters["AmbientColor"] != null) { effect.Parameters["AmbientColor"].SetValue(AmbientColor.ToVector3()); } if (effect.Parameters["Falloff"] != null) { effect.Parameters["Falloff"].SetValue(FallOff); } if (effect.Parameters["SpecularColor"] != null) { effect.Parameters["SpecularColor"].SetValue(SpecularColor); } base.SetEffectParameters(effect); }
protected virtual void WriteDataJson(JsonWriter writer) { writer.WritePropertyName(nameof(Name)); writer.WriteValue(Name); writer.WritePropertyName(nameof(DiffuseColor)); DiffuseColor.WriteJson(writer); writer.WritePropertyName(nameof(AmbientColor)); AmbientColor.WriteJson(writer); writer.WritePropertyName(nameof(SpecularColor)); SpecularColor.WriteJson(writer); writer.WritePropertyName(nameof(EmissiveColor)); EmissiveColor.WriteJson(writer); writer.WritePropertyName(nameof(Opacity)); writer.WriteRawValue(Opacity.ToRoundTripString()); writer.WritePropertyName(nameof(SpecularExponent)); writer.WriteRawValue(SpecularExponent.ToRoundTripString()); writer.WritePropertyName(nameof(FaceMap)); writer.WriteValue(FaceMap); writer.WritePropertyName(nameof(TwoSided)); writer.WriteValue(TwoSided); }
public void ConfigureEffect() { UniversalEffect effect = RendererAssetPool.UniversalEffect; effect.LightParameters.EnableLighting = GraphicOptions.ShadingSupport; effect.ShadowParameters.EnableShadows = RendererAssetPool.DrawShadows; //Light Parameters effect.LightParameters.Position = worldLight.Position; effect.LightParameters.View = worldLight.View; effect.LightParameters.Projection = worldLight.Projection; effect.LightParameters.Color = lightColor; //Camera Parameters effect.CameraParameters.Position = CurrentCamera.Position; effect.CameraParameters.Projection = CurrentCamera.Projection; effect.CameraParameters.View = CurrentCamera.View; //World Parameters effect.WorldParameters.WorldMatrix = Matrix.Identity; if (!GraphicOptions.ShadingSupport) { AmbientColor = Color.White; } effect.LightParameters.AmbientColor = AmbientColor; if (RendererAssetPool.ParticleEffect != null) { RendererAssetPool.ParticleEffect.Parameters["xAmbient"].SetValue(AmbientColor.ToVector4()); } }
protected Cairo.Color GetBorderColor(AmbientColor color) { if (color.HasBorderColor) { return(color.BorderColor); } return(color.Color); }
void SelectAmbientColor(TreeIter iter, AmbientColor ambientColor) { notebookColorChooser.Page = 1; SetColorToButton(colorbuttonPrimary, ambientColor.Color); SetColorToButton(colorbuttonSecondary, ambientColor.SecondColor); colorbuttonSecondary.Sensitive = ambientColor.HasSecondColor; SetColorToButton(colorbuttonBorder, ambientColor.BorderColor); colorbuttonBorder.Sensitive = ambientColor.HasBorderColor; }
public override bool Equals(object obj) { var @class = obj as LightClass; return(@class != null && AmbientColor.Equals(@class.AmbientColor) && DiffuseColour.Equals(@class.DiffuseColour) && Direction.Equals(@class.Direction) && SpecularColor.Equals(@class.SpecularColor) && SpecularPower == @class.SpecularPower); }
public override void SetEffectParameters(Effect effect) { effect.Parameters["LightColor"]?.SetValue(LightColor.ToVector3()); effect.Parameters["AmbientColor"]?.SetValue(AmbientColor.ToVector3()); effect.Parameters["DiffuseColor"]?.SetValue(DiffuseColor.ToVector3()); effect.Parameters["Position"]?.SetValue(Position); effect.Parameters["ModelTexture"]?.SetValue(Texture); effect.Parameters["NormalTexture"]?.SetValue(Normal); effect.Parameters["Attenuation"]?.SetValue(Attenuation); base.SetEffectParameters(effect); }
public override void SetEffectParameters(Effect effect) { effect.Parameters["LightColor"]?.SetValue(LightColor.ToVector3()); effect.Parameters["AmbientColor"]?.SetValue(AmbientColor.ToVector3()); effect.Parameters["DiffuseColor"]?.SetValue(DiffuseColor.ToVector3()); effect.Parameters["SpecularColor"]?.SetValue(SpecularColor.ToVector3()); effect.Parameters["SpecularPower"]?.SetValue(SpecularPower); effect.Parameters["Position"]?.SetValue(Position); effect.Parameters["ModelTexture"]?.SetValue(Texture); effect.Parameters["NormalTexture"]?.SetValue(Normal); effect.Parameters["SpecularTexture"]?.SetValue(Specular); effect.Parameters["CameraPosition"]?.SetValue(GameRoot.MainCamera.Position); effect.Parameters["Attenuation"]?.SetValue(Attenuation); base.SetEffectParameters(effect); }
protected virtual void ReadDataJson(JsonReader reader, string propName) { switch (propName) { case nameof(Name): Name = reader.ReadAsString(); break; case nameof(DiffuseColor): DiffuseColor.ReadJson(reader); break; case nameof(AmbientColor): AmbientColor.ReadJson(reader); break; case nameof(SpecularColor): SpecularColor.ReadJson(reader); break; case nameof(EmissiveColor): EmissiveColor.ReadJson(reader); break; case nameof(Opacity): Opacity = (float)reader.ReadAsDouble(); break; case nameof(SpecularExponent): SpecularExponent = (float)reader.ReadAsDouble(); break; case nameof(FaceMap): FaceMap = reader.ReadAsBoolean().Value; break; case nameof(TwoSided): TwoSided = reader.ReadAsBoolean().Value; break; default: break; throw new Exception("Unexpected property name!"); } }
void SetAmbientColor(Gtk.TreeIter iter, AmbientColor oldStyle) { var newStyle = new AmbientColor(); newStyle.Color = GetColorFromButton(colorbuttonPrimary); newStyle.SecondColor = GetColorFromButton(colorbuttonSecondary); colorStore.SetValue(iter, 2, newStyle); var newscheme = colorSheme.Clone(); ApplyStyle(newscheme); this.textEditor.TextViewMargin.PurgeLayoutCache(); this.textEditor.Document.MimeType = "text/x-csharp"; this.textEditor.GetTextEditorData().ColorStyle = newscheme; this.textEditor.QueueDraw(); }
public override void SetEffectParam(Effect effect) { if (effect.Parameters["AmbientLightColor"] != null) { effect.Parameters["AmbientLightColor"].SetValue(AmbientColor.ToVector3()); } if (effect.Parameters["DiffuseColor"] != null) { effect.Parameters["DiffuseColor"].SetValue(DiffuseColor.ToVector3()); } if (effect.Parameters["LightPosition"] != null) { effect.Parameters["LightPosition"].SetValue(LightPosition); } if (effect.Parameters["LightColor"] != null) { effect.Parameters["LightColor"].SetValue(LightColor.ToVector3()); } if (effect.Parameters["LightAttenuation"] != null) { effect.Parameters["LightAttenuation"].SetValue(Attenuation); } if (effect.Parameters["LightFalloff"] != null) { effect.Parameters["LightFalloff"].SetValue(LightFallOff); } if (effect.Parameters["Texture"] != null) { effect.Parameters["Texture"].SetValue(LightFallOff); } base.SetEffectParam(effect); }
public override int GetHashCode() { return(AmbientColor.GetHashCode() ^ DiffuseColor.GetHashCode() ^ SpecularColor.GetHashCode() ^ Exponent.GetHashCode() ^ TextureID.GetHashCode() ^ Flags.GetHashCode()); }
public DebugTextMarker(int offset, int length, AmbientColor background, ChunkStyle forground = null) : base(offset, length) { this.forground = forground; this.background = background; }
public override void Draw(GameTime gameTime) { base.Draw(gameTime); World = Matrix.CreateScale(Scale) * Matrix.CreateRotationY(Rotation.Y) * Matrix.CreateRotationX(Rotation.X) * Matrix.CreateRotationX(Rotation.Z) * Matrix.CreateTranslation(Position); if (VertexBuffer != null && IndexBuffer != null) { // Pass our Index Buffer and our Vertex Buffer to the Graphics Device GraphicsDevice.Indices = IndexBuffer; GraphicsDevice.SetVertexBuffer(VertexBuffer); if (CustomEffect != null) { // Setup our Shader if (SetShaderParameters != null) { SetShaderParameters.Invoke(gameTime); } foreach (EffectPass p in CustomEffect.CurrentTechnique.Passes) { p.Apply(); GraphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, _width * _height, 0, TriangleCount); } } else { RasterizerState state = new RasterizerState(); state.FillMode = FillMode; state.CullMode = CullMode; GraphicsDevice.RasterizerState = state; // Pass in our Lighting Colors SimpleEffect.AmbientLightColor = AmbientColor.ToVector3(); SimpleEffect.DiffuseColor = DiffuseColor.ToVector3(); SimpleEffect.EmissiveColor = EmissiveColor.ToVector3(); SimpleEffect.SpecularColor = SpecularColor.ToVector3(); SimpleEffect.SpecularPower = SpecularPower; // Update the world, view and projection matrices on the basic effect SimpleEffect.World = World; SimpleEffect.View = Camera.View; SimpleEffect.Projection = Camera.Projection; // Pass our texture to our graphics device for rendering if (Texture != null) { SimpleEffect.Texture = Texture; SimpleEffect.TextureEnabled = true; } foreach (EffectPass pass in SimpleEffect.CurrentTechnique.Passes) { pass.Apply(); GraphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, _width * _height, 0, TriangleCount); } } } }
public Vector3 ShadeBackground(Ray ray) => AmbientColor.ToVector3();
public override void Draw(GameTime gameTime) { if (Content != null && Camera != null && Enabled && Visible) { // Copy any parent transforms. Matrix[] transforms = new Matrix[Content.Bones.Count]; Content.CopyAbsoluteBoneTransformsTo(transforms); foreach (ModelMesh mesh in Content.Meshes) { // Update our World Matrix for this Model World = transforms[mesh.ParentBone.Index] * Matrix.CreateRotationX(Rotation.X) * Matrix.CreateRotationY(Rotation.Y) * Matrix.CreateRotationZ(Rotation.Z) * Matrix.CreateScale(Scale) * Matrix.CreateTranslation(Position); if (CustomEffect != null) { #region Custom HLSL Effect Rendering /********************************************************************************************************* * -- Please do not f**k with this to much haha unless ya ask me (AR-50 LOCKED AND LOADED!) -- *********************************************************************************************************/ // Pass our meshes Index buffer to our graphics device //GraphicsDevice.Indices = mesh.IndexBuffer; // Loop thru the Custom Effect's passes foreach (EffectPass pass in CustomEffect.CurrentTechnique.Passes) { // Begin our First pass pass.Apply(); // Render this pass over the parts inside the mesh foreach (ModelMeshPart part in mesh.MeshParts) { // Pass our mesh part's Vertex declaration to our graphics device //GraphicsDevice.VertexDeclaration = part.VertexDeclaration; // Manually pass our vertices to our graphics device //GraphicsDevice.Vertices[0].SetSource(mesh.VertexBuffer, part.StreamOffset, part.VertexStride); // TODO: Need to rework this .. the double casts will kill performance! *Refactor OUT* // Check and see if the part has an attached texture if (((BasicEffect)part.Effect).Texture != null) { // If it does pass the texture our graphics device instead of manually in our shader GraphicsDevice.Textures[0] = ((BasicEffect)part.Effect).Texture; } // Finally Draw our Index Primitives (Triangles) for this part of our mesh GraphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, part.NumVertices, 0, part.NumVertices, part.StartIndex, part.PrimitiveCount); } } #endregion } else { #region Basic Effect Rendering Loop // Setup culling / fill RasterizerState rasterizerState1 = new RasterizerState(); rasterizerState1.CullMode = CullMode; rasterizerState1.FillMode = FillMode; GraphicsDevice.RasterizerState = rasterizerState1; // Set our alpha blending states if enabled if (EnableAlphaBlending) { GraphicsDevice.BlendState = BlendState.AlphaBlend; //GraphicsDevice.RenderState.AlphaBlendEnable = true; //GraphicsDevice.RenderState.AlphaTestEnable = true; //GraphicsDevice.RenderState.AlphaFunction = CompareFunction.Greater; //GraphicsDevice.RenderState.SourceBlend = Blend.SourceAlpha; //GraphicsDevice.RenderState.DestinationBlend = Blend.InverseSourceAlpha; //GraphicsDevice.RenderState.BlendFunction = BlendFunction.Load; } foreach (BasicEffect effect in mesh.Effects) { effect.EnableDefaultLighting(); effect.AmbientLightColor = AmbientColor.ToVector3(); effect.DiffuseColor = DiffuseColor.ToVector3(); effect.EmissiveColor = EmissiveColor.ToVector3(); effect.SpecularColor = SpecularColor.ToVector3(); effect.World = World; effect.View = Camera.View; effect.Projection = Camera.Projection; } mesh.Draw(); // Reset our alpha blending states if (EnableAlphaBlending) { //GraphicsDevice.RenderState.AlphaBlendEnable = false; //GraphicsDevice.RenderState.AlphaTestEnable = false; //GraphicsDevice.RenderState.SourceBlend = Blend.Zero; //GraphicsDevice.RenderState.DestinationBlend = Blend.Zero; } #endregion } base.Draw(gameTime); } } }
public override void SetEffect(GameTime gameTime, Effect effect) { base.SetEffect(gameTime, effect); if (effect.Parameters["AmbientIntensity"] != null) { effect.Parameters["AmbientIntensity"].SetValue(AmbientIntensity); } if (effect.Parameters["AmbientColor"] != null) { effect.Parameters["AmbientColor"].SetValue(AmbientColor.ToVector4()); } if (effect.Parameters["itw"] != null) { effect.Parameters["itw"].SetValue(Matrix.Invert(Matrix.Transpose(World))); } if (MultiLight) { // Calculate the light direction in relation to me. if (effect.Parameters["LightDirection"] != null) { effect.Parameters["LightDirection"].SetValue(Lights.Select(p => p.Position - Position).ToArray()); } if (effect.Parameters["DiffuseIntensity"] != null) { effect.Parameters["DiffuseIntensity"].SetValue(Lights.Select(p => p.LightIntensity).ToArray()); } if (effect.Parameters["DiffuseColor"] != null) { effect.Parameters["DiffuseColor"].SetValue(Lights.Select(p => p.Color.ToVector4()).ToArray()); } if (effect.Parameters["SpecularColor"] != null) { effect.Parameters["SpecularColor"].SetValue(Lights.Select(p => p.SpecularColor.ToVector4()).ToArray()); } if (effect.Parameters["SpecularIntensity"] != null) { effect.Parameters["SpecularIntensity"].SetValue(Lights.Select(p => p.SpecularIntensity).ToArray()); } } else { if (effect.Parameters["LightDirection"] != null) { effect.Parameters["LightDirection"].SetValue(Lights[0].Position - Position); } if (effect.Parameters["DiffuseIntensity"] != null) { effect.Parameters["DiffuseIntensity"].SetValue(Lights[0].LightIntensity); } if (effect.Parameters["DiffuseColor"] != null) { effect.Parameters["DiffuseColor"].SetValue(Lights[0].Color.ToVector4()); } if (effect.Parameters["SpecularColor"] != null) { effect.Parameters["SpecularColor"].SetValue(Lights[0].SpecularColor.ToVector4()); } if (effect.Parameters["SpecularIntensity"] != null) { effect.Parameters["SpecularIntensity"].SetValue(Lights[0].SpecularIntensity); } } if (effect.Parameters["CameraPosition"] != null) { effect.Parameters["CameraPosition"].SetValue(camera.Position); } if (effect.Parameters["ColorMap"] != null) { effect.Parameters["ColorMap"].SetValue(Game.Content.Load <Texture2D>(ColorAsset)); } if (effect.Parameters["GlowMap"] != null) { effect.Parameters["GlowMap"].SetValue(Game.Content.Load <Texture2D>(GlowAsset)); } if (effect.Parameters["BumpMap"] != null) { effect.Parameters["BumpMap"].SetValue(Game.Content.Load <Texture2D>(BumpAsset)); } if (effect.Parameters["ReflectionMap"] != null) { effect.Parameters["ReflectionMap"].SetValue(Game.Content.Load <Texture2D>(ReflectionAsset)); } if (effect.Parameters["worldIT"] != null) { effect.Parameters["worldIT"].SetValue(Matrix.Invert(Matrix.Transpose(World))); } if (effect.Parameters["viewI"] != null) { effect.Parameters["viewI"].SetValue(Matrix.Invert(camera.View)); } if (effect.Parameters["cubeMap"] != null) { effect.Parameters["cubeMap"].SetValue(Game.Content.Load <TextureCube>(ColorAsset)); } if (effect.Parameters["tint"] != null) { effect.Parameters["tint"].SetValue(Tint.ToVector4()); } if (effect.Parameters["fresnelTex"] != null) { effect.Parameters["fresnelTex"].SetValue(Game.Content.Load <Texture2D>(GlowAsset)); } if (effect.Parameters["EyePosition"] != null) { effect.Parameters["EyePosition"].SetValue(camera.Position); } if (effect.Parameters["time"] != null) { effect.Parameters["time"].SetValue((float)gameTime.TotalGameTime.TotalSeconds * 3); } if (effect.Parameters["CloudMap"] != null) { effect.Parameters["CloudMap"].SetValue(Game.Content.Load <Texture2D>(CloudMap)); } if (effect.Parameters["WaveMap"] != null) { effect.Parameters["WaveMap"].SetValue(Game.Content.Load <Texture2D>(WaterRipples)); } if (effect.Parameters["AtmosMap"] != null) { effect.Parameters["AtmosMap"].SetValue(Game.Content.Load <Texture2D>(AtmosAsset)); } if (effect.Parameters["cloudSpeed"] != null) { effect.Parameters["cloudSpeed"].SetValue(cloudSpeed); } if (effect.Parameters["cloudHeight"] != null) { effect.Parameters["cloudHeight"].SetValue(cloudHeight); } if (effect.Parameters["cloudShadowIntensity"] != null) { effect.Parameters["cloudShadowIntensity"].SetValue(cloudShadowIntensity); } }