Esempio n. 1
0
 public override void CommitVisual(CCommandList cmd, Graphics.CGfxCamera camera, GamePlay.SceneGraph.CheckVisibleParam param)
 {
     if (EngineNS.CIPlatform.Instance.PlayMode == CIPlatform.enPlayMode.Editor)
     {
         mLineMeshComponent?.CommitVisual(cmd, camera, param);
     }
 }
Esempio n. 2
0
        //string mStrFileName;
        internal void RenderTick(CCommandList cmd)
        {
            foreach (var actor in mWorld.Actors.Values)
            {
                actor.PreUse(true);
            }

            CalculateCamera(mCamera, 1.0);

            EngineNS.CEngine.Instance.TextureManager.PauseKickResource = true;
            var saveTime   = EngineNS.CEngine.Instance.EngineTime;
            var saveElapse = EngineNS.CEngine.Instance.EngineElapseTime;

            var savedCall = mRP_Snapshot.OnAfterTickLogic;

            for (int i = 0; i < mFrameNum; i++)
            {
                EngineNS.CEngine.Instance._UpdateEngineTime(saveTime + mDuration * i / mFrameNum);
                EngineNS.CEngine.Instance.SetPerFrameCBuffer();

                mRP_Snapshot.OnAfterTickLogic = null;
                TickLogicEvent?.Invoke(this, i);
                mRP_Snapshot.TickSync();
                mRP_Snapshot.TickRender(null);

                mRP_Snapshot.OnAfterTickLogic = savedCall;
                TickLogicEvent?.Invoke(this, i);
                mRP_Snapshot.TickSync();
                mRP_Snapshot.TickRender(null);
            }
            EngineNS.CEngine.Instance._ResetTime(saveTime, saveElapse);
            EngineNS.CEngine.Instance.SetPerFrameCBuffer();
            EngineNS.CEngine.Instance.TextureManager.PauseKickResource = false;
        }
        public override void _OnEditorCommitVisual(CCommandList cmd, Graphics.CGfxCamera camera, GamePlay.SceneGraph.CheckVisibleParam param)
        {
            if (CEngine.PhysicsDebug == false)
            {
                return;
            }
            if (mDebugActor == null && mReady == false)
            {
                mReady = true;
                var test = CreateDefaultCapsule();

                test = SetMaterial();
            }

            if (mDebugActor != null)
            {
                float r          = 0.5f;
                float halfHeight = 0.5f;
                HostShape.IfGetCapsule(ref r, ref halfHeight);
                var trans = Placement.Transform * SocketMatrix * HostPlaceable.Placement.WorldMatrix;
                //mDebugActor.Placement.Location = RigidBody.Position;
                Vector3    scale, loc;//mDebugActor.Placement.Scale;
                Quaternion rotate;
                trans.Decompose(out scale, out rotate, out loc);
                var y = (r + halfHeight) * 2;
                scale.SetValue(scale.X * r * 2, scale.Y * y, scale.Z * r * 2);
                mDebugActor.Placement.Scale = scale;
            }
        }
Esempio n. 4
0
        public void OnCheckVisible(CCommandList cmd, GSceneGraph scene, CGfxCamera camera, CheckVisibleParam param)
        {
            if (HostSet == null)
            {
                throw new InvalidOperationException("");
            }
            var bitSet = HostSet.PvsData[PvsIndex];

            if (scene.PVSActors != null && scene.PVSActors.Length == bitSet.BitCount)
            {
                for (int i = 0; i < bitSet.BitCount; i++)
                {
                    if (!bitSet.IsBit(i))
                    {
                        continue;
                    }

                    Actor.GActor actor = scene.PVSActors[i];
                    if (actor.NeedCheckVisible(param) == false)
                    {
                        continue;
                    }
                    if (param.FrustumCulling && actor.CheckContain(camera.CullingFrustum, true) == CGfxCamera.CFrustum.CONTAIN_TYPE.CONTAIN_TEST_OUTER)
                    {
                        continue;
                    }

                    actor.OnCheckVisible(cmd, scene, camera, param);
                }
            }
        }
Esempio n. 5
0
 partial void CheckVisible_Editor(CCommandList cmd, Graphics.CGfxCamera camera, SceneGraph.CheckVisibleParam param)
 {
     foreach (var i in EditorActors.Values)
     {
         i.OnCheckVisible(cmd, null, camera, param);
     }
 }
