glsl

Texture edges are moving when camera is moved

时光总嘲笑我的痴心妄想 提交于 2019-12-06 16:29:05
The textures look good as long as the camera remains in a fixed position and rotation. However, when the camera is moving or rotating, (partial) lines appear between textures. I think it has to do something with subpixel correction. The texel is switching between the previous and the next one. For my textures I use: glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); The

Applying a blur shader to sf::RectangleShape

随声附和 提交于 2019-12-06 15:40:48
I have an object that is a 2d array of sf::RectangleShapes (for a tile-based game). It's supposed to look like a cloud, so I want to add some blur to it. Here is what it looks like now: And I want it to look like this: Instinctively, it seems to achieve this blur effect on the low level, I would have to draw the cloud object to a buffer, and then apply the blur object to the buffer. But I'm not sure if SFML is doing this already. In my main loop, I have this: for( CloudIterator it = clouds.begin(); it != clouds.end(); it++ ) { window.draw(**it); } Which I hope to replace with: for(

How to get completely rid of shadow acne and erroneous self shadowing?

别来无恙 提交于 2019-12-06 15:24:38
I'm doing Simple Shadow Mapping and have problems with handling shadow acne and erroneous self shadowing and just can't get rid of it. I already tried adding a bias to the depth value and rendering back faces to the depth buffer, but it doesn't remove all artifacts. I also have problems choosing the right bias which leads to Peter Panning. Here I have some screenshots. So my questions are: Is there a robust (and easy) way to completely eliminate shadow acne and erroneous self shadowing? How to choose the perfect bias? There's a technique called variance shadow maps which is subject to its own

FBO offscreen rendering slow

百般思念 提交于 2019-12-06 13:47:08
问题 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

Qt & OpenGL OS X: GLSL shader version only 120 on Mountain Lion

无人久伴 提交于 2019-12-06 13:35:27
I'm trying to move some code from the fixed function OpenGL to GLSL shaders, by following along with the arcsynthesis tutorials. First I ran into the issue that version 330 isn't available which after a quick search seemed common, but the recommendation is that 150 should work fine. However, aside from 120 there's no other GLSL shader versions available, is this normal for a 2013 Macbook Air on 10.8.4? Or is there some weirdness going on with the combination of OpenGL + Qt 5 under OS X? EDIT: https://developer.apple.com/library/ios/samplecode/GLEssentials/Introduction/Intro.html if I build the

Only glsl shader version 120 works on mac OS X

家住魔仙堡 提交于 2019-12-06 12:57:29
问题 I have a problem with the glsl's version on my mac os X 10.9.2. I'm making a program in c++ with OpenGL and SDL2 I can't upgrade from my version 120 to any version higher. How I can upgrade please ? I compile like this : g++ and my flag is : -framework SDL2 -lSDLmain -framework OpenGL -framework SDL2_image -framework cocoa ERROR: 0:3: '' : version '330' is not supported 回答1: On OS/X 10.9 to create an OpenGL 3.3/4.1 context you need to add the following snippet before SDL_CreateWindow . SDL

How vertex and fragment shaders communicate in OpenGL?

被刻印的时光 ゝ 提交于 2019-12-06 12:35:40
I really do not understand how fragment shader works. I know that vertex shader runs once per vertices fragment shader runs once per fragment Since fragment shader does not work per vertex but per fragment how can it send data to the fragment shader? The amount of vertices and amount of fragments are not equal. How can it decide which fragment belong to which vertex? To make sense of this, you'll need to consider the whole render pipeline. The outputs of the vertex shader (besides the special output gl_Position ) is passed along as "associated data" of the vertex to the next stages in the

OpenGL shader: a spotlight and a directional light

懵懂的女人 提交于 2019-12-06 11:09:18
I want to have two light sources: a directional one and a spotlight. I cannot seem to get what I am doing wrong -- probably not understanding how shaders work! I get the first light fine but no sign of the effects of the second one (aka spotlight). Here is the fragement shader that I came up with: varying vec4 diffuse,ambientGlobal, ambient; varying vec3 normal,lightDir,halfVector; varying float dist; void main() { vec3 n, halfV, viewV, ldir; float NdotL, NdotHV; vec4 color = ambientGlobal; float att, spotEffect; n = normalize(normal); NdotL = max(dot(n,normalize(lightDir)),0.0); if (NdotL > 0

OpenGL ES 2.0 Shader - 2D Radial Gradient in Polygon

北战南征 提交于 2019-12-06 09:27:50
问题 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

Multiple subroutine types defined in the same fragment shader does not work correctly using GLSL Shaders

喜夏-厌秋 提交于 2019-12-06 09:20:14
I'm working on a program using GLSL shaders. I coded 2 different ways to compute ADS (Ambient + Diffuse + Specular) shading in 2 different methods. To do the job properly I used subroutines to use one or the other method to compute ADS shading. Here's a piece of the fragment shader code : subroutine vec3 LightShadingEffectType(int idx, vec3 normal, vec3 lightDir); subroutine uniform LightShadingEffectType LightShadingEffect; subroutine (LightShadingEffectType) vec3 Basic_ADS_Shading(int idx, vec3 normal, vec3 lightDir) { vec3 reflectDir = reflect(-lightDir, normal); vec3 viewDir = normalize(