public Refraction Create(Refraction itemToCreate) { var refraction = _context.Refractions.Add(itemToCreate); _context.SaveChanges(); return(refraction); }
internal void Validate(WaterRenderingModuleParameters parameters) { Refraction.Validate(parameters.RefractionParameters); RefractionPartiallySubmergedObjects.Validate(parameters.RefractionPartiallySubmergedObjectsParameters); Reflection.Validate(parameters.ReflectionParameters); ReflectionPartiallySubmergedObjects.Validate(parameters.ReflectionPartiallySubmergedObjectsParameters); RenderPixelLights = parameters.RenderPixelLights; FarClipPlane = parameters.FarClipPlane; AllowMSAA = parameters.AllowMSAA; AllowHDR = parameters.AllowHDR; SortingLayerID = parameters.SortingLayerID; SortingOrder = parameters.SortingOrder; ReflectionZOffset = parameters.ReflectionZOffset; }
public TemplarAssasin(Context context) { Context = context; LocalHero = EntityManager.LocalHero; var spellBook = LocalHero.Spellbook; Refraction = new Refraction(spellBook.GetSpellById(AbilityId.templar_assassin_refraction), Context); Meld = new Meld(spellBook.GetSpellById(AbilityId.templar_assassin_meld), Context); Trap = new Trap(spellBook.GetSpellById(AbilityId.templar_assassin_trap), Context); PsionicProj = new PsionicProj(spellBook.GetSpellById(AbilityId.templar_assassin_trap_teleport), Context); PsionicTrap = new PsionicTrap(spellBook.GetSpellById(AbilityId.templar_assassin_psionic_trap), Context); UpdateManager.CreateIngameUpdate(1000, ItemChecker); }
public WaterGenerator(byte[] options, bool applyFixes = false) { this.waveshape = (Waveshape)options[0]; this.watercolor = (Watercolor)options[1]; this.reflection = (Reflection)options[2]; this.refraction = (Refraction)options[3]; this.bankalpha = (Bankalpha)options[4]; this.appearance = (Appearance)options[5]; this.global_shape = (Global_Shape)options[6]; this.foam = (Foam)options[7]; this.reach_compatibility = options.Length > 8 ? (Reach_Compatibility)options[8] : Reach_Compatibility.Disabled; ApplyFixes = applyFixes; TemplateGenerationValid = true; }
public WaterGenerator(Waveshape waveshape, Watercolor watercolor, Reflection reflection, Refraction refraction, Bankalpha bankalpha, Appearance appearance, Global_Shape global_shape, Foam foam, Reach_Compatibility reach_compatibility, bool applyFixes = false) { this.waveshape = waveshape; this.watercolor = watercolor; this.reflection = reflection; this.refraction = refraction; this.bankalpha = bankalpha; this.appearance = appearance; this.global_shape = global_shape; this.foam = foam; this.reach_compatibility = reach_compatibility; ApplyFixes = applyFixes; TemplateGenerationValid = true; }
public void Load() { Foam = TextureFactory.Create(Utils.Utils.GetImageResource <ITerrain>("Landscape.Terrains.foam.jpg"), TextureWrapMode.Repeat); LoadWaveNumbersModerate(); DataTexture.LoadData(SizedInternalFormat.Rgba16f, WaveNumbers); Texture3 = Foam; Texture4 = DataTexture; Texture5 = TextureFactory.Create(Utils.Utils.GetImageResource <ITerrain>("Landscape.Terrains.IKT4l.jpg"), TextureWrapMode.Repeat); for (int i = 0; i < Width; i += 1) { for (int j = 0; j < Height; j += 1) { Vertices[i + j * Width] = new Vbo { Position = new Vector3((float)i, (float)1, (float)j), TexCoord = new Vector2((float)i / Width, (float)j / Height), Normal = new Vector3(0, 1, 0), }; } } for (int i = 0; i < Width - 1; i++) { for (int j = 0; j < Height - 1; j++) { Indices.Add(j * Width + i); Indices.Add(j * Width + i + 1); Indices.Add((j + 1) * Width + i); Indices.Add((j + 1) * Width + i + 1); Indices.Add((j + 1) * Width + i); Indices.Add(j * Width + i + 1); } } indice = Indices.ToArray(); Refraction = FramBufferOBjectFactory.Create(Width, Height); Refraction.Load(); Reflection = FramBufferOBjectFactory.Create(Width, Height); Reflection.Load(); InitWaterShader(); }
public static (HitResult hit, double refractiveIndexEntering, double refractiveIndexExiting) prepareComputations(Ray r, Intersection i, Intersection[] ixs) { var h = i.figure .AllHits(r.origin, r.dir) .First(hit => Core.Constants.EpsilonCompare(hit.Distance, i.t)); if (ixs == null) { return(h, 1.0, 1.0); } var all = ixs.Select(x => x.figure .AllHits(r.origin, r.dir) .First(hit => Core.Constants.EpsilonCompare(hit.Distance, x.t))) .ToArray(); var(refractiveIndexEntering, refractiveIndexExiting) = Refraction.computeRefractiveIndexes(h.Distance, all); return(h, refractiveIndexEntering, refractiveIndexExiting); }
internal override void Render(RenderingCameraInformation renderingCameraInformation) #endif { var materialModule = _materialModule as WaterMaterialModule; bool renderRefraction = materialModule.IsRefractionEnabled; bool renderReflection = materialModule.IsReflectionEnabled; var mainModule = _mainModule as WaterMainModule; var largeWaterAreaManager = mainModule.LargeWaterAreaManager; bool isConnectedToLargeWaterArea = largeWaterAreaManager != null; ComputeVisibleAreas(!isConnectedToLargeWaterArea ? _meshModule.Bounds : largeWaterAreaManager.GetWaterObjectsBoundsRelativeToSpecifiedWaterObject(mainModule)); #if !GAME_2D_WATER_KIT_LWRP && !GAME_2D_WATER_KIT_URP int pixelLightCount = QualitySettings.pixelLightCount; if (!_renderPixelLights) { QualitySettings.pixelLightCount = 0; } #endif _meshModule.SetRendererActive(false); Color backgroundColor = renderingCameraInformation.CurrentCamera.backgroundColor; backgroundColor.a = 1f; bool isUsingOpaqueRenderQueue = _materialModule.RenderQueue == 2000; if (renderRefraction && !isUsingOpaqueRenderQueue) { SetupRefractionMask(); } #if GAME_2D_WATER_KIT_LWRP || GAME_2D_WATER_KIT_URP _renderingContext = context; #endif if (!materialModule.IsFakePerspectiveEnabled) { if (renderRefraction) { if (!isUsingOpaqueRenderQueue) { SetRefractionMaskLayer(Refraction.GetValidRefractionMaskLayer()); } ExecuteRendering(Refraction, _g2dwCamera, _wholeWaterVisibleArea, backgroundColor, _allowHDR, _allowMSAA); materialModule.SetRefractionRenderTexture(Refraction.RenderTexture); } if (renderReflection) { _refractionMask.SetActive(false); ExecuteRendering(Reflection, _g2dwCamera, _wholeWaterVisibleArea, _clearColor, _allowHDR, _allowMSAA); materialModule.SetReflectionRenderTexture(Reflection.RenderTexture); } } else { if (renderRefraction) { int extraLayersToIgnoreMask = RefractionPartiallySubmergedObjects.CullingMask; if (!isUsingOpaqueRenderQueue) { SetRefractionMaskLayer(Refraction.GetValidRefractionMaskLayer(extraLayersToIgnoreMask)); } ExecuteRendering(Refraction, _g2dwCamera, _wholeWaterVisibleArea, backgroundColor, _allowHDR, _allowMSAA, extraLayersToIgnoreMask); materialModule.SetRefractionRenderTexture(Refraction.RenderTexture); if (!isUsingOpaqueRenderQueue) { SetRefractionMaskLayer(RefractionPartiallySubmergedObjects.GetValidRefractionMaskLayer()); } ExecuteRendering(RefractionPartiallySubmergedObjects, _g2dwCamera, _wholeWaterVisibleArea, _clearColor, _allowHDR, _allowMSAA); materialModule.SetRefractionPartiallySubmergedObjectsRenderTexture(RefractionPartiallySubmergedObjects.RenderTexture); } if (renderReflection) { _refractionMask.SetActive(false); ExecuteRendering(Reflection, _g2dwCamera, _surfaceVisibleArea, _clearColor, _allowHDR, _allowMSAA, ReflectionPartiallySubmergedObjects.CullingMask); materialModule.SetReflectionRenderTexture(Reflection.RenderTexture); ExecuteRendering(ReflectionPartiallySubmergedObjects, _g2dwCamera, _surfaceBelowSubmergeLevelVisibleArea, _clearColor, _allowHDR, _allowMSAA); materialModule.SetReflectionPartiallySubmergedObjectsRenderTexture(ReflectionPartiallySubmergedObjects.RenderTexture); } } _refractionMask.SetActive(false); #if !GAME_2D_WATER_KIT_LWRP && !GAME_2D_WATER_KIT_URP QualitySettings.pixelLightCount = pixelLightCount; #endif _meshModule.SetRendererActive(true); var worldToVisibleAreaMatrix = Matrix4x4.TRS(_wholeWaterVisibleArea.RefractionProperties.Position, _wholeWaterVisibleArea.RefractionProperties.Rotation, new Vector3(1f, 1f, -1f)).inverse; var projectionMatrix = _wholeWaterVisibleArea.RefractionProperties.ProjectionMatrix; materialModule.SetWaterMatrix(projectionMatrix * worldToVisibleAreaMatrix * _mainModule.LocalToWorldMatrix); materialModule.SetReflectionLowerLimit(_mainModule.Height * 0.5f); materialModule.ValidateMaterialPropertyBlock(); if (isConnectedToLargeWaterArea) { SetCurrentFrameRenderInformationToLargeWaterAreaManager(largeWaterAreaManager, renderRefraction, renderReflection, projectionMatrix, worldToVisibleAreaMatrix, renderingCameraInformation.CurrentCamera); } }
public override void Start() { var graphics = Application.GraphicsDevice; // Setup PostProcess. #if !DESKTOP var ssao = new ScreenSpaceAmbientObscurance(graphics); AddPostProcess(ssao); // var ssgi = new ScreenSpaceGlobalIllumination(graphics); //AddPostProcess(ssgi); #endif var fastBloom = new FastBloom(graphics); AddPostProcess(fastBloom); AddPostProcess(new C64Filter(graphics)); AddPostProcess(new CGAFilter(graphics)); AddPostProcess(new ConvolutionFilter(graphics)); AddPostProcess(new FilmFilter(graphics)); AddPostProcess(new GrayScaleFilter(graphics)); AddPostProcess(new AverageColorFilter(graphics)); AddPostProcess(new MotionBlur(graphics)); var refractionPass = new Refraction(graphics); AddPostProcess(refractionPass); refractionPass.RefractionTexture = Application.Content.Load <Texture2D>("Textures/hexagrid"); refractionPass.TextureTiling = new Vector2(0.5f); var vignette = new Vignette(graphics); AddPostProcess(vignette); AddPostProcess(new GlobalFog(graphics)); AddPostProcess(new FXAA(graphics)); // Setup UI var titles = new List <string>(); #if !DESKTOP titles.AddRange(new string[] { "Ambient Obscurance", // "SSGI" }); #endif titles.AddRange(new string[] { "Bloom", "C64 Filter", "CGA Filter", "Convolution", "Film", "GrayScale", "Average Color", "Motion Blur", "Refraction", "Vignette", "Global Fog", "FXAA" }); var count = titles.Count; _boxRect = new Rectangle(Screen.VirtualWidth - 220, 10, 210, 45 * count); _widgets = new Widget[count]; for (int i = 0; i < count; i++) { _widgets[i] = new Widget(); _widgets[i].Name = titles[i]; if (i == 0) { _widgets[i].Rect = new Rectangle(_boxRect.X + 10, _boxRect.Y + 30, _boxRect.Width - 20, 30); } else { _widgets[i].Rect = new Rectangle(_boxRect.X + 10, _widgets[i - 1].Rect.Y + 40, _boxRect.Width - 20, 30); } _widgets[i].RectExt = new Rectangle(_widgets[i].Rect.X - 1, _widgets[i].Rect.Y - 1, _widgets[i].Rect.Width + 1, _widgets[i].Rect.Height + 1); } _backgroundTexture = GraphicsHelper.CreateTexture(Color.CornflowerBlue, 1, 1); var renderSettings = Scene.current.RenderSettings; renderSettings.FogDensity = 0.0085f; renderSettings.FogMode = FogMode.Linear; renderSettings.Skybox.OverrideSkyboxFog(FogMode.Exp2, 0.05f, 0, 0); }
public override void Start() { var graphics = Application.GraphicsDevice; // Setup PostProcess. #if !DESKTOP var colorGrading = new ColorGrading(graphics); AddPostProcess(colorGrading); colorGrading.LookUpTable = Application.Content.Load <Texture2D>("Textures/Luts/lut_default"); #endif var oldBloom = new BloomLegacy(graphics); AddPostProcess(oldBloom); oldBloom.Settings = new BloomLegacySettings("Profile", 0.15f, 1f, 4.0f, 1.0f, 1f, 1f); var newBloom = new Bloom(graphics); AddPostProcess(newBloom); newBloom.SetPreset(new float[] { 5, 1, 1, 1, 1 }, new float[] { 1, 1, 1, 1, 1 }, 1, 5); AddPostProcess(new C64Filter(graphics)); AddPostProcess(new CGAFilter(graphics)); AddPostProcess(new ConvolutionFilter(graphics)); AddPostProcess(new FilmFilter(graphics)); AddPostProcess(new FXAA(graphics)); AddPostProcess(new GrayScaleFilter(graphics)); AddPostProcess(new AverageColorFilter(graphics)); AddPostProcess(new MotionBlur(graphics)); var refractionPass = new Refraction(graphics); AddPostProcess(refractionPass); refractionPass.RefractionTexture = Application.Content.Load <Texture2D>("Textures/hexagrid"); refractionPass.TextureTiling = new Vector2(0.5f); var vignette = new Vignette(graphics); AddPostProcess(vignette); // Setup UI var titles = new List <string>(); #if !DESKTOP titles.Add("Color Grading"); #endif titles.AddRange(new string[] { "Old Bloom", "New Bloom", "C64 Filter", "CGA Filter", "Convolution", "Film", "FXAA", "GrayScale", "Average Color", "Motion Blur", "Refraction", "Vignette" }); var count = titles.Count; _boxRect = new Rectangle(Screen.VirtualWidth - 190, 10, 180, 45 * count); _widgets = new Widget[count]; for (int i = 0; i < count; i++) { _widgets[i] = new Widget(); _widgets[i].Name = titles[i]; if (i == 0) { _widgets[i].Rect = new Rectangle(_boxRect.X + 10, _boxRect.Y + 30, _boxRect.Width - 20, 30); } else { _widgets[i].Rect = new Rectangle(_boxRect.X + 10, _widgets[i - 1].Rect.Y + 40, _boxRect.Width - 20, 30); } _widgets[i].RectExt = new Rectangle(_widgets[i].Rect.X - 1, _widgets[i].Rect.Y - 1, _widgets[i].Rect.Width + 1, _widgets[i].Rect.Height + 1); } _backgroundTexture = GraphicsHelper.CreateTexture(Color.CornflowerBlue, 1, 1); }
void CastLight() { // Debug.LogWarning("CastLight 1"); int spIdx = 0; int gunIdx = 0; linePoints.Clear(); //光线起始点 Vector2 startPoint = transform.position; //光线射出方向 Vector2 direction = (Vector2)transform.up; if (_shotDir != Vector2.zero) { direction = _shotDir; } linePoints.Add(startPoint); RaycastHit2D hit = new RaycastHit2D(); // do // { // Debug.LogWarning("CastLight 2"); hit = Physics2D.Raycast(startPoint, direction); if (hit.collider != null) { linePoints.Add(hit.point); //添加击中点闪光 if (spIdx >= _shiningPoints.Count) { var ogg = ObjectPool.GetInstance().GetShiningPoint(); _shiningPoints.Add(ogg); } GameObject gObj = _shiningPoints[spIdx]; // gObj.transform.parent = transform; gObj.transform.position = hit.point; spIdx++; // Debug.LogWarning("CastLight 3 var obj = hit.collider.gameObject; LightCondition lc = obj.GetComponent <LightCondition>(); bool isMatch = true; if (lc != null) { lc.LightShining(color, LineStrenth); isMatch = lc.isMatch(); } if (!isMatch) { ClearDirty(spIdx, gunIdx); return; } // Debug.LogWarning("CastLight 4"); Reflect re = obj.GetComponent <Reflect>(); if (re != null) { //利用Vector2的反射函数来计算反射方向 var inDirection = hit.point - (Vector2)startPoint; direction = re.GetOutDirection(inDirection, hit.normal); if (gunIdx >= _guns.Count) { var gg = ObjectPool.GetInstance().GetGun(); _guns.Add(gg); } GameObject gun = _guns[gunIdx]; Gun g = gun.GetComponent <Gun>(); g.SetShotDir(direction); // gun.transform.parent = transform; // gun.transform.position = hit.point + direction * 0.01f; gun.transform.position = hit.point + direction * 0.01f; // Debug.LogWarning("Reflect hit.point=" + hit.point + ",gun position=" + gun.transform.position); gunIdx++; } // Debug.LogWarning("CastLight 5"); ThroughPass th = obj.GetComponent <ThroughPass>(); if (th != null) { // Debug.Log("Exec ThroughPass LightShining"); var inDirection = hit.point - (Vector2)startPoint; Vector2 hitP = th.GetOutPosition(hit.point, inDirection); if (gunIdx >= _guns.Count) { _guns.Add(ObjectPool.GetInstance().GetGun()); } GameObject gun = _guns[gunIdx]; Gun g = gun.GetComponent <Gun>(); if (th.UseOriginLight) { g.color = color; g.LineStrenth = LineStrenth; // g.ResetLight(); } else { var c = th.OutColor; if (th.OutColor == 0) { c = color; } var l = th.OutLineStrength; if (th.OutLineStrength == 0) { l = LineStrenth; } g.color = c; g.LineStrenth = l; // g.ResetLight(); } g.SetShotDir(inDirection); g.SetLightInfo(g.color, g.LineStrenth); // gun.transform.parent = transform; // gun.transform.position = hit.point + direction * 0.01f; gun.transform.position = hitP; // Debug.LogWarning("Through[" + th.gameObject.name + "] hit.point=" + hit.point + ",gun position=" + gun.transform.position); gunIdx++; // th.LightShining(lineRenderer,hit.point,linePoints[linePoints.Count-1]-linePoints[linePoints.Count-2],color,LineStrenth); } // Debug.LogWarning("CastLight 6"); Refraction refr = obj.GetComponent <Refraction>(); if (refr != null) { var inDirection = hit.point - (Vector2)startPoint; Vector2 outDir = refr.GetOutDir(inDirection); Vector2 hitP = refr.GetOutPosition(outDir); if (gunIdx >= _guns.Count) { _guns.Add(ObjectPool.GetInstance().GetGun()); } GameObject gun = _guns[gunIdx]; Gun g = gun.GetComponent <Gun>(); if (refr.UseOriginLight) { g.color = color; g.LineStrenth = LineStrenth; } else { var c = refr.OutColor; if (refr.OutColor == 0) { c = color; } var l = refr.OutLineStrength; if (refr.OutLineStrength == 0) { l = LineStrenth; } g.color = c; g.LineStrenth = l; // g.ResetLight(); } g.SetShotDir(outDir); g.SetLightInfo(g.color, g.LineStrenth); // gun.transform.parent = transform; // gun.transform.position = hit.point + direction * 0.01f; gun.transform.position = hitP; // Debug.LogWarning("Refraction[" + refr.gameObject.name + "] hit.point=" + hit.point + ",gun position=" + gun.transform.position); gunIdx++; } ActiveObject ao = obj.GetComponent <ActiveObject>(); if (ao != null) { // Debug.Log("Exec LightShining"); ao.LightShining(lineRenderer); } Diliver di = obj.GetComponent <Diliver>(); if (di != null) { // Debug.Log("Exec Diliver LightShining"); di.LightShining(lineRenderer); } Collections co = obj.GetComponent <Collections>(); if (co != null) { // Debug.Log("Exec Collections LightShining"); co.LightShining(); } FrameAni fa = obj.GetComponent <FrameAni>(); if (fa != null) { // Debug.LogWarning("Exec FrameAni LightShining"); fa.LightShining(); } } else { var p = startPoint + (direction * 1920 / 100f); linePoints.Add(p); } ClearDirty(spIdx, gunIdx); // } while (needReflect); }
public void MakeRefractionTextures(BeginMode mode, Matrix4 viewMatrix, Matrix4 invertedViewMatrix, Matrix4 projectionMatrix, float[] clipPlaneEq, Action <BeginMode, Matrix4, Matrix4, Matrix4, float[]> renderFunc) { Refraction.GenerateProjectiveTexture(mode, invertedViewMatrix, projectionMatrix, clipPlaneEq, renderFunc); }
public Refraction Update(Refraction itemToUpdate) { _context.Entry(itemToUpdate).State = EntityState.Modified; _context.SaveChanges(); return(itemToUpdate); }