Esempio n. 6
0
        public void Tick(CCommandList cmd, CGfxParticleSystem sys, float elaspe)
        {
            ScopeTick.Begin();

            sys.Simulate(elaspe);//这里处理粒子死亡释放

            ScopeTickDeath.Begin();
            ScopeTickSubDeath.Begin();
            sys.DealDeathParticles();
            ScopeTickSubDeath.End();
            ScopeTickSubBorn.Begin();

            sys.TriggerParticle();

            ScopeTickSubBorn.End();
            ScopeTickDeath.End();

            //粒子系统的更新
            if (sys.MacrossNode != null)
            {
                ParticleData.ParticleSystem = sys;
                sys.MacrossNode.Update(elaspe, ParticleData);
            }
            ScopeTickState.Begin();
            sys.UpdateParticleSubState(elaspe);
            ScopeTickState.End();

            ScopeTickCompose.Begin();
            sys.DealParticleStateCompose(elaspe);
            ScopeTickCompose.End();

            sys.Flush2VB(cmd);

            ScopeTick.End();
        }
Esempio n. 7
0
        //private CMRTClearColor[] mClearColorArray = new CMRTClearColor[]
        //{
        //    new CMRTClearColor(0, 0xFFFFFFFF),
        //    new CMRTClearColor(1, 0x00000000),
        //};

        public CGfxRP_SceneCapture()
        {
            var RHICtx = CEngine.Instance.RenderContext;

            var cmdListDesc = new CCommandListDesc();

            mCommandList_Final = RHICtx.CreateCommandList(cmdListDesc);
        }
Esempio n. 8
0
 public override void CommitVisual(CCommandList cmd, EngineNS.Graphics.CGfxCamera camera, GamePlay.SceneGraph.CheckVisibleParam param)
 {
     base.CommitVisual(cmd, camera, param);
     if (mMeshComponent != null)
     {
         mMeshComponent?.CommitVisual(cmd, camera, param);
     }
 }
Esempio n. 9
0
 public override void OnEditorCommitVisual(CCommandList cmd, Graphics.CGfxCamera camera, GamePlay.SceneGraph.CheckVisibleParam param)
 {
     for (int i = 0; i < Components.Count; ++i)
     {
         var comp = Components[i];
         comp.OnEditorCommitVisual(cmd, camera, param);
     }
     base.OnEditorCommitVisual(cmd, camera, param);
 }
Esempio n. 10
0
 public void Flush2VB(CCommandList cmd)
 {
     ScopeFlush2VB.Begin();
     lock (this)
     {
         SDK_GfxParticleSystem_Flush2VB(CoreObject, cmd.CoreObject, vBOOL.FromBoolean(false));
     }
     ScopeFlush2VB.End();
 }
Esempio n. 11
0
 public override void CommitVisual(CCommandList cmd, Graphics.CGfxCamera Camera, SceneGraph.CheckVisibleParam param)
 {
     for (int i = 0; i < Components.Count; ++i)
     {
         var comp = Components[i];
         comp.CommitVisual(cmd, Camera, param);
     }
     base.CommitVisual(cmd, Camera, param);
 }
Esempio n. 12
0
        public void DrawImage(CCommandList cmd, Graphics.View.CGfxScreenView view, Graphics.Mesh.CGfxImage2D image, int zOrder)
        {
            var pass = image.GetPass();

            pass.ViewPort = view.Viewport;
            pass.BindCBuffer(pass.Effect.ShaderProgram, pass.Effect.CacheData.CBID_View, view.ScreenViewCB);
            pass.ShadingEnv.BindResources(image.Mesh, pass);
            cmd.PushPass(pass);
        }
Esempio n. 13
0
        public override void Cleanup()
        {
            mCommandList_Final.Cleanup();
            mCommandList_Final = null;

            mCaptureSV.Cleanup();
            mCaptureSV = null;

            base.Cleanup();
        }
Esempio n. 14
0
        public void SlowDrawAll(CCommandList cmd, Graphics.CGfxCamera camera, SceneGraph.CheckVisibleParam param)
        {
            var it = Scenes.Values.GetEnumerator();

            while (it.MoveNext())
            {
                it.Current.SlowDrawAll(cmd, camera, param);
            }
            it.Dispose();
        }
Esempio n. 15
0
 partial void OnEditorCheckVisible(CCommandList cmd, Graphics.CGfxCamera camera, GamePlay.SceneGraph.CheckVisibleParam param)
 {
     if (CIPlatform.Instance.PlayMode == CIPlatform.enPlayMode.Game)
     {
         return;
     }
     for (int i = 0; i < Components.Count; ++i)
     {
         Components[i].OnEditorCommitVisual(cmd, camera, param);
     }
 }
