glsl

C++ OpenGL shading version error - GLSL x is not supported [Ubuntu 16.04]

旧街凉风 提交于 2020-01-03 13:36:17
问题 I am currently working on a project using OpenGL on Ubuntu 16.04 and have run into a major issue. At this point I have no idea what to do as it feels like I have tried everything in order to fix this. For some reason my shader just won't compile and returns the following error: Failed to compile vertex shader! 0:1(10): error: GLSL 4.50 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.00 ES, 3.00 ES, 3.10 ES, and 3.20 ES` I have adjusted the version in the shader file without any

Prevent loop unwinding in fragment shader

∥☆過路亽.° 提交于 2020-01-03 13:30:36
问题 I'm writing a fragment shader for WebGL(GLSL ES 1.0) using the latest version of Chrome(and Firefox), and I wrote an iterative algorithm. So first of all, I found out the hard way that the length of the loop is quite restricted (doc says it must be guessable at compile-time, which means it must be a constant or very close). In addition, I must write a ( for , since it's the only one which must be implemented according to the standard) loop that's potentially long but that breaks almost every

openGL shader: two object and one line to connect them

杀马特。学长 韩版系。学妹 提交于 2020-01-03 05:21:27
问题 I'm using shaders and the programmable pipeline, I need to connect two meshes with a line (maybe colored) but I just have the model matrices of these two objects. The line should start at the center of these objects so I assume the object-coords of the two points should be: start point: 0,0,0 end point: 0,0,0 to connect the two objects I assume I'll have to multiply these points in the shader by their respective object's model matrix. And then multiply everything by the view matrix (this is

Fragment shader: No uniform with name in shader

£可爱£侵袭症+ 提交于 2020-01-03 05:09:06
问题 I have problem with fragment shader in libgdx. Below is my fragment shader. #ifdef GL_ES precision mediump float; #endif uniform float u_aspectRatio; varying vec2 v_texCoords; uniform sampler2D u_texture; void main() { gl_FragColor = texture2D(u_texture, v_texCoords); } In program I do shader.setUniformi("u_texture", 0); // work fine shader.setUniformf("u_aspectRatio", 0.0f); //no uniform with name 'u_aspectRatio' in shader shader.isCompiled() return true and first set work fine, but in

Efficiently making a particle system without textures

会有一股神秘感。 提交于 2020-01-03 04:53:07
问题 I am trying to make a particle system where instead of a texture, a quad is rendered by a fragment shader such as below. uniform vec3 color; uniform float radius; uniform float edge; uniform vec2 position; uniform float alpha; void main() { float dist = distance(gl_FragCoord.xy, position); float intensity = smoothstep(dist-edge, dist+edge, radius); gl_FragColor = vec4(color, intensity*alpha); } Each particle is an object of a c++ class that wraps this shader and all the variables together and

Calculate Normals Geometry Shader

我的未来我决定 提交于 2020-01-03 03:35:10
问题 Im currently writing my own GLSL shaders, and wanted to have smooth shading. The shading worked when i calculated the normals bevore sending them to a VBO, but the problem here is when I implement animations with bone matricies, the normals are not corect. I am using a geometry shader to calculate the normals, but i cant find out how to smooth them. Here is my geometry shader: #version 150 layout(triangles) in; layout (triangle_strip, max_vertices=3) out; in vec2 texCoord0[3]; in vec3

Can one fragment access all texture pixel values in WebGL GLSL? (Not just it's own TexCoord)

心已入冬 提交于 2020-01-03 00:56:33
问题 Let's pretend I'm making a compute shader using WebGL and GLSL. In this shader, each fragment (or pixel) would like to look at every pixel on a texture, then decide on it's own color. Normally a fragment samples it's provided texture coordinate (UV value) from a few textures, but I want to sample effectively all UV values from a single texture for a single fragment. Is this possible? 回答1: EDIT: I was able to sample from each pixel in a 128x128 texture, but moving to 256x256 causes Chrome to

how does GLM handle translation

两盒软妹~` 提交于 2020-01-02 19:23:46
问题 The OpenGL maths library(GLM) uses the following algorithm to compute the translation matrix: //taken from source code template<typename T, qualifier Q> GLM_FUNC_QUALIFIER mat<4, 4, T, Q> translate(mat<4, 4, T, Q> const& m, vec<3, T, Q> const& v) { mat<4, 4, T, Q> Result(m); Result[3] = m[0] * v[0] + m[1] * v[1] + m[2] * v[2] + m[3]; return Result; } (Here the vector v is a 3 dimensional vector and the matrix m is a 4X4 matrix, since we're using homogeneous coordinates the vector v is also 4

Add clipping to THREE.ShaderMaterial

扶醉桌前 提交于 2020-01-02 09:55:37
问题 I'm trying to create a shader that takes into account the clipping planes I'm defining in the scene. These clipping planes work fine for all of the 'vanilla' materials I'm using: THREE.MeshLambertMaterial , THREE.MeshPhongMaterial , and THREE.MeshPhysicalMaterial , but THREE.ShaderMaterial is missing this implementation. This is an example of what I mean: https://jsfiddle.net/fraguada/27LrLsv5/ In this example there are two cubes, one with a THREE.MeshStandardMaterial and one with a material

Shader - Simple SSS lighting issue

夙愿已清 提交于 2020-01-02 09:28:07
问题 I am trying to create a simple subsurface scattering effect using a shader but I am facing a small issue. Look at those screenshots. The three images represents three lighting states (above surface, really close to surface, subsurface) with various lighting colors (red and blue) and always the same subsurface color (red). As you might notice when the light is above the surface and really close to this surface its influence appears to minimize which is the expected behavior. But the problem is