glsl

Opengl shadow acne when using shadow2D

依然范特西╮ 提交于 2019-12-08 04:46:21
问题 I'm trying to implement shadow mapping in opengl. It's working, however aliasing is visible, so I decided to use sampler2Dshadow with shadow2D, cause I've read it serves as simple anti-aliasing solution. But as soon as I use it, it causes very significant shadow acne across whole scene. Note that when using sampler2D with texture2D, there's none. Is this intended? If so, how should I solved it? This is how it looks while using sampler2DShadow: This is part of fragment shader that handles

Vertex shader error C5145: must write to gl_Position using QShaderProgram

本小妞迷上赌 提交于 2019-12-08 04:24:28
问题 I am translating a Visual Studio C++ OpenGL project to a Qt project to implement a UI . I have all the code translated and I am using Qt classes to implement OpenGL part. The problem I am having now is that when I link the shaderProgram it throws me an error that says: Vertex info (0) : error C5145: must write to gl_Position I am implementing QOpenGLFunctions_4_1_Core and I debug the compile function to see if the code was well read and yes All the code is read and the compile function

Mapbox Android SDK crash - “java.lang.Error: Vertex shader fill failed to compile”

試著忘記壹切 提交于 2019-12-08 03:47:06
问题 After upgrading my Android Studio version to 2.1.3, my application crashes every time I launch it. More precisely, it crashes when trying to load my Mapbox View (that was perfectly working before that). I did some research, and it seems to be a known issue, but I couldn't find any workaround to pass through it... I think it MAY be a problem with the Emulator only, but for now I couldn't try on a lot of physical devices, so I'm not sure about that. But anyway, I really need to use the emulator

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

落爺英雄遲暮 提交于 2019-12-08 03:39:59
问题 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

How to add fog to texture in shader (THREE.JS R76)

故事扮演 提交于 2019-12-08 03:27:28
So firstly, I am aware of this post: ShaderMaterial fog parameter does not work My question is a bit different... I am trying to apply the fog in my three.js scene to a shader thats using a TEXTURE and I can't figure it out. My best guess as to what is supposed to go into the frag was: resultingColor = mix(texture2D(glowTexture, vUv), fogColor, fogFactor); This works when the texture2D part is just a normal color but as a texture it doesn't render. THREE.glowShader = { vertexShader: [ ` varying vec2 vUv; void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4(position,1

Shaders: How to draw 3D point verts without generating geometry?

最后都变了- 提交于 2019-12-08 02:25:26
问题 I have a 3D Webgl scene. I am using Regl http://regl.party/ . Which is WebGL. So I am essentially writing straight GLSL. This is a game project. I have an array of 3D positions [[x,y,z] ...] which are bullets, or projectiles. I want to draw these bullets as a simple cube, sphere, or particle. No requirement on the appearance. How can I make shaders and a draw call for this without having to create a repeated duplicate set of geometry for the bullets? Preferring an answer with a vert and frag

Opengl Simple Fragment Shader to overlay semi-transparent Triangle Strip over texture

自作多情 提交于 2019-12-08 00:13:39
问题 I have a textured triangle strip that forms a quad. when you click on it i want the surrounding areas to get marked with semi-transparent quads so you can still see the textures underneath. i have the quads getting displayed correctly, but they are not transparent at all and completely cover whatever is underneath. i have a very simple fragment shader that i thought would work with glEnable(GL_BLEND) and glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) : #version 130 out vec4 flatColor; void

Depth of Field shader for points/strokes in Processing

孤街浪徒 提交于 2019-12-07 23:53:21
问题 Recently I've been using the Depth of Field shader below (originally from the ofxPostProcessing library for OpenFrameworks) for my Processing sketches. depth.glsl uniform float maxDepth; void main() { float depth = gl_FragCoord.z / gl_FragCoord.w; gl_FragColor = vec4(vec3(1.0 - depth/maxDepth), 1.0); } dof.glsl uniform sampler2D texture; varying vec4 vertexture; varying vec4 vertTexCoord; uniform sampler2D tDepth; uniform float maxBlur; // max blur amount uniform float aperture; // aperture -

How to input video (frames) into a GLSL shader

故事扮演 提交于 2019-12-07 23:33:21
问题 I'm trying to do video processing using GLSL. I'm using OpenCV to open a video file up and take each frame as a single image an then I want to use each frame in a GLSL shader What is the best/ideal/smart solution to using video with GLSL? Reading From Video VideoCapture cap("movie.MOV"); Mat image; bool success = cap.read(image); if(!success) { printf("Could not grab a frame\n\7"); exit(0); } Image to Texture GLuint tex; glGenTextures(1, tex); glActiveTexture(GL_TEXTURE0); glBindTexture(GL

OpenGL shader: a spotlight and a directional light

放肆的年华 提交于 2019-12-07 22:17:21
问题 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;