glsl

How to cut/hide projected area from bottom and top of GLControl - openTK

荒凉一梦 提交于 2019-12-13 01:18:44
问题 With the help of this link, I can project an image in cylindrical shape. Can I able to remove or hide the projected area from top and bottom of image as shown in the image below? 回答1: You have to discard fragmnts dependent on the u ( .y ) texture coordinate. According to the fragment shader of the original question How to project top and bottom area of openGL control: precision highp float; uniform sampler2D sTexture; varying vec2 vTexCoord; void main() { vec2 pos = vTexCoord.xy * 2.0 - 1.0;

What kind of shader for 2D games (ie. Super Mario)

空扰寡人 提交于 2019-12-13 00:18:05
问题 I've been trying to figure out how to use OpenGL ES 2.0 for 2D. So far I think I have a handle on most things. But the one thing that I haven't figured out is what to do for the shaders? I understand that you set up the camera/view and the lights in the shader, but I don't want shadows or any kind of sign of lighting. Basically I just want to move sprites around the screen and have the sprites look exactly like they did when I drew them in photoshop. Anyone have an example of a shader that

GLSL Shader - Coverflow Reflection of a 2D object

百般思念 提交于 2019-12-13 00:04:12
问题 I want to write a shader that creates a reflection of an image similiar to the ones used for coverflows. // Vertex Shader uniform highp mat4 u_modelViewMatrix; uniform highp mat4 u_projectionMatrix; attribute highp vec4 a_position; attribute lowp vec4 a_color; attribute highp vec2 a_texcoord; varying lowp vec4 v_color; varying highp vec2 v_texCoord; mat4 rot = mat4( -1.0, 0.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ); void main() { gl_Position = (u

GLSL - unresolved external on Visual C++

别来无恙 提交于 2019-12-12 23:52:52
问题 I'm getting started with the GLSL. What should i do to resolve this: error LNK2001: unresolved external symbol _pglLinkProgram error LNK2001: unresolved external symbol _pglAttachShader error LNK2001: unresolved external symbol _pglCompileShader error LNK2001: unresolved external symbol _pglShaderSource error LNK2001: unresolved external symbol _pglCreateShader error LNK2001: unresolved external symbol _pglCreateProgram error LNK2001: unresolved external symbol _pglGetProgramInfoLog error

WebGL fragment shader opacity

风流意气都作罢 提交于 2019-12-12 22:11:31
问题 Alright, first off, I'm pretty new at GLSL shaders, and I'm trying to wrap my head around the following shader #ifdef GL_ES //precision mediump float; precision highp float; #endif uniform vec2 uTimes; varying vec2 texCoord; varying vec2 screenCoord; void main(void) { vec3 col; float c; vec2 tmpv = texCoord * vec2(0.8, 1.0) - vec2(0.95, 1.0); c = exp(-pow(length(tmpv) * 1.8, 2.0)); col = mix(vec3(0.02, 0.0, 0.03), vec3(0.96, 0.98, 1.0) * 1.5, c); gl_FragColor = vec4(col * 0.5, 0); } So far, I

Fastest way to do min-max based on specific component of vectors in GLSL?

≡放荡痞女 提交于 2019-12-12 20:43:05
问题 I need to call this kind of function many many times in my GLSL code. vec2 minx(vec2 a, vec2 b) { if (a.x < b.x) return a; else return b; } I'm concerned of the excessive branching. Is there a way to do this avoiding if-else constructs? 回答1: I suggest to use the GLSL functions mix and step. mix interpolates between 2 values according to a floating point interpolation value a in the range [0.0, 1.0]. If the a is equal 0.0 then the 1st value is returned and if the a is equal 1.0 then the 2nd

Does SPIR-V bytecode provide obfuscation?

耗尽温柔 提交于 2019-12-12 20:27:51
问题 It is straightforward for a reverse engineer to attach a graphics debugger to an OpenGL application to extract the shader source code. It is my understanding that Vulkan, on the other hand, uses SPIR-V bytecode, rather than passing plaintext shaders to the graphics API. Does SPIR-V bytecode obfuscate the shader source, or is it fairly easy to decompile? 回答1: There is an entire specification explaining, in explicit detail, the behavior of each and every SPIR-V opcode. That's kinda the opposite

GLSL extracting modelmatrix from modelviewmatrix and viewmatrix

瘦欲@ 提交于 2019-12-12 19:39:09
问题 since in GLSL the modelmatrix is not available, i was wondering if it is possible to get it programatically from the gl_ModelViewMatrix and the "viewmatrix" which i would pass as a uniform? if yes, how? thank you! 回答1: You can obtain the model matrix by multiplying the modelview matrix with the inverse of your view matrix. gl_ModelViewMatrix * myViewMatrixInverse 来源: https://stackoverflow.com/questions/1147280/glsl-extracting-modelmatrix-from-modelviewmatrix-and-viewmatrix

Geometry shader doesn't do anything when fed GL_POINTS

时光怂恿深爱的人放手 提交于 2019-12-12 19:32:07
问题 I'm trying to use geometry shaders to turn points into line segments (GL_POINTS to GL_LINE_STRIP), but no line segments appear. If I change the input to GL_LINES, and just repeat the vertex, then I get the behavior I'm expecting. What's going on? Here's a complete program that demonstrates the behavior. As-is, I get nothing but a black window. Setting USE_POINTS to False gets me the rotating psychedelic flashing lines I'm expecting. #!/usr/bin/python from OpenGL.GL import * from OpenGL.GLU

Deferred Rendering Skybox OpenGL

不羁的心 提交于 2019-12-12 18:47:37
问题 I've just implemented deferred rendering and am having trouble getting my skybox working. I try rendering my skybox at the very end of my rendering loop and all I get is a black screen. Here's the rendering loop: //binds the fbo gBuffer.Bind(); //the shader that writes info to gbuffer geometryPass.Bind(); glDepthMask(GL_TRUE); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_DEPTH_TEST); glDisable(GL_BLEND); //draw geometry geometryPass.SetUniform("model", transform.GetModel())