Friday, June 16, 2017

OpenTK Example - FBO / Render Target TV

Available on Github

This is a small example of how to use a framebuffer object (sometimes the output is called a render target, although that's more of a DirectX term) in OpenTK. There's a second camera in the scene with its position indicated by the arrow. What that camera sees is put into a texture and then displayed on a model of a TV.



This is also significant because it allows us to get the depth information of the scene. This allows us to create shadows later by easily determining if there is an object closer to the light (which would have a camera "seeing" from its direction above or in the scene), and darkening parts where that is true.

Controls:

  • WASDQE - Move main camera
  • UHJK - Move texture camera
  • C - Switch between color view and depth view
  • V - Toggle TV static shader on/off

6 comments:

  1. Hi !

    I'm learning opentk in c#m do you have good document for this.

    Thanks !

    ReplyDelete
  2. You actually make it appear really easy along with your presentation however I to find this
    topic to be actually one thing that I feel I would never understand.
    It kind of feels too complex and very vast for me. I am taking a look forward in your subsequent submit,
    I will try to get the cling of it!

    ReplyDelete
  3. Ciao, ma sei italiano?

    ReplyDelete
  4. This comment has been removed by a blog administrator.

    ReplyDelete
  5. Hello, I have got error like obj makes unendless and it crashes sometimes. Please fix it!

    I am using Visual Studio 2017 Community and OpenTK 3.00 preview or 2.00 stable. Thanks!

    ReplyDelete
    Replies
    1. And I show you like it happens

      Check screenshot:
      https://i.imgur.com/Kqt1JxM.png

      Delete