New answers tagged

1

Spaces and Matrices First of all, as you know, we use matrices to represent and to do coordinate transformations. They can be any of the affine transformations. That includes translation, scaling, rotation, shear, and reflection transformations. We (traditionally) have three coordinate systems to work with: Model space (Sometimes called "Object space"): ...


2

You'll need some persistent state and a frame counter passed in: float lightning(lightningState* state, uint64 frame){ if(!state->enabled) return 0.0f; if(frame - state->lastStart < state->flashDuration) // during flash return 1.0f; //can also have a decreasing function here based on the difference if(frame - state-...


0

Like daniel_1985 pointed out I was wrongly converting the assim matrices…. The convetion above (ToMatrix4(aiMatrix4x4 …)) should fix things


0

For true undistorted two-point perspective, the camera must always face horizontally, otherwise vertical lines will not project to vertical lines. So you need to edit your 'gluLookAt' call to make the camera face horizontally. Unfortunately, this means that the horizon line will be at eye level with the observer, i.e. in the center of the screen. If most of ...


0

So as Daniel_1985 pointed out the function was returning an array that was getting out of scope. So I've changed my method to this: GLfloat* Matrix4::ToGlArray() { GLfloat* result = new GLfloat[16] { row0.x, row0.y, row0.z, row0.w, row1.x, row1.y, row1.z, row1.w, row2.x, row2.y, row2.z, row2.w, row3.x, row3.y, row3.z,...


0

The problem lies within the shader, a lot of implementations don't allow for dynamic looping in GLSL, therefore numLights, when used in "i < numLights" is being evaluated as zero, an easy way to fix it would be to use a constant number, another could be to use SSBOs or something like that, not sure if that would work either.


0

As I'm now a bit more advanced with OpenGL, I can tell that I couldn't express what I was looking for. What I was really looking for was a way to draw multiple objects in a performance saving way, i.e. batch rendering or instancing. I solved my problem in choosing instanced rendering. It roughly boils down to: Set up everything as usual Specify a mat4 ...


0

I have implemented a simple solution that seems to be working for myself. I solved it by ensuring that my shader takes in both colour and texture coordinate data. The other requirement is that you set the colour of all textured vertices to black. My fragment shader is then set up as follows: #version 330 core out vec4 gl_FragColor; in vec2 ...


0

I figured out a solution, now I keep track of the cameraoffset/delta (xy distance the camera moved from the initial position) as a uniform vec2 and then add it to gl_FragCoord.xy in main() Line #1


Top 50 recent answers are included