glsl

webgl glsl emulate texture3d

▼魔方 西西 提交于 2020-01-05 02:33:09
问题 I'm porting a piece of opengl to webgl and i'm trying to emulate texture3d. Somehow something is going wrong. No interpolation is needed because it is only used for calculations. I'm not sure about the geometry part of the original code, the per layer properties are now fetched trough a texture. Update : Ok i rewrote the texture 3d functions, I still encounter some problems : const vec3 volumeTextureSize = vec3( 256.0, 128.0, 32.0 ); const vec2 imageSize = vec2( 1024.0, 1024.0 ); vec2

how to calculate the number of specified colored pixels using GLSL?

人走茶凉 提交于 2020-01-04 09:15:20
问题 I have a grayscale texture (8000*8000) , the value of each pixel is an ID (actually, this ID is the ID of triangle to which the fragment belongs, I want to using this method to calculate how many triangles and which triangles are visible in my scene). now I need to count how many unique IDs there are and what are them. I want to implement this with GLSL and minimize the data transfer between GPU RAM and RAM. The initial idea I come up with is to use a shader storage buffer, bind it to an

Copying depth render buffer to the depth buffer

核能气质少年 提交于 2020-01-04 06:19:06
问题 Currently I am rendering some stuff to a FBO with an attached depth render buffer. However, after I am done with the render buffer, the depth information is pretty much lost. How can I copy the data from the render buffer to the fixed function depth buffer? 回答1: You can use glBlitFramebuffer, enabling the GL_DEPTH_BUFFER_BIT flag. Example code: glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo_id); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); glBlitFramebuffer(offset_x, offset_y, offset_x + size_x,

Colour bit-wise shift in OpenGL shader GLSL

廉价感情. 提交于 2020-01-04 05:14:08
问题 I am passing vec4 to the shaders with xyz and a colour value and I tried to bit-wise shift the colour component to their own r g and b floats but having issues: Vertex shader: #version 150 in vec4 position; out vec2 Texcoord; uniform mat4 model; uniform mat4 view; uniform mat4 proj; void main() { Texcoord = vec2(position.w, position.w); gl_Position = proj * view * model * vec4(position.xyz, 1.0); } Fragment shader: #version 150 in vec2 Texcoord; out vec4 outColor; uniform sampler2D tex; void

Do (Unused) GLSL uniforms/in/out Contribute to Register Pressure?

ぐ巨炮叔叔 提交于 2020-01-04 04:20:08
问题 I don't know how uniforms are represented in memory. Uniforms seem like they could take up valuable register space, but they're ultimately passed in/through/out into global memory, right? Does the situation change when the uniforms are unused? Can the compiler optimize them away?--I have gotten invalid (-1) as a binding location when this is the case, so I assume yes. 回答1: First of all the GLSL specification doesn't say anything about the actual implementation of it's concepts, so the

How to use Pivot Point in Transformations

蹲街弑〆低调 提交于 2020-01-03 19:58:39
问题 How to translate object using Center point I have a rectangle which has a center point away from the position of rectangle. when i rotate rectangle it rotates around its center axis. if i multyply position before rotation in the modelView matrix ModelViewMatrix = Rotation * Scaling * Position Suppose if i want to do these translations. 1) Translate the rectangle position by x = 10 units. 1) Rotate the rectangle by 35 degree with the center point at the center of the rectangle. 2) Translate

Cocos2d - lunar eclipse effect on iPhone

我是研究僧i 提交于 2020-01-03 19:35:32
问题 i have a question about achieving an effect like on a lunar eclipse. The effect should look like in the first seconds of this gif. So just like a black shadow which goes over the circle. The ideal situation would be a function where i can passed a parameter in percentage to get this amount as a shadow on the circle: The problem which i am facing is that my background is an gradient. So it's not possible to have a black circle which moves over the moon to get the effect. I tried something with

Cocos2d - lunar eclipse effect on iPhone

a 夏天 提交于 2020-01-03 19:35:16
问题 i have a question about achieving an effect like on a lunar eclipse. The effect should look like in the first seconds of this gif. So just like a black shadow which goes over the circle. The ideal situation would be a function where i can passed a parameter in percentage to get this amount as a shadow on the circle: The problem which i am facing is that my background is an gradient. So it's not possible to have a black circle which moves over the moon to get the effect. I tried something with

Cocos2d - lunar eclipse effect on iPhone

流过昼夜 提交于 2020-01-03 19:35:03
问题 i have a question about achieving an effect like on a lunar eclipse. The effect should look like in the first seconds of this gif. So just like a black shadow which goes over the circle. The ideal situation would be a function where i can passed a parameter in percentage to get this amount as a shadow on the circle: The problem which i am facing is that my background is an gradient. So it's not possible to have a black circle which moves over the moon to get the effect. I tried something with

Image Processing with GLSL shaders?

亡梦爱人 提交于 2020-01-03 17:35:13
问题 I am enrolled in shaders course and interested in computer vision and image processing. I was wondering how can I mix GLSL shaders knowledge with image processing? What do I gain if I implement image processing algorithms with GLSL? 回答1: The first obvious answer is that you gain parallelism. Now, why using GLSL rather than, say CUDA which is more flexible ? GLSL doesn't require you to have an NVIDIA graphics card, so it's a much more portable solution (you'd still have the option of OpenCL