Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

Telanor

Member Since 01 Sep 2011
Offline Last Active Today, 04:14 AM
-----

#5054348 Projective Texturing

Posted by Telanor on 17 April 2013 - 05:43 PM

I found part of the problem was from me using the ViewProjection matrix from the wrong camera but now there seems to be an issue with the sampling coordinates for the projection depth map being wrong.

RuinValor 2013-04-17 19-33-24-01.png

The projector camera is positioned approximately where the cursor is and is looking straight downwards. Ive changed the code from before slightly
float4 decalPos = mul(position, DecalViewProjection);
decalPos /= decalPos.w;
decalPos.xy = float2(decalPos.x, -decalPos.y) / 2.0f + 0.5f;

float shadowDepth = ProjectorDepthMap.Sample(pointSampler, decalPos.xy);

return float4(shadowDepth.rrr, 1);



#5054109 Projective Texturing

Posted by Telanor on 17 April 2013 - 12:36 AM

That's what I figured but I wasn't able to get it to work. It just considers everything to be out of the shadow.
float4 position = //bunch of code to reconstruct world space position from log depth

float4 decalPos = mul(position, DecalViewProjection);

float shadowDepth = ProjectorDepthMap.Sample(pointSampler, decalTexCoord.xy);

if(shadowDepth < decalPos.z / decalPos.w)
	discard;



#5054097 Projective Texturing

Posted by Telanor on 16 April 2013 - 11:20 PM

I'm trying to implement projective texturing but I'm having some trouble getting it to a usable state. Right now it works but it projects to infinity (or more specifically, to the far plane). I can't just pull back the far plane because it could result in the texture being cut off on steep surfaces, and wouldn't solve the problem of projecting through surfaces. I've tried to mimic a sort of spotlight shadow technique but wasn't able to get that to work since there are pretty much no tutorials on shadows for deferred shading pipelines. So, my question: How do you get a projective texture to stop at the first surface it hits?


Edit: I forgot to add tags. I'm using DX11 & sharpdx


#5050510 Collida Model Loading + Bones + Control Rigs = Fail?

Posted by Telanor on 05 April 2013 - 11:46 PM

Turns out we had to bake animations and ignore any bones that didn't have animations


#5041404 Problems with camera looking up

Posted by Telanor on 09 March 2013 - 10:49 PM

I'm trying to calculate a view/projection/bounding frustum for the 6 directions of a point light and I'm having trouble with the views pointing along the Y axis. Our game uses a right-handed, Y-up system. For the other 4 directions I create the LookAt matrix using (0, 1, 0) as the up vector. Obviously that doesn't work when looking along the Y axis so for those I use an up vector of (-1, 0, 0) for -Y and (1, 0, 0) for +Y. The view matrix seems to come out correctly (and the projection matrix always stays the same), but the bounding frustum is definitely wrong.

This is the code I'm using:
camera.Projection = Matrix.PerspectiveFovRH((float)Math.PI / 2, ShadowMapSize / (float)ShadowMapSize, 1, 5);

for(var i = 0; i < 6; i++)
{
	var renderTargetView = shadowMap.GetRenderTargetView((TextureCubeFace)i);
	var up = DetermineLightUp((TextureCubeFace) i);
	var forward = DirectionToVector((TextureCubeFace) i);

	camera.View = Matrix.LookAtRH(Position, Position + forward, up);
	camera.BoundingFrustum = new BoundingFrustum(camera.View * camera.Projection);
}

private static Vector3 DirectionToVector(TextureCubeFace direction)
{
	switch (direction)
	{
		case TextureCubeFace.NegativeX:
			return -Vector3.UnitX;
		case TextureCubeFace.NegativeY:
			return -Vector3.UnitY;
		case TextureCubeFace.NegativeZ:
			return -Vector3.UnitZ;
		case TextureCubeFace.PositiveX:
			return Vector3.UnitX;
		case TextureCubeFace.PositiveY:
			return Vector3.UnitY;
		case TextureCubeFace.PositiveZ:
			return Vector3.UnitZ;
		default:
			throw new ArgumentOutOfRangeException("direction");
	}
}

private static Vector3 DetermineLightUp(TextureCubeFace direction)
{
	switch (direction)
	{
		case TextureCubeFace.NegativeY:
			return -Vector3.UnitX;
		case TextureCubeFace.PositiveY:
			return Vector3.UnitX;
		default:
			return Vector3.UnitY;
	}
}
I can post some example output if it'll help.


#5038349 Help me to make work D2D with D3D11

Posted by Telanor on 02 March 2013 - 03:57 AM

