Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 19 Feb 2006
Offline Last Active May 26 2016 02:25 PM

Posts I've Made

In Topic: Animated grid of quads UI Control

02 April 2016 - 07:49 AM

The closest I can find to the effect is SpringyStars but it's not quite what I'm after.


I have a grid of quads rendering and use linear interpolation to animate their translation/rotation/scaling every frame. So as far as animation goes that is already done and now I'm more interested in the application of an algorithm to imitate the effect in the first video.


I have stored in each quad an array of the neighbouring quads so I can calculate the distance and scaling of the quads around it. So if the "selected" quad is scaled I need the neighbouring quads to push away from it.


I guess it could be as simple as adding the distance * scaling of the selected quad to each neighbouring quad's translation. I would just like to see a working example if possible.

In Topic: Using two shaders at the same time

19 December 2013 - 12:47 PM

In this particular case I may have to sacrifice performance for convenience. My engine needs to be flexible enough to apply two separate shaders. What I need to know is if it's possible and then the actual code to do it.

The reason I can't mix the shaders is because I have 32 'effects' and 31 'transitions'. That would be 992 shaders to combine them.

Transitions only occur when two 'layouts' transition between each other. A 'layout' is a bunch of objects that could include a 3d model, some quads, some text, a video etc. There can be two layouts in memory at one time. One is 'current' and the other is 'next'. The 'next' layout is only used when transitioning from one layout to the next. The 'current' layout is rendered to render target 0 (m_screenTexture[0].DXTexture) and 'next' is rendered to render target 1 (m_screenTexture[1].DXTexture). As you can see in the code these are assigned to the transition shader as Input1 / Input2. For the 'effect' shader render target 0 (m_screenTexture[0].DXTexture) is assigned to SourceTexture in the shader.

The transitions work great but for the sake of flexibility I need to be able to apply an 'effect' during this transition process.

In Topic: Setting members in VB.NET without constructors

13 November 2013 - 05:41 AM

That's great thanks. Never seen curly brackets used like that in VB.NET before. Is this feature only available to Visual Studio 9 (2008) and higher?

In Topic: Array.Sort performance issue

28 October 2013 - 05:20 PM

Here is the new CompareTo method


public int CompareTo(RenderObject other)
    if (this.Layer != other.Layer)
        return this.Layer.CompareTo(other.Layer);

    if (this.Translation.Z != other.Translation.Z)
        return this.Translation.Z.CompareTo(other.Translation.Z);

    for (int i = 0; i < TEXTURE_ARRAY_COUNT; i++)
        if (this.TextureArray[i] == null)
            if (other.TextureArray[i] != null)
                return -1;
        else if (other.TextureArray[i] == null)
            return 1;
        else if (this.TextureArray[i].Id != other.TextureArray[i].Id)
            return this.TextureArray[i].Id.CompareTo(other.TextureArray[i].Id);

    if (this.BlendMode != other.BlendMode)
        return this.BlendMode.CompareTo(other.BlendMode);

    if (this.ScissorRect != other.ScissorRect)
        return (this.ScissorRect.GetHashCode() - other.ScissorRect.GetHashCode());

    return this.Index.CompareTo(other.Index);


Unfortunately the performance has not improved.

In Topic: Array.Sort performance issue

28 October 2013 - 04:29 PM

I understand about StopWatch and how to profile performance. I did state in my original post that having only one evaluation in CompareTo would not effect performance. The frame rate drop is not a perfect measurement but it's enough to see there is a substantial performance hit. So I don't need to profile to know where the issue lies. At this stage it's important that my engine maintains a solid 60 FPS.

I think the best thing to do is break the render object list up into separate lists for each layer as suggested.

Another thing I could try would be to use a different sorting algorithm. Array.Sort uses a QuickSort and does not maintain the original list order (unstable). Any suggestions there would be appreciated.

phil_t and Eck make some good points about some of issues with comparisons I've made. Layer and Translation.Z are just floats so there is no reference comparison there. But you're right about the Texture's and null values and I did make a mistake with the BlendMode comparison returning 0 instead of -1. For the ScissorRect I've changed it to compare using Rect.GetHashCode().

Thanks to everyone for all the suggestions.