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

## Recommended Posts

http://software.intel.com/en-us/articles/deferred-rendering-for-current-and-future-rendering-pipelines/ I'm learning about deferred rendering from this sample.What do you think about the method used for the lighting?I'm still having some confusion about how the compute shader works in the sample.What does this part mean:

[CODE]#define MAX_LIGHTS_POWER 10
#define MAX_LIGHTS (1<<MAX_LIGHTS_POWER)[/CODE]

In the sample exe,the max light number is 1024.How do you get 1024 from 1<<10?What does << do?

Also the main function of the Pixel Shader(GBufferPS) returns a struct:

[CODE]struct GBuffer
{
float4 normal_specular : SV_Target0;
float4 albedo : SV_Target1;
};[/CODE]

Instead of a float4.How does the gpu even work with this?I mean a pixel shader can only return a color,right?Not a whole struct.

##### Share on other sites
The << is a bitshift. It shifts the number (1 in this case) left ten bits, which is the equivilant of multiplying 1 by 2^10. 2^10=1024, 1024*1=1024

##### Share on other sites
[quote name='mrheisenberg' timestamp='1349540440' post='4987428']
Also the main function of the Pixel Shader(GBufferPS) returns a struct:

[CODE]struct GBuffer
{
float4 normal_specular : SV_Target0;
float4 albedo : SV_Target1;
};[/CODE]

Instead of a float4.How does the gpu even work with this?I mean a pixel shader can only return a color,right?Not a whole struct.
[/quote]

If you look at what's being returned you'll see that it's returning 3 colours - one in SV_Target0, one in SV_Target1 and one in SV_Target2. That means that it has 3 rendertargets bound to the pipeline, and each rendertarget gets it's own colour from the pixel shader. That's just a classic multiple rendertargets approach, nothing special.

Pixels shaders can also return depth by the way; see http://msdn.microsoft.com/en-us/library/windows/desktop/bb509647%28v=vs.85%29.aspx#System_Value

##### Share on other sites
[quote name='mrheisenberg' timestamp='1349540440' post='4987428']
Also the main function of the Pixel Shader(GBufferPS) returns a struct:

[CODE]struct GBuffer
{
float4 normal_specular : SV_Target0;
float4 albedo : SV_Target1;
};[/CODE]

Instead of a float4.How does the gpu even work with this?I mean a pixel shader can only return a color,right?Not a whole struct.
[/quote]

This features is called "multiple render targets" (MRT), and like the name suggests it allows the GPU to output to up to 8 render targets simultaneously. Honestly it's a pretty basic GPU/D3D feature, and if you're not familiar with such things yet I would stick to simpler material before looking at the Intel sample (which is quite advanced!). Edited by MJP