vertex-shader

OpenGL degenerate GL_TRIANGLES sharing same vertices

若如初见. 提交于 2019-12-11 01:25:53
问题 I send a VertexBuffer+IndexBuffer of GL_TRIANGLES via glDrawElements() to the GPU. In the vertex shader I wanted snap some vertices to the same coordinates to simplify a large mesh on-the-fly. As result I expeceted a major performance boost because a lot of triangle are collapsing to the same point and would be degenerated. But I don't get any fps gain. Due testing I set my vertex shader just to gl_Position(vec4(0)) to degenerate ALL triangles, but still no difference... Is there any flag to

How does gl_ClipVertex work relative to gl_ClipDistance?

旧街凉风 提交于 2019-12-10 21:50:12
问题 I was planning on using gl_ClipDistance in my vertex shader until I realized my project is OpenGL 2.1/GLSL 1.2 which means gl_ClipDistance is not available. gl_ClipVertex is the predecessor to gl_ClipDistance but I can find very little information about how it works and, especially relative to gl_ClipDistance , how it is used. My goal is to clip the intersection of clipping planes without the need for multiple rendering passes. In the above referenced question, it was suggested that I use gl

for-loop in shader code working with hardcoded number but not with uniform variable

大城市里の小女人 提交于 2019-12-10 05:37:14
问题 I asked for help about an OpenGL ES 2.0 Problem in this question. What seems to be the answer is very odd to me. Therefore I decided to ask this question in hope of being able to understand what is going on. Here is the piece of faulty vertex-shader code: // a bunch of uniforms and stuff... uniform int u_lights_active; void main() { // some code... for ( int i = 0; i < u_lights_active; ++i ) { // do some stuff using u_lights_active } // some other code... } I know this looks odd but this is

Rotate Normals in Shader

社会主义新天地 提交于 2019-12-09 18:24:00
问题 I have a scene with several models with individual positions and rotations. Given normals, the shaders apply simple bidirectional lighting to each pixel. That is my vertex shader. #version 150 in vec3 position; in vec3 normal; in vec2 texcoord; out vec3 f_normal; out vec2 f_texcoord; uniform mat4 model; uniform mat4 view; uniform mat4 proj; void main() { mat4 mvp = proj * view * model; f_normal = normal; f_texcoord = texcoord; gl_Position = mvp * vec4(position, 1.0); } And here is the

Are MTLVertexAttributeDescriptors necessary? Why are they needed?

岁酱吖の 提交于 2019-12-09 14:56:09
问题 I've been learning Metal for iOS / OSX, and I began by following a Ray Wenderlich tutorial. This tutorial works fine but it makes no mention of MTLVertexAttributeDescriptors . Now that I'm developing my own app, I'm getting weird glitches and I'm wondering if the fact that I don't use MTLVertexAttributeDescriptors may be related to the problem. What difference do they make? I've been able to make a variety of shaders with varying vertex structures and I never even knew about these things. I

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

Texture Mapping and Lighting Vertex Shader ErrorJava OpenGL

孤街浪徒 提交于 2019-12-07 14:07:36
问题 I am trying to map texture to a 3D cube and trying to write shaders so that it has lighting and texture. I have tried writing texture shader only and it works. I have also tried lighting shader only with 3D values set to red color, and that light shader works too. But when i try to combine that two, I am having problem. I have provided my code below, but i am getting error that Attached vertex shader is not compiled. Shader could not be linked. Vertex Shader #version 330 core layout(location

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

OpenGL - Fixed pipeline shader defaults (Mimic fixed pipeline with shaders)

梦想的初衷 提交于 2019-12-07 08:59:04
问题 Can anyone provide me the shader that are similar to the Fixed function Pipeline? I need the Fragment shader default the most, because I found a similar vertex shader online. But if you have a pair that should be fine! I want to use fixed pipeline, but have the flexability of shaders, so I need similar shaders so I'll be able to mimic the functionality of the fixed pipeline. Thank you very much! I'm new here so if you need more information tell me:D This is what I would like to replicate:

Generic picking solution for 3D scenes with vertex-shader-based geometry deformation applied

谁说我不能喝 提交于 2019-12-07 08:42:54
问题 I'm trying to implement a navigation technique for 3D scenes (in OpenSceneGraph with OpenGL). Among other things the user should be able to click on an scene object on the screen to move towards it. The navigation technique should be integrated into another project which uses a vertex shader to apply a global deformation to the scene geometry. And here is the problem: Since the geometry is deformed using a vertex shader, it is not straight forward to un-project the mouse cursor position to