Jump to content
Posted 26 August 2011 - 01:17 PM
Posted 26 August 2011 - 02:29 PM
Posted 26 August 2011 - 04:58 PM
Follow my RTS game ICBM
Posted 26 August 2011 - 06:05 PM
Doesn't look as if there's anything wrong with your g-buffer textures. As regards your questions:
1) All of the fragment output can be done in the lighting pass - your g-buffer is an input to the lighting stage, you accumulate 'lit' pixels in the final framebuffer.
2) You can draw anything you like in the lighting pass, as long as it covers the pixels which need to be lit. You could draw a full screen-aligned quad for every light, which is pretty inefficient (you'll end up shading a lot of pixels which don't need to be shaded). Drawing the light volumes is the optimal solution: a sphere for point lights, a cone for spotlights is generally the way to go.
3) You'll need to write material properties to a target in the g-buffer. How you do this depends on what your lighting stage requires and the sort of material properties you need to support. A simple format might be something like R = specular level, G = specular power B = emissiveness A = AO factor.
Here's a few links to some deferred rendering resources (you may have already seen some of them):
The first thing you have to do right before you draw lights, is put the full screen diffuse to the screen. Then for each light such as a point light, you will have to draw a physical sphere , but your shader isnt drawing the sphere, its just using it to do lighting on the diffuse you already drew to the screen. It just continually blend with what is on screen and your screen will fill up as more objects are drawn.
Posted 27 August 2011 - 03:20 AM
Posted 27 August 2011 - 08:52 AM
Posted 27 August 2011 - 09:21 AM
Posted 27 August 2011 - 01:41 PM
Posted 27 August 2011 - 02:13 PM
Posted 27 August 2011 - 06:06 PM
Posted 27 August 2011 - 11:16 PM
Follow my RTS game ICBM
Posted 28 August 2011 - 03:57 AM
1st, your diffuse has all perfectly lit green grass. So if you have a sunlight, you should calculate that first and put that in your diffuse buffer as well.
1. The albedo texture should be a combo of the material diffuse property and the objects texture?
2. No ambient material should be needed since it is usually the same as the diffuse property. Later i can add SSAO
3. And now there will be no emissive or specular color but instead a factor that will be multiplied by the light properties?
Only question that remains for me now is if the materials are now like this, will the light sources properties be similar or do they still retain their RGBA values
Posted 28 August 2011 - 06:39 AM
The only real thing you need, to get started are what you already have: position, normal, diffuse (texture) color.
1st, your diffuse has all perfectly lit green grass. So if you have a sunlight, you should calculate that first and put that in your diffuse buffer as well. For all other lights (lamposts, vehicles etc): they are contributing (addding) EXTRA light to the scene. So first again, you put your original diffuse on the screen (with or without sunlight), then you use addative blending of each extra light. Again keyword add/extra (addative). For each light you draw a physical model of the actual lights area. For a lampost it might be a 3d cone, a lightbulb would be a sphere. Hopefully you already knew that cuz if not, then your stepping too far.
After that you should have basic lighting. Again with materials like metal you have a certain specular power, as well as certain spots of metal that have different amounts of specular. Imagine a piece of metal with rust, the rust portions have no specular, and the clear ones do because they reflect light back. But even more when the light hits that surface, it has a specular power, either it is really focused and hard metal, or not as focused and soft. So you could (and eventually will), want to have those properties stored either in the color,normal,position, anywhere.
Any property/material that effects light from an object standpoint, is saved. The light properties are just used when you draw those 3d models.
1. I would say that an objects texture is its material's diffuse property, i.e. the colour which modulates any reflected, diffuse light. So your grass texture represents the final colour you'd see if there was a 100% white light shining on it.
Posted 28 August 2011 - 10:18 AM
Posted 24 October 2011 - 01:28 AM
ambient = material_diffuse * light_color * light_ambient_level;
diffuse = material_diffuse * light_color * light_diffuse_level;
specular = light_color * material_specular_level * light_specular_level ^ material_specular_power;
emissive = material_emissiveness * material_diffuse;
result = ambient + diffuse + specular + emissive;