glsl

Vertex Attribute Buffers getting bound to wrong attribute

时光怂恿深爱的人放手 提交于 2019-12-11 06:56:25
问题 When I bind my buffers to attributes for my shaders, they seem to be getting flipped. So, I've got a vertex shader: precision highp float; uniform mat4 projection_matrix; uniform mat4 modelview_matrix; in vec3 in_position; in vec3 in_color; out vec3 ex_Color; void main(void) { gl_Position = projection_matrix * modelview_matrix * vec4(in_position, 1); ex_Color = in_color; } and a fragment shader precision highp float; in vec3 ex_Color; out vec4 out_frag_color; void main(void) { out_frag_color

Projection is not working when cutting particular area from top and bottom of openGL control

左心房为你撑大大i 提交于 2019-12-11 06:48:02
问题 With the help of this link i can apply projection on my texture. Now I want to cut/remove equal area from top and bottom of my glcontrol and then need to apply same projection on remain area. I have tried like below. But as shown in the image top and bottom curve is missing on projection. How can I bring it back in remain area? precision highp float; uniform sampler2D sTexture; varying vec2 vTexCoord; void main() { float img_h_px = 432.0; // height of the image in pixel float area_h_px = 39.0

Problems outputting gl_PrimitiveID to custom frame buffer object (FBO)

我们两清 提交于 2019-12-11 06:23:47
问题 I have a very basic fragment shader which I want to output 'gl_PrimitiveID' to a fragment buffer object (FBO) which I have defined. Below is my fragment shader: #version 150 uniform vec4 colorConst; out vec4 fragColor; out uvec4 triID; void main(void) { fragColor = colorConst; triID.r = uint(gl_PrimitiveID); } I setup my FBO like this: GLuint renderbufId0; GLuint renderbufId1; GLuint depthbufId; GLuint framebufId; // generate render and frame buffer objects glGenRenderbuffers( 1,

Three.JS: Gaussian blur in GLSL shader

本秂侑毒 提交于 2019-12-11 06:04:07
问题 I have this vert/frag shader, which is using vertex data and two textures. I am trying to apply post blur effect, but having only rectangles after it. vert: attribute float type; attribute float size; attribute float phase; attribute float increment; uniform float time; uniform vec2 resolution; uniform sampler2D textureA; uniform sampler2D textureB; varying float t; void main() { t = type; vec4 mvPosition = modelViewMatrix * vec4(position, 1.0 ); if(t == 0.) { gl_PointSize = size * 0.8; }

how to convert shadershop formula into glsl

不想你离开。 提交于 2019-12-11 05:57:19
问题 I have been learning some basic of shaders recently and I came up with a great visual tools : shadershop But I am having trouble to convert the formula I created in this site into glsl. A simple example, I created a formula in this site: And I am able to convert this in glsl: And then I moved on, I created a two dimension formula on shadershop : But this I just have no clue how to convert this formula into glsl just like I did before. Any advice will be appreciated, thanks :) UPDATE I tried

GLSL - vertex shader and batching using uniform buffer object

[亡魂溺海] 提交于 2019-12-11 05:39:27
问题 I have the following vertex shader: #version 450 core ... layout (binding=2, std140) uniform MATRIX_BLOCK { mat4 projection; mat4 view; mat4 model[128]; mat4 mvp[128]; }; layout (location = 0) in vec3 aPos; layout (location = 1) in vec2 aTexCoord; layout (location = 3) in uint object_idx; out vec2 TexCoord; flat out uint instance_idx; void main() { gl_Position = mvp[object_idx] * vec4(aPos.x, aPos.y, aPos.z, 1.0); TexCoord = aTexCoord; instance_idx = object_idx; } I'm using a uniform buffer

Performance of GLSL geometry shaders unexpectedly slow

假装没事ソ 提交于 2019-12-11 05:38:39
问题 I'm trying to learn how to program GLSL Geometry shaders. My test project works like this: I have N VBO's which are modeling "blades of grass". Without the shader, each blade of grass is just basically a line strip with 20 segments. I was able to get this animating more or less smoothly with almost N=10k blades so that's 200,000 lines. The shader takes each line segment and blows it out to a cylinder of the same length centered on that line segment, so the blades of grass are now tubes with

OpenGL uniform nof found if uniform block gets too big

徘徊边缘 提交于 2019-12-11 05:34:26
问题 I´m trying to implement a Uniform Block. This is how the block looks like in my fragment shader: struct Light { uint LightType; vec3 Direction; float SpotBlur; vec3 AmbientColor; float LinearAttenuation; vec3 DiffuseColor; float QuadraticAttenuation; vec3 SpecularColor; float CubicAttenuation; vec3 Position; float SpotCutoff; }; layout(std140) uniform LightBlock { Light values; } lights[32]; As you can see, I defined an array of the Light struct with a fixed size of 32. I can upload the data

how to write a cga shader in glsl?

左心房为你撑大大i 提交于 2019-12-11 05:25:27
问题 How to write a CGA shader that limit the palette to 4 colors and match the original colors with those (cyan, magenta, black, white)?? I'm working on Game Maker Studio Professional, that actually allows the using of shaders writing vertex and fragment code I already asked this question also in the yoyogames community and in the openGl forum someone answered me with this : varying vec2 v_vTexcoord; varying vec4 v_vColour; const mat3 rgb_to_wcm = mat3(1,-1, 0, 1, 0,-1, -1, 1, 1); void main() {

Benchmarking GLSL shaders to compare speed of alternative implementations

会有一股神秘感。 提交于 2019-12-11 05:18:48
问题 I want to plot two-dimensional function z = f(x,y) using OpenGL and GLSL shaders. I'd like to map the value of function to color using a colormap, but some colormaps are expressed using HSL or HSV colorspace (for example hue maps). You can find (here and in other places) different alternative implementtions of hsv2rgb() in GLSL. How can I benchmark those shaders (those functions) to find out which one is fastest? 回答1: Implement all alternatives you want to try and apply the usual benchmark