u/sleep-depr

▲ 7 r/Kanye

Why is donda 2 so hated

Idk every rating I see donda 2 is on the bottom. The shorter version of 530 on donda 2 is better than the full one from vultures 2. Surely not the best album but nor is it as bad as people show it to be.

reddit.com
u/sleep-depr — 12 hours ago
▲ 2 r/opengl

Previous drawing cleared when switching shader

So I am planning to use instancing to draw wheels for a truck. I draw the truck first and then the wheels. Since I need to use a separate shader for instancing, Whenever I bind that shader, the truck disappears and only the wheels I draw are visible.

For the shaders, I have the same fragment shader (main.fs) and for the vertex shaders I have two (main.vs & wheels.vs) which I have attached below.
> main.vs

#version 410


layout(location = 0) in vec3 positionIn;
layout(location = 1) in vec2 textureCoord;
layout(location = 2) in vec3 normalIn;


out vec3 position;
out vec2 textureCoordinate;
out vec3 normal;


uniform mat4 projMat;
uniform mat4 transMat;


void main() {
    normal = (transMat * vec4(-normalIn, 0)).xyz;
    
    textureCoordinate = textureCoord;
    
    position = (transMat * vec4(positionIn, 1)).xyz;
    gl_Position = projMat * transMat * vec4(positionIn, 1);
}

> wheels.vs

#version 410


layout(location = 0) in vec3 positionIn;
layout(location = 1) in vec2 textureCoord;
layout(location = 2) in vec3 normalIn;


out vec3 position;
out vec2 textureCoordinate;
out vec3 normal;


uniform mat4 projMat;
uniform vec3[10] offsets;
uniform vec2[10] rotationXY;


void main() {   
    
    vec3 offset = offsets[gl_InstanceID];
    
    vec2 rotation = rotationXY[gl_InstanceID];
    
    mat4 transMat = mat4(
    cos(rotation.y), 0, sin(rotation.y), 0,
    0, 1, 0, 0,
    -sin(rotation.y), 0, cos(rotation.y), 0,
    0, 0, 0, 1
    );
    
    transMat *= mat4(
    1, 0, 0, 0,
    0, cos(rotation.x), -sin(rotation.x), 0,
    0, sin(rotation.x), cos(rotation.x), 0,
    0, 0, 0, 1
    );
    
    normal = (transMat * vec4(-normalIn, 0)).xyz;
    
    textureCoordinate = textureCoord;
    
    position = (transMat * vec4(positionIn + offset, 1)).xyz;
    gl_Position = projMat * vec4(position, 1);
}

And this is how I render the object. Note that the child.render() has the exact same structure, apart from the fact that no transformation matrix is sent and glDrawElementsInstanced is used instead.

texture.bind();
glUniformMatrix4fv(transMatrix, false, getTransformationMatrix());

glBindVertexArray(vertexArray);
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glEnableVertexAttribArray(2);

glDrawElements(mode, vertexCount, GL_UNSIGNED_INT, 0);

glDisableVertexAttribArray(0);
glDisableVertexAttribArray(1);
glDisableVertexAttribArray(2);
glBindVertexArray(0);
texture.unbind();

for(LCObject child : children) {
  child.getShader().bind();
  child.render();
}

PS: Im on a Mac M1 if that is of any importance.

reddit.com
u/sleep-depr — 5 days ago