vertex-shader

GLSL - Using custom output attribute instead of gl_Position

让人想犯罪 __ 提交于 2019-11-27 13:46:19
I am currently learning OpenGL with shaders (3.3). There is one thing i can't seem to work out though. I have read that using built-in variables like gl_Position and gl_FragCoords is deprecated in OpenGL 3+, therefore I wanted to use my own output variable. So instead of this: #version 330\n layout(location=0) in vec2 i_position; out vec4 o_position; void main() { gl_Position = vec4(i_position, 0.0, 1.0); }; I wrote this: #version 330\n layout(location=0) in vec2 i_position; out vec4 o_position; void main() { o_position = vec4(i_position, 0.0, 1.0); }; The shaders compile without problems in

Vertex shader vs Fragment Shader [duplicate]

别等时光非礼了梦想. 提交于 2019-11-27 09:04:14
问题 This question already has an answer here: What are Vertex and Pixel shaders? 5 answers I've read some tutorials regarding Cg, yet one thing is not quite clear to me. What exactly is the difference between vertex and fragment shaders? And for what situations is one better suited than the other? 回答1: A fragment shader is the same as pixel shader. One main difference is that a vertex shader can manipulate the attributes of vertices. which are the corner points of your polygons. The fragment

Retrieve Vertices Data in THREE.js

筅森魡賤 提交于 2019-11-27 01:59:19
问题 I'm creating a mesh with a custom shader. Within the vertex shader I'm modifying the original position of the geometry vertices. Then I need to access to this new vertices position from outside the shader, how can I accomplish this? 回答1: In lieu of transform feedback (which WebGL 1.0 does not support), you will have to use a passthrough fragment shader and floating-point texture (this requires loading the extension OES_texture_float ). That is the only approach to generate a vertex buffer on

Drawing a border on a 2d polygon with a fragment shader

大城市里の小女人 提交于 2019-11-26 19:20:02
问题 I have some simple polygons (fewer than 20 vertices) rendering flat on a simple xy plane, using GL_TRIANGLES and a flat color, a 2d simulation. I would like to add a border of variable thickness and a different color to these polygons. I have something implemented using the same vertices and glLineWidth/GL_LINE_LOOP, which works, but is another rendering pass and repeats all the vertex transforms. I think I should be able to do this in the fragment shader using gl_FragCoord and the vertex

GLSL - Using custom output attribute instead of gl_Position

北城以北 提交于 2019-11-26 16:32:42
问题 I am currently learning OpenGL with shaders (3.3). There is one thing i can't seem to work out though. I have read that using built-in variables like gl_Position and gl_FragCoords is deprecated in OpenGL 3+, therefore I wanted to use my own output variable. So instead of this: #version 330\n layout(location=0) in vec2 i_position; out vec4 o_position; void main() { gl_Position = vec4(i_position, 0.0, 1.0); }; I wrote this: #version 330\n layout(location=0) in vec2 i_position; out vec4 o