Due to the volume of spam comments I've had to remove lately, I've set commenting to require an account for the time being. It doesn't have to be a Google account, any OpenID account will work (so you can even log in through Steam).
I hope one day soon I can have more content to add to this blog, but I at least want to prevent it from being overrun by spammers. I'm always reading the comments.
Monday, November 27, 2017
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.
Controls:
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
Friday, August 12, 2016
Update on next tutorial/example
Here's an update on what I have planned next.
I wanted to jump right into shadows next, but I realized that there's a few prerequisites before we get to that. One of those is rendering to a framebuffer/texture, and another is getting a depth map from another camera. So, next up is handling both of those. In addition, cube maps would be needed to handle shadows from point lights, so that's another topic to add.
However, my job is going to be picking up soon, and these require a lot of changes to the existing code that would take a lot of time to make as another tutorial in the series. Like before, I'm considering doing examples instead of tutorials here on out, so we can cover more topics in less time. The examples would still break down the new stuff, but they won't follow the process of adding it to the previous topic's project files.
I wanted to jump right into shadows next, but I realized that there's a few prerequisites before we get to that. One of those is rendering to a framebuffer/texture, and another is getting a depth map from another camera. So, next up is handling both of those. In addition, cube maps would be needed to handle shadows from point lights, so that's another topic to add.
However, my job is going to be picking up soon, and these require a lot of changes to the existing code that would take a lot of time to make as another tutorial in the series. Like before, I'm considering doing examples instead of tutorials here on out, so we can cover more topics in less time. The examples would still break down the new stuff, but they won't follow the process of adding it to the previous topic's project files.
![]() |
| Here the TV screen is showing the view from a second camera (the second camera is at the arrow) |
![]() |
| Here it is rendering the depth information from the other camera |
Friday, July 29, 2016
OpenTK Tutorial 9 Part 3: Specular Maps and Attenuation
In the previous part of this tutorial, we added spot lights and directional lights. This time, we're adding specular maps and light attenuation.
Tuesday, July 26, 2016
OpenTK Tutorial 9 Part 2: New Light Types (Spot and Directional)
In the first part of this tutorial, we made it possible to use more than one light in a scene. In this part of the tutorial, we'll be adding two new light types.
The next (and final) part of this tutorial will add specular mapping and attenuation.
The next (and final) part of this tutorial will add specular mapping and attenuation.
Sunday, June 12, 2016
OpenTK Tutorial 9 Part 1: Multiple Lights
This will be the first part of our more advanced lighting arc. In this part, we'll allow the scene to have many lights instead of just one.
This next part will add two new types of light: spot lights that only shine in a limited cone, and directional lights that shine at a constant angle on the whole scene. A third part will add specular maps and attenuation, to make the lighting look a little more realistic.
This next part will add two new types of light: spot lights that only shine in a limited cone, and directional lights that shine at a constant angle on the whole scene. A third part will add specular maps and attenuation, to make the lighting look a little more realistic.
Thursday, April 28, 2016
Detecting Markov Bots on Reddit, my lazy way
I've been getting annoyed at the number of comment bots on Reddit that are clearly just a program running a Markov chain. If you're not familiar with Markov chains, the basic explanation is that it looks at all the comments and makes a list of what words came directly after what other words, and then goes through the list to find a string of words where each pair was found in that order in the real comments. There are other ones that use larger portions of the text and ones that could use more than just the comments on one post, but the Reddit bots don't seem to be those (Wikipedia has an article with a far better explaination about Markov chains). Sometimes this makes a decent looking comment, but other times it just makes gibberish. There's a whole subreddit, /r/subredditsimulator, where the only posters allowed are Markov chain bots trained on other subreddits. That's the only place I'd like to see them.
Wednesday, April 27, 2016
Update on Next Tutorial
I wanted to give everyone an update on the next tutorial, since it's been a while.
As you can see in the pictures, there's multiple lights at once, specular maps (look at the difference between the land and ocean), and spot lights. This code also includes directional lighting, but I think it didn't make the pictures.
I'm sorry to let this take so long. Life has been busy, but it should be less busy relatively soon.
The other problem has been trying to break this tutorial up into manageable chunks. I may have to switch to making it into an annotated example project instead of a tutorial (which might be better overall, and would let me make more content). Feel free to leave comments if you have any feelings about this (and I know some people have asked for that sort of change in the past).
As you can see in the pictures, there's multiple lights at once, specular maps (look at the difference between the land and ocean), and spot lights. This code also includes directional lighting, but I think it didn't make the pictures.
I'm sorry to let this take so long. Life has been busy, but it should be less busy relatively soon.
The other problem has been trying to break this tutorial up into manageable chunks. I may have to switch to making it into an annotated example project instead of a tutorial (which might be better overall, and would let me make more content). Feel free to leave comments if you have any feelings about this (and I know some people have asked for that sort of change in the past).
Wednesday, December 16, 2015
OpenTK Tutorial 8 Part 2: Adding Textures and Specular Lighting
In the first part of this tutorial, we added normals. In this tutorial, we'll use them to do something interesting, adding specular lighting and diffuse maps.
Sunday, August 9, 2015
OpenTK Tutorial 8 Part 1: Normals, Materials, and Loading More From Files
In the previous tutorial, we loaded a simple object in from a file. Right now, it's hard to see the detail in the models because they're all one color (or have a texture applied wrong). By the end of this tutorial (that is, after the second part), we'll have diffuse lighting with specular highlights on our models, making them look much nicer.
This part will cover loading texture coordinates and normals from a file, calculating normals for geometry that doesn't come with them (such as shapes we're generating through code) and loading basic materials from a file.
(UPDATED 2015-11-24 to fix some issues with loading normals from a file)
(UPDATED 2015-12-16 to make the MTL file have materials that look nicer under lighting)
(UPDATED 2018-11-06 to make compatible with input handling changes in Tutorial 5)
This part will cover loading texture coordinates and normals from a file, calculating normals for geometry that doesn't come with them (such as shapes we're generating through code) and loading basic materials from a file.
(UPDATED 2015-11-24 to fix some issues with loading normals from a file)
(UPDATED 2015-12-16 to make the MTL file have materials that look nicer under lighting)
(UPDATED 2018-11-06 to make compatible with input handling changes in Tutorial 5)
Sunday, July 5, 2015
Progress Update
It's been a while, and I want to fill everyone in on what/when the next tutorial will be. This weekend is the first time I haven't had a million other projects I should be doing, so I was able to make some real progress.The next tutorial is going to be broken into two parts (for length's sake, but Part 1 will be useful on its own).
The first part will handle loading more complex OBJ files, and loading materials from MTL files. The OBJ loader we already had only works on really, really simple OBJ files, and it won't cut it for loading most models with texture maps.
The second part will put this to better use by adding some simple lighting to the project.
Expect the whole thing before the end of the month. After the next tutorial, I plan on making a model viewer example to show what can be done.
Tuesday, April 14, 2015
OpenTK Tutorial 7: Simple Objects from OBJ files
This tutorial is going to be rather short. What we'll do is add a new class that can open very simple OBJ files and add some sample models to the project.
Wednesday, March 25, 2015
Inside the Sprite Example
Last time I posted a new example that uses OpenTK for a 2D view with sprites. Let's go into a bit more detail about how it works:
Tuesday, March 10, 2015
OpenTK Sprites Example
A new example is available on the GitHub repository:
https://github.com/neokabuto/OpenTKTutorialContent/tree/master/TKSprites
This example features 2D drawing of textures, with motion and alpha blending. 30,000 sprites are added by default, but you can add more by hitting the + key. Most of the sprites are off-screen (and not drawn to help keep things running smoothly), but you can move the view with the arrow keys (and speed up with the shift key) to pan around the world. Clicking on one of the sprites will change its texture!
UPDATE 3-11-15: New feature: multiple shaders! Hit V to change which shader is used, or hit M to toggle a mode where the shader is chosen based on the texture.
https://github.com/neokabuto/OpenTKTutorialContent/tree/master/TKSprites
This example features 2D drawing of textures, with motion and alpha blending. 30,000 sprites are added by default, but you can add more by hitting the + key. Most of the sprites are off-screen (and not drawn to help keep things running smoothly), but you can move the view with the arrow keys (and speed up with the shift key) to pan around the world. Clicking on one of the sprites will change its texture!
UPDATE 3-11-15: New feature: multiple shaders! Hit V to change which shader is used, or hit M to toggle a mode where the shader is chosen based on the texture.
Wednesday, February 25, 2015
OpenTK Tutorial 6 Project File now on GitHub
Missed having OpenTK content? Good news, I'm working on making more of it soon! Up next is a demo on using orthographic projection with what we've covered in previous tutorials to make sprites (as requested by an anonymous commenter a while back).
While you all wait for that, the basic textures tutorial project is now up on GitHub:
https://github.com/neokabuto/OpenTKTutorialContent/tree/master/OpenTKTutorial6
While you all wait for that, the basic textures tutorial project is now up on GitHub:
https://github.com/neokabuto/OpenTKTutorialContent/tree/master/OpenTKTutorial6
Tuesday, February 24, 2015
SFML.Net Example: Breakout Clone
Here's a second basic SFML.Net example. This time it's a clone of the game Breakout (copyright Atari, please don't sue).
https://github.com/neokabuto/SFML.NET-Examples/tree/master/SFMLBreakout
https://github.com/neokabuto/SFML.NET-Examples/tree/master/SFMLBreakout
Wednesday, February 18, 2015
SFML.Net Example: Pong Clone
Here's an example of a simple game made in SFML.Net. It's a clone of a
certain well known table-tennis game that tends to be a common early
project. Try to hit the ball off the right side of the screen while the
computer attempts to do the same to the left side of the screen.
https://github.com/neokabuto/SFML.NET-Examples/tree/master/SFMLPong
https://github.com/neokabuto/SFML.NET-Examples/tree/master/SFMLPong
Sunday, January 4, 2015
Tutorial Files Now Available on Github!
The project files from the first 5 OpenTK tutorials are now on GitHub. I've been commenting them with excerpts from the tutorials where I can, which should help people follow along. The code could use a bit of cleanup, but all the required code is there and tested.
This format has a few advantages for me. It's easy to upload to (and unlike file hosts, is accessible possible to upload to from my university without a VPN) and filters out files that don't need to be uploaded. It also means that if there's something that needs correcting, it's possible for someone else to submit the fix (and get credit for it!) without much work on my part. If anyone sends a pull request/issue that improves the tutorial content, I'll modify the tutorial here to match the new changes.
This format has a few advantages for me. It's easy to upload to (and unlike file hosts, is accessible possible to upload to from my university without a VPN) and filters out files that don't need to be uploaded. It also means that if there's something that needs correcting, it's possible for someone else to submit the fix (and get credit for it!) without much work on my part. If anyone sends a pull request/issue that improves the tutorial content, I'll modify the tutorial here to match the new changes.
Monday, October 13, 2014
SFML Tutorial: Hello World
In this tutorial, we'll create a SFML window and draw a shape and some text, and demonstrate a basic animation.
This tutorial assumes that you already have the SFML.Net libraries and their dependencies, but we will create a new project file for this tutorial. This and all future tutorials will assume that you are using Visual Studio (however, it's definitely possible to use SFML.Net with Mono!).
A portion of the code used in this tutorial (and likely future tutorials) is taken from the official examples for SFML.Net.
This tutorial assumes that you already have the SFML.Net libraries and their dependencies, but we will create a new project file for this tutorial. This and all future tutorials will assume that you are using Visual Studio (however, it's definitely possible to use SFML.Net with Mono!).
A portion of the code used in this tutorial (and likely future tutorials) is taken from the official examples for SFML.Net.
Friday, October 10, 2014
Setting up SFML.Net
SMFL.Net is a binding of the Simple and Fast Multimedia Library that allows us to use its functions in C# and VB.Net. It's simple to use (hence the name) and portable (although my tutorials will only focus on Windows).
However, setting it up requires some extra work compared to some other libraries. The pre-built libraries available on the SFML website are not only a year old (so they're missing quite a few changes made since then), but the dependencies included probably won't work and one of the DLLs is MIA (technically it wasn't missing at the time, but now it's an important part of the library).
(I know things have been mostly OpenTK up until this point, but I needed a bit of a break. And if these SFML.Net tutorials go on long enough, they'll end up back in OpenTK territory, so don't worry!)
However, setting it up requires some extra work compared to some other libraries. The pre-built libraries available on the SFML website are not only a year old (so they're missing quite a few changes made since then), but the dependencies included probably won't work and one of the DLLs is MIA (technically it wasn't missing at the time, but now it's an important part of the library).
(I know things have been mostly OpenTK up until this point, but I needed a bit of a break. And if these SFML.Net tutorials go on long enough, they'll end up back in OpenTK territory, so don't worry!)
Subscribe to:
Posts (Atom)





