glsl

What does the GL_ARRAY_BUFFER target mean in glBindBuffer?

我的未来我决定 提交于 2019-12-03 05:46:05
问题 I was confused about the VBO, glGenBuffers(1, &positionBufferObject); glBindBuffer(GL_ARRAY_BUFFER, positionBufferObject); Besides GL_ARRAY_BUFFER, there are other target types: GL_ATOMIC_COUNTER_BUFFER, GL_COPY_READ_BUFFER... However, the Opengl manual doesn't mention what these targets mean. I checked the glew.h: #define GL_ARRAY_BUFFER 0x8892 Does this mean the targets (like GL_ARRAY_BUFFER) are addresses? What does the target--GL_ARRAY_BUFFER mean in glBindBuffer? 回答1: In General Most

How does the default GLSL shaders look like? for version 330

末鹿安然 提交于 2019-12-03 05:40:19
问题 What do the default vertex, fragment and geometry GLSL shaders look like for version #330? I'll be using #version 330 GLSL Version 3.30 NVIDIA via Cg compiler, because that is what my graphics card supports. With default shaders, I mean shaders that do the same exact thing as the graphics card would do when the shader program is turned off. I can't find a good example for #version 330 . Been googling all day. Not sure if the term default shader is called something else like trivial or basic

What does sampler2D store?

蹲街弑〆低调 提交于 2019-12-03 05:40:03
问题 I've read a texture example in OpenGL 2.1 . The fragment shader looks like this: #version 120 uniform sampler2D texture; varying vec2 texcoord; void main(void) { gl_FragColor = texture2D(texture, texcoord); } The texcoord is passed from vertex shader. The following C++ rendering code is used: void render() { glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, texture_id); glUniform1i(unf_texture, 0); } I am confused about some things. I have some question: In the fragment shader, the

How to get pixel information inside a fragment shader?

好久不见. 提交于 2019-12-03 05:38:54
问题 In my fragment shader I can load a texture, then do this: uniform sampler2D tex; void main(void) { vec4 color = texture2D(tex, gl_TexCoord[0].st); gl_FragColor = color; } That sets the current pixel to color value of texture. I can modify these, etc and it works well. But a few questions. How do I tell "which" pixel I am? For example, say I want to set pixel 100,100 (x,y) to red. Everything else to black. How do I do a : "if currentSelf.Position() == (100,100); then color=red; else color

How do I get the current color of a fragment?

百般思念 提交于 2019-12-03 05:34:19
问题 I'm trying to wrap my head around shaders in GLSL, and I've found some useful resources and tutorials, but I keep running into a wall for something that ought to be fundamental and trivial: how does my fragment shader retrieve the color of the current fragment? You set the final color by saying gl_FragColor = whatever , but apparently that's an output-only value. How do you get the original color of the input so you can perform calculations on it? That's got to be in a variable somewhere, but

What is the difference between opengl and GLSL?

时光毁灭记忆、已成空白 提交于 2019-12-03 05:18:00
问题 I recently started programming with openGL. I've done code creating basic primitives and have used shaders in webGL. I've googled the subject extensively but it's still not that clear to me. Basically, here's what I want to know. Is there anything that can be done in GLSL that can't be done in plain openGL, or does GLSL just do things more efficiently? 回答1: The short version is: OpenGL is an API for rendering graphics, while GLSL (which stands for GL shading language) is a language that gives

OpenGL point sprites rotation in fragment shader

我是研究僧i 提交于 2019-12-03 04:44:31
I'm following this tutorial to learn something more about OpenGL and in particular point sprites. But I'm stuck on one of the exercises at the end of the page: Try to rotate the point sprites 45 degrees by changing the fragment shader. There are no hints about this sort of thing in the chapter, nor in the previous ones. And I didn't find any documentation on how to do it. These are my vertex and fragment shaders: Vertex Shader #version 140 attribute vec2 coord2d; varying vec4 f_color; uniform float offset_x; uniform float scale_x; uniform float point_size; void main(void) { gl_Position = vec4(

Matrix stacks in OpenGL deprecated?

倖福魔咒の 提交于 2019-12-03 03:42:39
I just read this: "OpenGL provided support for managing coordinate transformations and projections using the standard matrix stacks (GL_MODELVIEW and GL_PROJECTION). In core OpenGL 4.0, however, all of the functionality supporting the matrix stacks has been removed. Therefore, it is up to us to provide our own support for the usual transformation and projection matrices, and then to pass them into our shaders." This is strange, so how do I set the modelview and projection matrices now? I should create them in the opengl app and then multiply the vertices in the vertex shader with the matrices?

HDR, adaptive tone mapping and MSAA in GLSL

删除回忆录丶 提交于 2019-12-03 03:31:39
In an effort to teach myself OpenGL, I am working my way trough the 5th edition of the Superbible . I am currently trying to figure out how to combine HDR and MSAA (as described in chapter 9). For HDR, the book suggests a method for adaptive tone mapping that is based on calculating the average luminance for a 5x5 convolution filter for each fragment. For MSAA, the method used averages all samples by weights calculated from the sample distance. My attempt at combining both, found in the pastebin below, applies tone mapping to each sample then averages them to compute the final fragment color.

Shaders in WebGL vs openGL? [closed]

白昼怎懂夜的黑 提交于 2019-12-03 03:13:15
I want to use shaders to use in WebGL and specifically three.js. Is there a specific version of GLSL that WebGL and three.js uses? WebGL shaders follow the GLSL ES 1.017 spec https://www.khronos.org/registry/gles/specs/2.0/GLSL_ES_Specification_1.0.17.pdf That's different than Desktop OpenGL in several ways. One it's the 1.0 version of GLSL ES where as desktop GL at version 4.2 of GLSL (not ES) One big difference between WebGL GLSL and many articles found about shaders on the internet is there's no fixed function pipeline in OpenGL ES 2.0 and therefore no fixed function pipeline in WebGL. The