• Advertisement
Sign in to follow this  

Questions about Intel Sample

This topic is 1933 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

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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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!). Edited by MJP

Share this post


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

  • Advertisement