private void ControllerDraw(Controller3D mc, ulong unused) { System.Diagnostics.Debug.WriteLine("Draw"); GLMatrixCalcUniformBlock mcub = (GLMatrixCalcUniformBlock)items.UB("MCUB"); mcub.SetFull(gl3dcontroller.MatrixCalc); rObjects.Render(glwfc.RenderState, gl3dcontroller.MatrixCalc, false); GLStatics.Check(); //GLStatics.Flush(); var t1 = ts1.GetCounter(); var t2 = ts2.GetCounter(); System.Diagnostics.Debug.WriteLine($"Time Taken {t2 - t1} ns"); var t = sync.ClientWait(ClientWaitSyncFlags.SyncFlushCommandsBit, 100000000); System.Diagnostics.Debug.WriteLine($"Sync {t}"); sync.Dispose(); var azel = gl3dcontroller.PosCamera.EyePosition.AzEl(gl3dcontroller.PosCamera.LookAt, true); this.Text = "Looking at " + gl3dcontroller.MatrixCalc.LookAt + " from " + gl3dcontroller.MatrixCalc.EyePosition + " cdir " + gl3dcontroller.PosCamera.CameraDirection + " azel " + azel + " zoom " + gl3dcontroller.PosCamera.ZoomFactor + " dist " + gl3dcontroller.MatrixCalc.EyeDistance + " FOV " + gl3dcontroller.MatrixCalc.FovDeg; }
private void ControllerDraw(Controller3D mc, ulong unused) { GLMatrixCalcUniformBlock mcub = (GLMatrixCalcUniformBlock)items.UB("MCUB"); mcub.Set(gl3dcontroller.MatrixCalc); vecoutbuffer.ZeroBuffer(); rObjects.Render(glwfc.RenderState, gl3dcontroller.MatrixCalc); int count = vecoutbuffer.ReadInt(0); if (count > 0) { float[] values = vecoutbuffer.ReadFloats(4, Math.Min(2000, count), true); System.Diagnostics.Debug.WriteLine("Count " + count + " min " + values.Min() + " max " + values.Max()); for (int i = 0; i < count; i = i + 4) { Vector3 pos = new Vector3(values[i], values[i + 1], values[i + 2]); System.Diagnostics.Debug.Write(" " + i / 4 + " = " + pos + " : " + values[i + 3]); Vector3 up = new Vector3(0, 1, 0); float value = Vector3.Dot(up, pos); value = 0.0f + value; System.Diagnostics.Debug.WriteLine(" -> dotp" + value); } } this.Text = "Looking at " + gl3dcontroller.MatrixCalc.LookAt + " dir " + gl3dcontroller.PosCamera.CameraDirection + " Dist " + gl3dcontroller.MatrixCalc.EyeDistance; }
private void ControllerDraw(Controller3D mc, ulong time) { // System.Diagnostics.Debug.WriteLine("Draw eye " + gl3dcontroller.MatrixCalc.EyePosition + " to " + gl3dcontroller.Pos.Current); float zeroone10s = ((float)(time % 10000)) / 10000.0f; float zeroone5s = ((float)(time % 5000)) / 5000.0f; float zerotwo5s = ((float)(time % 5000)) / 2500.0f; float degrees = zeroone10s * 360; // matrixbuffer.Write(Matrix4.CreateTranslation(new Vector3(zeroone * 20, 50, 0)),0,true); if (items.Contains("ShaderPos")) { ((GLMultipleTexturedBlended)items.Shader("ShaderPos")).CommonTransform.YRotDegrees = degrees; ((GLMultipleTexturedBlended)items.Shader("ShaderPos")).Blend = zerotwo5s; } if (items.Contains("ShaderMat")) { ((GLMultipleTexturedBlended)items.Shader("ShaderMat")).CommonTransform.ZRotDegrees = degrees; ((GLMultipleTexturedBlended)items.Shader("ShaderMat")).Blend = zerotwo5s; } GLMatrixCalcUniformBlock mcub = (GLMatrixCalcUniformBlock)items.UB("MCUB"); mcub.Set(gl3dcontroller.MatrixCalc); rObjects.Render(glwfc.RenderState, gl3dcontroller.MatrixCalc); this.Text = "Looking at " + gl3dcontroller.MatrixCalc.LookAt + " dir " + gl3dcontroller.PosCamera.CameraDirection + " Dist " + gl3dcontroller.MatrixCalc.EyeDistance; }
private void ControllerDraw(Controller3D mc, ulong unused) { GLMatrixCalcUniformBlock mcub = (GLMatrixCalcUniformBlock)items.UB("MCUB"); mcub.Set(gl3dcontroller.MatrixCalc); rObjects.Render(glwfc.RenderState, gl3dcontroller.MatrixCalc); }
private void ControllerDraw(Controller3D mc, ulong unused) { // System.Diagnostics.Debug.WriteLine("Draw eye " + gl3dcontroller.MatrixCalc.EyePosition + " to " + gl3dcontroller.Pos.Current); GLMatrixCalcUniformBlock mcub = (GLMatrixCalcUniformBlock)items.UB("MCUB"); mcub.Set(gl3dcontroller.MatrixCalc); countbuffer.ZeroBuffer(); rObjects.Render(glwfc.RenderState, gl3dcontroller.MatrixCalc); GLMemoryBarrier.Vertex(); int count = countbuffer.ReadInt(0); Vector4[] d = rejectedbuffer.ReadVector4s(0, count); for (int i = 0; i < count; i++) { System.Diagnostics.Debug.WriteLine(i + " = " + d[i]); } redraw.DrawCount = count; // render passed back ones using red from vecoutbuffer rObjects2.Render(glwfc.RenderState, gl3dcontroller.MatrixCalc); }
private void ControllerDraw(Controller3D mc, ulong unused) { System.Diagnostics.Debug.WriteLine("Draw"); GLMatrixCalcUniformBlock mcub = (GLMatrixCalcUniformBlock)items.UB("MCUB"); mcub.SetFull(gl3dcontroller.MatrixCalc); rObjects.Render(glwfc.RenderState, gl3dcontroller.MatrixCalc, true); GLStatics.Check(); GLStatics.Flush(); var t1 = ts1.GetCounter(); var t2 = ts2.GetCounter(); System.Diagnostics.Debug.WriteLine($"Time Taken {t2-t1} ns"); GLMemoryBarrier.All(); Vector3[] values3 = varyingbuffer.ReadVector3sPacked(0, 8); // varyings seem to ignore the vec3->vec4 packed thingy.. System.Diagnostics.Debug.Assert(values3[1] == new Vector3(shape[1].X, shape[1].Y, shape[1].Z)); System.Diagnostics.Debug.Assert(values3[3] == new Vector3(shape[3].X, shape[3].Y, shape[3].Z)); var azel = gl3dcontroller.PosCamera.EyePosition.AzEl(gl3dcontroller.PosCamera.LookAt, true); this.Text = "Looking at " + gl3dcontroller.MatrixCalc.LookAt + " from " + gl3dcontroller.MatrixCalc.EyePosition + " cdir " + gl3dcontroller.PosCamera.CameraDirection + " azel " + azel + " zoom " + gl3dcontroller.PosCamera.ZoomFactor + " dist " + gl3dcontroller.MatrixCalc.EyeDistance + " FOV " + gl3dcontroller.MatrixCalc.FovDeg; }
private void ControllerDraw(Controller3D mc, ulong unused) { //System.Diagnostics.Debug.WriteLine("Draw"); GLMatrixCalcUniformBlock mcub = (GLMatrixCalcUniformBlock)items.UB("MCUB"); mcub.SetFull(gl3dcontroller.MatrixCalc); rObjects.Render(glwfc.RenderState, gl3dcontroller.MatrixCalc); var azel = gl3dcontroller.PosCamera.EyePosition.AzEl(gl3dcontroller.PosCamera.LookAt, true); this.Text = "Looking at " + gl3dcontroller.MatrixCalc.LookAt + " from " + gl3dcontroller.MatrixCalc.EyePosition + " cdir " + gl3dcontroller.PosCamera.CameraDirection + " azel " + azel + " zoom " + gl3dcontroller.PosCamera.ZoomFactor + " dist " + gl3dcontroller.MatrixCalc.EyeDistance + " FOV " + gl3dcontroller.MatrixCalc.FovDeg; //GL.MemoryBarrier(MemoryBarrierFlags.AllBarrierBits); //Vector4[] databack = dataoutbuffer.ReadVector4(0, 4); //for (int i = 0; i < databack.Length; i += 1) //{ // // databack[i] = databack[i] / databack[i].W; // // databack[i].X = databack[i].X * gl3dcontroller.glControl.Width / 2 + gl3dcontroller.glControl.Width/2; // // databack[i].Y = gl3dcontroller.glControl.Height - databack[i].Y * gl3dcontroller.glControl.Height; // System.Diagnostics.Debug.WriteLine("{0}={1}", i, databack[i].ToStringVec(true)); //} //GLStatics.Check(); }
private void ControllerDraw(Controller3D mc, ulong time) { // System.Diagnostics.Debug.WriteLine("Draw eye " + gl3dcontroller.MatrixCalc.EyePosition + " to " + gl3dcontroller.Pos.Current); float zeroone10000s = ((float)(time % 10000000)) / 10000000.0f; float zeroone5000s = ((float)(time % 5000000)) / 5000000.0f; float zeroone1000s = ((float)(time % 1000000)) / 1000000.0f; float zeroone500s = ((float)(time % 500000)) / 500000.0f; float zeroone100s = ((float)(time % 100000)) / 100000.0f; float zeroone10s = ((float)(time % 10000)) / 10000.0f; float zeroone5s = ((float)(time % 5000)) / 5000.0f; float zerotwo5s = ((float)(time % 5000)) / 2500.0f; float timediv10s = (float)time / 10000.0f; float timediv100s = (float)time / 100000.0f; if (items.Contains("STAR")) { int vid = items.Shader("STAR").GetShader(OpenTK.Graphics.OpenGL4.ShaderType.FragmentShader).Id; ((GLRenderDataTranslationRotation)(rObjects["sun"].RenderData)).RotationDegrees = new Vector3(0, -zeroone100s * 360, 0); var stellarsurfaceshader = (GLPLStarSurfaceFragmentShader)items.Shader("STAR").GetShader(OpenTK.Graphics.OpenGL4.ShaderType.FragmentShader); stellarsurfaceshader.TimeDeltaSpots = zeroone500s; stellarsurfaceshader.TimeDeltaSurface = timediv100s; } if (items.Contains("STAR-M2")) { var vid = items.Shader("STAR-M2").GetShader(OpenTK.Graphics.OpenGL4.ShaderType.VertexShader); ((GLPLVertexShaderModelCoordWorldAutoscale)vid).ModelTranslation = Matrix4.CreateRotationY((float)(-zeroone10s * Math.PI * 2)); var stellarsurfaceshader = (GLPLStarSurfaceFragmentShader)items.Shader("STAR-M2").GetShader(OpenTK.Graphics.OpenGL4.ShaderType.FragmentShader); stellarsurfaceshader.TimeDeltaSpots = zeroone500s; stellarsurfaceshader.TimeDeltaSurface = timediv100s; } if (items.Contains("STAR-M3")) { var vid = items.Shader("STAR-M3").GetShader(OpenTK.Graphics.OpenGL4.ShaderType.VertexShader); ((GLPLVertexShaderModelCoordWorldAutoscale)vid).ModelTranslation = Matrix4.CreateRotationY((float)(-zeroone10s * Math.PI * 2)); var stellarsurfaceshader = (GLPLStarSurfaceFragmentShader)items.Shader("STAR-M3").GetShader(OpenTK.Graphics.OpenGL4.ShaderType.FragmentShader); stellarsurfaceshader.TimeDeltaSpots = zeroone500s; stellarsurfaceshader.TimeDeltaSurface = timediv100s; } if (items.Contains("CORONA")) { ((GLShaderStarCorona)items.Shader("CORONA")).TimeDelta = (float)time / 100000f; } GLMatrixCalcUniformBlock mcub = (GLMatrixCalcUniformBlock)items.UB("MCUB"); mcub.Set(gl3dcontroller.MatrixCalc); rObjects.Render(glwfc.RenderState, gl3dcontroller.MatrixCalc); GL.MemoryBarrier(MemoryBarrierFlags.AllBarrierBits); this.Text = //"Freq " + frequency.ToString("#.#########") + " unRadius " + unRadius + " scutoff" + scutoff + " BD " + blackdeepness + " CE " + concentrationequator " Looking at " + gl3dcontroller.MatrixCalc.LookAt + " dir " + gl3dcontroller.PosCamera.CameraDirection + " Dist " + gl3dcontroller.MatrixCalc.EyeDistance; }
private void ControllerDraw(Controller3D mc, ulong unused) { GLMatrixCalcUniformBlock mcub = (GLMatrixCalcUniformBlock)items.UB("MCUB"); mcub.Set(gl3dcontroller.MatrixCalc); rObjects.Render(glwfc.RenderState, gl3dcontroller.MatrixCalc); GL.MemoryBarrier(MemoryBarrierFlags.VertexAttribArrayBarrierBit); }
// called on Paint of scene private void Draw(object mc, ulong unused) { //System.Diagnostics.Debug.WriteLine("Draw"); GLMatrixCalcUniformBlock mcub = (GLMatrixCalcUniformBlock)items.UB("MCUB"); mcub.SetFull(matrixcalc); // need to store the matrixcalc information into the uniform block rObjects.Render(glwfc.RenderState, matrixcalc); // execute render }
private void ControllerDraw(Controller3D mc, ulong unused) { GLMatrixCalcUniformBlock mcub = (GLMatrixCalcUniformBlock)items.UB("MCUB"); mcub.Set(gl3dcontroller.MatrixCalc); rObjects.Render(glwfc.RenderState, gl3dcontroller.MatrixCalc); this.Text = "Looking at " + gl3dcontroller.MatrixCalc.LookAt + " dir " + gl3dcontroller.PosCamera.CameraDirection + " Dist " + gl3dcontroller.MatrixCalc.EyeDistance; }
private void ControllerDraw(Controller3D mc, ulong time) { float degrees = ((float)time / 5000.0f * 360.0f) % 360f; float degreesd2 = ((float)time / 10000.0f * 360.0f) % 360f; GLMatrixCalcUniformBlock mcub = (GLMatrixCalcUniformBlock)items.UB("MCUB"); mcub.Set(gl3dcontroller.MatrixCalc); System.Diagnostics.Debug.WriteLine("Draw eye " + gl3dcontroller.MatrixCalc.EyePosition + " to " + gl3dcontroller.PosCamera.LookAt); rObjects.Render(glwfc.RenderState, gl3dcontroller.MatrixCalc); }
private void ControllerDraw(Controller3D mc, ulong unused) { //System.Diagnostics.Debug.WriteLine("Draw"); GLMatrixCalcUniformBlock mcub = (GLMatrixCalcUniformBlock)items.UB("MCUB"); mcub.SetFull(gl3dcontroller.MatrixCalc); rObjects.Render(glwfc.RenderState, gl3dcontroller.MatrixCalc); var azel = gl3dcontroller.PosCamera.EyePosition.AzEl(gl3dcontroller.PosCamera.LookAt, true); this.Text = "Main Window Looking at " + gl3dcontroller.MatrixCalc.LookAt + " from " + gl3dcontroller.MatrixCalc.EyePosition + " cdir " + gl3dcontroller.PosCamera.CameraDirection + " azel " + azel + " zoom " + gl3dcontroller.PosCamera.ZoomFactor + " dist " + gl3dcontroller.MatrixCalc.EyeDistance + " FOV " + gl3dcontroller.MatrixCalc.FovDeg; }
private void ControllerDraw(Controller3Dd mc, ulong time) { // System.Diagnostics.Debug.WriteLine("Controller Draw"); GLMatrixCalcUniformBlock mcub = (GLMatrixCalcUniformBlock)items.UB("MCUB"); mcub.SetFull(gl3dcontroller.MatrixCalc); rObjects.Render(glwfc.RenderState, gl3dcontroller.MatrixCalc, false); rBodyObjects.Render(glwfc.RenderState, gl3dcontroller.MatrixCalc, false); if (jdscaling != 0 && lasttime != ulong.MaxValue) { var diff = time - lasttime; // ms between calls currentjd += diff / (60.0 * 60 * 24 * 1000) * jdscaling; // convert ms delta to days, with scaling } lasttime = time; }
private void ControllerDraw(Controller3D mc, ulong time) { //System.Diagnostics.Debug.WriteLine("Draw"); GLMatrixCalcUniformBlock mcub = (GLMatrixCalcUniformBlock)items.UB("MCUB"); mcub.SetFull(gl3dcontroller.MatrixCalc); rObjects.Render(glwfc.RenderState, gl3dcontroller.MatrixCalc, false); if (jdscaling != 0 && lasttime != ulong.MaxValue) { var diff = time - lasttime; // ms between calls currentjd += diff / (60.0 * 60 * 24 * 1000) * jdscaling; // convert ms delta to days, with scaling } lasttime = time; var azel = gl3dcontroller.PosCamera.EyePosition.AzEl(gl3dcontroller.PosCamera.LookAt, true); this.Text = "Looking at " + gl3dcontroller.MatrixCalc.LookAt + " from " + gl3dcontroller.MatrixCalc.EyePosition + " cdir " + gl3dcontroller.PosCamera.CameraDirection + " azel " + azel + " zoom " + gl3dcontroller.PosCamera.ZoomFactor + " dist " + gl3dcontroller.MatrixCalc.EyeDistance + " FOV " + gl3dcontroller.MatrixCalc.FovDeg; }
private void Controller3DDraw(Controller3D c3d, ulong time) { long t1 = hptimer.ElapsedTicks; //TBD // GL.Finish(); // use GL finish to ensure last frame is done - if we are operating above sys tick rate, this will be small time. If we are rendering too much, it will stall long t2 = hptimer.ElapsedTicks; GLMatrixCalcUniformBlock mcb = ((GLMatrixCalcUniformBlock)items.UB("MCUB")); mcb.SetFull(gl3dcontroller.MatrixCalc); // set the matrix unform block to the controller 3d matrix calc. // set up the grid shader size if (gridrenderable != null) { gridrenderable.InstanceCount = gridvertshader.ComputeGridSize(gl3dcontroller.MatrixCalc.EyeDistance, out lastgridwidth); lasteyedistance = gl3dcontroller.MatrixCalc.EyeDistance; gridvertshader.SetUniforms(gl3dcontroller.MatrixCalc.LookAt, lastgridwidth, gridrenderable.InstanceCount); } if (gridbitmapvertshader != null) { float coordfade = lastgridwidth == 10000 ? (0.7f - (c3d.MatrixCalc.EyeDistance / 20000).Clamp(0.0f, 0.7f)) : 0.7f; Color coordscol = Color.FromArgb(coordfade < 0.05 ? 0 : 150, Color.Cyan); gridbitmapvertshader.ComputeUniforms(lastgridwidth, gl3dcontroller.MatrixCalc, gl3dcontroller.PosCamera.CameraDirection, coordscol, Color.Transparent); } if (edsmgalmapregions != null) { edsmgalmapregions.SetY(gl3dcontroller.PosCamera.LookAt.Y); } if (elitemapregions != null) { elitemapregions.SetY(gl3dcontroller.PosCamera.LookAt.Y); } // set the coords fader // set the galaxy volumetric block if (galaxyrenderable != null) { galaxyrenderable.InstanceCount = volumetricblock.Set(gl3dcontroller.MatrixCalc, volumetricboundingbox, gl3dcontroller.MatrixCalc.InPerspectiveMode ? 50.0f : 0); // set up the volumentric uniform //System.Diagnostics.Debug.WriteLine("GI {0}", galaxyrendererable.InstanceCount); galaxyshader.SetDistance(gl3dcontroller.MatrixCalc.InPerspectiveMode ? c3d.MatrixCalc.EyeDistance : -1f); } long t3 = hptimer.ElapsedTicks; if (travelpath != null) { travelpath.Update(time, gl3dcontroller.MatrixCalc.EyeDistance); } if (galmapobjects != null) { galmapobjects.Update(time, gl3dcontroller.MatrixCalc.EyeDistance); } if (galaxystars != null) { galaxystars.Update(time, gl3dcontroller.MatrixCalc.EyeDistance); } if (galaxystars != null && gl3dcontroller.MatrixCalc.EyeDistance < 400) { galaxystars.Request9BoxConditional(gl3dcontroller.PosCamera.LookAt); } long t4 = hptimer.ElapsedTicks; //int[] queryID = new int[2]; //GL.GenQueries(2, queryID); //GL.QueryCounter(queryID[0], QueryCounterTarget.Timestamp); var tmr1 = new GLOperationQueryTimeStamp(); var tmr2 = new GLOperationQueryTimeStamp(); tmr1.Execute(null); rObjects.Render(glwfc.RenderState, gl3dcontroller.MatrixCalc, verbose: false); tmr2.Execute(null); // GL.QueryCounter(queryID[1], QueryCounterTarget.Timestamp); // GL.Flush(); // ensure everything is in the grapghics pipeline //while (tmr2.IsAvailable() == false) // ; long a = tmr1.GetCounter(); long b = tmr2.GetCounter(); //int done = 0; //while (done == 0) //{ // GL.GetQueryObject(queryID[1], GetQueryObjectParam.QueryResultAvailable, out done); //} //GL.GetQueryObject(queryID[0], GetQueryObjectParam.QueryResult, out long a); //GL.GetQueryObject(queryID[1], GetQueryObjectParam.QueryResult, out long b); //System.Diagnostics.Debug.WriteLine($"timer {a} {b} {b-a}" ); long t5 = hptimer.ElapsedTicks; if (debugbuffer != null) { GLMemoryBarrier.All(); Vector4[] debugout = debugbuffer.ReadVector4s(0, 4); System.Diagnostics.Debug.WriteLine("{0},{1},{2},{3}", debugout[0], debugout[1], debugout[2], debugout[3]); } long t = hptimer.ElapsedMilliseconds; long diff = t - lastms; for (int i = frametimes.Length - 1; i > 0; i--) { frametimes[i] = frametimes[i - 1]; } frametimes[0] = diff; lastms = t; double fps = (1000.0 / diff); if (fpsavg <= 1) { fpsavg = fps; } else { fpsavg = (fpsavg * 0.95) + fps * 0.05; } tmr1.Dispose(); tmr2.Dispose(); if (diff > 0) { // System.Diagnostics.Debug.Write($"Frame {hptimer.ElapsedMilliseconds,6} {diff,3} fps {fpsavg:#.0} frames {frametimes[0],3} {frametimes[1],3} {frametimes[2],3} {frametimes[3],3} {frametimes[4],3} {frametimes[5],3} sec {galaxystars.Sectors,3}"); // System.Diagnostics.Debug.WriteLine($" finish {(t2 - t1) * 1000000 / Stopwatch.Frequency,5} t3 {(t3 - t2) * 1000000 / Stopwatch.Frequency,4} t4 {(t4 - t3) * 1000000 / Stopwatch.Frequency,4} render {(t5 - t4) * 1000000 / Stopwatch.Frequency,5} tot {(t5 - t1) * 1000000 / Stopwatch.Frequency,5}"); } // this.Text = "FPS " + fpsavg.ToString("N0") + " Looking at " + gl3dcontroller.MatrixCalc.TargetPosition + " eye@ " + gl3dcontroller.MatrixCalc.EyePosition + " dir " + gl3dcontroller.Pos.CameraDirection + " Dist " + gl3dcontroller.MatrixCalc.EyeDistance + " Zoom " + gl3dcontroller.Pos.ZoomFactor; }