glsl

Billboarding a vertex array with GLSL?

I have a vector array of triangles which basically consist of a bunch of squares that need to be billboarded. Something that looks like GLfloat vertexpositions[60 * 3]; // [x,y,z] * 6 for each square, and there are 10 squares And after that, calling glDrawArray with the appropriate arguments to draw a total of 10 squares. Is it poss...

Question about variable constructors:

If... vec3 myVec3 = vec3(1.0, 0.0, 0.5); // myVec3 = {1.0, 0.0, 0.5} vec3 temp = vec3(myVec3); // temp = myVec3 vec2 myVec2 = vec2(myVec3); // myVec2 = {myVec3.x, myVec3.y} myVec4 = vec4(myVec2, temp, 0.0); // myVec4 = {myVec2.x, myVec2.y, temp.x, 0.0} Then what does the following represent? myVec4 = vec4(temp, myVec2, 0.0); // myVe...

What is half-vector of light in glsl?

I'm playing with per pixel lighting shaders and i don't know one thing: What is half vector of light source ? vec3 halfVector = normalize(gl_LightSource[1].halfVector.xyz); I would like i you can explain it in math rows, i understand math better than words :) ...

How to detect in glsl if fragment is multisampled?

Is there any fast(for performance) way to detect in glsl if fragment has been multisampled, but in second(light) pass using textures where been 1st pass rendered. Or how is opengl storing informations about multisampling? ...

What is the point of GLSL when there is OpenCL?

Consider this the complete form of the question in the title: Since OpenCL may be the common standard for serious GPU programming in the future (among other devices programming), why not when programming for OpenGL - in a future-proof way - utilize all GPU operations on OpenCL? That way you get the advantages of GLSL, without its program...

Does GLSL utilize SLI? Does OpenCL? What is better, GLSL or OpenCL for multiple GPUs?

To what extend does OpenGL's GLSL utilize SLI setups? Is it utilized at all at the point of execution or only for end rendering? Similarly, I know that OpenCL is alien to SLI but assuming one has several GPUs, how does it compare to GLSL in multiprocessing? Since it might depend on the application, e.g. common transformation, or ray tr...

Sum image intensities in GPU

I have an application where I need take the average intensity of an image for around 1 million images. It "feels" like a job for a GPU fragment shader, but fragment shaders are for per-pixel local computations, while image averaging is a global operation. An image sum will suffice, since it only differs from the average by a constant...

WebGL/GLSL vertex shader collapses 9 points into single point when I set x coord of gl_Position to zero

I do not understand why the following two shaders produce different results when I render a vertex buffer with x coordinates equal to zero: First: attribute vec3 position; void main() { gl_Position = vec4(position.x, position.y, 0.0, 1.0); } Second: attribute vec3 position; void main() { gl_Position = vec4(0.0, position.y, 0.0...

What is Half vector in modern GLSL?

http://www.lighthouse3d.com/opengl/glsl/index.php?ogldir2 reports that half vector in OpenGL context is 'Eye position - Light position' but then it goes on to say 'luckily OpenGL calculates it for us' [which is now deprecated]. How can, practically be calculated (a simple example would be greatly appreciated) [mainly, it puzzles me wh...

GLSL Shaders Attributes as ints

Hello, I'm just learning OpenGL and I'm running into some issues. I'm using OpenGL 3.0 and GLSL 1.2. I have an array of matrices which I would like to selectively apply to different vertices. Instead of copying a matrix each time I want to indicate an index, I would instead like to pass in an integer as an index and use that integer...

Alpha blending with OpenGL ES 2.0?

What's the best way? I tried to do this naïvely with a fragment shader that looks like this: varying lowp vec4 color; void main() { lowp vec4 alpha = colorVarying.wwww; const lowp vec4 one = vec4(1.0, 1.0, 1.0, 1.0); lowp vec4 oneMinusAlpha = one-alpha; gl_FragColor = gl_FragColor*oneMinusAlpha + colorVarying*alpha; ...

Is there any kind of Java image filtering engine capable of using Cg or HLSL or GLSL filtering code on Google app engine server?

Is there any kind of Java image filtering engine/library/framework capable of using Cg or HLSL or GLSL filtering code on Google app engine runtime\servers? Has any one tried doing image manipulations/filtering with gae? ...

Change color component

Hello, I'm writing graphic shader program. I wrote everything I need except the color changing. In cycle there is passing some counter variable to the shader and I have to change it's color from white to orange shade. What I have change to achive this? ...

OpenGL: Render to FBO using multiple textures

Hi, I'm experimenting with a renderer. What I want is to write a color buffer and a normal buffer to two separate textures. I got that part figured out. However, the color buffer is supposed to be a combination of two textures. This should do the trick: glActiveTexture(GL_TEXTURE0_ARB); glEnable(GL_TEXTURE_2D); g_Tex->Bind(); glActiv...

GLSL Shader multi-texture lookup with different texCoord (iPad)

I'm in GLSL texture hell: I load 4 different textures of the same size in uniform sampler2D variables in my fragment shader and try to access them with different texture coordinates: uniform sampler2D image0, image1, image2, image3; varying highp vec2 texCoord; void main() { highp vec2 tc = vec2(texCoord.x, mod(1.0-texCoord.y, 0.2) ...

Using shader for calculations

Is it possible to use shader for calculating some values and then return them back for further use? For example I send mesh down to GPU, with some parameters about how it should be modified(change position of vertices), and take back resulting mesh? I see that rather impossible because I haven't seen any variable for comunication from ...

NPR GLSL examples

I'm looking for a few NPR (Non-Photorealistic Rendering) GLSL shader examples, mostly sketch or toon inspired. Does anyone have some links? :) ...

Geometry shader doesn't do anything when fed GL_POINTS

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 ...

Converting depth buffer into depth texture for GLSL

What is the easiest way to get the existing depth buffer into a depth texture, or anything that can be used by GLSL? Is it possible to make a glsl shader that uses the depth buffer, and use it "as is" without having to modify the the way the original rendering is done (e.g modifying the frame buffer object to also render to an additiona...

Cg: Proper way to write/read from a floating point texture

I currently have a R8G8B8 floating point render target and want to use it as a R24 target. The code //cg out = float4(v, v, v, v); seems to clamp out between 0 and 1. What's the proper way to write/read to a floating point texture in Cg? ...