glsl

SSAO artefacts in Three

百般思念 提交于 2020-01-11 07:10:51
问题 I'm really struggling to fix an issue with my SSAO shader and could desperately use some help. Basically the shader seems to work on some objects, but looks really bad on others. From the below you can see the sphere looks correct, but the cube seems to be doing occlusion on normals that it shouldn't. Here is a screenshot: I am basing my shaders off of this tutorial: http://devmaster.net/posts/3095/shader-effects-screen-space-ambient-occlusion In my render chain I render 2 render targets

SSAO artefacts in Three

99封情书 提交于 2020-01-11 07:10:43
问题 I'm really struggling to fix an issue with my SSAO shader and could desperately use some help. Basically the shader seems to work on some objects, but looks really bad on others. From the below you can see the sphere looks correct, but the cube seems to be doing occlusion on normals that it shouldn't. Here is a screenshot: I am basing my shaders off of this tutorial: http://devmaster.net/posts/3095/shader-effects-screen-space-ambient-occlusion In my render chain I render 2 render targets

Is this diagram for OpenGL data types correct?

柔情痞子 提交于 2020-01-11 06:45:07
问题 I'm trying to understand glVertexAttribPointer , and I noticed that it accepts many more types than those that have an equivalent in GLSL. So to write down everything I know so far, I made this diagram matching all the types (except for the packed ones, which don't matter, and GL_FIXED , which I don't understand. Blue nodes represent the type in GLSL, while yellow nodes represent the symbolic constants passed to glVertexAttribPointer . Red nodes represent some kind of conversion between types

How can i make gradient sphere on glsl?

ぃ、小莉子 提交于 2020-01-10 05:40:13
问题 I'm just a noob to GLSL and don't know how to do this in GLSL. What I trying to do is making alpha value to 1 on center of sphere and drop gradually on outer. So I made a prototype using Blender node editor and that's how I did. Now I am trying to do this in glsl. Maybe i can use gl_Normal to replace "normal on Geometry" on Blender. (Though it's removed after version 140, my final goal is just "make" it, so ignore that.) And there are also dot function to calculate "dot product on vector math

gl_PointSize Corresponding to World Space Size

筅森魡賤 提交于 2020-01-09 10:07:12
问题 If you want to render an imposter geometry (say like a sphere), then the standard practice is to draw it using two triangles (say by passing one vertex and making a triangle strip with a geometry shader). This is nice because it allows the extent of the billboard to be set fairly simply: you compute the actual world space positions directly. Geometry shaders can alternately output point primitives, and I don't see a reason why they shouldn't. The only issue is finding some way to scale gl

fragment shader if statment and loading array of mat4 into uniform

♀尐吖头ヾ 提交于 2020-01-06 21:12:15
问题 I have problem with if here, for reasons uknown to me, it dosnt work. When i delete if statment or malualy write shadowMap[0] 1 or 2 it works fine, but with if i just get set of white triangles and squares. here is part of my frag shader float shadow(float bias) { float visibility = 0; int index=1; if(gl_FragCoord.z<1.0){ index=0; } vec4 shadowCoord=depthPV*vPos; if ( texture(shadowMap[index], shadowCoord.xy).z < shadowCoord.z+bias){ visibility = -1; } return visibility; } Other problem i

GLSL: Data Distortion

雨燕双飞 提交于 2020-01-06 12:51:42
问题 I'm using OpenGL 3.3 GLSL 1.5 compatibility. I'm getting a strange problem with my vertex data. I'm trying to pass an index value to the fragment shader, but the value seems to change based on my camera position. This should be simple : I pass a GLfloat through the vertex shader to the fragment shader. I then convert this value to an unsigned integer. The value is correct the majority of the time, except for the edges of the fragment. No matter what I do the same distortion appears. Why is

GLSL: How to do switch-like statement

余生颓废 提交于 2020-01-06 08:57:08
问题 I would like to dynamically invoke an easing based on the data passed into the shader. So in pseudocode: var easing = easings[easingId] var value = easing(point) I'm wondering the best way to accomplish this in GLSL. I could use a switch statement in some way, or could perhaps put the easings into an array and use them like that. Or maybe there is a way to create a hashtable and use it like the above example. easingsArray = [ cubicIn, cubicOut, ... ] uniform easingId main() { easing =

Use sampler without passing through value

两盒软妹~` 提交于 2020-01-06 03:42:09
问题 I'm dealing with texture in fragment shader and I use a sampler2D to get the 2D texture but I do not pass through the value in OpenGL program. However, the value of that sampler2D is correct. I feel really confused about this and any explanation about this? 回答1: The default value of a sampler variable is 0. From the GLSL 3.30 spec, section "4.3.5 Uniforms": The link time initial value is either the value of the variable's initializer, if present, or 0 if no initializer is present. Sampler

Use sampler without passing through value

醉酒当歌 提交于 2020-01-06 03:42:07
问题 I'm dealing with texture in fragment shader and I use a sampler2D to get the 2D texture but I do not pass through the value in OpenGL program. However, the value of that sampler2D is correct. I feel really confused about this and any explanation about this? 回答1: The default value of a sampler variable is 0. From the GLSL 3.30 spec, section "4.3.5 Uniforms": The link time initial value is either the value of the variable's initializer, if present, or 0 if no initializer is present. Sampler