Questions about Intel Sample

Started by
2 comments, last by MJP 11 years, 6 months ago
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:

#define MAX_LIGHTS_POWER 10
#define MAX_LIGHTS (1<<MAX_LIGHTS_POWER)


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:

struct GBuffer
{
float4 normal_specular : SV_Target0;
float4 albedo : SV_Target1;
float2 positionZGrad : SV_Target2;
};


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.
Advertisement
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

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

struct GBuffer
{
float4 normal_specular : SV_Target0;
float4 albedo : SV_Target1;
float2 positionZGrad : SV_Target2;
};


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.


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

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.


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

struct GBuffer
{
float4 normal_specular : SV_Target0;
float4 albedo : SV_Target1;
float2 positionZGrad : SV_Target2;
};


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.


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!).

This topic is closed to new replies.

Advertisement