Jump to content

  • Log In with Google      Sign In   
  • Create Account

Calling all IT Pros from Canada and Australia.. we need your help! Support our site by taking a quick sponsored surveyand win a chance at a $50 Amazon gift card. Click here to get started!


Gavin Williams

Member Since 04 Dec 2010
Offline Last Active Aug 23 2015 08:12 AM

#5248192 Moving from Xna4 to MonoGame 3.4

Posted by Gavin Williams on 22 August 2015 - 03:25 AM

1. I haven't used XNA for a long time, but I worked with mono-game a while back and it looks almost identical to XNA as i remember. There is the namespace Microsoft.Xna.Framework.Content and it's all loaded as you would expect with content.Load<type>(). I don't know about custom content, I would guess that it's exactly the same situation as with XNA.

2.XNA and monogame provide their own input system : Microsoft.Xna.Framework.Input, which is what i used. But if you prefer to consume windows messages, then it should definitely work ok with monogame. XNA to monogame is pretty much a direct mapping.




#5246634 DirectX Camera Jitter

Posted by Gavin Williams on 14 August 2015 - 10:32 PM

You shouldn't be scaling mouse movement by the time delta. Mouse movement should have a direct mapping to rotation. These lines:

 

XMMATRIX xRotation = XMMatrixRotationY(((float)-deltaX  * (float)timer.Delta()));
XMMATRIX yRotation = XMMatrixRotationX(((float)-deltaY * (float)timer.Delta()));

This is wrong. You're camera movement should be tied to the frame-time just like all movement. Otherwize, a 30 fps game would result in a more sluggish camera rotation compared to when it was running at 60 fps. 

In any case, it doesn't explain the issue.

 

Edit : Unless of course, you're not taking input snapshots per frame, but rather updating input at a frame-independent rate, such as by directly pushing windows msgs into your engine.




#5233478 Texturing a Minecraft-style cube

Posted by Gavin Williams on 07 June 2015 - 10:18 PM

An alternative to using a texture atlas is to use a texture array to store all your cube faces. In order to use the texture array in your shader you'll include an additional texture index in your vertices, so all vertices on one face will share the same texture index.
 

Texture arrays don't have the edge issues that an atlas can have. I've found arrays useful for cube face textures, walls and tile based terrain, as well as for sprites (where the sprites are the same size).




#5200693 Still a little confused about changing structs

Posted by Gavin Williams on 29 December 2014 - 06:48 PM

Hi,

 

