Chroma keying, obviously, is a way of treating certain color as transparent one. In our case - green: Of course, after loading an image, before pushing it to a texture, we can easily scan it for green pixels and set their Alpha-channels to zero. But when GL rasterizer picks tUV coordinates near the green areas, […]
Category: Cross-platform 3D
Chapter 28. Model Loader
Our next goal is to move model building process out of TheGame class. We will need some kind of models text descriptor, XML format seems quite suitable. We will keep models descriptions outside of executable, in /dt folder. Then we'll need a class that will load, read and process these descriptors and build actual 3D […]
Chapter 27. Shader groups
Here I want to add "reflection" and "over mask" shaders, each of which will double number of shader-programs. Correspondingly, we'll need a function which will load a group of shaders in 1 shot (for example - Phong or flat for different data feeds). Also, we'll need a function that will pick particular shader number depending […]
Chapter 26. Render to and read from GL texture
Here I want to render a bit more complicated white noise images. I want bigger dots with a soft transition between them. The task splits in following steps: Generate initial black/white image (as we did in previous chapter) Generate a GL texture out of it Make it renderable (associate a render buffer with it) Force […]
Chapter 25. Writing BMP and TGA files
I was planning to generate and save a few "white noise" images for future use in some recognizable graphics format. In order not to overload the project by new heavy libraries, I decided to write own little function. For the sake of simplicity I won't use compression and will support only 1 pixel format - […]
Chapter 24. Synchronization
Right now on both my devices (Android and PC) the box makes 1 revolution in approximately 4 seconds. It's 360 frames (rotation speed is set to 1 degree per frame). This means 360/4=90 frames per second (FPS). Obviously, on another devices it can be different. Besides, speed can depend on background processes and other factors. […]
Chapter 23. #ifdef in shaders
Right now we have 6 shaders (3 vertex+fragment pairs), which generate 3 shader-programs. Now we need to add textured Phong shader, then we'll need color or texture over transparency mask for both flat and phong cases, which will double number of shaders, and so on, and soon it will be hard to manage them all. […]
Chapter 22. Screen resize
When screen size changed, we need to re-position the camera to fit new screen size optimally. For example, in our case optimal scene/"stage" size would be, let's say, 500x300 (to fit our spinning box into the screen). Our camera's view angle is 30 degrees. so, ? / 250 = cosine(15) / sine(15) = cotangent(15) ? […]
Chapter 21. Textured surface
Now let's apply a texture to a complicated multi-vertex surface, to the right (blue) side for example. Hope, it's clear enough how to write a textured Phong shader, but we'll do it later, in some other chapter. For now the flat one (which we have already) will be good enough. We will need: to pass […]
Chapter 20. Modeler. Round shapes
Our current rectangular model does not allow us to appreciate all the beauty of the Phong shader, in particular - the glares. For that we'll need something more round-shaped. Let's extend our Modeler accordingly. Windows 1. Start VS. Open C:\CPP\a997modeler\p_windows\p_windows.sln. First - we'll need to extend VirtualShape.h. 2. Open VirtualShape.h and replace code by: New […]