shader

Why I can't use uniform1f instead of uniform4f for setting a vec4 uniform?

做~自己de王妃 提交于 2019-12-10 22:28:33
问题 I learn WebGL step by step via this book. I try to draw three points through using of the buffer ( gl.ARRAY_BUFFER ) instead of cycle (as I did the same earlier in other samples of the book). var u_FragColor = gl.getUniformLocation(gl.program, 'u_FragColor'); if(!u_FragColor){ console.log('Can\'t to get the "u_FragColor" variable.'); return -1; } // gl.uniform1f(u_FragColor, 1.0); // <- this variant doesn't work! Why? gl.uniform4f(u_FragColor, 1.0, 0.0, 0.0, 1.0); It works fine, but I have a

GLSL fragment shader syntax error

本小妞迷上赌 提交于 2019-12-10 19:26:07
问题 the following simple fragment shader code fails, leaving me with an uninformative message in the log: ERROR: 0:1: 'gl_Color' : syntax error syntax error void main() { vec4 myOutputColor(gl_Color); gl_FragColor = myOutputColor; } while the following one works: void main() { glFragColor = gl_Color; } This boggles my mind, as in Lighthouse3D's tutorial gl_Color is said to be a vec4. Why can't I assign it to another vec4? 回答1: Try normal assignment. Like this: void main() { vec4 myOutputColor =

OpenGL ES 2.0 with iPhone: GL_POINT_SMOOTH draws squares with ES 2.0 but works in ES 1.0

帅比萌擦擦* 提交于 2019-12-10 19:01:25
问题 I'm trying to draw circles by using a Vertex Buffer Object to draw points with GL_POINT_SMOOTH enabled in OpenGL ES 2.0 on iPhone. I've used the following ES 1.0 rendering code to draw circles successfully on iPhone 4: glVertexPointer(2, GL_FLOAT, 0, circleVertices); glEnableClientState(GL_VERTEX_ARRAY); glEnable(GL_POINT_SMOOTH); glPointSize(radius*2); glDrawArrays(GL_POINTS, 0, 1); I'm now trying to achieve the same effect using a set-up VBO followed by this ES 2.0 rendering code: glEnable

ios - pass a 4x4 matrix to glUniformMatrix4fv

╄→гoц情女王★ 提交于 2019-12-10 18:24:12
问题 I'm trying to pass a 4x4 matrix to glUniformMatrix4fv but can't figure out the last bit. I create a 4x4 by directly inputing 16 values. glUniformMatrix4fv excepts an UnsafePointer<GLfloat>! as its last argument var proj = GLKMatrix4(m: ( -1.1269710063934326, 0.0, -1.380141455272968e-16, 0.0, 0.0, 0.800000011920929, 0.0, 0.0, 0.0, -0.0, 0.0, -4.950000286102295, -1.2246468525851679e-16, 0.0, 1.0, 5.050000190734863) ) var loc = GLint(_locations.uniforms.projection) var f = GLboolean(GL_FALSE)

Gradient with fixed number of levels

百般思念 提交于 2019-12-10 17:44:34
问题 I drawing a set of quads. For each quad I have a defined color in a vertex of it. E.g. now my set of quads looks like: I achive such result in rather primitive way just passing into vertex shader as attribute color of each vertex of an quad. My shaders are pretty simple: Vertex shader #version 150 core in vec3 in_Position; in vec3 in_Color; out vec3 pass_Color; uniform mat4 projectionMatrix; uniform mat4 viewMatrix; uniform mat4 modelMatrix; void main(void) { gl_Position = projectionMatrix *

Three.js Shader-Texture Blinking

怎甘沉沦 提交于 2019-12-10 17:23:38
问题 I'm new to three.js and think it's great. I'm trying to get a better hold on moving texture data to the shader so I can mostly use GPU. I base my program on Mr. Doob's magic dust example, but I'm not using particles rather loaded models stored in a texture. I'm having an issue currently where I get flickering. The code below is a rough example of the flickering and has some closeness to what I'm doing. If anyone could help me understand what I'm doing wrong or where the flickering is coming

Pix, A couple of issues I'm not understanding

試著忘記壹切 提交于 2019-12-10 17:07:09
问题 I've been asked to split questions which I asked here: HLSL and Pix number of questions I thought two and three would both fit in the same question as a solution of one may help resolve the other. I'm trying to debug a shader and seem to be running into issues. Firstly Pix seems to be skipping a large amount of code when I'm running analyse mode. This is analysing an experiment with F12 captures and with D3DX analysis turned off. I have to turn it off as I'm using XNA. The shader code in

Threejs Shader - gl_FragColor with Alpha (opacity not changing)

偶尔善良 提交于 2019-12-10 16:49:05
问题 I'm trying to write a simple shader where half of my scene will be displayed and half of the scene will be transparent. I can't seem to figure out why the transparency isn't working: uniform sampler2D tDiffuse; varying vec2 vUv; void main(){ vec2 p = vUv; vec4 color; if(p.x < 0.5){ color = (1.0, 0.0, 0.0, 0.0); }else{ color = texture2D(tDiffuse, p); } gl_FragColor = color; } The shader is definitely running without errors - the right half of the screen is my threejs scene and the left half of

Cg problems with OpenGL

我怕爱的太早我们不能终老 提交于 2019-12-10 15:54:16
问题 I'm working on an OpenGL project on Windows, using GLEW to provide the functionality the provided Windows headers lack. For shader support, I'm using NVIDIA's Cg. All the documentation and code samples I have read indicate that the following is the correct method for loading an using shaders, and I've implemented things this way in my code: Create a Cg context with cgCreateContext . Get the latest vertex and pixel shader profiles using cgGLGetLatestProfile with CG_GL_VERTEX and CG_GL_FRAGMENT

QGLShaderProgram will not compile any shader since upgrading to Qt5

折月煮酒 提交于 2019-12-10 15:08:53
问题 I am finding that QGLShaderProgram is consistently failing to compile any shader and providing no error log. Here are the symptoms: QGLShaderProgram reports that it failed to compile but produces an empty error log. If I try to bind the shader an exception is thrown. I can compile a shader using glCompileShader without problem. However, the first time I try to compile this way after QGLShaderProgram has failed, fails with this error log: ERROR: error(#270) Internal error: Wrong symbol table