Generating a normal map from a height map?

Example GLSL code from my water surface rendering shader: #version 130 uniform sampler2D unit_wave noperspective in vec2 tex_coord; const vec2 size = vec2(2.0,0.0); const ivec3 off = ivec3(-1,0,1); vec4 wave = texture(unit_wave, tex_coord); float s11 = wave.x; float s01 = textureOffset(unit_wave, tex_coord, off.xy).x; float s21 = textureOffset(unit_wave, tex_coord, off.zy).x; float s10 = textureOffset(unit_wave, tex_coord, off.yx).x; … Read more

How exactly does OpenGL do perspectively correct linear interpolation?

The output of a vertex shader is a four component vector, vec4 gl_Position. From Section 13.6 Coordinate Transformations of core GL 4.4 spec: Clip coordinates for a vertex result from shader execution, which yields a vertex coordinate gl_Position. Perspective division on clip coordinates yields normalized device coordinates, followed by a viewport transformation (see section 13.6.1) … Read more

Haskell library for 2D drawing [closed]

Instead of picking individual libraries, I’ll have a go at a quick overview at all of them, as listed in the Graphics section on Hackage. Basic frameworks: OpenGL Part of the Haskell Platform Used for many small 2 and 3D games. Examples: lambdacube-engine, roguestar-gl, hpong, monadius, raincat, frag GTK cabal install cairo Used for high … Read more

How to convert a 3D point into 2D perspective projection?

The standard way to represent 2D/3D transformations nowadays is by using homogeneous coordinates. [x,y,w] for 2D, and [x,y,z,w] for 3D. Since you have three axes in 3D as well as translation, that information fits perfectly in a 4×4 transformation matrix. I will use column-major matrix notation in this explanation. All matrices are 4×4 unless noted … Read more

Graphics on indexed image

Refering to this, it can be solved by creating a blank bitmap with the same dimensions and the correct PixelFormat and the draw on that bitmap. // The original bitmap with the wrong pixel format. // You can check the pixel format with originalBmp.PixelFormat Bitmap originalBmp = (Bitmap)Image.FromFile(“YourFileName.gif”); // Create a blank bitmap with the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)