glsl

Reflection/refraction with chromatic aberration - eye correction

ⅰ亾dé卋堺 提交于 2019-12-03 15:28:11
I am writing a GLSL shader that simulates chromatic aberration for simple objects. I am staying OpenGL 2.0 compatible, so I use the built-in OpenGL matrix stack. This is the simple vertex shader: uniform vec3 cameraPos; varying vec3 incident; varying vec3 normal; void main(void) { vec4 position = gl_ModelViewMatrix * gl_Vertex; incident = position.xyz / position.w - cameraPos; normal = gl_NormalMatrix * gl_Normal; gl_Position = ftransform(); } The cameraPos uniform is the position of the camera in model space, as one might imagine. Here is the fragment shader: const float etaR = 1.14; const

Spritekit and OpenGL: smooth smoke trail

。_饼干妹妹 提交于 2019-12-03 15:23:47
I want to achieve this effect in my Spritekit game where there is a smooth trail behind the character. See the trail behind the coin in jetpack joyride: And this trail behind the hero in Jupiter Jump: Or this super smooth trail behind the hero in Ski Safari: This appears to be a standard feature in other game engines maybe? I think a spritekit particle emitter will only provide a blocky/stamped trail, not a smooth trail. Should I be using some kind of sprite custom shader? Any other inventive thoughts? Your question did not include a key issue which is the type of movement to be used. My

What is, in simple terms, textureGrad()?

送分小仙女□ 提交于 2019-12-03 14:41:31
I read the khronos wiki on this But I don;t really understand what it is saying. What exactly does textureGrad do? I think it samples multiple mipmap levels and computes some color mixing using the explicit derivative vectors given to it. But I am not sure. derhass When you sample a texture, you need the specific texture coordinates to sample the texture data at. For sake of simplicity, I'm going to assume a 2D texture, so the texture coordinates are a 2D vector (s,t) . (The explanation is analogous for other dimensionalities). If you want to texture-map a triangle, one typically uses one of

Shaders in WebGL vs openGL? [closed]

心已入冬 提交于 2019-12-03 13:59:06
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . I want to use shaders to use in WebGL and specifically three.js. Is there a specific version of GLSL that WebGL and three.js uses? 回答1: WebGL shaders follow the GLSL ES 1.017 spec https://www.khronos.org/registry/gles/specs/2.0/GLSL_ES_Specification_1.0.17.pdf That's different than Desktop OpenGL in several ways

Floating point textures in OpenGL ES 2.0 on iOS without clamping them to [0, 1]

心不动则不痛 提交于 2019-12-03 13:53:18
I need gl_FragColor to "paint" floating point values, which also can be negative (x < 0) and > 1.0. I then want to use the color attachement of the FBO this values where rendered to and use it as a texture in another FBO. Now I have read on http://www.khronos.org/opengles/sdk/docs/man/ (under glTexImage2D) that all values are clamped to a range of [0, 1] and also I didn't find a glClampColor instruction. Is there a possibility to find a workaround here or does somebody have an idea which could help me with my problem? :) SOLVED It is possible and the values are not clamped to [0, 1] at all,

Matrix stacks in OpenGL deprecated?

回眸只為那壹抹淺笑 提交于 2019-12-03 13:48:59
问题 I just read this: "OpenGL provided support for managing coordinate transformations and projections using the standard matrix stacks (GL_MODELVIEW and GL_PROJECTION). In core OpenGL 4.0, however, all of the functionality supporting the matrix stacks has been removed. Therefore, it is up to us to provide our own support for the usual transformation and projection matrices, and then to pass them into our shaders." This is strange, so how do I set the modelview and projection matrices now? I

HDR, adaptive tone mapping and MSAA in GLSL

二次信任 提交于 2019-12-03 13:36:18
问题 In an effort to teach myself OpenGL, I am working my way trough the 5th edition of the Superbible. I am currently trying to figure out how to combine HDR and MSAA (as described in chapter 9). For HDR, the book suggests a method for adaptive tone mapping that is based on calculating the average luminance for a 5x5 convolution filter for each fragment. For MSAA, the method used averages all samples by weights calculated from the sample distance. My attempt at combining both, found in the

OpenGL Shader Compilation Errors: unexpected $undefined at token “<undefined>”

旧巷老猫 提交于 2019-12-03 12:55:48
问题 I saw this question and it really shedded some light. Despite this, I can't seem to figure out how I'm "improperly" loading my shader, because this has executed before without any recent changes to the shader loading code, so I assume these errors must be coming from my draw calls. Despite this, I'll still post the shader files for the sake of brevity, the draw function used to draw the circle I'm trying to render, and the code which loads in the shader file as a string. Basically what I need

Gaussian Blur - standard deviation, radius and kernel size

折月煮酒 提交于 2019-12-03 12:32:31
问题 I've implemented a gaussian blur fragment shader in GLSL. I understand the main concepts behind all of it: convolution, separation of x and y using linearity, multiple passes to increase radius... I still have a few questions though: What's the relationship between sigma and radius? I've read that sigma is equivalent to radius, I don't see how sigma is expressed in pixels. Or is "radius" just a name for sigma, not related to pixels? How do I choose sigma? Considering I use multiple passes to

GLSL reusable/shared functions, shared constants (OpenGL ES 2.0)?

拥有回忆 提交于 2019-12-03 12:03:52
Short: Can I define a function that every shader can use? Or I have to define it per shader? The whole story: I want to create numerous shaders intended to colorize the input fragments with predefined gradient ramps (something like this - http://www.thinkboxsoftware.com/storage/krakatoa-support-images/krakatoa15_kcm_densitybyage_gradientrampmap.png ). I want to define a gradient ramp constant for each shader (an array of vec4 color samples, where the alpha value holds the gradient position, see Pos in the picture above) And I need a function that can return a color sample from the given