glsl

How Do I Export OBJ From Three.js geometry that is being displaced by GLSL shader?

ぃ、小莉子 提交于 2019-12-06 05:31:19
问题 I attempted to use the following code I found on Stack Overflow to export an OBJ from geometry in a Three.js scene. The geometry is being displaced by a GLSL shader so the displacement of vertices doesn't seem to export with the geometry. When I import the OBJ into Blender I only get the flat plane that is not displaced. You can inspect a working version of the displacement at http://kineticvideo.co How do I export an OBJ while using a GLSL shader to displace the geometry? Please help. I was

Switch shader program in WebGL

笑着哭i 提交于 2019-12-06 05:17:31
问题 I have an existing WebGL renderer (too much code to be useful to share) which used to be very simple: it only had one vertex shader, one fragment shader, and one shader program with both. It was for rendering quads. I'm trying to extend it to have a second shader program it switches to and from, for rendering point sprites. It has its own vertex attribute array, and a second vertex shader, fragment shader and shader program. I can't seem to switch between the two properly: I keep getting

How to use glslang

我是研究僧i 提交于 2019-12-06 05:15:34
I am trying to use glslang to compile glsl shader code to SPIR-V binaries. The glslang project can be found here: https://github.com/KhronosGroup/glslang It works well via the glslangValidator.exe manually in the command line. But i would like to use the c++ interface. I have build the project as described on the github page, and now I am struggling with how to actually use the interface. I would rather not actually include any projects in my solution (I am using Visual Studio), but link the .lib's and headers needed to use it. I just cannot find out which ones i need to link. The github page

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

◇◆丶佛笑我妖孽 提交于 2019-12-06 04:48:35
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 main(void) { flatColor = vec4(0.0,1.0,0.0,0.5); } If i texture the quads with a simple image it works

How to create latitudinal (horizontal) contour lines in GLSL?

眉间皱痕 提交于 2019-12-06 04:47:13
问题 I'm aiming for this effect: (horizontal-only contour lines): I did find this example, however it creates horizontal and vertical contour lines. I can't quite wrap my head around how the call to fwidth() is generating the lines. uniform float gsize;//size of the grid uniform float gwidth;//grid lines'width in pixels varying vec3 P; void main() { vec3 f = abs(fract (P * gsize)-0.5); vec3 df = fwidth(P * gsize); float mi=max(0.0,gwidth-1.0), ma=max(1.0,gwidth);//should be uniforms vec3 g=clamp(

Multi-pass shaders in OpenGL ES 2.0

大兔子大兔子 提交于 2019-12-06 04:45:33
问题 First - Does subroutines require GLSL 4.0+? So it unavailable in GLSL version of OpenGL ES 2.0? I quite understand what multi-pass shaders are. Well what is my picture: Draw group of something (e.g. sprites) to FBO using some shader. Think of FBO as big texture for big screen sized quad and use another shader, which, for example, turn texture colors to grayscale. Draw FBO textured quad to screen with grayscaled colors. Or is this called else? So multi-pass = use another shader output to

How to write const array in GLSL ES

孤人 提交于 2019-12-06 03:58:20
I am trying to write a simple vertex shader for an OpenGL ES app on the iPhone, but my array constructor is causing me trouble. attribute vec4 normal; attribute vec4 position; void main(void){ const vec4 vertices[3] = vec4[](vec4(0.25, -0.25, 0.5, 1.0), vec4(-0.25, -0.25, 0.5, 1.0), vec4(0.25, 0.25, 0.5, 1.0)); gl_Position = vertices[gl_VertexID]; } When using this code the shader is unable to compile, and gives me the eror message: ERROR: 0:13: '(' : syntax error: Array size must appear after variable name The GLSL version used with ES 2.0 does not support constant arrays. From section "4.3.2

Is this a practical and enough performant shader for doing blur on mobile device

◇◆丶佛笑我妖孽 提交于 2019-12-06 03:15:16
I am trying to implement Blur effect in my game on mobile devices using GLSL shader. I don't have any former experience with writing shaders. And I don't understand if my shader is enough good. Actually I have copyied the GLSL code from a tutorial and I don't know it this tutorial is for vivid demo or also can be used in practice. Here is the code of two pass blur shader that uses Gaussian weights ( http://www.cocos2d-x.org/wiki/User_Tutorial-RenderTexture_Plus_Blur ): #ifdef GL_ES precision mediump float; #endif varying vec4 v_fragmentColor; varying vec2 v_texCoord; uniform vec2 pixelSize;

RGB to YUV using GLSL [closed]

旧街凉风 提交于 2019-12-06 03:04:41
I am looking for sample GLSL fragment shader code that can convert RGB frame (say pixel format as ARGB) to YUV (say YUV420). Imagine an RGB frame of size 1920x1080. I like to use fragment shader to convert it to YUV frame. Can you point me to code that can be compiled and run on UBuntu box? miguelao For future reference, a bunch of colorspace conversions in GLSL shaders can be found in Gstreamer gst-plugins-gl codebase :) user1118321 First, you should know that your question is poorly phrased. Nobody is going to write you sample code. You can use a search engine (or even search this site) for

Gamma correction doesn't look properly corrected, is this linear?

 ̄綄美尐妖づ 提交于 2019-12-06 03:01:51
I want to implement gamma correction to my OpenGL lighting, but with gamma correction applied, my results do not seem linear at all. I also found OpenGL: Gamma corrected image doesn't appear linear which is very similar to my issue, but hasn't yet received an answer nor discussed actual diffuse lights. As an illustration, I have the following 4 light colors defined in linear space: glm::vec3 lightColors[] = { glm::vec3(0.25), glm::vec3(0.50), glm::vec3(0.75), glm::vec3(1.00) }; With each light source seperated and a basic linear attenuation applied to a diffuse lighting equation I get the