See here for instructions: http://blog.rthand.com/post/2010/10/25/Capture-DirectX-1011-debug-output-to-Visual-Studio.aspx

I think you need to add the application to the list before D3D11_CREATE_DEVICE_DEBUG has any effect


#5038215 Specular Control

Posted by Telanor on 01 March 2013 - 06:46 PM

Ah, so the shadows are supposed to be added into the lighting buffer output apparently. Since I wasn't the one who set this up originally I hadn't really done much research into the compositing stage of shadows, so I just assumed it was normal to add them in during the final gbuffer pass. Thanks for the help guys.


#5038171 Help me to make work D2D with D3D11

Posted by Telanor on 01 March 2013 - 04:29 PM

I suggest you enable the directx debug runtimes and fix all the errors it reports. There are several of them


#5037778 Help me to make work D2D with D3D11

Posted by Telanor on 28 February 2013 - 04:36 PM

Your LightShader::RenderText method doesn't appear to draw the contents of the shared texture to screen. It looks like it sets up for it but never actually does the draw call.


#5037532 Specular Control

Posted by Telanor on 28 February 2013 - 04:04 AM

How do you do that with a deferred renderer? Ambient and diffuse are precombined.


#5036020 Transparent voxels

Posted by Telanor on 24 February 2013 - 01:08 AM

I had the wrong blend mode. Halos are fixed now. Can we use premultiplied alpha to get rid of the grass-on-grass darkness? Or does that not work?

Edit: Another question: will this work for glass and other transparent blocks without looking terrible?


#5036006 Transparent voxels

Posted by Telanor on 23 February 2013 - 11:34 PM

-- Drawing your grass with additive blending and no depth testing, and a write mask of rgb=false, a=true (so that only the alpha channels are summed).

-- Drawing your grass with depth-testing and alpha-testing (no blending), and a write mask of rgb=true, a=false (so that only the color channels are written).

First pass state:
descBlendAlphaOnly.RenderTarget[0].IsBlendEnabled = true;
descBlendAlphaOnly.RenderTarget[0].RenderTargetWriteMask = ColorWriteMaskFlags.Alpha;
descBlendAlphaOnly.RenderTarget[0].SourceBlend = BlendOption.SourceAlpha;
descBlendAlphaOnly.RenderTarget[0].SourceAlphaBlend = BlendOption.SourceAlpha;
descBlendAlphaOnly.RenderTarget[0].DestinationBlend = BlendOption.One;
descBlendAlphaOnly.RenderTarget[0].DestinationAlphaBlend = BlendOption.One;
Second pass state:
descBlendColorOnly.RenderTarget[0].IsBlendEnabled = false;
descBlendColorOnly.RenderTarget[0].RenderTargetWriteMask = ColorWriteMaskFlags.Red | ColorWriteMaskFlags.Green | ColorWriteMaskFlags.Blue;
Are these correct?

This is the result I'm getting:
RuinValor 2013-02-24 00-33-06-95.png

I have no alpha testing on the first pass and the 2nd pass uses this:
if(color.a == 0.0f)
	discard;



#5035979 Transparent voxels

Posted by Telanor on 23 February 2013 - 08:48 PM

Is there a way to properly render layered transparent objects when you can't do depth sorting? Since the terrain is all built up into 2 vertex buffers per region (1 for solid blocks, 1 for transparent blocks), we can't do the typical depth sorting. Are there any alternatives?

This is what its coming out like right now:

RuinValor 2013-02-23 21-42-37-02.png


#5034909 Cascaded Shadow Map Issue

Posted by Telanor on 21 February 2013 - 02:21 AM

Increasing the shadow bias fixed the remaining issue:

RuinValor 2013-02-21 03-13-26-14.png

So it's pretty much working now. I'm getting just about every other problem possible though. Peter panning, jittering when moving, shadows disappearing when the object is behind the camera, and some weird issue where a triangle of shadow pops in on the right hand side (you can see it in the screenshot). The last two issues are particularly problematic though.

Edit: Switching to our old ESM shadow filtering (instead of PCF from the sample) mostly fixes issues 1, 2, and possibly 4. 3rd one is still something I'd really like to fix.


#5034872 Cascaded Shadow Map Issue

Posted by Telanor on 20 February 2013 - 10:22 PM

I can't get the reconstructed position to even come close to the position_ws_VS.  I found something else out, however, while reading MJPs blog about reconstructing linear depth.  The GetCorners function in SharpDX returns the corners in a different order than XNA.  So I switched the indexes around and now the first shader output seems a little closer to what it should be (at least I think so...).  It no longer rotates with the camera, but it's still moving with it:
 
http://www.youtube.com/watch?v=I0iOqgSWOmE




PARTNERS