public void Render( GraphicsContext graphics, Camera camera, LightModel light, Model model, BgModel bg ) { // setup a camera aligned with the light source float aspect = offWidth / (float)offHeight; float fov = 45.0f * (float)(FMath.PI / 180.0f); Matrix4 proj = Matrix4.Perspective( fov, aspect, 1.0f, 10000.0f ); Matrix4 view = Matrix4.LookAt( light.Position, model.Position, new Vector3( 0.0f, 1.0f, 0.0f ) ); Matrix4 world = model.Posture; Matrix4 lightVP = proj * view; // pass 1 renderShadowMap( graphics, lightVP * world, model ); // pass 2 graphics.Clear(); drawModel( graphics, camera, lightVP, model ); light.Render( graphics, camera ); // test texRenderer.Begin(); int width = texShadow.Width / 2; int height = texShadow.Height / 2; texRenderer.Render( texShadow, ShaderCatalog.DspWidth - width, 0, 0, 0, width, height ); texRenderer.End(); }
public void Render( GraphicsContext graphics, Camera camera, LightModel light, Model model, BgModel bg ) { graphics.Clear(); drawModel(graphics, camera, light, model); light.Render(graphics, camera); bg.Render(graphics, camera); }
private void renderSimpleScene( GraphicsContext graphics, Camera camera, LightModel light, Model model, BgModel bg ) { // rendering graphics.Clear(); Matrix4 world = model.Posture; Matrix4 worldViewProj = camera.Projection * camera.View * world; shaderTexture.SetUniformValue(shaderTexture.FindUniform("WorldViewProj"), ref worldViewProj); graphics.SetShaderProgram(shaderTexture); graphics.SetVertexBuffer(0, vbTeapot); graphics.SetTexture(0, texture); graphics.DrawArrays(model.Mesh.Prim, 0, model.Mesh.IndexCount); light.Render(graphics, camera); bg.Render(graphics, camera); }