Jump to content

  • Log In with Google      Sign In   
  • Create Account


siri

Member Since 10 Apr 2013
Offline Last Active Oct 26 2013 10:39 AM

Topics I've Started

Pixel Perfect

23 October 2013 - 11:39 AM

Hi,

 

Not sure if this counts as a beginner question or not. I apologise if it's in the wrong section.

 

I'm currently playing around with some deferred rendering. It seems to be working ok. I have directional and point lighting. I'm rendering the lights in to a render target and then using that to calculate the final stuff. But I think my projective co-ords are slightly off. If you look at the image below you'll see that at the geometry edge there's a white line. As though the lighting texture doesn't quite match up.

 

zco7nx9.png

 

The code I am using to build the projective co-ordinates is as follows:

//suv are the co-ords for tex2Dproj()
//invWidth is (0.5f / screen_width)
//invHeight is (0.5f / screen_height)

v2fout.p       = mul(a2vin.p, wvp);
v2fout.uv      = a2vin.uv;	
v2fout.suv     = v2fout.p;
v2fout.suv.xy  = float2(v2fout.suv.x * 0.5, -v2fout.suv.y * 0.5);
v2fout.suv.xy += (0.5 * v2fout.suv.w);
v2fout.suv.x  += 0.5f * invWidth * v2fout.suv.w;
v2fout.suv.y  += 0.5f * invHeight * v2fout.suv.w;

Thanks for any help/advice.


Adding Elements ?

11 April 2013 - 07:26 PM

Hello,

 

I've spent the day getting a triangle to render in SlimDX and reading up on things. It was all going well until I tried to make the shader a little more complex. I just want to add a per-vertex colour. But when I did my vertex layout broke and I'm not sure why. The exception being thrown is the following:

 

 

 
An unhandled exception of type 'SlimDX.Direct3D11.Direct3D11Exception' occurred in SlimDX.dll
 
Additional information: E_INVALIDARG: An invalid parameter was passed to the returning function (-2147024809)

 

I managed to find a thread that seems related: http://www.gamedev.net/topic/607455-slimdx-directx11-inputlayout-failure/

 

I'm not sure if that really helps or not as I don't fully understand it. He seems to be passing his DataStream as the signature which I'm not doing( Or if I am it's in such a way that I don't realise I am. ). I'm using the ShaderByteCode from the vertex program. This all worked for a triangle with only positional data being sent. It breaks on the Layout creation line.

 

 

 
            var elements = new[] { new DX.InputElement("POSITION", 0, GI.Format.R32G32B32_Float, 0),
                                   new DX.InputElement("COLOR", 0, GI.Format.R32G32B32A32_Float, DX.InputElement.AppendAligned)
            };
 
//Breaks on this line.
            VertexLayout = new DX.InputLayout(CoreComponents.mVideo.mDevice, HLSL.ShaderSignature.GetInputSignature(VPByte), elements);

 

The shader looks like this:

 

 

 
struct a2v {
float3 p : POSITION;
float4 c : COLOR0;
};
 
struct v2f {
float4 p : SV_POSITION;
float4 c : TEXCOORD0;
};
 
v2f vp(a2v a2vin) {
v2f v2fout;
 
v2fout.p  = float4(a2vin.p, 1);
v2fout.c  = a2vin.c;
 
return v2fout;
}
 
float4 fp(v2f v2fin): SV_TARGET {
return v2fin.c;
}

 

Any help or advice would be appreciated. Thank you.


PARTNERS