public override void DrawArc(ref Vector3 center, ref Vector3 normal, ref Vector3 axis, float radiusA, float radiusB, float minAngle, float maxAngle, Color3 color, bool drawSect, float stepDegrees) { Vector3 vx = axis; Vector3 vy = Vector3.Cross(normal, axis); float step = stepDegrees * ((float)Math.PI / 180.0f); int nSteps = (int)((maxAngle - minAngle) / step); if (nSteps == 0) nSteps = 1; Vector3 next = center + radiusA * vx * (float)Math.Cos(minAngle) + radiusB * vy * (float)Math.Sin(minAngle); if (drawSect) DrawLine(ref center, ref next, color); int intColor = ColorToInt(ref color); PositionColored last = new PositionColored(ref next, intColor); for (int i = 1; i <= nSteps; i++) { lines.Add(last); float angle = minAngle + (maxAngle - minAngle) * i / nSteps; next = center + radiusA * vx * (float)Math.Cos(angle) + radiusB * vy * (float)Math.Sin(angle); last = new PositionColored(ref next, intColor); lines.Add(last); } if (drawSect) DrawLine(ref center, ref next, color); }
public LightingEffectBase(Color3 lightingColor, float lightingIntensity, IServiceProvider services, string effectAsset, IEnumerable<RenderTargetLayerType> requiredRenderTargets) : base(services, effectAsset, 0, requiredRenderTargets) { LightingColor = lightingColor; LightingIntensity = lightingIntensity; }
protected PhongLight( UInt16 numberOfSamples, Color3 ambient, Color3 diffuse, Color3 specular, bool castsShadows, float constantFalloff, float linearFalloff, float quadraticFalloff ) : this(numberOfSamples, ambient, diffuse, specular, castsShadows, new Vector( 0.0f, 0.0f, -1.0f ), 1.0f, 180.0f, constantFalloff, linearFalloff, quadraticFalloff) { }
public BrdfSample( Color3 Reflectance, Vector Outgoing, bool IsSpecular, float Pdf ) { this.Reflectance = Reflectance; this.Outgoing = Outgoing; this.IsSpecular = IsSpecular; this.Pdf = Pdf; }
public bool AddParticleDefinition(string Name, double Mass, Color3 Color, int MidiOutput, int Note) { if (m_Count < MAX_PARTICLE_TYPES) { AtomicInfo info = new AtomicInfo(m_Count, Name, Mass); info.Color = Color; info.RenderColor = new Vector4(info.Color.Red, info.Color.Green, info.Color.Blue, (float)info.Radius); info.MidiOutput = MidiOutput; info.Note = Note; info.Enabled = true; info.AttractiveOrRepulsive = -1.0; // repulsive is -1.0; attractive is 1.0 info.IsSoundOn = true; // does what it says Lookup[m_Count++] = info; info.ActiveParticle = false; CalculateEnergyTerms(); return true; } else { return false; } }
protected PhongLight( UInt16 numberOfSamples, Color3 ambient, Color3 diffuse, Color3 specular, bool castsShadows, Vector spotDirection, float spotExponent, float spotCutoff ) : this(numberOfSamples, ambient, diffuse, specular, castsShadows, spotDirection, spotExponent, spotCutoff, 1.0f, 0.0f, 0.0f) { }
public LightRay( Color3 RadiantIntensity, Ray GeneratedRay, Vector Normal, float Pdf ) { this.RadiantIntensity = RadiantIntensity; this.GeneratedRay = GeneratedRay; this.Normal = Normal; this.Pdf = Pdf; }
public void Init() { if (Values.ContainsKey("fogenable")) bool.TryParse(Values["fogenable"], out Enabled); if (Values.ContainsKey("fogblend")) bool.TryParse(Values["fogblend"], out FogBlend); try { if (Values.ContainsKey("fogcolor")) { string[] split = Values["fogcolor"].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); int[] pars = new int[] { int.Parse(split[0]), int.Parse(split[1]), int.Parse(split[2]) }; FogColor = new Color3(pars[2], pars[1], pars[0]); } if (Values.ContainsKey("fogstart")) FogStart = float.Parse(Values["fogstart"], System.Globalization.CultureInfo.InvariantCulture); if (Values.ContainsKey("fogend")) FogEnd = float.Parse(Values["fogend"], System.Globalization.CultureInfo.InvariantCulture); if (Values.ContainsKey("fogmaxdensity")) MaxDensity = float.Parse(Values["fogmaxdensity"], System.Globalization.CultureInfo.InvariantCulture); } catch { } }
public LightSample( Color3 RadiantIntensity, Vector ToLight, float Distance, float Pdf ) { this.RadiantIntensity = RadiantIntensity; this.ToLight = ToLight; this.Distance = Distance; this.Pdf = Pdf; }
public Particle(Vector3 Position, Vector3 Velocity, Color3 Color, float LifeBar, ParticleType type) { this.Position = Position; this.Velocity = Velocity; this.Color = Color; this.LifeBar = LifeBar; this.ParticleType = type; }
public PrelitVertex(Vector3 position, Vector2 uv, Color3 color, Vector3 normal) : this() { _position = position; _uv = uv; _normal = normal; _color = color; }
public Material() { Diffuse = new Color3(0.6f, 0.6f, 0.6f); Alpha = 1f; Shineness = 0f; IlluminationModel = 1; IOR = 1f; Clamp = new bool[Enum.GetValues(typeof(TextureType)).Length]; }
/// <summary> /// Initializes a new instance of the <see cref="Material"/> class. /// </summary> /// <param name="ambient">The ambient.</param> /// <param name="diffuse">The diffuse.</param> /// <param name="emissive">The emissive.</param> /// <param name="specular">The specular.</param> /// <param name="power">The power.</param> /// <param name="opacity">The opacity.</param> public Material(Color3 ambient, Color3 diffuse, Color3 emissive, Color3 specular, float power, float opacity) { this.Ambient = ambient; this.Diffuse = diffuse; this.Emissive = emissive; this.Specular = specular; this.Power = power; this.Opacity = opacity; }
public KinectFieldImageTextureFloat(DS.Simulation.CompositeFieldImage.KinectFieldImage source, Color3 color, KinectFieldImageType type) { m_Source = source; m_Color = color; m_ImageType = type; m_Image = new ImageBoxFloat(null); m_Image.OverlayType = RugTech1.Framework.Effects.ImposterOverlayType.Add; }
/// <summary> /// Initializes a new instance of class <see cref="LightShaftsPlugin"/>. /// </summary> public LightShaftsPlugin(string name) : base(name) { BoundingBoxes = new List<Mesh>(); LightColor = new Color3(1, 1, 1); ExtinctionFactor = 0.001f; ExtinctionRatio = 0.9f; DensityFactor = 0.01f; StepCount = 8; }
/// <summary> /// Sets the color from a <see cref="LightComponent"/> assuming that the <see cref="LightComponent.Type"/> is an instance of <see cref="IColorLight"/> /// </summary> /// <param name="light">The light component.</param> /// <param name="color">The light color.</param> /// <exception cref="InvalidOperationException">If the LightComponent doesn't contain a color light type IColorLight</exception> public static void SetColor(this LightComponent light, Color3 color) { var colorLight = light.Type as IColorLight; if (colorLight == null) throw new InvalidOperationException("The LightComponent doesn't contain a color light type IColorLight"); var lightColorRgb = colorLight.Color as ColorRgbProvider ?? new ColorRgbProvider(); lightColorRgb.Value = color; colorLight.Color = lightColorRgb; }
/// <summary> /// Initializes a new instance of the <see cref="ColorCombiner"/> class. /// </summary> /// <param name="context">The context.</param> /// <param name="colorCombinerShaderName">Name of the color combiner shader.</param> public ColorCombiner(string colorCombinerShaderName = "ColorCombinerEffect") { EffectName = colorCombinerShaderName; factors = new float[TexturingKeys.DefaultTextures.Count]; modulateRGB = new Color3[TexturingKeys.DefaultTextures.Count]; for (int i = 0; i < TexturingKeys.DefaultTextures.Count; i++) { factors[i] = 1f; modulateRGB[i] = new Color3(1f, 1f, 1f); } }
Color3 PS(double x, double y) { Color3 c = new Color3(1, 1, 1); double f = Math.Cos((x - y) * 2 * Math.PI); f = saturate(f); c *= 1 - (float)f; return c; }
public static Color3 FesnelDielectric( float CosI, float CosT, Color3 EtaI, Color3 EtaT ) { Color3 tmp1 = EtaT * CosI; Color3 tmp2 = EtaI * CosI; Color3 tmp3 = EtaT * CosT; Color3 tmp4 = EtaI * CosT; Color3 rparl = ( tmp1 - tmp4 ) / ( tmp1 + tmp4 ); Color3 rperp = ( tmp2 - tmp3) / ( tmp2 + tmp3 ); return ( rparl * rparl + rperp * rperp ) * 0.5f; }
public void SetFogParameters(DeviceContext context, float start, float end, Color3 fogColour) { Contract.Requires<ArgumentNullException>(fogColour != null, "fogColour"); using (DataStream data = new DataStream(System.Runtime.InteropServices.Marshal.SizeOf(typeof(FogCBuffer)), true, true)) { data.Write(start); data.Write(end); data.Write(fogColour); data.Position = 0; context.UpdateSubresource(new DataBox(0, 0, data), fogConstantBuffer, 0); context.VertexShader.SetConstantBuffer(fogConstantBuffer, 0); } }
public override void ProcessLights(ProcessLightsParameters parameters) { // Sum contribution from all lights var ambientColor = new Color3(); for (int index = parameters.LightStart; index < parameters.LightEnd; index++) { var light = parameters.LightCollection[index]; ambientColor += light.Color; } // Store ambient sum for this view lightShaderGroup.AmbientColor[parameters.ViewIndex] = ambientColor; }
public static Color3 FesnelConductor( float CosI, Color3 Eta, Color3 k ) { Color3 tmp = ( Eta * Eta + k * k ) * CosI * CosI; Color3 tmp2 = 2.0f * Eta * CosI; Color3 tmp3 = Eta * Eta + k * k; float tmp4 = CosI * CosI; Color3 cosi2 = new Color3( tmp4, tmp4, tmp4 ); Color3 rparl2 = ( tmp - tmp2 + Color3.White ) / ( tmp + tmp2 + Color3.White ); Color3 rperp2 = ( tmp3 - tmp2 + cosi2 ) / ( tmp3 + tmp2 + cosi2 ); return ( rparl2 + rperp2 ) * 0.5f; }
public bool Scatter(Ray rayIn, HitRecord hitRecord, out Color3 colorAttenuation, out Ray scatteredRay) { // generate scattered diffuse ray scatteredRay = new Ray() { Origin = hitRecord.Point, Direction = hitRecord.Normal + Vector3.GetRandomUnitVector() }; colorAttenuation = this.Albedo; // a diffuse material doesn't reflect, so it always scatters or absorbs (attenuation is the amount of absorbance) return(true); }
public Framebuffer( Color3 Fill, int Rows, int Columns ) { this.Pixels = new Color3[Rows, Columns]; this.Rows = Rows; this.Columns = Columns; for ( int i = 0; i < Rows; i++ ) { for ( int j = 0; j < Columns; j++ ) { Pixels[i, j] = Fill; } } }
public NiMaterialProperty(NiFile file, BinaryReader reader) : base(file, reader) { if (Version <= eNifVersion.VER_10_0_1_2) { Flags = reader.ReadUInt16(); } AmbientColor = reader.ReadColor3(); DiffuseColor = reader.ReadColor3(); SpecularColor = reader.ReadColor3(); EmissiveColor = reader.ReadColor3(); Glossiness = reader.ReadSingle(); Alpha = reader.ReadSingle(); }
public StandardMaterial(string name) { ID = Guid.NewGuid(); Name = name; DiffuseTexture = ""; Diffuse = new Color3(1, 1, 1); Specular = new Color3(1, 1, 1); SpecularPower = 32; Alpha = 1.0f; BackFaceCulling = true; }
public static Color3[] ReadColor3Array(EndianAwareBinaryReader reader, int count) { var rValues = ReadFloatArray(reader, count); var gValues = ReadFloatArray(reader, count); var bValues = ReadFloatArray(reader, count); var colorValues = new Color3[count]; for (var i = 0; i < count; i++) { colorValues[i] = new Color3(rValues[i], gValues[i], bValues[i]); } return(colorValues); }
public void DrawText(Vector2D location, string text, Color3 color) { #if DEBUG location = _GetRestrictedVector(location); #endif _gtkContext.SetSourceRGB(color.Red, color.Green, color.Blue); var layout = _drawingArea.CreatePangoLayout(text); layout.FontDescription = new Pango.FontDescription { Family = "Monospace", Weight = Pango.Weight.Bold }; _gtkContext.MoveTo(location.X, location.Y); Pango.CairoHelper.ShowLayout(_gtkContext, layout); }
private static Vector3 Profile(float r, Color3 falloff) // Based on "SeparableSSS::profile()". { // We used the red channel of the original skin profile defined in // [d'Eon07] for all three channels. We noticed it can be used for green // and blue channels (scaled using the falloff parameter) without // introducing noticeable differences and allowing for total control over // the profile. For example, it allows to create blue SSS gradients, which // could be useful in case of rendering blue creatures. return // 0.233f * Gaussian(0.0064f, r, falloff) + // We consider this one to be directly bounced light, accounted by the strength parameter (see @STRENGTH) (0.100f * Gaussian(0.0484f, r, falloff) + 0.118f * Gaussian(0.187f, r, falloff) + 0.113f * Gaussian(0.567f, r, falloff) + 0.358f * Gaussian(1.99f, r, falloff) + 0.078f * Gaussian(7.41f, r, falloff)); }
/// <summary> /// Reads the unmanaged data from the native value. /// </summary> /// <param name="nativeValue">Input native value</param> void IMarshalable <Light, AiLight> .FromNative(ref AiLight nativeValue) { m_name = nativeValue.Name.GetString(); m_lightType = nativeValue.Type; m_angleInnerCone = nativeValue.AngleInnerCone; m_angleOuterCone = nativeValue.AngleOuterCone; m_attConstant = nativeValue.AttenuationConstant; m_attLinear = nativeValue.AttenuationLinear; m_attQuadratic = nativeValue.AttenuationQuadratic; m_position = nativeValue.Position; m_direction = nativeValue.Direction; m_diffuse = nativeValue.ColorDiffuse; m_specular = nativeValue.ColorSpecular; m_ambient = nativeValue.ColorAmbient; }
public WiredCube(Device device, Effect effect, float width, float height, float depth, Color3 cubeColor, Camera camera) { this.device = device; this.effect = effect; this.width = width; this.height = height; this.depth = depth; this.color = (int)RgbPalette.ColorARGB(cubeColor); this.camera = camera; world = Matrix.Identity; SetUpBuffers(); }
public PmxMaterialMorph(BinaryStream bs, byte materialIdxSize) { Index = bs.ReadIndex(materialIdxSize); Offset = (OffsetEnum)bs.ReadByte(); Diffuse = bs.Color3(); Alpha = bs.ReadSingle(); Specular = bs.Color3(); Specularity = bs.ReadSingle(); Ambient = bs.Color3(); EdgeColor = bs.Color4(); EdgeSize = bs.ReadSingle(); NormalTexturity = bs.Vector4(); SphereTexturity = bs.Vector4(); ToonTexturity = bs.Vector4(); }
/// <summary> /// Reads the JSON representation of the object. /// </summary> /// <param name="reader">The Newtonsoft.Json.JsonReader to read from.</param> /// <param name="objectType">Type of the object.</param> /// <param name="existingValue">The existing value of object being read.</param> /// <param name="serializer">The calling serializer.</param> /// <returns>The object value.</returns> public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { Color3 value = default; float[] floatArray = serializer.Deserialize <float[]>(reader); if (floatArray != null) { if (floatArray.Length == 3) { value = new Color3(floatArray[0], floatArray[1], floatArray[2]); } } return(value); }
public static Color3 GetBackgroundColorOrDefault(this ImmlDocument document, Color3 defaultValue) { if(string.IsNullOrWhiteSpace(document.Background)) { return defaultValue; } Background backgroundElement = null; if (document.TryGetElementByName<Background>(document.Background, out backgroundElement)) { return backgroundElement.Colour; } throw new MarkupException("Document does not contain the specified background element"); }
public void Draw(Matrix4 transform, Color3 color) { _verticesBuffer.Bind(); _verticesBuffer.Clear(); // orphaning _verticesBuffer.SetData(_vertices, 0, _vertexCount); _program.Bind(); _program.Transform.SetValue(transform); _program.Position.SetValue(_verticesBuffer.GetView(v => v.Position)); _program.Color.SetValue(new Vector3(color.R, color.G, color.B)); GL.DrawArrays(GL.LINES, 0, _vertexCount); Program.Unbind(); _verticesBuffer.Unbind(); }
public ColorSequence ReadAttribute(Attribute attr) { int numKeys = attr.ReadInt(); var keypoints = new ColorSequenceKeypoint[numKeys]; for (int i = 0; i < numKeys; i++) { int envelope = attr.ReadInt(); float time = attr.ReadFloat(); Color3 value = Color3Token.ReadColor3(attr); keypoints[i] = new ColorSequenceKeypoint(time, value, envelope); } return(new ColorSequence(keypoints)); }
public void Serialize(ref Color3 value) { // Write optimized version without using Serialize methods if (Mode == SerializerMode.Write) { Writer.Write(value.Red); Writer.Write(value.Green); Writer.Write(value.Blue); } else { value.Red = Reader.ReadSingle(); value.Green = Reader.ReadSingle(); value.Blue = Reader.ReadSingle(); } }
public bool ReadProperty(Property prop, XmlNode token) { if (XmlPropertyTokens.ReadPropertyGeneric(token, out uint value)) { uint r = (value >> 16) & 0xFF; uint g = (value >> 8) & 0xFF; uint b = value & 0xFF; Color3uint8 result = Color3.FromRGB(r, g, b); prop.Value = result; return(true); } return(false); }
public void SetPoints(Color3[] list) { ColorCube cube = new ColorCube(list.Length); for (int i = 0; i < list.Length; i++) { PixelInfo px = new PixelInfo(); px.A = px.B = px.C = 0; px.Index = i; cube.Pixels.Add(px); } this.max = new LabColor(); this.min = new LabColor(); for (int i = 0; i < cube.Pixels.Count; i++) { Color3 c = list[cube.Pixels[i].Index]; LabColor lab = new LabColor(c.A, c.B, c.C); if (i == 0) { min.L = max.L = lab.L; min.A = max.A = lab.A; min.B = max.B = lab.B; continue; } min.L = MedianCutClustering.Min(lab.L, min.L); min.A = MedianCutClustering.Min(lab.A, min.A); min.B = MedianCutClustering.Min(lab.B, min.B); max.L = MedianCutClustering.Max(lab.L, max.L); max.A = MedianCutClustering.Max(lab.A, max.A); max.B = MedianCutClustering.Max(lab.B, max.B); } for (int i = 0; i < cube.Pixels.Count; i++) { PixelInfo px = cube.Pixels[i]; Color3 c = list[cube.Pixels[i].Index]; LabColor lab = new LabColor(c.A, c.B, c.C); px.A = MedianCutClustering.Hash(lab.L, min.L, max.L); px.B = MedianCutClustering.Hash(lab.A, min.A, max.A); px.C = MedianCutClustering.Hash(lab.B, min.B, max.B); } this.cubes = new List <ColorCube>(); this.cubes.Add(cube); }
public MmdMaterial(Pmd.PmdMaterial Mat, Pmd.PmdToon[] Ton) { Name = ""; Diffuse = Mat.Diffuse; Alpha = Mat.Alpha; Specular = Mat.Specular; Specularity = Mat.Specularity; Ambient = Mat.Mirror; if (Mat.EdgeFlag == 1) { DrawFlag = DrawFlagEnumes.DrawBoth; } else { DrawFlag = 0; } Memo = ""; if (Mat.TextureFileName != null) { NormalTexture = Mat.TextureFileName; } if (Mat.SphereFileName != null) { if (Mat.SphereFileName.Contains(".spa")) { AddSphereTexture = Mat.SphereFileName; } else if (Mat.SphereFileName.Contains(".sph")) { MultiplySphereTexture = Mat.SphereFileName; } } if (Mat.ToonIndex > 0 && Mat.ToonIndex <= 10) { var toon = Ton[Mat.ToonIndex].FileName; if (Regex.IsMatch(toon, @"toon(10|0[1-9]).bmp")) { ToonTexture = @"toon\" + toon; } else { ToonTexture = toon; } } IndiciesCount = Mat.IndiciesCount; }
public override void ProcessLights(ProcessLightsParameters parameters) { // Sum contribution from all lights var ambientColor = new Color3(); foreach (var index in parameters.LightIndices) { var light = parameters.LightCollection[index]; ambientColor += light.Color; } // Consume all the lights parameters.LightIndices.Clear(); // Store ambient sum for this view lightShaderGroup.AmbientColor[parameters.ViewIndex] = ambientColor; }
/// <summary> /// Creates a light entity based on the deferred lightning example /// </summary> /// <param name="direction">Light direction</param> /// <param name="color">Light color</param> /// <param name="intensity">Light intensity</param> private LightComponent CreateDirectLight(Vector3 direction, Color3 color, float intensity) { var directLightEntity = new Entity(); LightComponent directLightComponent = new LightComponent { Type = LightType.Directional, Color = color, Deferred = false, Enabled = true, Intensity = intensity, LightDirection = direction }; directLightEntity.Add(directLightComponent); Entities.Add(directLightEntity); return(directLightComponent); }
public override void Read(NiHeader header, BinaryReader reader) { base.Read(header, reader); if (!((header.GetVersion() == 335675399U) && (header.GetUserVersion() >= 11) && (header.GetUserVersion2() > 21))) { this.ambientColor = Utils.ReadColor3(reader); this.diffuseColor = Utils.ReadColor3(reader); } this.specularColor = Utils.ReadColor3(reader); this.emissiveColor = Utils.ReadColor3(reader); this.glossiness = reader.ReadSingle(); this.alpha = reader.ReadSingle(); if ((header.GetVersion() == 335675399U) && (header.GetUserVersion() >= 11) && (header.GetUserVersion2() > 21)) { this.emitMulti = reader.ReadSingle(); } }
public override void Initialize() { if (effect == null) { effect = Effect.FromStream(device, this.GetType().Assembly.GetManifestResourceStream("DynamicDataDisplay.Visualization3D.Shaders.PerPixelLightning.fx"), ShaderFlags.None); } SetCamera(); vertexList = new List <MetaballVertex>(); Color3 mbColor = RgbPalette.GetColor(fTargetValue, dataSource.Maximum, dataSource.Minimum, dataSource.MissingValue); effect.SetValue("mbColor", new Vector4(mbColor.Red, mbColor.Green, mbColor.Blue, 1.0f)); MarchingCubes(); Completed(); base.Initialize(); }
protected PhongLight( UInt16 numberOfSamples, Color3 ambient, Color3 diffuse, Color3 specular, bool castsShadows, Vector spotDirection, float spotExponent, float spotCutoff, float constantFalloff, float linearFalloff, float quadraticFalloff ) { NumberOfSamples = numberOfSamples; Ambient = ambient; Diffuse = diffuse; Specular = specular; CastsShadows = castsShadows; SpotDirection = spotDirection; SpotExponent = spotExponent; SpotCutoff = spotCutoff; ConstantFalloff = constantFalloff; LinearFalloff = linearFalloff; QuadraticFalloff = quadraticFalloff; }
public void Render(DeviceContext context, Matrix screen, Matrix projection, Color3 light) { //Render First person view of the tool, only if the tool is used by the current playing person ! _cubeToolEffect.Begin(context); _cubeToolEffect.CBPerDraw.Values.Projection = Matrix.Transpose(projection); _cubeToolEffect.CBPerDraw.Values.Screen = Matrix.Transpose(screen); _cubeToolEffect.CBPerDraw.Values.LightColor = light; _cubeToolEffect.CBPerDraw.IsDirty = true; _cubeToolEffect.Apply(context); //Set the buffer to the device _cubeVb.SetToDevice(context, 0); _cubeIb.SetToDevice(context, 0); //Draw things here. context.DrawIndexed(_cubeIb.IndicesCount, 0, 0); }
/// <summary> /// Sends the given <paramref name="message"/> with the specified <paramref name="color"/> to the player. /// </summary> /// <param name="player">The player.</param> /// <param name="message">The message to send.</param> /// <param name="color">The color to send the message as.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="player"/> or <paramref name="message"/> are <see langword="null"/>. /// </exception> public static void SendMessage(this IPlayer player, NetworkText message, Color3 color) { if (player is null) { throw new ArgumentNullException(nameof(player)); } if (message is null) { throw new ArgumentNullException(nameof(message)); } var packet = new ServerMessage { Color = color, Message = message, LineWidth = -1 }; player.SendPacket(packet); }
void ConstructColorMap() { //allowedColors.Clear(); paletteColors.Clear(); for (int r = 0; r <= 7; r++) { for (int g = 0; g <= 7; g++) { for (int b = 0; b <= 7; b++) { //allowedColors.Add(Color.FromArgb(ClampColor(r * 37), ClampColor(g * 37), ClampColor(b * 37))); var thisColor = new Color3(ClampColor((int)Math.Round(r * bitSpacing)), ClampColor((int)Math.Round(g * bitSpacing)), ClampColor((int)Math.Round(b * bitSpacing))); paletteColors.Add(thisColor); paletteColorDictionary.Add(thisColor.Packed, thisColor); } } } }
private void CreateLights() { _lights = new Frame[6]; Random ran = new Random(); Color3[] colors = new Color3[8] { new Color3(Color.Yellow.ToArgb()), new Color3(Color.Red.ToArgb()), new Color3(Color.Green.ToArgb()), new Color3(Color.LightCoral.ToArgb()), new Color3(Color.DarkBlue.ToArgb()), new Color3(Color.Gray.ToArgb()), new Color3(Color.IndianRed.ToArgb()), new Color3(Color.LightSalmon.ToArgb()) }; float step = Numerics.TwoPI / _lights.Length; Spherical spherical = new Spherical(Numerics.PIover2, 0); for (int i = 0; i < _lights.Length; i++) { var light = new Light() { Diffuse = colors[i % 8], //Diffuse = new Vector3((float)ran.NextDouble(),(float)ran.NextDouble(),(float)ran.NextDouble()), Specular = new Vector3(0.2f, 0.2f, 0.2f), Type = LightType.Point, Enable = true }; spherical.Phi = step * i; var pos = spherical.ToCartesian() * 300; pos.Y = 50; var instance = new FrameLight(light); var node = SceneManager.Scene.Create("light" + i, instance, localPosition: pos, localRotationEuler: Euler.FromDirection(new Vector3(0, -1, 0)), localScale: new Vector3(1, 1, 1)); SceneManager.Scene.Dynamics.Add(new Dynamic(x => { Frame n = node; n.LocalPosition = Vector3.TransformCoordinates(n.LocalPosition, Matrix.RotationY(Numerics.ToRadians(1))); n.ComputeLocalPose(); n.CommitChanges(); })); _lights[i] = node; } }
private int[,] NoDithering(Bitmap image, int width, int height) { Color3[,] initialColorArray = new Color3[height, width]; for (int row = 0; row < height; row++) { for (int col = 0; col < width; col++) { initialColorArray[row, col] = ColorToColor3(image.GetPixel(col, row)); } } int[,] convertedColorArray = new int[height, width]; for (int row = 0; row < height; row++) { for (int col = 0; col < width; col++) { var pixelColor = initialColorArray[row, col]; if (pixelColor.A < 36) //and check rgb too { if (checkBoxTransparency.Checked) { convertedColorArray[row, col] = -141; } else { convertedColorArray[row, col] = backgroundColorPacked; } } else { convertedColorArray[row, col] = GetClosestColorFast(pixelColor).Packed; } if (progressBarForm.DialogResult != DialogResult.Abort) { backgroundWorkerDithering.ReportProgress(GetPercentCompletion(height, width, row, col)); } } } return(convertedColorArray); }
public void WriteProperty(Property prop, XmlDocument doc, XmlNode node) { Color3 color = prop.CastValue <Color3>(); float[] rgb = new float[3] { color.R, color.G, color.B }; for (int i = 0; i < 3; i++) { string field = Fields[i]; float value = rgb[i]; XmlElement channel = doc.CreateElement(field); channel.InnerText = value.ToInvariantString(); node.AppendChild(channel); } }
private Color3 SampleLightDirectly(ISurfaceLight light, Color3 brdf, Intersection intersection) { var rPoint = light.GetRandomPoint(_rng, intersection); //get random point on light var l = rPoint.Location - intersection.Location; //vector to light var dist = l.LengthFast; l.Normalize(); var lightRay = Ray.CreateFromIntersection(intersection, l, dist); //ray to light var nlightDotL = Vector3.Dot(rPoint.Normal, -l); //light normal dot light var nDotL = Vector3.Dot(intersection.SurfaceNormal, l); //normal dot light if (nDotL > 0 && nlightDotL > 0 && !IntersectionHelper.DoesIntersect(lightRay, _scene.Objects, light)) { var solidAngle = (nlightDotL * light.Area) / (dist * dist); //light area on hemisphere return(light.Color * solidAngle * brdf * nDotL); } return(Color4.Black); }
private static Entity CreatePointLight(Vector3 position, Color3 color) { return(new Entity() { new LightComponent { Enabled = true, Color = color, Intensity = 0.5f, Layers = RenderLayers.RenderLayerAll, Deferred = true, Type = LightType.Point, DecayStart = 120.0f }, new TransformationComponent { Translation = position } }); }
public BSLightingShaderProperty() { this.shaderType = 0U; this.shaderFlags1 = 2185233152U; this.shaderFlags2 = 32801U; this.uvOffset = new UVCoord(0.0f, 0.0f); this.uvScale = new UVCoord(1f, 1f); this.textureSet = -1; this.emissiveColor = new Color3(0.0f, 0.0f, 0.0f); this.emissiveMultiplier = 1f; this.textureClampMode = 3U; this.alpha = 1f; this.unknownFloat2 = 0.0f; this.glossiness = 80f; this.specularColor = new Color3(1f, 1f, 1f); this.specularStrength = 1f; this.lightingEffect1 = 0.3f; this.lightingEffect2 = 2f; }
private Color3 SetupAmbientLight(IList <ILight> lights) { Color3 ambientColor = Color3.Black; if (lights == null) { return(ambientColor); } foreach (ILight oneLight in lights) { if (oneLight is IAmbientLight && oneLight.IsEnabled) { ambientColor += ((IAmbientLight)oneLight).Color; } } return(ambientColor); }
/// <summary> /// Initializes a new instance of the <see cref="CameraRendererModeWireFrame"/> class. /// </summary> public CameraRendererModeWireFrame() { ModelEffect = WireFrameEffect; // Render only CameraComponent and ModelComponent RenderComponentTypes.Add(typeof(CameraComponent)); RenderComponentTypes.Add(typeof(ModelComponent)); modelComponentAndPickingRenderer = new ModelComponentAndPickingRenderer(); RendererOverrides.Add(typeof(ModelComponent), modelComponentAndPickingRenderer); FrontColor = new Color3(0, 1.0f, 0.0f); BackColor = new Color3(0, 0.5f, 0.0f); AlphaBlend = 1.0f; ColorBlend = 1.0f; BlendFactor = 1.0f; ShowBackface = true; }
/// <summary> /// Initializes a new instance of the <see cref="Vignetting"/> class. /// </summary> public Vignetting(string effect) : base(effect) { Amount = 0.8f; Radius = 0.7f; Color = new Color3(0f); }
public DirectionalLightingEffect(IServiceProvider services, Color3 lightingColor, float lightingIntensity) : base(lightingColor, lightingIntensity, services, "Shaders/VisualEffects/DirectionalLighting.fx", new[] { RenderTargetLayerType.Color, RenderTargetLayerType.Normal }) { Direction = new Vector3(1f, 1f, -1f); }