glsl

Normal mapping and phong shading with incorrect specular component

旧城冷巷雨未停 提交于 2019-12-04 06:45:18
I'm implementing normal/bump mapping in world space coordinates (I find those easier to work with) and my lighting worked fine without normal mapping, but when introducing normal mapping (and the new vectors calculated with the TBN matrix) the specular component of my lighting is off. The specular component is not between the camera and the light where it should be so something is wrong. However, looking at my code I could not find any issues. The tangent and bitangent come from the ASSIMP object loader and the eyePos and lightPos are in world coordinates as well. Since the lighting seems to

Cubemap shadow mapping not working

主宰稳场 提交于 2019-12-04 06:33:10
问题 I'm attempting to create omnidirectional/point lighting in openGL version 3.3. I've searched around on the internet and this site, but so far I have not been able to accomplish this. From my understanding, I am supposed to Generate a framebuffer using depth component Generate a cubemap and bind it to said framebuffer Draw to the individual parts of the cubemap as refrenced by the enums GL_TEXTURE_CUBE_MAP_* Draw the scene normally, and compare the depth value of the fragments against those in

GL_APPLE_shader_framebuffer_fetch gl_lastFragData

笑着哭i 提交于 2019-12-04 06:26:34
Apple introduced a new shader extension called GL_APPLE_shader_framebuffer_fetch, which allows fully programmable blending. There is also a wwdc video explaining the functionallity. It's the video 513 of wwdc 2012. Sadly this extension doesn’t work for me. F-Shader: #extension GL_APPLE_shader_framebuffer_fetch : require varying lowp vec4 colorVarying; void main(void) { gl_FragColor = gl_lastFragData[0] + vec4(colorVarying.x, colorVarying.y, colorVarying.z, 1.0); } Debug output: extension ‘GL_APPLE_shader_framebuffer_fetch’ is not supported Tried to run it on the iOS 6.0 iPad Simulator ‘n on an

WebGL Float modulus behaviour

我的梦境 提交于 2019-12-04 06:22:20
问题 I am experiencing strange behaviours for below fragment Shader: varying vec3 worldSpaceCoords; uniform float rows; void main() { float testNumber = 7.0; vec4 outputColor = vec4(0.0,0.0,0.0,1.0); if(rows == testNumber) { if(worldSpaceCoords.x < 0.5) { outputColor.x = mod(floor(testNumber * worldSpaceCoords.y), rows ) / rows; } else { outputColor.x = mod(floor(testNumber * worldSpaceCoords.y), testNumber ) / testNumber; } } else { outputColor = vec4(1.0,1.0,1.0,1.0); } gl_FragColor =

THREE.JS GLSL sprite always front to camera

对着背影说爱祢 提交于 2019-12-04 06:19:33
问题 I'm creating a glow effect for car stop lights and found a shader that makes it possible to always face the camera: uniform vec3 viewVector; uniform float c; uniform float p; varying float intensity; void main() { vec3 vNormal = normalize( normalMatrix * normal ); vec3 vNormel = normalize( normalMatrix * -viewVector ); intensity = pow( c - dot(vNormal, vNormel), p ); gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); } This solution is quite simple and almost works. It

texturing using texelFetch()

别等时光非礼了梦想. 提交于 2019-12-04 05:44:16
When I pass non max values into texture buffer, while rendering it draws geometry with colors at max values. I found this issue while using glTexBuffer() API. E.g. Let’s assume my texture data is GLubyte, when I pass any value less than 255, then the color is same as that of drawn with 255, instead of mixture of black and that color. I tried on AMD and nvidia card, but the results are same. Can you tell me where could be going wrong? I am copying my code here: Vert shader: in vec2 a_position; uniform float offset_x; void main() { gl_Position = vec4(a_position.x + offset_x, a_position.y, 1.0, 1

OpenGL GLSL Binding Sampler for Fragment Shader

こ雲淡風輕ζ 提交于 2019-12-04 05:28:54
问题 I am hoping to implement a shader on a 2D OpenGL application. My plan is to render a scene to a framebuffer object, and then render that framebuffer object to the screen using a shader. Here is the scene, which I have drawn to a framebuffer object, and then to the screen from there. Using the arrow keys makes the moon move around (I am quite proud of it!) However, when I try to render the framebuffer object to the screen using my shader program, I get this: It is very sad. This fragment

Export from Shadertoy to Three.js

主宰稳场 提交于 2019-12-04 04:43:58
问题 I am making my first steps coding. I made some courses on internet, then I played with some three.js experiments, and now I would like to continue learning experimenting with Shaders. I found Shadertoy.com and it's really amazing! There are a lot of difference experiments with incredible effects. I am trying to use one of these shaders in Three.js but is not so easy. The Shaders are already written, it's true. But I don't know what to do with that, I don't know how I can use it. Because it's

How can I correctly unpack a V210 video frame using GLSL?

穿精又带淫゛_ 提交于 2019-12-04 04:30:37
I have 10-bit YUV (V210) video frames coming in from a capture card, and I would like to unpack this data inside of a GLSL shader and ultimately convert to RGB for screen output. I'm using a Quadro 4000 card on Linux (OpenGL 4.3). I am uploading the texture with the following settings: video frame: 720x486 pixels physically occupies 933120 bytes in 128-byte aligned memory (stride of 1920) texture is currently uploaded as 480x486 pixels (stride/4 x height) since this matches the byte count of the data internalFormat of GL_RGB10_A2 format of GL_RGBA type of GL_UNSIGNED_INT_2_10_10_10_REV

How to add transparency with a shader in SceneKit?

被刻印的时光 ゝ 提交于 2019-12-04 04:27:36
问题 I would like to have a transparency effect from an image, for now I just test with a torus, but the shader does not seem to work with alpha. From what I understood from this thread (Using Blending Functions in Scenekit) and this wiki link about transparency : (http://en.wikibooks.org/wiki/GLSL_Programming/GLUT/Transparency), GLBlendFunc is replaced by pragma transparency in SceneKit. Would you know what is wrong with this code? I created a new project with SceneKit, and I changed the ship