# Piyush Verma

Member

22

400 Neutral

• Rank
Member

• Role
Programmer
• Interests
Programming

2. ## Texture Masking for Pseudo-Lens Flares

Thanks a lot for explaining it in detail. I think I should be able to implement it based on the info you provided.      I was actually planning on implementing something that is used in games/engines currently and would be a bit more flexible. That said, I think both techniques have their own uses based on the current scenario. I think I'll implement both eventually haha. Thanks again, for putting in the time to explain the solutions.
3. ## Texture Masking for Pseudo-Lens Flares

@Hodgin   I am not really aware of how SSBOs work yet, but I'll definitely take a look at that. But regarding the other approach you mentioned, wouldn't it be an expensive task to calculate the vector between the sun and the center of the camera, and rendering sprites based on the vector? Also, would using a uniform buffer object for sprites help with the performance?  Also, if I understand correctly, according to the GPU technique, we get the bright spots and calculate the flare geometry (positions) in the shader, and read that using the SSBO, and then render the flares using that data?  Please feel free to correct me if I interpreted your solution wrongly.    Thanks a lot for the suggestions. :)
4. ## OpenGL Texture Masking for Pseudo-Lens Flares

I've implemented John Chapman's Pseudo lens-flare in my OpenGL project and the result somewhat looks like this:         What I'm trying to figure out is, how can I use a simple hexagonal or a circle texture to mask each lens flare "ghost" to make look somewhat more like this:         Here's a fragment shader snippet where I'm calculating the lens flare ghosts and adding them to the sun shafts:    vec3 texture2DDistorted(sampler2D Texture, vec2 TexCoord, vec2 Direction, vec3 Distortion) { return vec3( texture2D(Texture, TexCoord + Direction * Distortion.r).r, texture2D(Texture, TexCoord + Direction * Distortion.g).g, texture2D(Texture, TexCoord + Direction * Distortion.b).b ); } // Calculate Lens flare ghosts // this is inside main() texCoord = vec2(1.0) - uv; vec2 texelSize = 1.0 / vec2(textureSize(lightScene, 0)); vec3 Distortion = vec3(-texelSize.x * distortion, -texelSize.y * distortion, texelSize.x * distortion); vec2 ghostVec = (vec2(0.5) - texCoord) * dispersal; direction = normalize(ghostVec); vec3 result = vec3(0.0); for (int i = 0; i < ghosts; i++) { vec2 offset = fract(texCoord + ghostVec * float(i)); float weight = length(vec2(0.5) - offset) / length(vec2(0.5)); result += texture2DDistorted(lightScene, offset, direction, Distortion) * weight; } // Radial gradient of 1D rainbow color texture result *= texture(lensColor, length(vec2(0.5) - texCoord) / length(vec2(0.5))).rgb; I add the result to the final color value in the shader. Is there a way to mask the color value of these ghosts with the hexagon texture so that they look more shaped like an actual lens flare rather than just blurred out blobs? I feel like it should be pretty straight forward, but at the same time I'm pretty much stumped about how to do it.
5. ## Triangle Strip and Perlin Noise.

Sorry about the late reply as well. So you're saying my first and the last vertices would actually be actually some dummy value. When the first line adjacency primitive is sent to the geometry shader, it sends it as [v0, v1, v2, v3] where v0 = dummy number. Is that correct?    Also, I looked a bit into perlin noise for vertices. What I couldn't figure out was, how would I animate the vertices with the perlin noise so that it looks smooth? For that, whatever noise is at v0 in the current frame, I was the same noise to be at v1 the next frame, and v1's noise goes to v2 and so on. The starting and end vertices get new noise values each frame. That way I think it would look like a smooth animation.
6. ## Triangle Strip and Perlin Noise.

Thanks for replying! I think I get it now about moving the bands along the earth. About the lines_adjacency primitive, I haven't used it before, so I have very little experience with it. Do I have to specify the adjacent vertices in the point list through an index buffer or by specifying GL_LINES_ADJACENCY, OpenGL itself would give me 4 coordinates per primitive?
7. ## Triangle Strip and Perlin Noise.

Also, from what I understand, Geometry shaders store the data of a triangle, and not a mesh. Is it any way possible to calculate or manipulate vertex normals in the geometry shader for smooth shading just like show in the image in the OP?
8. ## Triangle Strip and Perlin Noise.

I think I get it more or less. About moving the bands along the earth, do you mean that as the earth rotates, the bands should relatively rotate around the poles too?
9. ## OpenGL Triangle Strip and Perlin Noise.

Hi Folks,   I am working on an Earth Simulation in OpenGL/GLSL and I've gotten pretty far until now. I was trying to find a way to render Aurora Borealis at the North and the South poles of my planet and I found this blog where the author has done something similar to what I've been trying to do. Specifically, I'm trying to imitate the following image:     In his version of Aurora Borealis, he creates 2D bands (most probably using triangle strips) and animate them in real-time using perlin noise. I have been trying to achieve this, but the only way I can think of is to: Generate the mesh once for a band. Generate noise each frame for each band and update the vertices. Generate Normals for each band using the updated vertices. Send the new vertices & normals via an OpenGL call to the GPU.  Rinse and repeat. Now, this method seems super expensive. I was hoping if anyone can suggest a way that could make it possible to introduce the noise to the vertices inside the vertex shader itself and update the normals based on the noise that we just introduced to our vertices.    I apologize that I don't have any code to show for the bands right now, since I am still brainstorming the topic and trying to come up with a most optimal solution for the problem.    I could use some ideas and would really appreciate them.
10. ## Struggling with casting cloud shadow on earth sphere in OpenGL

Ah got it! I'll try it out when I'm done adding other features in this project! Thanks for the suggestion! :)
11. ## Struggling with casting cloud shadow on earth sphere in OpenGL

Sadly, taking the difference of the two rotations and rotating the uv coord didn't work either. But the method that IYP suggested worked :     Although, I had to subtract the value instead of adding it and to the uv coord instead though, but that maybe because of the direction in which I'm rotating the sphere. But that works for now. Also you mentioned that this method won't work in case of a directional light, could you explain how would I go about implementing that so that the directional light always takes in account the angle at which the shadow is casted?  Thanks again for the help

13. ## Multiple Texture using multiple shader programs

Probably a bit late on replying, but I was able to solve it by implementing texture management from scratch in my engine. Somewhere down the line, I was managing textures wrong on the C++ side and that was causing this issue. I wrote a dedicated TextureManager class to handle textures and it did the trick for me.

15. ## Multiple Texture using multiple shader programs

Yup I do. The first line in my render function is glUseProgram(program); I'll post the whole function when I get back from work...