/// <summary> /// It assumes that this shader is not the default LPP shader, and it will use ONLY the first technique /// </summary> /// <param name="camera"></param> /// <param name="graphicsDevice"></param> /// <param name="renderStatistics"></param> public void GenericRender(Camera camera, GraphicsDevice graphicsDevice) { RenderEffect.SetMatrices(GlobalTransform, camera.EyeTransform, camera.ProjectionTransform); if (_parent.BoneMatrixes != null) { RenderEffect.SetBones(_parent.BoneMatrixes); } RenderEffect.Apply(); graphicsDevice.SetVertexBuffer(_meshPart.VertexBuffer, _meshPart.VertexOffset); graphicsDevice.Indices = _meshPart.IndexBuffer; graphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, _meshPart.NumVertices, _meshPart.StartIndex, _meshPart.PrimitiveCount); }
public void ReconstructShading(Camera camera, GraphicsDevice graphicsDevice) { //this pass uses the light diffuse and specular accumulation texture (already bound in the setup stage) and reconstruct the mesh's shading //our parameters were already filled in the first pass RenderEffect.SetCurrentTechnique(1); //we don't need to do this again, it was done on the previous step //_renderEffect.SetMatrices(GlobalTransform, camera.EyeTransform, camera.ProjectionTransform); // if (_parent.BoneMatrixes != null) // _renderEffect.SetBones(_parent.BoneMatrixes); RenderEffect.Apply(); graphicsDevice.SetVertexBuffer(_meshPart.VertexBuffer, _meshPart.VertexOffset); graphicsDevice.Indices = _meshPart.IndexBuffer; graphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, _meshPart.NumVertices, _meshPart.StartIndex, _meshPart.PrimitiveCount); }
public virtual void RenderToGBuffer(Camera camera, GraphicsDevice graphicsDevice) { RenderEffect.SetCurrentTechnique(0); RenderEffect.SetMatrices(GlobalTransform, camera.EyeTransform, camera.ProjectionTransform); //our first pass is responsible for rendering into GBuffer RenderEffect.SetFarClip(camera.FarClip); if (_parent.BoneMatrixes != null) { RenderEffect.SetBones(_parent.BoneMatrixes); } RenderEffect.Apply(); graphicsDevice.SetVertexBuffer(_meshPart.VertexBuffer, _meshPart.VertexOffset); graphicsDevice.Indices = _meshPart.IndexBuffer; graphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, _meshPart.NumVertices, _meshPart.StartIndex, _meshPart.PrimitiveCount); }
public virtual void RenderShadowMap(ref Matrix viewProj, GraphicsDevice graphicsDevice) { //render to shadow map RenderEffect.SetCurrentTechnique(2); RenderEffect.SetLightViewProj(viewProj); //we need to set this every frame, there are situations where the object is not on screen but it still cast shadows _renderEffect.SetWorld(GlobalTransform); if (_parent.BoneMatrixes != null) { _renderEffect.SetBones(_parent.BoneMatrixes); } RenderEffect.Apply(); graphicsDevice.SetVertexBuffer(_meshPart.VertexBuffer, _meshPart.VertexOffset); graphicsDevice.Indices = _meshPart.IndexBuffer; graphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, _meshPart.NumVertices, _meshPart.StartIndex, _meshPart.PrimitiveCount); }