Sun bursts and glows.

This is a discussion on Sun bursts and glows. within the Game Programming forums, part of the General Programming Boards category; Ok, I tried to add a point sprite to my game engine and the code works. However, my goal was ...

Sun bursts and glows.

Ok, I tried to add a point sprite to my game engine and the code works. However, my goal was to put a 'sun' in my world and well it looks more like a moon.

I want to create the star like glow around the sun and then blend it with the surrounding sky color and/or texture. Glow mapping is one idea, but I've not been able to understand exactly how to get it done.

So if anyone understands the Direct3D SetTextureStageState() method for doing this, plz help me. My books are, at best, vague on this topic.

It describes the glow effect in the Tron game. It's a pretty easy effect to accomplish once you read the article. If you read it and still have questions I would be happy to answer them. Especially about things they gloss over like rendering to textures. I'm not sure if you're familiar with that. Anyways, good luck.

"...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

By the way I'm using a single quad to represent the sky. Do you think this is ideal - in other words does it take longer for D3D to render my large quad than it would say several smaller quads?

I could just make the sky plane a small mesh of quads with no height values - but it seems to me this would add more primitives.

Also I downloaded that paper and it works great.

Ok, now for water and adding DirectInput instead of the slow keyboard crap I have now. I'm getting 80 to 100 FPS but the game still hesitates when using the keyboard because of the latency in the Windows API GetAsyncKeyState().

By the way I'm using a single quad to represent the sky. Do you think this is ideal - in other words does it take longer for D3D to render my large quad than it would say several smaller quads?

I could just make the sky plane a small mesh of quads with no height values - but it seems to me this would add more primitives.

Also I downloaded that paper and it works great.

Ok, now for water and adding DirectInput instead of the slow keyboard crap I have now. I'm getting 80 to 100 FPS but the game still hesitates when using the keyboard because of the latency in the Windows API GetAsyncKeyState().

DirectInput, DirectSound, and DirectMusic are next.

D3D Hates too many DrawPrimitive calls with a small amount of vertices. So just drawing one large textured quad as opposed to several smaller ones will be better for performance.

"...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

I've tried alpha blending and using the DX9 texture tool - convert the surface to ARGB8 and then load onto alpha channel the inverse of the image , but it alters the colors too much.

I'm seriously considering dumping the point sprite for the sun. It seems that it is clamped to 64x64 pixels no matter what size I make it. This is not good on a 1024x768 or larger screen. Perhaps going back to the old billboard technique is the best solution here.

"...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

I am using native point sprites for the sun - but they seem clamped to 64x64 pixels which aint big enough.

This 'game' is going to be whatever I can make it for. I doubt it will be good enough for commercial...but it might help me get into the industry if they see what I can do...and then again maybe it won't.

I haven't used d3d since I discovered openGL to be far easier.
So I cant give you technical pointers.
However, I can give general idea that you may be able to convert.

Considering the sun is only one entity, I don't see their being a problem with not using the point sprite class functionality. Just make your own helper functions to rotate a single quad polygon toward the camera. From there you can use this general forumala for a good "sun" effect.

Draw the sun polygon just below your sky quad, distance = 1/2 width of sun polygon. // so rotation of polygon toward camera wont clip some of the edges against the sqy quad.

Then draw N more triangles a very very small distance ahead of the first one, and slightly larger. N is based on performance VS. effect. 11 might be a nice effect, it really depends. Make sure every n'th additional polygon is slightly larger then the last one.

With the polygons being blended together you will create a blur of the sprite (which is appropriate when you look at the sun its not defined, its very guassian.

The blending method should be additional, so black is just transparent, but any color should be added to the current pixel value. (Createing the white out you usualy see when looking toward the sun). I have no idea which d3d alpha blend method this is.

Well I'm going to keep the CPointSprite class except that all of these bases will have a virtual function called prerender that will setup all the Direct3D testure and render states. My goal is to draw all the alpha blended objects together, switch back to non-alpha blending, and then draw the rest.

But I will have to make a CBillboard class for billboarding large point sprites. The CPointSprite class is not useless but being clamped to 64 or 128 pixels is simply not big enough for certain special effects. Plus, I need billboard functionality to populate the ground with bushes, grass, and other foliage.

CBillboard does have some of the same functionality of CPointSprite but they differ so much in the method that I'm going to make them totally independent of each other.

My next step really is animated sprites...among other things I want to get working.