glsl

Tools for GLSL editing [closed]

此生再无相见时 提交于 2019-11-28 13:35:42
问题 I'm looking for some kind of tool to work with GLSL. I want to experiment with shaders in the WebGL application, so what I'm looking for is something like RenderMonkey. As far as I know - RenderMonkey is not supported anymore, so there must be some other tool that took it's place. The best would be if I could do both the "effect composing" like RM and the raw GLSL code development. 回答1: Looking forward to see some nice answers. In the meantime, I recommend having a play with ShaderToy and

What is the purpose of `glEnableVertexAttribArray(GLuint index)` in OpenGL?

假装没事ソ 提交于 2019-11-28 12:58:53
After calling glVertexAttribPointer(GLuint index, ...) the vertex attribute is disabled by default as the docs say By default, all client-side capabilities are disabled, including all generic vertex attribute arrays. Why must we enable it using an extra function? Can someone name a case, where this is useful? When researching I learned the following: By using the layout(location = x) qualifier in GLSL or glBindAttribLocation we can set the location explicitly rather then letting OpenGL generate it. But this is not the point of my question. glEnableVertexAttribArray can not be used to draw one

OpenGL font rendering using Freetype2

旧街凉风 提交于 2019-11-28 12:08:15
I'm trying to render a freetype font using OpenGL, following the example posted at http://en.wikibooks.org/wiki/OpenGL_Programming/Modern_OpenGL_Tutorial_Text_Rendering_02 . I've been able to generate a texture atlas from the font, creating shaders and creating quads. What I seem to get stuck at is passing the texture to the shader and/or getting the correct UVs for my quads. Been struggling for a good while now and really need the help. The following is the struct I use to create my texture atlas. struct FontCharacter { float advanceX; float advanceY; float bitmapWidth; float bitmapHeight;

Qt5 OpenGL GLSL version error

谁说胖子不能爱 提交于 2019-11-28 11:40:49
I'm starting out on using OpenGL with Qt, and with Shaders (I have OpenGL experience, but not with shaders yet) I'm following this tutorial: http://releases.qt-project.org/learning/developerguides/qtopengltutorial/OpenGLTutorial.pdf (the official Qt5 OpenGL tutorial). The problem is, that when I try to run my program, I get a black screen and the following error messages: QGLShader::compile(Vertex): ERROR: 0:1: '' : version '130' is not supported QGLShader::compile(Fragment): ERROR: 0:1: '' : version '130' is not supported My program is based on a QGLWidget With some browsing on the interwebs

SceneKit shader modifiers with GLSL arrays

半城伤御伤魂 提交于 2019-11-28 11:06:33
问题 I'm trying to pass in an array of points into a shader modifier in SceneKit, but I can't work out the correct syntax. In my shader extension code I have: uniform vec2 points[100]; If I call… material.setValue(NSValue(point: CGPoint(x: 100.5, y: 50.5)), forKey: "points") …then it sets the value of points[0] , which makes me think that maybe it's not possible. I've tried lots of other combinations for both the key and the value, but nothing seems to work. Is there a better way to do this? My

How do I convert gl_FragCoord to a world space point in a fragment shader?

≡放荡痞女 提交于 2019-11-28 10:32:33
问题 My understanding is that you can convert gl_FragCoord to a point in world coordinates in the fragment shader if you have the inverse of the view projection matrix, the screen width, and the screen height. First, you convert gl_FragCoord.x and gl_FragCoord.y from screen space to normalized device coordinates by dividing by the width and height respectively, then scaling and offsetting them into the range [-1, 1]. Next you transform by the inverse view projection matrix to get a world space

gl_PointSize Corresponding to World Space Size

别说谁变了你拦得住时间么 提交于 2019-11-28 09:15:16
If you want to render an imposter geometry (say like a sphere ), then the standard practice is to draw it using two triangles (say by passing one vertex and making a triangle strip with a geometry shader). This is nice because it allows the extent of the billboard to be set fairly simply: you compute the actual world space positions directly. Geometry shaders can alternately output point primitives, and I don't see a reason why they shouldn't. The only issue is finding some way to scale gl_PointSize so that you get that effect. The only precedent I could find were this question (whose answer I

How does vertex shader pass color information to fragment shader?

≡放荡痞女 提交于 2019-11-28 09:01:48
In a simple hello-world OpenGL program, which simply draws a static triangle on the window, when I set the 3 vertex of the triangle to red, green and blue color, the triangle is filled with gradient. But when I use shaders like this: Vertex Shader: attribute vec4 aVertex; attribute vec4 aColor; varying vec4 vColor; void main(void) { gl_Position = gl_ModelViewMatrix * gl_ProjectionMatrix * aVertex; vColor = aColor; } where the attributes aVertex and aColor comes from a vertex buffer, passed through a call of glVertexAttribPointer . Fragment Shader: varying vec4 vColor; void main(void) { gl

Can you tell if a vertex attribute is enabled from within a vertex shader?

人盡茶涼 提交于 2019-11-28 07:31:52
问题 I was wondering if there was a way to tell if a vertex attribute is enabled from within a vertex shader? I know that if the vertex attribute is disabled all the values will be treated as 0.0, so I could do a test like the following: if (attribute == 0) { // Do something different to normal. } else { // Use the attribute. } But this has the obvious problem for the case that the attribute is enabled and the value is just set to 0 (it will be treated as if it's disabled)! The other solution

OpenGL 4.1(?) under Mavericks

狂风中的少年 提交于 2019-11-28 07:26:06
I've just upgraded my MacBook Pro to Mavericks (MacOS 10.9), including Xcode. According to Apple's "OpenGL Capabilities Table", this version has support for OpenGL 4.1, but a call to glGetString(GL_VERSION) returns "1.2" and my GLSL 3.30 shader, which begins with "#version 330" refuses to load, saying that version is not supported. Do I need to do something to Mavericks to enable 4.1 support? When you request your pixel format using one of the lower-level APIs on OS X, you need to add the following to your attribute list in order to use a core profile: CGL: kCGLPFAOpenGLProfile,