Salomonsson.se
Sep 21 2015

Playing with shaders - Part 3

My recent days of night dev has been a bit fragmented due to the fact that I have two newborn kids that require a lot of attention. But whenever I get a spare moment I try to do a little bit of programming, so todays post is actually the result of several short days of work.

First of all I needed to read up on plasma effects again. Haven’t done that in several years, and it turned out I did not fully remember how it was done. But I did find the excellent tutorial I used several years ago, I highly recommend reading it!!! It is ugly, but very interesting read: http://lodev.org/cgtutor/

After that I started playing with shaderToy, trying to get a plasma shader running.

And lastly, I implemented that shader into my c++ sandbox project. Something seems to be a bit off though, it is way to bright. I think it is because the range of each sine/cos-effect (that is merged together to form the plasma) has an incorrect range (not 0-1), or perhaps the area is too zoomed in – but it’s too late to start bug-hunting now so this will have to do for now.

Next up: colors and bitmaps!

Sep 10 2015

Playing with shaders - Part 2

Spent several hours rewriting my setup code to play with shaders. This is a tutorial that explains it very nice and cleanly: https://open.gl/introduction

I also found a library for loading png files from disc, that don’t require you to invoke make-scripts and all that madness. Just add one .h and one .cpp-file to your project and you’re done! The name is LodePNG. However, did not come far enough to read textures into my shader.

However I managed to get uniforms working, so I could pass the current time to my shader and animate it. I guess that’s something. That’s all for tonight.

Sep 08 2015

Playing with shaders - Part 1

Since I became a father of two twins, two months ago, I haven’t been able to do much coding at all. Any opportunity I get I have to make sure I do something really small since my work time gets very fragmented.

So I started a c++ project, open a window with an openGL context, and started playing with some really basic shader code. As I said, I didn’t get very far before I had to abort. But it’s something.

Just wanted to save the links to some pages that helped me setting up GLFW on windows in Visual Studio 1013. http://www.41post.com/5178/programming/opengl-configuring-glfw-and-glew-in-visual-cplusplus-express

http://www.codeincodeblock.com/2013/05/introduction-to-modern-opengl-3x-with.html

https://github.com/smokindinesh/Modern-OpenGL-Series

#version 420 core

out vec4 color;
void main() {
float x = mod(gl_FragCoord.x, 100.0) / 100.0;
float y = mod(gl_FragCoord.y, 100.0) / 100.0;
color = vec4(x,y,1.0,1.0); }