Jump to content

  • Log In with Google      Sign In   
  • Create Account

Paksas

Member Since 15 Mar 2008
Offline Last Active Oct 04 2012 04:20 PM

Topics I've Started

specular light flickers when a ray is parallel to the lit surface

26 September 2012 - 03:22 AM

Hi everyone

I'm writing a deferred renderer using DX9.

I ran to a problem with specular reflections produced by directional lights. when the ray of light is parallel to the lit surface, specular reflection produced by the light starts flickering as I move the camera.

Attached File  flicker_1.png   17.77KB   35 downloads
Attached File  flicker_2.png   17.25KB   29 downloads

I made sure that all normals were normalized after they came through the rasterizer. I'm even renormalizing them once they've been sampled from the normals texture.

I think it's got something to do with the precision loss as the normals go through the rasterizer, but the weird thing is that if I decrease the light angle even by a fraction,the artifact disappears altogether and the reflection becomes stable ( which would suggest that it's not a precision issue after all ).

I'm storing my normals uncompressed in a DXT5 texture, but I tried different formats as well, including a 32bit color texture. I'm sampling it using a POINT filter ( tried linear, but nothing changes as well ).

I'd be grateful for all suggestions.

Cheers,
Paksas

noob issues with render target size

20 March 2011 - 05:57 AM

Hi

I'm trying to render a scene to a render target, blur it and then output it to the back buffer. The thing is that only the top left half of the scene gets rendered to the back buffer.

Original:
Attached File  original.jpg   24.56KB   25 downloads


Post processed:
Attached File  blured.jpg   14.12KB   24 downloads


I narrowed it down to be an issue with the render target texture size - the scene gets rendered to a texture matching the viewport size ( lets say 800x600 ). The blur filter renders its results to a texture half that size ( 400x300 ), and then that texture gets rendered back to the viewport's backbuffer ( 800x600).

Somewhere along the way the image is cropped and only its top left part gets rendered.

I removed everything from the blur pixel shader, leaving only a simple pass-through code there, which also yielded such results. Here's the code:


float4 PassThroug( in float2 t : TEXCOORD0 ) : COLOR
{
	float4 col = tex2D( inputTex, t );
	return col;
}


Could you please tell me what I'm doing wrong?

Thanks,
Paksas

converting a quaternion to euler angles

20 April 2010 - 07:26 PM

Hello I know that this subject's already been on the board, and I've tried using the equations posted in other posts as well as those that can be found here Euclidean space. As you can probably guess - I couldn't get them to work for me. My code looks like this:
D3DXQUATERNION q;
   D3DXQuaternionRotationYawPitchRoll(&q, DEG2RAD(124), DEG2RAD(269), DEG2RAD(351));

   float sqx = q.x * q.x;
   float sqy = q.y * q.y;
   float sqz = q.z * q.z;

   float yaw   = atan2( 2.f * ( q.y * q.w - q.x * q.z ), 1.f - 2.f * ( sqy + sqz ) );
   float pitch = asin ( 2.f * ( q.x * q.y + q.z * q.w ) );
   float roll  = atan2( 2.f * ( q.x * q.w - q.y * q.z ), 1.f - 2.f * ( sqx + sqz ) );

   float gimbaLockTest = q.x * q.y + q.z * q.w;
   if ( gimbaLockTest > 0.499f )
   {
      yaw = 2.f * atan2( q.x, q.w );
      roll = 0;
   }
   else if ( gimbaLockTest < -0.499f )
   {
      yaw = -2.f * atan2( q.x, q.w );
      roll = 0;
   }


   yaw = RAD2DEG(yaw);
   pitch = RAD2DEG(pitch);
   roll = RAD2DEG(roll);

   CPPUNIT_ASSERT_DOUBLES_EQUAL(124.f, yaw, 1e-3);
   CPPUNIT_ASSERT_DOUBLES_EQUAL(264.f, pitch, 1e-3);
   CPPUNIT_ASSERT_DOUBLES_EQUAL(351.f, roll, 1e-3);


The results I get are: [yaw = 115.00134, pitch = 0.15642539, roll = -90.987679]. If I conjugate the quaternion before calculating the angles, I get the following results: [yaw = 178.03929, pitch = -64.983093, roll = -92.336105]. Could you please help me spot the error? Thanks :) Paksas

using DrawPrimitive and ID3DXEffect

07 January 2010 - 01:05 AM

Hi What is the problem with the following code?
ID3DXEffect* effect;
IDirect3DVertexBuffer9* vb;

/* effect & vb initialization code */

d3Device->SetStreamSource(0, m_vb, 0, sizeof(Vertex));
d3Device->SetVertexDeclaration(vertexDecl);

UINT iPass, cPasses;
effect->Begin( &cPasses, 0 ) );
for( iPass = 0; iPass < cPasses; iPass++ )
{
   effect->BeginPass( iPass );

   d3Device->DrawPrimitive(D3DPT_LINELIST, 0, linesCount);

   effect->EndPass();
}
effect->End();

I removed the Begin/End/Present code etc. What I'm trying to do is draw a bunch of lines using an effect (a very simple one). The lines get drawn, but in a way that indicates the effect doesn't work. Can someone tell me what am I doing wrong here? Thanks a lot :) Paksas

implementing a decision tree

20 July 2008 - 08:46 AM

Hi DISCLAIMER - I know the subject's been discussed like a million times - I have browsed through this and a number of other forums. But I failed to find an answer to the question that's bugging one hell out of me. I'm trying to make a game. I was trying to put some AI toghether - I started simple using the FSMs. However I soon noticed that I'm plugging common behaviours all over the code - behaviours such as finding a path, or moving, or acting idle etc. Then I came across this article about the DT on AIGameDev.net (http://aigamedev.com/hierarchical-logic/). So I patched together a very simple DT - I used the Composite pattern. Now I don't know - maybe I misread something - but I kinda got the impression that such a tree can cover a great range of behaviors. So for instance I can have a tree that defines an action like this - goToKitchen - drinkWater - eatSandwich - goToRoom Now I want to do them sequentailly - one by one - pacing them in a timely manner, because each of them takes some time to complete. And everything would be great, if it wasn't for a small matter of the Composite executing the whole tree of actions at once :( Could somebody please help me understand how such a tree should be implemented? Many thanks to you all. Paksas

PARTNERS