public Settings() { basicSettings = new BasicSettings(); mapSettings = new MapSettings(); lightSettings = new LightSettings(); effectSettings = new EffectSettings(); }
///<summary> /// Создает DirectX-овский объект Light из данных настроек. /// </summary> /// <returns></returns> public static Light ToDirectXLight(this LightSettings lsets) { Color color = Color.FromName(lsets.ColorString); var l = new Light { Diffuse = color, Specular = color, Direction = lsets.Direction.ToDirectXVector(), Position = lsets.Position.ToDirectXVector(), Type = LightType.Directional, Phi = (float)lsets.OuterAngle.Radian, Theta = (float)lsets.InnerAngle.Radian, Falloff = 1.0f, Range = 1000, Attenuation0 = 1f, Attenuation1 = 0.001f, }; if (lsets.Type == LightSettings.MyLightType.Ambient) { l.Ambient = color; l.Direction = -Vector3.UnitZ; } LightType x; if (Enum.TryParse(lsets.Type.ToString(), out x)) { l.Type = x; } return(l); }
private void DoForces(Rigidbody2D body, LightEdge edge, RotatableLight.RotationConstraints constraints) { var edgeAccel = edge.GetAppliedAngularAcceleration(); var accelTowardsCenter = edge.GetAppliedAccelTowardsCenter(); //if (edgeAccel != 0) { // Debug.Log("Edge accel: " + edgeAccel); // Debug.Log("Central Force" + accelTowardsCenter); //} LightSettings s = settings; edge.SetInertia(s.inertia); var accel = -edge.GetAppliedAngularAcceleration() * s.mult; //accel = Mathf.Sign(accel) * Mathf.Sqrt(Mathf.Abs(accel)); accelTowardsCenter *= s.centralAccelerationConstant; accel = Mathf.Sign(accel) * (Mathf.Abs(accel) + Mathf.Abs(accelTowardsCenter)); accel = Mathf.Clamp(accel, -s.maxAccel, s.maxAccel); if (Mathf.Abs(accel) < s.minAccel) { accel = 0; } body.rotation -= Mathf.Clamp(edge.AngularDifferenceFromTarget() * s.resolveConstant, -s.maxResolve, s.maxResolve); constraints.Apply(body); body.AddTorque(accel * body.inertia); }
internal static RenderPipelineSettings NewDefault() => new RenderPipelineSettings() { supportShadowMask = true, supportSSAO = true, supportSubsurfaceScattering = true, sssSampleBudget = new IntScalableSetting(new[] { (int)DefaultSssSampleBudgetForQualityLevel.Low, (int)DefaultSssSampleBudgetForQualityLevel.Medium, (int)DefaultSssSampleBudgetForQualityLevel.High }, ScalableSettingSchemaId.With3Levels), supportVolumetrics = true, supportDistortion = true, supportTransparentBackface = true, supportTransparentDepthPrepass = true, supportTransparentDepthPostpass = true, colorBufferFormat = ColorBufferFormat.R11G11B10, supportCustomPass = true, customBufferFormat = CustomBufferFormat.R8G8B8A8, supportedLitShaderMode = SupportedLitShaderMode.DeferredOnly, supportDecals = true, supportDecalLayers = false, decalLayerName0 = "Decal Layer default", decalLayerName1 = "Decal Layer 1", decalLayerName2 = "Decal Layer 2", decalLayerName3 = "Decal Layer 3", decalLayerName4 = "Decal Layer 4", decalLayerName5 = "Decal Layer 5", decalLayerName6 = "Decal Layer 6", decalLayerName7 = "Decal Layer 7", msaaSampleCount = MSAASamples.None, supportMotionVectors = true, supportRuntimeDebugDisplay = false, supportRuntimeAOVAPI = false, supportDitheringCrossFade = true, supportTerrainHole = false, lightLoopSettings = GlobalLightLoopSettings.NewDefault(), hdShadowInitParams = HDShadowInitParameters.NewDefault(), decalSettings = GlobalDecalSettings.NewDefault(), postProcessSettings = GlobalPostProcessSettings.NewDefault(), dynamicResolutionSettings = GlobalDynamicResolutionSettings.NewDefault(), lowresTransparentSettings = GlobalLowResolutionTransparencySettings.NewDefault(), xrSettings = GlobalXRSettings.NewDefault(), postProcessQualitySettings = GlobalPostProcessingQualitySettings.NewDefault(), lightingQualitySettings = GlobalLightingQualitySettings.NewDefault(), lightSettings = LightSettings.NewDefault(), supportRayTracing = false, supportedRayTracingMode = SupportedRayTracingMode.Both, lodBias = new FloatScalableSetting(new[] { 1.0f, 1, 1 }, ScalableSettingSchemaId.With3Levels), maximumLODLevel = new IntScalableSetting(new[] { 0, 0, 0 }, ScalableSettingSchemaId.With3Levels), lightLayerName0 = "Light Layer default", lightLayerName1 = "Light Layer 1", lightLayerName2 = "Light Layer 2", lightLayerName3 = "Light Layer 3", lightLayerName4 = "Light Layer 4", lightLayerName5 = "Light Layer 5", lightLayerName6 = "Light Layer 6", lightLayerName7 = "Light Layer 7", supportProbeVolume = false, probeVolumeSettings = GlobalProbeVolumeSettings.@default, };
public void SetLighting(LightSettings lightSettings) { if (null == lightSettings) { throw new ArgumentNullException(nameof(lightSettings)); } _altaxoLightSettings = lightSettings; }
internal static RenderPipelineSettings NewDefault() { RenderPipelineSettings settings = new RenderPipelineSettings() { supportShadowMask = true, supportSSAO = true, supportSubsurfaceScattering = true, sssSampleBudget = new IntScalableSetting(new[] { (int)DefaultSssSampleBudgetForQualityLevel.Low, (int)DefaultSssSampleBudgetForQualityLevel.Medium, (int)DefaultSssSampleBudgetForQualityLevel.High }, ScalableSettingSchemaId.With3Levels), supportVolumetrics = true, supportDistortion = true, supportTransparentBackface = true, supportTransparentDepthPrepass = true, supportTransparentDepthPostpass = true, colorBufferFormat = ColorBufferFormat.R11G11B10, supportCustomPass = true, customBufferFormat = CustomBufferFormat.R8G8B8A8, supportedLitShaderMode = SupportedLitShaderMode.DeferredOnly, supportDecals = true, supportDecalLayers = false, supportSurfaceGradient = true, decalNormalBufferHP = false, msaaSampleCount = MSAASamples.None, supportMotionVectors = true, supportRuntimeAOVAPI = false, supportDitheringCrossFade = true, supportTerrainHole = false, supportWater = false, waterSimulationResolution = WaterSimulationResolution.Medium128, planarReflectionResolution = new PlanarReflectionAtlasResolutionScalableSetting(new[] { PlanarReflectionAtlasResolution.Resolution256, PlanarReflectionAtlasResolution.Resolution1024, PlanarReflectionAtlasResolution.Resolution2048 }, ScalableSettingSchemaId.With3Levels), lightLoopSettings = GlobalLightLoopSettings.NewDefault(), hdShadowInitParams = HDShadowInitParameters.NewDefault(), decalSettings = GlobalDecalSettings.NewDefault(), postProcessSettings = GlobalPostProcessSettings.NewDefault(), dynamicResolutionSettings = GlobalDynamicResolutionSettings.NewDefault(), lowresTransparentSettings = GlobalLowResolutionTransparencySettings.NewDefault(), xrSettings = GlobalXRSettings.NewDefault(), postProcessQualitySettings = GlobalPostProcessingQualitySettings.NewDefault(), lightingQualitySettings = GlobalLightingQualitySettings.NewDefault(), lightSettings = LightSettings.NewDefault(), supportRayTracing = false, supportedRayTracingMode = SupportedRayTracingMode.Both, lodBias = new FloatScalableSetting(new[] { 1.0f, 1, 1 }, ScalableSettingSchemaId.With3Levels), maximumLODLevel = new IntScalableSetting(new[] { 0, 0, 0 }, ScalableSettingSchemaId.With3Levels), supportProbeVolume = false, probeVolumeMemoryBudget = ProbeVolumeTextureMemoryBudget.MemoryBudgetMedium, supportProbeVolumeStreaming = false, probeVolumeSHBands = ProbeVolumeSHBands.SphericalHarmonicsL1, }; return(settings); }
public void ValidAmbient() { Light l = new LightSettings { ColorString = "White", Type = LightSettings.MyLightType.Ambient, }.ToDirectXLight(); Assert.That(Color.White.RgbEquals(l.Ambient.ToColor())); ValidateWithDevice(l); }
public void Directional() { var direction = new Point3D(0, 0, -1); Light l = new LightSettings { ColorString = "White", Type = LightSettings.MyLightType.Directional, Direction = direction }.ToDirectXLight(); ValidateWithDevice(l); }
public void ValidColor() { Light l = new LightSettings { ColorString = "Red", Type = LightSettings.MyLightType.Directional, Direction = new Point3D(0, 0, -1) }.ToDirectXLight(); Assert.That(Color.Red.RgbEquals(l.Diffuse.ToColor())); ValidateWithDevice(l); }
public void Point() { var position = new Point3D(200, 300, -100); Light l = new LightSettings { ColorString = "White", Type = LightSettings.MyLightType.Point, Position = position, }.ToDirectXLight(); Assert.AreEqual(position.ToDirectXVector(), l.Position); ValidateWithDevice(l); }
public void Spot() { var position = new Point3D(200, 300, -100); var direction = new Point3D(0, 0, -1); Light l = new LightSettings { ColorString = "White", Type = LightSettings.MyLightType.Spot, Position = position, Direction = direction }.ToDirectXLight(); ValidateWithDevice(l); }
private string LayerName; // The name of the Layer used for drawing the light public DrawLight(Model model, int numLight, Point3D centerScene, double radius, string layerName) { ModelOriginal = model; NumLight = numLight; CenterScene = centerScene; Radius = radius; LayerName = layerName; switch (NumLight) { case 1: Light = ModelOriginal.Light1; break; case 2: Light = ModelOriginal.Light2; break; case 3: Light = ModelOriginal.Light3; break; case 4: Light = ModelOriginal.Light4; break; case 5: Light = ModelOriginal.Light5; break; case 6: Light = ModelOriginal.Light6; break; case 7: Light = ModelOriginal.Light7; break; case 8: Light = ModelOriginal.Light8; break; } }
public void Update_LightSettings(bool enabled, LightSettings lightSettings) { if (enabled) { if (lightSettings == LightSettings.Baked) { Light[] lights = GameObject.FindObjectsOfType <Light> (); foreach (Light l in lights) { SerializedObject serialLightSource = new SerializedObject(l); SerializedProperty SerialProperty = serialLightSource.FindProperty("m_Lightmapping"); SerialProperty.intValue = 2; serialLightSource.ApplyModifiedProperties(); } } if (lightSettings == LightSettings.Realtime) { Light[] lights = GameObject.FindObjectsOfType <Light> (); foreach (Light l in lights) { SerializedObject serialLightSource = new SerializedObject(l); SerializedProperty SerialProperty = serialLightSource.FindProperty("m_Lightmapping"); SerialProperty.intValue = 4; serialLightSource.ApplyModifiedProperties(); } } if (lightSettings == LightSettings.Mixed) { Light[] lights = GameObject.FindObjectsOfType <Light> (); foreach (Light l in lights) { SerializedObject serialLightSource = new SerializedObject(l); SerializedProperty SerialProperty = serialLightSource.FindProperty("m_Lightmapping"); SerialProperty.intValue = 1; serialLightSource.ApplyModifiedProperties(); } } } }
public ToonEffect(ContentManager content, BasicEffect effect) : base(content.Load<Effect>("Effect/toon")) { // EffectParamterの準備 ambientLightColor = Parameters["AmbientLightColor"]; lightSettings = new LightSettings[3]; for (int i = 0; i < 3; i++) { lightSettings[i] = new LightSettings(Parameters, "Light" + i); } worldMatrix = Parameters["World"]; viewMatrix = Parameters["View"]; projectionMatrix = Parameters["Projection"]; enableDepthShadow = Parameters["EnableDepthShadow"]; shadowmap = Parameters["Shadowmap"]; shadowViewMatrix = Parameters["ShadowView"]; shadowProjectionMatrix = Parameters["ShadowProjection"]; NormalTechnique = effect.TextureEnabled ? Techniques["Toon"] : Techniques["ToonWithoutTexture"]; CurrentTechnique = NormalTechnique; // 値を送る toneTexture = content.Load<Texture2D>("Effect/tone"); Parameters["ToneTexture"].SetValue(toneTexture); Parameters["AlbedTexture"].SetValue(effect.Texture); Parameters["DiffuseColor"].SetValue(effect.DiffuseColor); Parameters["SpecularColor"].SetValue(effect.SpecularColor); Parameters["EmissiveColor"].SetValue(effect.EmissiveColor); Parameters["SpecularPower"].SetValue(effect.SpecularPower * 0.2f); Parameters["Alpha"].SetValue(effect.Alpha); Vector2[] kernelStep = new Vector2[25]; for (int i = 0; i < 25; i++) { kernelStep[i] = new Vector2(1.0f / 4096 * ((i % 5) - 2), 1.0f / 4096 * ((i / 5) - 2)); } Parameters["KernelStep"].SetValue(kernelStep); }
public MainRenderer() { LightSettings = new LightSettings(); Meshes = new MeshManager(); InstanceList = new List <RenderInstance>(); Camera = new Cameras.FirstPersonCamera(); rasterizerStateDescFill.FillMode = FillMode.Solid; rasterizerStateDescFill.CullMode = CullMode.Back; rasterizerStateDescWireframe.FillMode = FillMode.Wireframe; rasterizerStateDescWireframe.CullMode = CullMode.None; // Setup new projection matrix with correct aspect ratio Camera.CameraPosition = new Vector3(0.0f, 0.0f, 0.0f); Camera.NearClipPlane = 0.1f; Camera.FarClipPlane = 100.0f; Camera.FieldOfView = (float)Math.PI / 4.0f; Camera.BackBufferResolution = new Vector2(GraphicsDevice.Instance.m_viewport.Width, GraphicsDevice.Instance.m_viewport.Height); Camera.SetMatrices(); }
private bool _isDisposed = false; // To detect redundant calls protected virtual void Dispose(bool disposing) { if (!_isDisposed) { if (disposing) { _altaxoDrawingGeometry?.Dispose(); _altaxoDrawingGeometry = null; _altaxoMarkerGeometry?.Dispose(); _altaxoMarkerGeometry = null; _altaxoOverlayGeometry?.Dispose(); _altaxoOverlayGeometry = null; _altaxoCamera = null; _altaxoLightSettings = null; } if (null != _cachedDevice) { Detach(); } _isDisposed = true; } }
private LightSettings previousSettings; // Lighting previous state values #endregion #region Main Methods public void AwakeBehaviour() { // Initialize values previousSettings = new LightSettings(directionalLight.intensity, directionalLight.color); }
public void SetLighting(LightSettings lightSettings, CameraBase camera) { Matrix4x3 cameraM = Matrix4x3.Identity; if (lightSettings.IsAnyLightAffixedToCamera) { // if a light is affixed to the camera, its position is considered to be in camera coordinates // but here we need the light in world coordinates // cameraM transforms from camera coordinates to world coordinates cameraM = camera.InverseLookAtRHMatrix; } // first ambient light var al = lightSettings.AmbientLight; SetAmbientLight(al.ColorBelow.Color, al.ColorAbove.Color, al.LightAmplitude, al.IsAffixedToCamera ? cameraM.Transform(al.DirectionBelowToAbove) : al.DirectionBelowToAbove); for (int idx = 0; idx < 4; ++idx) { var l = lightSettings.GetDiscreteLight(idx); if (null == l) { ClearSingleLight(idx); } else if (l is DirectionalLight) { var dl = (DirectionalLight)l; SetDirectionalLight( idx, dl.Color.Color, dl.LightAmplitude, dl.IsAffixedToCamera ? cameraM.Transform(dl.DirectionToLight) : dl.DirectionToLight ); } else if (l is PointLight) { var pl = (PointLight)l; SetPointLight( idx, pl.Color.Color, pl.LightAmplitude, pl.IsAffixedToCamera ? cameraM.Transform(pl.Position) : pl.Position, pl.Range ); } else if (l is SpotLight) { var sl = (SpotLight)l; // calculation of SpotCosInnerConeRcp: it is in reality not 1/CosInnerConeAngle, but it is 1/(Cos(InnerConeAngle) - Cos(OuterConeAngle)) double diffCos = Math.Cos(sl.InnerConeAngle) - Math.Cos(sl.OuterConeAngle); double SpotCosInnerConeRcp = diffCos >= 1E-18 ? 1 / diffCos : 1E18; SetSpotLight( idx, sl.Color.Color, sl.LightAmplitude, sl.IsAffixedToCamera ? cameraM.Transform(sl.Position) : sl.Position, sl.IsAffixedToCamera ? cameraM.Transform(sl.DirectionToLight) : sl.DirectionToLight, sl.Range, Math.Cos(sl.OuterConeAngle), SpotCosInnerConeRcp ); } else { throw new NotImplementedException(string.Format("The type of lighting ({0}) is not implemented here.")); } } AssembleLights(); }