Jump to content

  • Log In with Google      Sign In   
  • Create Account

BornToCode

Member Since 17 Apr 2004
Offline Last Active Dec 17 2014 05:30 PM

#5161706 Getting perspective Frustum in world coordinates

Posted by BornToCode on 20 June 2014 - 07:33 AM

Why don't you extract the 6 planes after you multiply world by projection. That would give you the enclosed frustum in world space.


#5160403 Creating Camera Bounding Frustum From View and Projection Matrix

Posted by BornToCode on 13 June 2014 - 06:59 PM

You just need to multiply the ViewMatrix*Projection Matrix. Then you need to extra the 6 planes that makes up the frustum.

 

//This is Column Major matrix.

//If you have row based then you would flip the multiplication order.

Matrix4x4 ViewProjection = ProjectionMatrix*ViewMatrix;
    
    Plane& right = GetPlaneRight();
    right.normal.x=ViewProjection.m14-ViewProjection.m11;
    right.normal.y=ViewProjection.m24-ViewProjection.m21;
    right.normal.z=ViewProjection.m34-ViewProjection.m31;
    right.distance=ViewProjection.m44-ViewProjection.m41;
    right.Normalized();

    Plane& left = GetPlaneLeft();
    left.normal.x=ViewProjection.m14+ViewProjection.m11;
    left.normal.y=ViewProjection.m24+ViewProjection.m21;
    left.normal.z=ViewProjection.m34+ViewProjection.m31;
    left.distance=ViewProjection.m44+ViewProjection.m41;
    left.Normalized();

    Plane& top = GetPlaneTop();
    top.normal.x=ViewProjection.m14-ViewProjection.m12;
    top.normal.y=ViewProjection.m24-ViewProjection.m22;
    top.normal.z=ViewProjection.m34-ViewProjection.m32;
    top.distance=ViewProjection.m44-ViewProjection.m42;
    top.Normalized();

    Plane& bottom = GetPlaneBottom();
    bottom.normal.x=ViewProjection.m14+ViewProjection.m12;
    bottom.normal.y=ViewProjection.m24+ViewProjection.m22;
    bottom.normal.z=ViewProjection.m34+ViewProjection.m32;
    bottom.distance=ViewProjection.m44+ViewProjection.m42;
    bottom.Normalized();

    Plane& front = GetPlaneFront();
    front.normal.x=ViewProjection.m14-ViewProjection.m13;
    front.normal.y=ViewProjection.m24-ViewProjection.m23;
    front.normal.z=ViewProjection.m34-ViewProjection.m33;
    front.distance=ViewProjection.m44-ViewProjection.m43;
    front.Normalized();

    Plane& back = GetPlaneBack();
    back.normal.x=ViewProjection.m14+ViewProjection.m13;
    back.normal.y=ViewProjection.m24+ViewProjection.m23;
    back.normal.z=ViewProjection.m34+ViewProjection.m33;
    back.distance=ViewProjection.m44+ViewProjection.m43;
    back.Normalized();




#5153593 Vertex buffers in DirectX 11

Posted by BornToCode on 14 May 2014 - 10:18 AM

Why don't you create an orthographic matrix using the screen resolution for your width and height. That way you can specify your coordinate directly in pixel coordinate.




#5153592 clear only partial bits of stencil buffer

Posted by BornToCode on 14 May 2014 - 10:16 AM

The entire stencil must be cleared at once. you cannot just clear a portion of it.




#5151014 Per-pixel displacement mapping GLSL

Posted by BornToCode on 02 May 2014 - 05:09 PM

 try flipping the binormal and see if it has any effects.




#5108896 DirectX11 Swap Chain Format

Posted by BornToCode on 13 November 2013 - 12:10 AM

 


So what about vista or windows 7 with directx 10/11 where flip sequential might not be available or using say discard as the presentation model?

It will use an additional BitBlit() to copy the DX surface to an intermediate DWM surface, which is slower. But same principal holds - if the swap-chain format matches the screen-format, this operation will be faster. When using the BitBlit mode, you also have more options for swap-chain formats.

 

This is not completely true for windows 7. As long your backbuffer matches your front buffer and you have your swap chain set to full screen. It will not bitblt, but swap the backbuffer with the front. The only time it bitblt is when the swapchain is in window mode or when the swap chain back buffer does not match the front buffer width/heigh and format.




#5108407 Fullscreen Direct3D 11 multi device (gpu), multi swap chain per device rendering

Posted by BornToCode on 10 November 2013 - 11:41 PM

One way you can handle is to called ChangeDisplayModeSettingEx to change the monitor screen resolution. Then create a bordeless window that is the same size that you have you display setting set to. This will simulate exactly what directx does when you go fullscreen. At my job we have to handle 4 monitors in full screen and that is how i did it.


#5099647 interpolating scalar instead of vector

Posted by BornToCode on 08 October 2013 - 11:54 AM

If you go down that route then it will interpolate across vertices instead of pixels. That basically means all the pixels across vertex bounds will have the same value.




#5098118 Improving Graphics Scene

Posted by BornToCode on 01 October 2013 - 01:11 PM

There are alot of things that can be done in order to increase perfomance. The beast optimization is not draw at all :). What i basically mean by that the less you draw the better. A way to handle that is to use a Scene partition algorithm, and depending on the type of game there are many out there you can choose from. Another thing you can look into is LOD(Level of detail), objects closer to the camera are drawned at full detail while things in the distance are drawned with lower amount of details. The same concept can be applied to textures in the case of mipmapping. That is just some of the few things you can do. Also make sure you use the correct data structure for what you are trying to do.

Hope that kind of give you an idea. Happy Coding :)




#5079680 API Wars horror - Will it matter?

Posted by BornToCode on 22 July 2013 - 04:06 PM

Most of the api are the same but they do have some difference for example there is no such thing as Pixel Buffer objects in DirectX. Just wanted to throw my two cent in there. But at the end of the day if you want to write GL api that looks very similar to DirectX11 it is not impossible. As this is something i am currently doing right now.




#5076025 How to make a map editor with cubes

Posted by BornToCode on 07 July 2013 - 09:21 PM

Build the editor into the engine, using the same rendering code for gameplay and editing, as well as the code that loads/saves maps.

Do not build the editor into the engine, Use the engine as the back end for the editor.




#5075506 How to make a map editor with cubes

Posted by BornToCode on 05 July 2013 - 12:16 PM

You know the grid size. So all you need to save the infromation for each tile of the grid that is filled. I do not see what the confusion is.




#5075318 I can't see anything?

Posted by BornToCode on 04 July 2013 - 03:04 PM

Run it through pix if you are on windows 7 or use the built in graphics debugger in VS2012 Pro or above to debug and see exactly what is getting set on the GPU side.




#5074018 HLSL5 tex2dproj equivalent?

Posted by BornToCode on 29 June 2013 - 05:49 PM

Can you do the projection yourself, by dividing each component by W. Then just use those values into texture.Sample for the UV coordinate.




#5072121 Using D3D9 Functions and, HLSL

Posted by BornToCode on 22 June 2013 - 07:52 PM

Another thing to know is that resource sharing across device is not possible. Resource on a IDirect3DDevice9 cannot be shared with ID3D11Device resources. The only thing you can do is copy between them.






PARTNERS