Jump to content

  • Log In with Google      Sign In   
  • Create Account

Naruto-kun

Member Since 15 Oct 2012
Offline Last Active Nov 17 2014 05:20 AM

Posts I've Made

In Topic: Splitting primatives between render targets

30 October 2014 - 12:26 PM

Ah! Set D3D11_TEXTURE2D_DESC::ArraySize to 2 when creating the texture?


In Topic: Splitting primatives between render targets

30 October 2014 - 11:58 AM

I see...I am using 2 separate ID3D11Texture2D objects for the render targets. You say it should be 1 3D texture with 2 slices?


In Topic: Splitting primatives between render targets

30 October 2014 - 11:11 AM

Ok this is odd....The first render target is getting the output of the second.

 

Here is my pixel shader input/geometry shader output:

struct PS_INPUT
{
	float4 p : SV_POSITION;
	float2 t : TEXCOORD0;
	float4 c : COLOR;
	uint rt : SV_RenderTargetArrayIndex;
};

And here is my geometry shader:

[maxvertexcount(93)]
void GS( point GS_INPUT sprite[1], inout TriangleStream<PS_INPUT> triStream )
{
	PS_INPUT v;

	float c = cos(hdg);
	float s = sin(hdg);
	
	float2x2 rotation = {c, -s, s, c};

	v.c = float4(0, 0, 0, 1);
	v.rt = 0;

	switch(col)
	{
	case 0:
		v.c = float4(0, 0, 0, 1);
		break;
	case 1:
		v.c = float4(0, 1, 0, 1);
		break;
	case 2:
		v.c = float4(1, 1, 0, 1);
		break;
	case 3:
		v.c = float4(1, 0, 0, 1);
		break;
	}
	v.t = float2(0, 0);
	float2 center = sprite[0].pos.xy;
	float r = 0;
	if(abs(sprite[0].size.x) > abs(sprite[0].size.y))
		r = abs(sprite[0].size.x)*0.9;
	else
		r = abs(sprite[0].size.y)*0.9;
	float2 rad = {r*rng, r*rng};

	if(abs(sprite[0].ctr.x) + r > 8300.0f)
		rad.x = (r - ((abs(sprite[0].ctr.x) + r)-8300.0f))*rng;
	if(abs(sprite[0].ctr.y) + r > 8300.0f)
		rad.y = (r - ((abs(sprite[0].ctr.y) + r)-8300.0f))*rng;

	v.p = float4(mul(center+float2(rad.x, 0), rotation)-float2(0.0f, 1.0f), sprite[0].pos.z, 1)*float4(0.78125f, 1.0f, 1.0f, 1.0f);
	triStream.Append(v);
		
	v.p = float4(mul(center+float2(rad.x*SIN45, rad.y*SIN45), rotation)-float2(0.0f, 1.0f), sprite[0].pos.z, 1)*float4(0.78125f, 1.0f, 1.0f, 1.0f);	
	triStream.Append(v);

	v.p = float4(mul(center+float2(rad.x*SIN45, -rad.y*SIN45), rotation)-float2(0.0f, 1.0f), sprite[0].pos.z, 1)*float4(0.78125f, 1.0f, 1.0f, 1.0f);	
	triStream.Append(v);

	v.p = float4(mul(center+float2(0, rad.y), rotation)-float2(0.0f, 1.0f), sprite[0].pos.z, 1)*float4(0.78125f, 1.0f, 1.0f, 1.0f);
	triStream.Append(v);

	v.p = float4(mul(center+float2(0, -rad.y), rotation)-float2(0.0f, 1.0f), sprite[0].pos.z, 1)*float4(0.78125f, 1.0f, 1.0f, 1.0f);
	triStream.Append(v);

	v.p = float4(mul(center+float2(-rad.x*SIN45, rad.y*SIN45), rotation)-float2(0.0f, 1.0f), sprite[0].pos.z, 1)*float4(0.78125f, 1.0f, 1.0f, 1.0f);	
	triStream.Append(v);

	v.p = float4(mul(center+float2(-rad.x*SIN45, -rad.y*SIN45), rotation)-float2(0.0f, 1.0f), sprite[0].pos.z, 1)*float4(0.78125f, 1.0f, 1.0f, 1.0f);	
	triStream.Append(v);

	v.p = float4(mul(center+float2(-rad.x, 0), rotation)-float2(0.0f, 1.0f), sprite[0].pos.z, 1)*float4(0.78125f, 1.0f, 1.0f, 1.0f);
	triStream.Append(v);

	triStream.RestartStrip();

	v.rt = 1;

	if(sprite[0].ctr.x < -8000.0f)
		v.c = float4(1, 0, 0, 0);
	if(sprite[0].ctr.y > 8000.0f)
		v.c = float4(0, 1, 0, 0);
	if(sprite[0].ctr.x > 8000.0f)
		v.c = float4(0, 0, 1, 0);
	if(sprite[0].ctr.y < -8000.0f)
		v.c = float4(0, 0, 0, 1);

	float4 ep = mul(float4(-8000.0f, 0, -8000.0f, 1), world);
	v.p = float4(mul((ep.xz-latlon)*rng, rotation)-float2(0.0f, 1.0f), 0, 1)*float4(0.78125f, 1.0f, 1.0f, 1.0f);
	triStream.Append(v);

	ep = mul(float4(-8000.0f, 0, 8000.0f, 1), world);
	v.p = float4(mul((ep.xz-latlon)*rng, rotation)-float2(0.0f, 1.0f), 0, 1)*float4(0.78125f, 1.0f, 1.0f, 1.0f);
	triStream.Append(v);

	ep = mul(float4(8000.0f, 0, -8000.0f, 1), world);
	v.p = float4(mul((ep.xz-latlon)*rng, rotation)-float2(0.0f, 1.0f), 0, 1)*float4(0.78125f, 1.0f, 1.0f, 1.0f);
	triStream.Append(v);

	ep = mul(float4(8000.0f, 0, 8000.0f, 1), world);
	v.p = float4(mul((ep.xz-latlon)*rng, rotation)-float2(0.0f, 1.0f), 0, 1)*float4(0.78125f, 1.0f, 1.0f, 1.0f);
	triStream.Append(v);
	triStream.RestartStrip();
}

And the pixel shader:

 

float4 PS( PS_INPUT input ) : SV_Target
{ 
	float4 color = input.c*0.02f;
	return color;
}

The first render target (v.rt = 0) is supposed to receive a bunch of octagons overlaid on eachother. The second (v.rt = 1) is supposed to receive a large square covering a set area. Instead, both render targets are getting the output of the second render target.

Any ideas?


In Topic: Splitting primatives between render targets

30 October 2014 - 08:20 AM

Ah ok thanks.


In Topic: XAudio2 controlling the pulse rate of a loop

01 September 2014 - 12:28 PM

That's my point...I know that's what I want to do in theory but I cant seem to find anything on how the API will let me do that.


PARTNERS