• Advertisement
Sign in to follow this  

OpenGL New Demo: Glow

This topic is 4651 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

As posted on my webpage: This demo written in OpenGL is based on an article I read a while ago in my GPU GEMS book and which is also available on the gamasutra site, check it out here. To create the glow effect, basically every 3D model in the scene is assigned a set of two textures; a regular RGB image encoding the diffuse color and a LUMINANCE one specifying the glow areas. A better approach would be to code the luminance values into the alpha channel of the diffuse image; that way we get to use a single texture instead of two. I chose to stick with the first approach since it gives me the possibilty of modifying the glow path without separating the RGB and ALPHA values into separate textures before combining them again (I only have Paint on my computer, sigh!!!) During the first pass a GLSL fragment shader retrieves the diffuse color bound to texture unit 0 and then multiplies it by the luminance value stored in the second texture. The result is copied into a 256*256 texture that we call the glow source. Originally I intended to use FBOs to accomplish the rendering to texture but since we're dealing with relatively small targets, I decided to stick with glCopyTexSubImage2D. Now depending on the amount of glow that we aim for, another shader (or ARB program, the user can modify the Blur.xml file in the data folder to switch from one to the other) takes the glow source and blurs it N times in two separate steps: a horizontal pass to bleed the source color along the x axis followed by a vertical pass that distributes the color in the y axis direction. In both steps the resulting color is multiplied by 1.15 to accentuate the glow effect. After each pass, the result is stored into a secondary texture; this is our blur target. Finally, the scene is drawn with diffuse textures only before turning on additive blending and drawing a full screen quad with the blur target bound to it. One drawback of this technique is the aliasing effects betraying the small size of the blur and glow targets. Later I will try to provide support for non DX9.0 hardware since the blur could be accomplished without shaders. Demo binaries. Demo source and build files. Engine source. [Edited by - JavaCoolDude on May 27, 2005 4:19:06 PM]

Share this post


Link to post
Share on other sites
Advertisement
Thats pretty neat.

What do you intend to do with all these neat effects you are creating?

Share this post


Link to post
Share on other sites
I'm shooting to get some of those effects into the NVIDIA SDK.
I'm flying to their headquarters in CA tomorrow for a job interview.
Wish me luck, I feel pretty nervous about the whole thing.

/wuss out [crying]

[razz]

Share this post


Link to post
Share on other sites
Wow, that must be pretty exciting. Good luck!

Share this post


Link to post
Share on other sites
Thank you all for your support; it means a lot to me [inlove]
Aight, let me get 4 hours of sleep before I head out for the Airport.

Share this post


Link to post
Share on other sites
Your stuff amazes me. I know a lot of people seemed to be making this kind stuff (atleast commerically), but you work it all out and then release it to the public. My hat goes off to you, sir. *round of applause*

Share this post


Link to post
Share on other sites
Don't know if this is too late or not, but good luck man! With all the awesome stuff you've been pumping out lately, you deserve the job!

Share this post


Link to post
Share on other sites
Quote:
I'm flying to their headquarters in CA tomorrow for a job interview.
Wish me luck, I feel pretty nervous about the whole thing.
just have a beer or seven on the plane and continue from there, ie treat the thing as a holiday

Share this post


Link to post
Share on other sites
Quote:
In both steps the resulting color is multiplied by 1.1 to accentuate the glow effect.

Wouldn't it have the same effect if you just multiplied by 1.21 once?

Share this post


Link to post
Share on other sites
Yo JCD, long time no chat. You probably don't remember but I used to chat with you back when you were actually a Java programmer workin with LWJGL :)

Anyway, all these demos are rockin', but this latest one I can't run because it says I need MSVCR71.dll Now, this is confusing to me because, I *do* have Visual Studio .NET 2003 installed, and the Microsoft .NET Framework 1.1. What am I missing?


Thanks, and GOOD LUCK!


EDIT: Turns out a simple file search turned up the missing DLL, I copied it into the same directory as scenegraph.exe, and voila it works. Begs the question why msvcr71.dll wasn't already in my path though...

Share this post


Link to post
Share on other sites
Hey howdy Optus buddy, long time no talk ah?
Glad to see you hanging around here (you and orangytang).

@Boruki
Thanks my man, my pleasure is derived from people's appreciation of my efforts [smile] (You can translate that into "My ego needs to be fed on a regular basis"...j/k [wink] )

So yeah, I'm posting these lines from a hotel right next to NVIDIA's headquarters. They sent a lemo to get me from the airport and I was like: are you sure you're not mistaking me for some other dude?
The interview is scheduled for tomorrow at 10:15 am. Right now I'm just skimming through my GPU GEMS and Orange book.
Aight, I'll keep y'all updated.

Share this post


Link to post
Share on other sites
Quote:
Original post by twanvl
Quote:
In both steps the resulting color is multiplied by 1.1 to accentuate the glow effect.