Esempio n. 16
0
 public override void CommitVisual(CCommandList cmd, CGfxCamera camera, CheckVisibleParam param)
 {
     if (CIPlatform.Instance.PlayMode == CIPlatform.enPlayMode.Editor)
     {
         var showMesh = Host.FindComponentBySpecialName("SphereVolumeShow") as GMeshComponent;
         if (showMesh != null)
         {
             showMesh.Visible = CEngine.ShowLightAssist;
         }
     }
     base.CommitVisual(cmd, camera, param);
 }
Esempio n. 17
0
        protected virtual void OnGameCommitRender(CCommandList cmd)
        {
            var RHICtx = EngineNS.CEngine.Instance.RenderContext;

            if (World == null || RenderPolicy == null)
            {
                return;
            }
            this.World.CheckVisible(cmd, GameCamera);

            RenderPolicy.TickLogic(GameCamera.SceneView, RHICtx);
        }
Esempio n. 18
0
        public void Tick(CCommandList cmd)
        {
            ScopeTickAutoMember.Begin();
            var rc = EngineNS.CEngine.Instance.RenderContext;

            using (var ite = mUIHostList.GetEnumerator())
            {
                while (ite.MoveNext())
                {
                    ite.Current.Value.Commit(cmd);
                }
            }
            ScopeTickAutoMember.End();
        }
Esempio n. 19
0
        public override void OnEditorCommitVisual(CCommandList cmd, CGfxCamera camera, CheckVisibleParam param)
        {
            if (ShowEditorVisual == false)
            {
                return;
            }
            var scene = this.Host.Scene;

            for (int i = 0; i < Elements.Count; i++)
            {
                Elements[i].ShowActor?.Actor.OnCheckVisible(cmd, scene, camera, param);
            }
            base.OnEditorCommitVisual(cmd, camera, param);
        }
Esempio n. 20
0
        public CGfxFramePass(CRenderContext rc, string debugName)
        {
            mCmdList = new CCommandList[2];

            EngineNS.CCommandListDesc CmdListDesc = new EngineNS.CCommandListDesc();
            mCmdList[0] = rc.CreateCommandList(CmdListDesc);
            mCmdList[1] = rc.CreateCommandList(CmdListDesc);

            if (!string.IsNullOrEmpty(debugName))
            {
                mCmdList[0].DebugName = debugName;
                mCmdList[1].DebugName = debugName;
            }
        }
Esempio n. 21
0
        private void CheckVisibleForShadow(CCommandList cmd, Graphics.CGfxCamera camera)
        {
            var it = Scenes.Values.GetEnumerator();

            while (it.MoveNext())
            {
                mCheckVisibleParam.Reset();
                mCheckVisibleParam.FrustumCulling      = false;
                mCheckVisibleParam.ForShadow           = true;
                mCheckVisibleParam.mShadowCullDistance = camera.mShadowDistance;
                it.Current.CheckVisible(cmd, camera, mCheckVisibleParam, true);
            }
            it.Dispose();
            mCheckVisibleParam.SerialID++;
        }
Esempio n. 22
0
        public void Commit(CCommandList cmd)
        {
            if (!mInitialized)
            {
                return;
            }
            var idMat = EngineNS.Matrix.Identity;

            foreach (var data in mTransformHandles)
            {
                data?.Show?.Commit(cmd, ref idMat, 1.0f);
            }
            foreach (var data in mCanvasAnchorsHandles)
            {
                data?.Show?.Commit(cmd, ref idMat, 1.0f);
            }
        }
Esempio n. 23
0
        public void PushPassToRHI(CCommandList CmdList)
        {
            if (CmdList == null || mPass == null)
            {
#if DEBUG
                Profiler.Log.WriteLine(Profiler.ELogTag.Error, "@Graphic", $"NullPtr here", "");
                System.Diagnostics.Debug.Assert(false);
#endif
                return;
            }

            //the shader is still on loading state...
            if (mPass.GpuProgram == null || mPass.ViewPort == null)
            {
                return;
            }
            CmdList.PushPass(mPass);
        }
