Sign in to follow this  

Starting in deferred shading

Recommended Posts

I decided to make a try with deferred shading. For now i would like to make a simple directional light. So made Gbuffers: Position, Basecolor from texture, Normal, Depth (depth it's simply a copy resource from depthbuffer in D3D10). With this shader
PS_OUT ps_main(PS_INPUT In)
	PS_OUT output = (PS_OUT)0;
	float4 BaseColor = Texture.Sample(SamplText,In.Tex);
	output.Position = In.WorldPos;
	output.Normal = 0.5f * (float4(In.Nor,1.0f) + 1.0f); 
	output.Diffuse = BaseColor;
	return output;
But i noticed that, in order to make trasformation from screen space to world space and all this kind of conversion, there are some operations to do that i do not know. Infact, directional light is not the same making it in forward rendering.
float4 ps_draw(in float4 Pos:SV_POSITION, in float2 Tex:TEXCOORD)	:	SV_TARGET
	float4 TexC = BaseColor.Sample(SamplText,Tex);
	float3 Norm = 2.0f * Normal.Sample(SamplText,Tex).xyz - 1.0f;
	return TexC * max(0.0f,dot(Norm,normalize(LightDirection)));

void vs_draw (in float4 Pos:POSITION, in float2 Tex:TEXCOORD,out float4 WP:SV_POSITION,out float2 Tx:TEXCOORD)
	WP = float4(,1);
	Tx = Tex - halfpixel;

How should i insert data in buffers and retrive it in the same way??

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this