Jump to content

  • Log In with Google      Sign In   
  • Create Account

TeaTreeTim

Member Since 18 May 2009
Offline Last Active Jun 30 2016 04:29 PM

Posts I've Made

In Topic: Subdividing triangles using a GS

28 June 2016 - 04:18 PM

Hi, A long hand version:

PSIn MidPoint(PSIn a, PSIn b)
{
	PSIn result;
	result.pos = (a.pos + b.pos) / 2.0f;
	result.tex = (a.tex + b.tex) / 2.0f;
// project pos to the same radius as the other points here
	return result;
}


[maxvertexcount(8)]
void GS(triangle PSIn input[3], inout TriangleStream<PSIn> triStream)
{
	PSIn pointA = input[0];
	PSIn pointB = input[1];
	PSIn pointC = input[2];

	PSIn pointAB = MidPoint(pointA, pointB);
	PSIn pointAC = MidPoint(pointA, pointC);
	PSIn pointBC = MidPoint(pointB, pointC);

	pointA.pos = mul(pointA.pos, viewMatrix);
	pointA.pos = mul(pointA.pos, projectionMatrix);
	pointB.pos = mul(pointB.pos, viewMatrix);
	pointB.pos = mul(pointB.pos, projectionMatrix);
	pointC.pos = mul(pointC.pos, viewMatrix);
	pointC.pos = mul(pointC.pos, projectionMatrix);
	pointAB.pos = mul(pointAB.pos, viewMatrix);
	pointAB.pos = mul(pointAB.pos, projectionMatrix);
	pointAC.pos = mul(pointAC.pos, viewMatrix);
	pointAC.pos = mul(pointAC.pos, projectionMatrix);
	pointBC.pos = mul(pointBC.pos, viewMatrix);
	pointBC.pos = mul(pointBC.pos, projectionMatrix);


	triStream.Append(pointA);
	triStream.Append(pointAB);
	triStream.Append(pointAC);
	triStream.Append(pointBC);
	triStream.Append(pointC);

	triStream.RestartStrip();

	triStream.Append(pointAB);
	triStream.Append(pointB);
	triStream.Append(pointBC);

	triStream.RestartStrip();
}

Using triangle strip just seems silly to me, I'd use list and it would make more logical sense but the above will work, you'd need to project the mid points to the sphere as well though. I stand by my original point that I think your order is incorrect, and add the second restart strip like I did.


In Topic: Subdividing triangles using a GS

26 June 2016 - 11:04 PM

Hi,

 

This order:

    outVerts[0] = inVerts[0];
    outVerts[1] = m[0];
    outVerts[2] = m[2];
    outVerts[3] = m[1];
    outVerts[4] = inVerts[2];
    outVerts[5] = inVerts[1];

Doesn't look right. m[1] is between inVert[1] and inVert[2] so a triangle made up from them doesn't seem correct. You should state, are you using triangle list or strip, because you have a restart strip command in there. Also a pic of what you expect would help.

 

PS: Why is max vertex count 8?


In Topic: Help with UV mapping procedural game

18 June 2016 - 05:07 PM

Just use the normal in the pixel shader. If the normal is float3(0, 0, 1) then use world coordinates x and y for the texture coordinates. The point of tri-planar is to merge plane aligned samples based on which plane you are closest to. In your case you are aligned on one only.


In Topic: Depth Buffer in D3D9 for Volumetric Fog

02 June 2016 - 08:56 PM

I don't think its so much about getting depth in the same pass (INTZ) as the hurdle being adding different fog sources together. Depth will be what ever is closest even if it is partly transparent and then you have order of drawing issues.  If you sum all back and front face depths of fog you can then calculate the final depth of fog. The author of that article glossed over the important bits; notice he refers to fog "sprites" not volumes. This is how I do it: http://socoso.com.au/Tiogra/fog.html


In Topic: Terrain Rendering

21 May 2016 - 05:59 PM

What you propose is a little old school. A step up from CPU based ROAM but a step down from modern geoclipmapping (a monolithic draw for all the terrain). At the newer end of the spectrum, you could have a single grid that uses tessellation based on distance and rockiness. Depends on if you want to support DX9.0, 10, 11.1 or 12.


PARTNERS