Wouldn't it have the same effect if you just multiplied by 1.21 once?


Nope, since the blur is accomplished through two separate steps acting on different fragments.

Share this post


Link to post
Share on other sites
Hello,
Wooow another great work , i'm sorry for late post :(
bye :)

Share this post


Link to post
Share on other sites
Well done and good luck for your interview!

I tried to do a glow effect in my game, and I wrote all the code - got everything perfect (like glow sources) but then found out MDX wasn't letting me set a texture as a render target! (That's the December update because I still have Win 2k, they'd better have fixed it by now *punches fist*)

And before any well-meaning soul tells me to check all the simple things; the viewport was set correctly, I was creating the texture with the RenderTarget flag, it was a supported render-target format, my graphics card supports ps_2_0 and it was a single level texture and I was setting the top level which was not null!

Cheers then! Hope the interview goes well!

Share this post


Link to post
Share on other sites
Can you tell me how can i make blur effect? :P i tried to read you code but your code complex :P
Good luck in your interview :D !
bye

Share this post


Link to post
Share on other sites
Hello everyone, missed you all so much (well not really since I managed to post few words from the hotel’s computer [disturbed] )
The interview lasted about six hours and went extremely well; the questions were diverse and really really technical (sometimes barely touching on anything related to graphics), but I believe I managed to answer all of them except that one where I was supposed to go in details about how Anisotropic filtering works (slaps forehead, I should have read a bit more about it in my GL super bible book). Anyway, you can’t know it all.
I met a lot of great engineers like William Ramey, Greg James (The author of the Glow article linked in my demos’s webpage), Cem Cebenoyan, Sim Dietrich etc…very friendly folks.
When I was done with the interview I needed a shower wicked bad since I was totally soaked in sweat (but no foul smell I swear); that's how nervous I was.
Well that was my trip to NVIDIA headquarters, hope I can get back there soon.

Back on topic:
I'll be modifying the demo a bit tonight to add some cool ghosting effects as the cube rotates around, make sure you come back to check it.

@DrGui (your nick is awesome dude)
Pardon my ignorance but what is MDX?


Share this post


Link to post
Share on other sites
Hey Java, sounds like a really great opportunity for you. Just curious about how old you are and how long you've been working in the field? Any professional experience, or just academic/self-taught?

Share this post


Link to post
Share on other sites
I'd hazard a guess MDX = Microsoft Direct X

Anyway, congrats on the interview going so well man! Ho I would LOVE to be in that position... too bad I don't have any cool demo's to show off. :(

Good luck!

Share this post


Link to post
Share on other sites
An interview rarely touches what you are really good at. In my last interview there wasn't much technical questions. It was more or less a discussion on the current job profile, an assessment of how well oriented I was, what the current situation was, what they were looking for etc. Very interesting interview which lasted around 2.5 hrs.

Share this post


Link to post
Share on other sites
Quote:
Original post by Mattman
Hey Java, sounds like a really great opportunity for you. Just curious about how old you are and how long you've been working in the field? Any professional experience, or just academic/self-taught?


Oh I'm not that young buddy, I'm 22.
I've been in the 3D field since I was involved with Java3D and later Xith3D, that's about 2 and half years ago. I developped a couple of commercial products and presented some software that I've written in SIGGRAPH 2004 where I met all the great folks at NVIDIA :D
I've taken an OpenGL course last semester and taught some of the material in class along with the Profressor (ha, I didn't expect that :P).


