Advertisement Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

607 Good

About Headkaze

  • Rank
    Advanced Member
  1. Headkaze

    Animated grid of quads UI Control

    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.
  2. I'm looking for a tutorial or example on how to create a grid of quads that animates based on the selected item. The selected item scales pushing the items around it away.   A video of the effect (at 19 seconds in):
  3. I have a project I'm working on that has folders relative to the "Release" folder that my application requires. This means I am constantly compiling in Release mode even during debugging.   The issue is I want to be able to toggle debug output on and off.   What should I do to deal with this situation? Should I set the Debug and Release output folders the same directory and use Debug when I want Debug output? Or should I use the Release mode and setup a #define for toggling Debug output?
  4. Headkaze

    Using two shaders at the same time

    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.
  5. I need to be able combine two different types of pixel shaders. One is for applying an effect and the other is for a transition. Here is an example transition pixel shader float Progress; texture Input1; sampler Input1Sampler = sampler_state { Texture = <Input1>; }; texture Input2; sampler Input2Sampler = sampler_state { Texture = <Input2>; }; float4 Fade(float2 uv) { float4 c1 = tex2D(Input1Sampler, uv); float4 c2 = tex2D(Input2Sampler, uv); return (lerp(c1, c2, Progress)); } float4 main(float2 uv : TEXCOORD) : COLOR { return (Fade(uv)); } technique FadeTransition { pass FadeTransition { VertexShader = null; PixelShader = compile ps_2_0 main(); } } Here is how I apply it m_transitionEffect.Technique = m_transitionEffect.GetTechnique(0); m_transitionEffect.SetTexture("Input1", m_screenTexture[0].DXTexture); m_transitionEffect.SetTexture("Input2", m_screenTexture[1].DXTexture); m_transitionEffect.SetValue<float>("Progress", m_progress); m_transitionEffect.CommitChanges(); m_transitionEffect.Begin(); m_transitionEffect.BeginPass(0); // Render stuff m_transitionEffect.EndPass(); m_transitionEffect.End();Here is an example effect pixel shader texture SourceTexture; sampler SourceTextureSampler = sampler_state { Texture = <SourceTexture>; }; float4 InvertColorFunc(float2 tex : TEXCOORD) : COLOR { float4 texcolor = tex2D(SourceTextureSampler, tex); float4 newcolor = 1.0f - texcolor; return (float4(newcolor.rgb, texcolor.a)); } technique InvertColor { pass InvertColor { VertexShader = null; PixelShader = compile ps_2_0 InvertColorFunc(); } }Here is how I apply it.   m_effectEffect.Technique = m_effectEffect.GetTechnique(0); m_effectEffect.SetTexture("SourceTexture", m_screenTexture[0].DXTexture); m_effectEffect.CommitChanges(); m_effectEffect.Begin(); m_effectEffect.BeginPass(0); // Render stuff m_effectEffect.EndPass(); m_effectEffect.End();How can I combine these two shaders and keep them in separate files? I have tried nesting the two together but it does not seem to work.
  6. 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?
  7. In C# I can do the following: MyClass myObject = new MyClass() { Member1 = value1, Member2 = value2, Member3 = value3 }; Is there an equivalent in VB.NET?
  8. Headkaze

    Array.Sort performance issue

    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.
  9. Headkaze

    Array.Sort performance issue

    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.
  10. Headkaze

    Array.Sort performance issue

    It's running at vsync 60 FPS so it is a significant performance hit. I have never tried using a LinkedList<T>. If it would be a significant benefit in this case I could give it a try. Not really.. the 1000 objects I refer to is all text (dynamic).
  11. Headkaze

    Array.Sort performance issue

    It's about minimizing state changes but also rendering order. For example you can place an object on a particular layer. The layer order takes precedence over its z order, and the z order takes precedence over the texture, etc. If you can shed some light on a more practical way of doing it, I'd like to hear it. But maintaing the order of the objects is important. BTW I never had any performance issues using this technique in my C++ engine.
  12. You could have a message only window that receives all raw input (using RIDEV_INPUTSINK) and passes it on to the other windows.
  13. I am working on a C#/SlimDX rendering engine. I noticed a performance issue after having around 1000 rendered objects in a List<T> and sorting them every frame. I need to sort these objects so they render in the appropriate order. I'm actually getting a significant frame rate drop of about 5 FPS.   The problem is not so much the sorting per se but that I need to perform multiple levels of sorting based on members in the objects such as the layer, texture and so on. Finally the objects need to sort based on the original order they were added to the List so I have an index member for that.   Here is the sorting code (no idea why the indentation isn't working here) [source]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);   if (this.TextureArray[0] != null && other.TextureArray[0] != null) if (this.TextureArray[0].Id != other.TextureArray[0].Id) return this.TextureArray[0].Id.CompareTo(other.TextureArray[0].Id);   if (this.TextureArray[1] != null && other.TextureArray[1] != null) if (this.TextureArray[1].Id != other.TextureArray[1].Id) return this.TextureArray[1].Id.CompareTo(other.TextureArray[1].Id);   if (this.TextureArray[2] != null && other.TextureArray[2] != null) if (this.TextureArray[2].Id != other.TextureArray[2].Id) return this.TextureArray[2].Id.CompareTo(other.TextureArray[2].Id);   if (this.TextureArray[3] != null && other.TextureArray[3] != null) if (this.TextureArray[3].Id != other.TextureArray[3].Id) return this.TextureArray[3].Id.CompareTo(other.TextureArray[3].Id);   if (this.BlendMode != other.BlendMode) return (this.BlendMode != other.BlendMode ? 1 : 0);   if (this.ScissorRect != other.ScissorRect) return (this.ScissorRect != other.ScissorRect ? 1 : 0);   return this.Index.CompareTo(other.Index); }[/source]   As you can see I've implemented IComparable<T> and call Array.Sort every frame. Unfortunately it's causing this performance issue. Now if I change it to only sort based on index, for example, then there is no problem. So it's the fact I need multiple parameters to sort the object list that is slowing things down.   On a final note I have to be able to sort every frame because some render objects (like text) are dynamic and are added/removed every frame. I actually had a massive 15 FPS drop when I used a loop to remove the objects but have since improve by using List.AddRange to add text character objects and List.RemoveAll to remove them. So now I only have 5 FPS drop that is due to the sorting.   I do not have Linq available to me (using .NET 2.0) so I'd like to hear some ideas on how I can improve the performance of this necessary  sorting.
  14. I want to create a texture of D3DFMT_A8R8G8B8 format. If I already know the width and height is there any way I can predict the pitch before calling CreateTexture?
  15. Headkaze

    DX9 Getting a Video on Texture

    I'd recommend you check out the Texture3D9 DirectShow Sample. You could write a C++/CLI dll to wrap the C++ code with a .NET interface. From that you can just 'new' it like a regular object.
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!