glsl

rotate Z axis on 2d image's matrix in shader

ぐ巨炮叔叔 提交于 2021-02-19 04:41:28
问题 I'm trying to rotate a 2d image's matrix inside the vertex shader. I want the 2d image to rotate around what I think would be the z axis. However The closes I've ever gotten is: Here is my matrix inside my shader that I apply translation and scaling on: mat4 worldPosTrans = mat4(vec4(scale.x * cos(rotateZ), 0, 0, 0), vec4(0, scale.y, 0, 0), vec4(0, 0, scale.z, 0), vec4(translation, 1)); This is a slightly changed version from something that was supposed to rotate everything: mat4

How to pass non interpolated data OpenGL ES (GLSL)

我是研究僧i 提交于 2021-02-19 03:57:07
问题 I'm trying to pass simple FLOAT value from vertex to fragment shader. How can I pass it "as is" without interpolation? On desktop I could use flat varying to disable interpolation, is there something similar in openGL es or the only way is through texture? 回答1: GLSL ES does currently not support the flat keyword, so the only way is to use the same float value in all the triangle vertices. The same answer was given here: In opengl es 2, is there a way to prevent interpolation of varyings 回答2:

How to quickly pack a float to 4 bytes?

情到浓时终转凉″ 提交于 2021-02-18 12:11:47
问题 I've been looking for a way to store floats on WebGL textures. I've found some solutions on the internet, but those only deal with floats on the [0..1) range. I'd like to be able to store arbitrary floats, and, for that, such a function would need to be extended to also store the exponent (on the first byte, say). I don't quite understand how those work, though, so it is not obvious how to do so. In short: What is an efficient algorithm to pack a float into 4 bytes? 回答1: It's ungodly slow,

When should I use STD140 in OpenGL?

旧时模样 提交于 2021-02-17 15:47:33
问题 When do I use the STD140 for uniform blocks in OpenGL? Although I am not a 100% sure, I believe there is an alternative to it which can achieve the same thing, called "Shared". Is it just preference for the coder? Or are there reasons to use one over the other? 回答1: Uniform buffer objects are described in http://www.opengl.org/registry/specs/ARB/uniform_buffer_object.txt The data storage for a uniform block can be declared to use one of three layouts in memory: packed , shared , or std140 .

When should I use STD140 in OpenGL?

[亡魂溺海] 提交于 2021-02-17 15:46:48
问题 When do I use the STD140 for uniform blocks in OpenGL? Although I am not a 100% sure, I believe there is an alternative to it which can achieve the same thing, called "Shared". Is it just preference for the coder? Or are there reasons to use one over the other? 回答1: Uniform buffer objects are described in http://www.opengl.org/registry/specs/ARB/uniform_buffer_object.txt The data storage for a uniform block can be declared to use one of three layouts in memory: packed , shared , or std140 .

Is there a way to draw a circle with the fragment shader at the position of a point from the vertex shader?

╄→尐↘猪︶ㄣ 提交于 2021-02-16 05:25:44
问题 So i am drawing a Point at a certain ... well ... point of the screen that is then moving around. My Vertex Shader looks like this. private final String vertexShaderCode = "attribute vec4 vPosition;" + "uniform mat4 Projection; \n" + "uniform mat4 ModelView; \n" + "void main() {" + " gl_Position = Projection * ModelView * vPosition;" + " gl_PointSize = 900.0; " + "}"; What i am trying to achive is to then render a circle around the position of this one vertice. For that i am using the

Is there a way to draw a circle with the fragment shader at the position of a point from the vertex shader?

帅比萌擦擦* 提交于 2021-02-16 05:24:40
问题 So i am drawing a Point at a certain ... well ... point of the screen that is then moving around. My Vertex Shader looks like this. private final String vertexShaderCode = "attribute vec4 vPosition;" + "uniform mat4 Projection; \n" + "uniform mat4 ModelView; \n" + "void main() {" + " gl_Position = Projection * ModelView * vPosition;" + " gl_PointSize = 900.0; " + "}"; What i am trying to achive is to then render a circle around the position of this one vertice. For that i am using the

i'm trying to implement index buffer object in opentk but don't know how to actually use it when drawing things

╄→гoц情女王★ 提交于 2021-02-11 05:59:46
问题 i'm trying to use an index buffer but have no idea how i really am stuck in a waall as to what i'm supposed to even try so. none of the tutorials really show anything similar to my code which is mostly why i'm having problems. i might have to rewrite cube vertex array creator. (on a different note maybe i shouldn't have just shoved opengl into some ready code)right now i've only enabled the top face as to see what's going on. /// <summary> /// Draws the specified Cube Onsccreen. /// </summary

i'm trying to implement index buffer object in opentk but don't know how to actually use it when drawing things

时光怂恿深爱的人放手 提交于 2021-02-11 05:56:41
问题 i'm trying to use an index buffer but have no idea how i really am stuck in a waall as to what i'm supposed to even try so. none of the tutorials really show anything similar to my code which is mostly why i'm having problems. i might have to rewrite cube vertex array creator. (on a different note maybe i shouldn't have just shoved opengl into some ready code)right now i've only enabled the top face as to see what's going on. /// <summary> /// Draws the specified Cube Onsccreen. /// </summary

glDrawBuffer(GL_NONE) vs glColorMask set to all GL_FALSE

北战南征 提交于 2021-02-10 20:00:24
问题 What is the difference between glDrawBuffer(GL_NONE) and glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE) Are both just another way of discarding any draws to color buffers? or there are some differences? 回答1: First and foremost, glDrawBuffer (...) applies to the current framebuffer only, it is a per-FBO state. glColorMask (...) , on the other hand, is a global state that masks writes from per-fragment operations to all logical framebuffers. Another problem with glColorMask (...) is that it