@Crack123:
There were almost no specific questions about OpenGL, Greg James questions involved among others stuff about CPU ASM and how would I implement a LOAD intstruction with only STORE, SUB, a registry and a couple of memory locations.
I got that one right in 4-5 instructions, but I was close to throwing the towel.
Aight peace

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
  • Advertisement
  • Popular Tags

  • Advertisement
  • Popular Now

  • Similar Content

    • By LifeArtist
      Good Evening,
      I want to make a 2D game which involves displaying some debug information. Especially for collision, enemy sights and so on ...
      First of I was thinking about all those shapes which I need will need for debugging purposes: circles, rectangles, lines, polygons.
      I am really stucked right now because of the fundamental question:
      Where do I store my vertices positions for each line (object)? Currently I am not using a model matrix because I am using orthographic projection and set the final position within the VBO. That means that if I add a new line I would have to expand the "points" array and re-upload (recall glBufferData) it every time. The other method would be to use a model matrix and a fixed vbo for a line but it would be also messy to exactly create a line from (0,0) to (100,20) calculating the rotation and scale to make it fit.
      If I proceed with option 1 "updating the array each frame" I was thinking of having 4 draw calls every frame for the lines vao, polygons vao and so on. 
      In addition to that I am planning to use some sort of ECS based architecture. So the other question would be:
      Should I treat those debug objects as entities/components?
      For me it would make sense to treat them as entities but that's creates a new issue with the previous array approach because it would have for example a transform and render component. A special render component for debug objects (no texture etc) ... For me the transform component is also just a matrix but how would I then define a line?
      Treating them as components would'nt be a good idea in my eyes because then I would always need an entity. Well entity is just an id !? So maybe its a component?
      Regards,
      LifeArtist
    • By QQemka
      Hello. I am coding a small thingy in my spare time. All i want to achieve is to load a heightmap (as the lowest possible walking terrain), some static meshes (elements of the environment) and a dynamic character (meaning i can move, collide with heightmap/static meshes and hold a varying item in a hand ). Got a bunch of questions, or rather problems i can't find solution to myself. Nearly all are deal with graphics/gpu, not the coding part. My c++ is on high enough level.
      Let's go:
      Heightmap - i obviously want it to be textured, size is hardcoded to 256x256 squares. I can't have one huge texture stretched over entire terrain cause every pixel would be enormous. Thats why i decided to use 2 specified textures. First will be a tileset consisting of 16 square tiles (u v range from 0 to 0.25 for first tile and so on) and second a 256x256 buffer with 0-15 value representing index of the tile from tileset for every heigtmap square. Problem is, how do i blend the edges nicely and make some computationally cheap changes so its not obvious there are only 16 tiles? Is it possible to generate such terrain with some existing program?
      Collisions - i want to use bounding sphere and aabb. But should i store them for a model or entity instance? Meaning i have 20 same trees spawned using the same tree model, but every entity got its own transformation (position, scale etc). Storing collision component per instance grats faster access + is precalculated and transformed (takes additional memory, but who cares?), so i stick with this, right? What should i do if object is dynamically rotated? The aabb is no longer aligned and calculating per vertex min/max everytime object rotates/scales is pretty expensive, right?
      Drawing aabb - problem similar to above (storing aabb data per instance or model). This time in my opinion per model is enough since every instance also does not have own vertex buffer but uses the shared one (so 20 trees share reference to one tree model). So rendering aabb is about taking the model's aabb, transforming with instance matrix and voila. What about aabb vertex buffer (this is more of a cosmetic question, just curious, bumped onto it in time of writing this). Is it better to make it as 8 points and index buffer (12 lines), or only 2 vertices with min/max x/y/z and having the shaders dynamically generate 6 other vertices and draw the box? Or maybe there should be just ONE 1x1x1 cube box template moved/scaled per entity?
      What if one model got a diffuse texture and a normal map, and other has only diffuse? Should i pass some bool flag to shader with that info, or just assume that my game supports only diffuse maps without fancy stuff?
      There were several more but i forgot/solved them at time of writing
      Thanks in advance
    • By RenanRR
      Hi All,
      I'm reading the tutorials from learnOpengl site (nice site) and I'm having a question on the camera (https://learnopengl.com/Getting-started/Camera).
      I always saw the camera being manipulated with the lookat, but in tutorial I saw the camera being changed through the MVP arrays, which do not seem to be camera, but rather the scene that changes:
      Vertex Shader:
      #version 330 core layout (location = 0) in vec3 aPos; layout (location = 1) in vec2 aTexCoord; out vec2 TexCoord; uniform mat4 model; uniform mat4 view; uniform mat4 projection; void main() { gl_Position = projection * view * model * vec4(aPos, 1.0f); TexCoord = vec2(aTexCoord.x, aTexCoord.y); } then, the matrix manipulated:
      ..... glm::mat4 projection = glm::perspective(glm::radians(fov), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f); ourShader.setMat4("projection", projection); .... glm::mat4 view = glm::lookAt(cameraPos, cameraPos + cameraFront, cameraUp); ourShader.setMat4("view", view); .... model = glm::rotate(model, glm::radians(angle), glm::vec3(1.0f, 0.3f, 0.5f)); ourShader.setMat4("model", model);  
      So, some doubts:
      - Why use it like that?
      - Is it okay to manipulate the camera that way?
      -in this way, are not the vertex's positions that changes instead of the camera?
      - I need to pass MVP to all shaders of object in my scenes ?
       
      What it seems, is that the camera stands still and the scenery that changes...
      it's right?
       
       
      Thank you
       
    • By dpadam450
      Sampling a floating point texture where the alpha channel holds 4-bytes of packed data into the float. I don't know how to cast the raw memory to treat it as an integer so I can perform bit-shifting operations.

      int rgbValue = int(textureSample.w);//4 bytes of data packed as color
      // algorithm might not be correct and endianness might need switching.
      vec3 extractedData = vec3(  rgbValue & 0xFF000000,  (rgbValue << 8) & 0xFF000000, (rgbValue << 16) & 0xFF000000);
      extractedData /= 255.0f;
    • By Devashish Khandelwal
      While writing a simple renderer using OpenGL, I faced an issue with the glGetUniformLocation function. For some reason, the location is coming to be -1.
      Anyone has any idea .. what should I do?
  • Advertisement