glsl

SceneKit painting on texture with texture coordinates

跟風遠走 提交于 2019-12-07 21:24:25
问题 I have a Collada model that I load into SceneKit. When I perform a hittest on the model I am able to retrieve the texture coordinates of the model that was hit. With these texture coordinates I should be able to replace texture coordinates with a color. So this way I should be able to draw on the model Correct me if I am wrong so far. I read a lot of articles till now but I just don't get my shaders right. ( Though I did get some funky effects ;-) My vertex shader : precision highp float;

Opengl error 1281 when trying to glUseProgram

青春壹個敷衍的年華 提交于 2019-12-07 18:18:38
问题 Any ideas how I could debug this opengl error further? 1281 I'm loading source from files, compiling, linking and then trying to check for errors after glUseProgram In my object's draw method .. log.info(gl2.glIsProgram(shaderProgram)); // true gl2.glUseProgram(shaderProgram); int error; while ((error = gl2.glGetError()) != GL2.GL_NO_ERROR) { throw new RuntimeException("glUseProgram" + ": glError " + error); } Output .. [13:38:08] INFO (IARectangle.java:99) - true java.lang.RuntimeException:

Converting GLSL modern OpenGL 3.2

我怕爱的太早我们不能终老 提交于 2019-12-07 16:38:02
问题 I'm following a freetype tutorial on wikibooks on a mac running 10.9 with Xcode 5. I have it running with shader version 120 but I want to use some modern features so I set the SDL hints to OpenGL 3.2 and convert my shaders to 150. The problem is in version 150, the use of texture2D will prevent the shader from compiling. Here is the version 120 of the shaders: const GLchar* vTextSource = "#version 120\n" "attribute vec4 coord;" "varying vec2 texcoord;" "void main(void) {" " gl_Position =

How to write const array in GLSL ES

寵の児 提交于 2019-12-07 16:06:44
问题 I am trying to write a simple vertex shader for an OpenGL ES app on the iPhone, but my array constructor is causing me trouble. attribute vec4 normal; attribute vec4 position; void main(void){ const vec4 vertices[3] = vec4[](vec4(0.25, -0.25, 0.5, 1.0), vec4(-0.25, -0.25, 0.5, 1.0), vec4(0.25, 0.25, 0.5, 1.0)); gl_Position = vertices[gl_VertexID]; } When using this code the shader is unable to compile, and gives me the eror message: ERROR: 0:13: '(' : syntax error: Array size must appear

Passing attributes to OpenGL vertex shader acts strangely

℡╲_俬逩灬. 提交于 2019-12-07 15:53:55
问题 The problem: Outcome 1: I pass a vertex attribute to the shader, the program runs for 5 seconds, then the graphics driver stops responding and recovers but the program doesn't. Outcome 2: I cap the framerate at 60 then do the same thing. The program runs fine, but when I try to pass different values for the vertex attribute in the same runtime it does not update the geometry (only the first vertex attribute passed works). I'm using OpenGL version 3.1 with GLSL 140. (The highest my graphics

Gamma correction doesn't look properly corrected, is this linear?

安稳与你 提交于 2019-12-07 14:21:23
问题 I want to implement gamma correction to my OpenGL lighting, but with gamma correction applied, my results do not seem linear at all. I also found OpenGL: Gamma corrected image doesn't appear linear which is very similar to my issue, but hasn't yet received an answer nor discussed actual diffuse lights. As an illustration, I have the following 4 light colors defined in linear space: glm::vec3 lightColors[] = { glm::vec3(0.25), glm::vec3(0.50), glm::vec3(0.75), glm::vec3(1.00) }; With each

Are there any non-mobile graphics cards that don't support “precision highp float”?

萝らか妹 提交于 2019-12-07 13:10:06
问题 I know it is common for mobile phones to not support 'precision highp float' in fragment shaders, but are there any desktop or laptop GPUs that don't support it? In other words, if I'm only writing my shader code for use in desktop/laptop scenarios, do I really need to do this conditional stuff recommended in the OpenGL ES 2.0 book? #ifdef GL_FRAGMENT_PRECISION_HIGH precision highp float; #else precision mediump float; #endif Or can I just stick with declaring it 'highp' and be done with it?

Vertex shader with array inputs

不问归期 提交于 2019-12-07 11:33:44
问题 Given a vertex shader that looks something like #version 400 compatibility const int max_valence = 6; in int valence; in vec3 patch_data[1 + 2 * max_valence]; ... What is the the proper way to map the data to the correct vertex attribs? I'm trying to use a VBO, but I can't figure out how to pass that large of a value in. glVertexAttribPointer takes at most a vector of size 4. What's the correct way to get the vertex attributes into the shader? 回答1: Arrays of vertex attributes are legal in

Where can I find documentation on the OpenGL shader function texture2DRect()?

前提是你 提交于 2019-12-07 10:04:10
问题 I'm normally a self-sufficient Googler, but I can't find any documentation on the OpenGL shader function texture2DRect() . Has anyone come across this before? It's being used in some sample code for writing shaders in openframeworks, so I know it exists, and it works, just can't find any official docs on it. Where can I learn more about this function? 回答1: That function is used to sample a 2D Texture Rectangle (A NPOT texture target), and it's specified in "Additions to version 1.10.59 of the

Ping-pong rendering between two FBOs fails after first frame.

戏子无情 提交于 2019-12-07 09:32:16
问题 I am trying to create two FBOs and implement a ping-pong render. But, I only get the first frame to work properly. I am trying to simulate a game-of-life and, after the first frame, I only get a black screen. Could you help me check it? I have spent hours on this issue. Edit Maybe I didn't describe clearly. Actually, I want to use the textureB as the texture and render it to textureA, then use the textureA to render to screen, then vice versa. Edit I can see the first frame, which is the