I'm still a bit confused about structs being copied when they are modified. I have a ray class, with two vectors ...

 

    public class Ray
    {
        public Vector3 Origin { get; set; }
        public Vector3 Direction { get; set; }

        public Ray(Vector3 origin, Vector3 direction)
        {
            Origin = origin;

            direction.Normalize();
            Direction = direction;

            /* this doesn't work*/
            //Direction = direction;
            //Direction.Normalize();
        }

What I don't get is why direction.Normalize() modifies direction, but Direction.Normalize() doesn't modify Direction.

Edit : My running theory, is that after Normalize is called, both direction and Direction are copies local to the constructor, and in the first case, it is actually assigned to the global, but in the second, it is left unused.




#5197439 Game Entity object graph serialization

Posted by Gavin Williams on 10 December 2014 - 01:27 PM

Binary is simple and effective for saving game-state.




#5197437 Want to become a Computer Scientist

Posted by Gavin Williams on 10 December 2014 - 01:24 PM

@Olof Hedman - no but it's damn hard. Most people who start a degree will not reach master or doctorate level. It does take unusual commitment.




#5196427 Please give me some lectures for directx programming

Posted by Gavin Williams on 05 December 2014 - 06:39 AM

There are a couple of books you could get ...

Introduction to 3D Game Programming with DirectX 11 - Frank D. Luna

Practical Rendering and Computation with Direct 3D 11 - Jason Z. Matt P. Jack H.

There is also a commonly referenced website:

 

http://www.rastertek.com/

***********************************************************

Direct X is a pretty huge topic, just asking for 'advice' on using it is almost like asking for advice on programming. What do you want people to say?

Here's some advice ... it's really great, very interesting, powerful, but difficult at times. You will need to spend A LOT of time learning it, and much more mastering it. Read Books, read websites & blogs on rendering topics and techniques, look at sample code. Start with creating your device, then render a triangle, then a cube, then get your cube to rotate. Texture it. Add lights. Learn High Level Shader Language - that's a must! HLSL is awsome but it can be difficult to debug and get working. Learn to use Graphics Diagnostics in VS. Beyond that any advice is going to start getting pretty specific. Good luck.




#5195650 how to create gui buttons with DirectX 11?

Posted by Gavin Williams on 01 December 2014 - 02:04 AM

If you have SpriteBatch available, you can use that ...

            if (srvNormal == null) // then render a simple text button
            {
                // set viewport - sprite batch uses full viewport
                Viewport windowViewport = new Viewport(0, 0, UI.Window.ClientSize.Width, UI.Window.ClientSize.Height);
                UI.Window.Device3D.ImmediateContext.Rasterizer.SetViewport(windowViewport);

                // render background
                if (State == States.Down)
                {
                    UserInterface.SpriteBatch.Begin();
                    SpriteBatchDraw.DrawSolidRectangleAA(new RectangleF(absRegion.X + 2, absRegion.Y + 2, absRegion.Width - 4, absRegion.Height - 4), Color.White);
                    SpriteBatchDraw.DrawSolidRectangleAA(new RectangleF(absRegion.X + 5, absRegion.Y + 5, absRegion.Width - 10, absRegion.Height - 10), Color.Black);
                    UserInterface.SpriteBatch.End();

                     // cost [3949-5037 ticks]
                    RenderTarget renderTarget2D = UI.Window.RenderTarget2d;
                    renderTarget2D.BeginDraw();
                    renderTarget2D.Transform = Matrix.Scaling((absRegion.Width - 4) / (float)absRegion.Width) * Matrix.Translation(2, 2, 0);
                    renderTarget2D.DrawText(Text, TextFormat, new RectangleF(absRegion.X, absRegion.Y, absRegion.Width, absRegion.Height), Brush);
                    renderTarget2D.EndDraw();
                }

If you don't have a SpriteBatch facility, then you're right, you can use screen co-ordinates.




#5195629 I am all prepared to get into game development, how do I start then?

Posted by Gavin Williams on 30 November 2014 - 11:43 PM

 

They only support the respective programming language in their name,

That used to be true, as of.. think its 2013, maybe 2012, either way they changed it. One install for all three languages.

are generally limited in their functionality and not allowed for use in commercial projects

They are almost completely fully featured, there are only a few things that you can't do with express that you can with the paid versions. Also I don't know where you read that but as far as I know you can use them for commercial projects just fine.

As for the OP, I highly recommend Visual studio 2013 express edition(desktop, since I doubt you want to write those silly windows store apps.)

 

 

In regards to your suggestion that store apps are silly, I don't think this is good advice at all to give someone starting today. They will take what you are saying to heart, and it's bad information to be bandying around. WinRT, with which store apps are built with is being lined up as the successor to Win32. As of next year, with the coming of Windows 10, WinRT apps will have equal billing on the desktop by the expansion of their windowing options, ie non-docked / snapped & desktop integration. WinRT is not a silly little toy cooked up to appease the mobile crowd only. Yes, it targets mobile very well, but the WinRT / XAML stack and the language projections provide a powerful system that will be just as effective for desktop application in the next generation of Windows. Arguably, it will be preferable to using traditional technologies as it is fleshed out.

I have worked with WinRT a little, and I completely believe that there will come a time, when it doesn't make sense to use Win32 and the traditional desktop model any more.

And with the availability of Community Edition, I would choose that over express from now on.




#5194523 real time reflections from arbitory surfaces.

Posted by Gavin Williams on 24 November 2014 - 07:36 PM

You need to ask a question please.




#5164924 Exporting non-indexed vertex data from 3DSMAx

Posted by Gavin Williams on 05 July 2014 - 01:33 PM

I think the answer is to write a custom exporter using MAXScript, which I'm trying to do now.




#5150015 limit on the how many bytes that can be passed across shaders

Posted by Gavin Williams on 27 April 2014 - 09:12 PM

Have a look here for the limits:

 

http://msdn.microsoft.com/en-us/library/windows/desktop/ff819065%28v=vs.85%29.aspx

 

So, the register limit looks to be 32 for shader inputs/outputs. You are creating 4x3x3+2 = 38 registers. So even with your a 'fix' for the alignment / padding, you will still be breaching the register limit. You will need another solution.

 

Edit: I agree with spazzarama below. I took a second look at it.




#5149750 ReportLiveObjects() isn't giving me enough information.

Posted by Gavin Williams on 26 April 2014 - 07:17 PM

Ok, so something I have never realized, is that a second (debug) device needs to be created in order to use reporting.

device3DDebug = new DeviceDebug(Device3D);

Then:

device3DDebug.ReportLiveDeviceObjects(ReportingLevel.Detail);

Gives the proper output. Thanks Mona2000

 

Edit: Some useful references

 

http://blogs.msdn.com/b/chuckw/archive/2012/11/30/direct3d-sdk-debug-layer-tricks.aspx

http://seanmiddleditch.com/journal/2014/02/direct3d-11-debug-api-tricks/




#5144921 change 1D addres to 2D addres

Posted by Gavin Williams on 07 April 2014 - 12:14 AM

Do you expect someone to have a faster method ? Do you have a performance issue with this code ?
 

If you are stressing over optimizations with code like this, I'll be surprised if you ever get anything done, really!

Just write your code, there is nothing wrong with your code unless you know there is something wrong. Especially this code, it's about as simple as it gets. There are a couple of ways to do it, but they boil down to the same thing, a few ops, which is totally not worth worrying about.

Come back when you have a function that's taking 10,000 ticks to complete, then we can talk about optimization.




#5127720 AMD's Mantle API

Posted by Gavin Williams on 31 January 2014 - 07:24 AM

Wow, the first I heard of Mantle was seeing an anouncement today that Battlefield 4 supports it as an alternative to DX with the 14.1 beta drivers. Here's a link to the BF4 page with performance comparisions ..

 

http://battlelog.battlefield.com/bf4/news/view/bf4-mantle-live/






PARTNERS