glsl

FBO offscreen rendering slow

百般思念 提交于 2019-12-04 18:22:46
I want to use offscreen rendering using openGL es 2.0 and GLSL shader I setup FBO and it seems working except there are two problems 1) The program goes about 30 fps but all the sudden, it drops to 20fps and then come back to 30 fps again, then few secs later, drops to 20fps again then come back to 30fps and so on...(keeps going on like that) and I don't know what cause this random pause/delay 2) When I close the application, it does not respond for awhile. In other words, it seems like there are some data to clean up or some delay...So when I close the program, it does not do so until few

How to do bilinear interpolation of normals over a quad?

喜欢而已 提交于 2019-12-04 18:14:56
问题 I'm working on a Minecraft-like engine as a hobby project to see how far the concept of voxel terrains can be pushed on modern hardware and OpenGL >= 3. So, all my geometry consists of quads, or squares to be precise. I've built a raycaster to estimate ambient occlusion, and use the technique of "bent normals" to do the lighting. So my normals aren't perpendicular to the quad, nor do they have unit length; rather, they point roughly towards the space where least occlusion is happening, and

Constant float values in GLSL shaders - any reason to use uniforms?

只谈情不闲聊 提交于 2019-12-04 17:02:18
问题 I'm looking at the source of an OpenGL application that uses shaders. One particular shader looks like this: uniform float someConstantValue; void main() { // Use someConstantValue } The uniform is set once from code and never changes throughout the application run-time. In what cases would I want to declare someConstantValue as a uniform and not as const float ? Edit: Just to clarify, the constant value is a physical constant. 回答1: First off, the performance difference between using a

How to select the front triangles of a stl model or a triangular mesh?

牧云@^-^@ 提交于 2019-12-04 16:49:10
There is a stl model(triangular mesh). I want to use a adjustable, rectangular shape to make selections. Like below picture. But I don't want the triangles on the other side are selected. That's to say only the visible triangles in the rectangular can be selected. AFAIK, there is a method to do this. First render each triangle with a specific and unique color. Then, retrieve the color of the pixels in the select rectangular, and convert those colors back to the original identifier. The triangle own the id is selected. I think this method is workable but inefficient. So is there any other

GLSL maximum number of instructions

爷,独闯天下 提交于 2019-12-04 16:48:52
问题 Is there a maximum number of assembly language instructions to be loaded into the fragment program unit? I have an algorithm on to port from cpu to gpu and apparently it doesn't fit on the gpu. 回答1: There are several hard and soft limits, some of which are not immediately obvious: Instruction slots: The total number of instructions that the hardware can accomodate in local memory. Executed instructions: The maximum number of instructions that will execute (including instructions that run

GLSL/OpenGL shader tessellation flickering and failure

久未见 提交于 2019-12-04 16:39:19
问题 I just started with OpenGL tessellation and have run into a bit a trouble. I am tessellating series of patches formed by one vertex each. These vertices/patches are structured in a gridlike fashion to later form a terrain generated by Perlin Noise. The problem I have run into is that starting from the second patch, and every 5 th patch after that, sometimes have a lot of tessellation (not the way i configured) but most of the time it doesn't get tessellated at all. Like so: The two white

Best way to detect NaN's in OpenGL shaders

和自甴很熟 提交于 2019-12-04 16:09:07
问题 I ran into what seemed a mysterious bug this morning that I feel very lucky to have stumbled upon a solution for quite quickly. I was dividing by a counter to produce an average inside of a fragment shader, and of course when the counter is zero, the resulting color value became NaN. During blending, NVidia gracefully treats a NaN as a 0 value, but Intel does not and appears to cascade the NaN, resulting in black fragments. And so this bug persisted until I tested the code on an Intel machine

OpenGL ES 2.0 Shader - 2D Radial Gradient in Polygon

天涯浪子 提交于 2019-12-04 15:50:33
I am trying to paint a radial gradient inside a Polygon. My Stage is 600x320 . I am able to draw a gradient but it`s 'distorted/streched'. The goal is a gradient like a light would produce. u_lightPosition is passed as a relative value : {0.5, 0.5} . Currently unused lightPositionAbsolute is passed in as absolute value {300.0, 160.0} . My fragment-shader currently looks like this: #ifdef GL_ES precision lowp float; #endif varying vec4 v_fragmentColor; uniform vec2 u_lightPosition; uniform vec2 u_lightPositionAbsolute; uniform vec4 u_outerColor; uniform vec4 u_innerColor; uniform float u_radius

read and write integer 1-channel texture opengl

折月煮酒 提交于 2019-12-04 15:24:15
I want to: create a read and writable 1-channel texture that contains integers. using a shader, write integer "I" to the texture. use the texture as a source, sample it and compare if the sample is equal to the integer I. All this with core profile 3.3. This is what I've got so far: I create the texture like so: glTexImage2D(GL_TEXTURE_2D, 0, GL_R8, width, height, 0, GL_RED, GL_INT, (java.nio.ByteBuffer) null); I've Also tried GL_R8I and GL_RED_INTEGER, but that won't work. I bind this texture as my FBO, set blendfunc to (GL_ONE, GL_ONE) (additive) and render 1 quad using a shader that simply

OpenGL - Java - Rendering Issue, Polygons flickering and disappearing

岁酱吖の 提交于 2019-12-04 15:12:23
I'm having some trouble with rendering Master Cheif in Java using LWJGL and GLSL shaders where the is some flickering, dissapearing of polygons and strange colouring. And for the life of me I can't figure out why. What it should look like: What it does look like when I move the camera a little: Shaders: https://github.com/marko5049/LucidEngine/tree/master/src/res/shaders MainShaders: LightingMain ShdaowMapping Smapler Filters All the code: https://github.com/marko5049/LucidEngine StaticMesh: public void addVertices(Vertex[] vertices, int[] indices, boolean calcNorm) { if(calcNorm) { vertices =