Esempio n. 24
0
        public void Flush2VB(CCommandList cmd)
        {
            mAttachVBs.NumInstances = mCurSize;
            if (mCurSize == 0)
            {
                return;
            }

            var rc = CEngine.Instance.RenderContext;

            unsafe
            {
                if (CRenderContext.ShaderModel >= 4)
                {
                    fixed(VSInstantData *p = &mInstDataArray[0])
                    {
                        mInstDataBuffer.UpdateBufferData(cmd, (IntPtr)p, (UInt32)(sizeof(VSInstantData) * mCurSize));
                    }
                }
                else
                {
                    fixed(Vector3 *p = &mPosData[0])
                    {
                        mPosVB.UpdateBuffData(cmd, (IntPtr)p, (UInt32)(sizeof(Vector3) * mCurSize));
                    }

                    fixed(Vector4 *p = &mScaleData[0])
                    {
                        mScaleVB.UpdateBuffData(cmd, (IntPtr)p, (UInt32)(sizeof(Vector4) * mCurSize));
                    }

                    fixed(Quaternion *p = &mRotateData[0])
                    {
                        mRotateVB.UpdateBuffData(cmd, (IntPtr)p, (UInt32)(sizeof(Quaternion) * mCurSize));
                    }

                    fixed(UInt32_4 *p = &mF41Data[0])
                    {
                        mF41VB.UpdateBuffData(cmd, (IntPtr)p, (UInt32)(sizeof(UInt32_4) * mCurSize));
                    }
                }
            }
        }
Esempio n. 25
0
        public void BuildMesh2(CFontMesh fontMesh, CCommandList cmd, bool flipV)
        {
            var rc     = CEngine.Instance.RenderContext;
            var number = fontMesh.Mesh.MtlMeshArray.Length;

            unsafe
            {
                var p = stackalloc CShaderResourceView.NativePointer[number];
                {
                    var ptr = SDK_FTTextDrawContext_BuildMesh(CoreObject, rc.CoreObject, p, flipV);
                    mBuildMeshSource.UnsafeReInit(ptr);
                }
                for (int i = 0; i < number; i++)
                {
                    var pass = fontMesh.Mesh.MtlMeshArray[i].GetPass((int)PrebuildPassIndex.PPI_Default);

                    pass.ShaderResources.PSBindTexturePointer(mTextureBindInfo.PSBindPoint, p[i]);
                }
            }
        }
Esempio n. 26
0
        public void Commit(CCommandList cmd, Graphics.CGfxCamera camera, GamePlay.SceneGraph.CheckVisibleParam param, EPoolType poolType)
        {
            switch (poolType)
            {
            case EPoolType.Normal:
            {
                using (var i = Meshes.Values.GetEnumerator())
                {
                    while (i.MoveNext())
                    {
                        if (i.Current.CurSize == 0)
                        {
                            continue;
                        }

                        i.Current.MeshComp.CommitVisual(cmd, camera, param);
                        i.Current.Flush2VB(cmd);
                    }
                }
            }
            break;

            case EPoolType.Shadow:
            {
                using (var i = ShadowMeshes.Values.GetEnumerator())
                {
                    while (i.MoveNext())
                    {
                        if (i.Current.CurSize == 0)
                        {
                            continue;
                        }

                        i.Current.MeshComp.CommitVisual(cmd, camera, param);
                        i.Current.Flush2VB(cmd);
                    }
                }
            }
            break;
            }
        }
Esempio n. 27
0
        public void CheckVisible(CCommandList cmd, Graphics.CGfxCamera camera)
        {
            ScopeCheckVisible.Begin();
            var it = Scenes.Values.GetEnumerator();

            while (it.MoveNext())
            {
                mCheckVisibleParam.Reset();
                mCheckVisibleParam.FrustumCulling = true;
                it.Current.CheckVisible(cmd, camera, mCheckVisibleParam, true);
            }
            it.Dispose();
            CheckVisible_Editor(cmd, camera, mCheckVisibleParam);
            mCheckVisibleParam.SerialID++;

            if (CEngine.EnableShadow)
            {
                CheckVisibleForShadow(cmd, camera);
            }

            camera.SceneView?.UpdatePointLights(this.mDefaultScene);
            ScopeCheckVisible.End();
        }
Esempio n. 28
0
        public void PushPassToRHIInMultiPassMode(CCommandList CmdList, UInt32 ActivePassIndex)
        {
            if (ActivePassIndex > mPassArray.Count - 1)
            {
                System.Diagnostics.Debug.Assert(false);
                return;
            }

            if (CmdList == null || mPassArray[(int)ActivePassIndex] == null)
            {
#if DEBUG
                Profiler.Log.WriteLine(Profiler.ELogTag.Error, "@Graphic", $"NullPtr here", "");
#endif
                return;
            }

            //the shader is still on loading state...
            if (mPassArray[(int)ActivePassIndex].GpuProgram == null || mPassArray[(int)ActivePassIndex].ViewPort == null)
            {
                return;
            }
            CmdList.PushPass(mPassArray[(int)ActivePassIndex]);
        }
Esempio n. 29
0
 partial void CheckVisible_Editor(CCommandList cmd, Graphics.CGfxCamera camera, SceneGraph.CheckVisibleParam param);
Esempio n. 30
0
        private unsafe void UpdateIndexBufferCPU(CCommandList cmd, Graphics.CGfxCamera Camera)
        {
            if (mCpuDrawIndexBuffer == null)
            {
                return;
            }
            CBMeshBatch cbMesh = new CBMeshBatch();
            {
                var pPlanes = stackalloc Plane[6];
                Camera.CullingFrustum.GetPlanes(pPlanes);
                CBMeshBatch *pCBuffer  = &cbMesh;
                Plane *      planesTar = (Plane *)pCBuffer;
                for (uint i = 0; i < 6; i++)
                {
                    planesTar[i] = pPlanes[i];
                }
                cbMesh.GpuDrivenCameraPosition = Camera.CullingFrustum.TipPos;
                BoundingBox box = new BoundingBox();
                Camera.CullingFrustum.GetBoundBox(ref box);
                cbMesh.GpuDrivenFrustumMinPoint = box.Minimum;
                cbMesh.GpuDrivenFrustumMaxPoint = box.Maximum;
                cbMesh.MeshBatchVertexStride    = (uint)AllVertices.Count;
                cbMesh.ClusterNumber            = (uint)GpuClusters.Count;

                UpdateCBMeshbatch(cmd, Camera);
            }

            UInt32_3 tri = new UInt32_3();

            mDrawIndices.Clear();
            for (int i = 0; i < GpuClusters.Count; i++)
            {
                var cluster = GpuClusters[i];
                var GpuDrivenCameraDirection = GpuClusters[i].BoundCenter - cbMesh.GpuDrivenCameraPosition;
                var cameraDirInBoundSpace    = Vector3.TransposeTransformNormal(GpuDrivenCameraDirection, GpuInstanceDatas[(int)cluster.InstanceId].InvMatrix);
                if (FrustumCull(ref cluster, ref cbMesh) == false)
                {
                    UInt64 visBits = 0;
                    if (cameraDirInBoundSpace.X >= 0)
                    {
                        visBits |= cluster.CubeFaces[(int)Cluster.GpuCluster.ECubeFace.CubeFace_NX];
                    }
                    else
                    {
                        visBits |= cluster.CubeFaces[(int)Cluster.GpuCluster.ECubeFace.CubeFace_X];
                    }
                    if (cameraDirInBoundSpace.Y >= 0)
                    {
                        visBits |= cluster.CubeFaces[(int)Cluster.GpuCluster.ECubeFace.CubeFace_NY];
                    }
                    else
                    {
                        visBits |= cluster.CubeFaces[(int)Cluster.GpuCluster.ECubeFace.CubeFace_Y];
                    }
                    if (cameraDirInBoundSpace.Z >= 0)
                    {
                        visBits |= cluster.CubeFaces[(int)Cluster.GpuCluster.ECubeFace.CubeFace_NZ];
                    }
                    else
                    {
                        visBits |= cluster.CubeFaces[(int)Cluster.GpuCluster.ECubeFace.CubeFace_Z];
                    }

                    uint InstanceStartIndex = cbMesh.MeshBatchVertexStride * cluster.InstanceId;
                    for (int j = 0; j < cluster.FaceCount; j++)
                    {
                        if (TestBit(visBits, j) == false)
                        {
                            continue;
                        }
                        int srcIndex = (int)(cluster.StartFaceIndex + j) * 3;
                        tri.x = InstanceStartIndex + AllIndices[srcIndex];
                        tri.y = InstanceStartIndex + AllIndices[srcIndex + 1];
                        tri.z = InstanceStartIndex + AllIndices[srcIndex + 2];
                        mDrawIndices.Add(tri);
                    }
                }
            }

            mDrawArgs.InstanceCount         = 1;
            mDrawArgs.IndexCountPerInstance = (uint)mDrawIndices.Count * 3;
            uint size = (uint)(mDrawIndices.Count * sizeof(UInt32_3));

            if (mCpuDrawIndexBuffer.Desc.ByteWidth > size)
            {
                mCpuDrawIndexBuffer.UpdateBuffData(cmd, mDrawIndices.GetBufferPtr(), size);
            }
        }