Jump to content

  • Log In with Google      Sign In   
  • Create Account

hawksprite

Member Since 18 Mar 2012
Offline Last Active Jan 11 2013 01:18 AM

Topics I've Started

FFT Water Shaders

08 January 2013 - 09:20 PM

So I've been trying to read up on it and I've googled around all day with no success.

 

I just can't figure out what i'm supposed to do for FFT.

 

I've been going off this paper:

 

http://www.limsater.com/files/ocean.pdf

 

But when I get to the equation for FFT there are variables like e that aren't referenced anywhere else, I have no idea what variables i'm supposed to pass to it.

 

Any help/insight would be greatly appreciated.

 

Thanks,

Justin.


Optimized Unity Compute Shader Particlers

25 December 2012 - 11:59 AM

So i've been toying with compute shader's to handle particle control and have run into an issue.  Everything is working fine so far but there's a bottleneck.  When I get up into the hundreds of thousands of particles it starts to lag, I haven't implemented other post processing effects on the particles such as blur and what have you so I'm concerned that there might be a serious performance problem later down the road.

 

I'll attach the script, shader, and compute shader.  I haven't done much optimization yet and i'm not sure how to properly use compute shaders so any advice you guys can give me would be greatly appreciated.  Thanks.

 

I just checked and it gets about 40-50 fps with 500k particles.

 

Part Controller:

http://pastebin.com/zJ9C5Ehx

 

Part Controller Shader

http://pastebin.com/GB24qttX

 

Part Controller Compute Shader

http://pastebin.com/zTw6rVAN


Terrain Design (Mostly Mountains)

23 December 2012 - 10:46 AM

I hope this is the right place to post this but anyways I've been having with terrain.  I've been working with unity and i'm trying to make a mountain.  My issue is making look like a mountain with the given height map tools.   It's driving me crazy because it seems no matter what I try it never looks anywhere even remotely close to other mountains.

 

I've come to realize that a large portion of the mountain is model based, however I'm not sure if it's one entire mountain or if theres a specific type of rock i'm supposed to somehow tile.

 

In the below image it appears that there's a base height map underneath, with some rock models sticking out of it.  What type of rock model would you use for this?

 

Sorry if some of this is a bit of a unorganized mess i've just been really baffled as to how to make these mountains look the way they do.  I've been trying with height map tools and a few rock for a couple days now and nothing I do looks anywhere near these mountains (I don't specifically mean skyrim I know that's a stretch but my mountains just look god awful).

 

Any help would be greatly appreciated. 

793559-1326946230.jpg


Textured object is not appearing

10 July 2012 - 12:08 PM

I've been trying to work on a method for drawing 2D objects, such as GUI's and what not in DX10 through SlimDX but they just won't appear.

Here's the class

[StructLayout(LayoutKind.Sequential)]
    struct Vertex
    {
        public Vector4 PositionRhw;
        public Vector4 Color;
        public Vector2 UV;
    }

    public static class TextureDrawer
    {
        public static Device TextureDevice;
    }

    public class T2D
    {
        public Texture2D Texture;

        Effect effect;
        EffectTechnique technique;
        EffectPass pass;
        InputLayout layout;
        Buffer vertices;
        List<Vector4> vertexPositions = new List<Vector4>();
        List<Vector2> textureCoords = new List<Vector2>();
        List<Vector4> vertexColors = new List<Vector4>();

        public T2D(string FileName, SlimDX.DXGI.SwapChain swapChain)
        {
            Texture = Texture2D.FromFile(TextureDrawer.TextureDevice, FileName);

            /*
            // Setup the spriteInstances
            spriteInstances = new SpriteInstance[1];
            spriteInstances[0] = new SpriteInstance(new ShaderResourceView(TextureDrawer.TextureDevice, Texture), new Vector2(10, 10), new Vector2(10, 10));
             */
            effect = Effect.FromFile(TextureDrawer.TextureDevice, "SimpleTexturedQuad.fx", "fx_4_0", SlimDX.D3DCompiler.ShaderFlags.None, SlimDX.D3DCompiler.EffectFlags.None);
            technique = effect.GetTechniqueByIndex(0);
            pass = technique.GetPassByIndex(0);

            EffectResourceVariable shaderTetxure = effect.GetVariableByName("texture2d").AsResource();
            ShaderResourceView textureView = new ShaderResourceView(TextureDrawer.TextureDevice, Texture);
            shaderTetxure.SetResource(textureView);

            InputElement[] inputElements = new InputElement[]
{
new InputElement("POSITION", 0, SlimDX.DXGI.Format.R32G32B32A32_Float, 0, 0),
new InputElement("COLOR", 0, SlimDX.DXGI.Format.R32G32B32A32_Float, 16, 0),
                        new InputElement("TEXCOORD", 0, SlimDX.DXGI.Format.R32G32_Float, 32, 0)
};

            layout = new InputLayout(TextureDrawer.TextureDevice, inputElements, pass.Description.Signature);

            vertexPositions.Add(new Vector4(-0.5f, -0.5f, 0.5f, 1.0f));
            vertexPositions.Add(new Vector4(-0.5f, 0.5f, 0.5f, 1.0f));
            vertexPositions.Add(new Vector4(0.5f, -0.5f, 0.5f, 1.0f));
            vertexPositions.Add(new Vector4(0.5f, 0.5f, 0.5f, 1.0f));

            textureCoords.Add(new Vector2(0.0f, 1.0f));
            textureCoords.Add(new Vector2(0.0f, 0.0f));
            textureCoords.Add(new Vector2(1.0f, 1.0f));
            textureCoords.Add(new Vector2(1.0f, 0.0f));

            vertexColors.Add(new Vector4(1.0f, 0.0f, 0.0f, 1.0f));
            vertexColors.Add(new Vector4(0.0f, 1.0f, 0.0f, 1.0f));
            vertexColors.Add(new Vector4(0.0f, 0.0f, 1.0f, 1.0f));
            vertexColors.Add(new Vector4(1.0f, 0.0f, 1.0f, 1.0f));

            DataStream stream = new DataStream(vertexPositions.Count * Marshal.SizeOf(typeof(Vertex)), true, true);
            for (int i = 0; i < vertexPositions.Count; i++)
            {
                stream.Write(vertexPositions[i]);
                stream.Write(vertexColors[i]);
                stream.Write(textureCoords[i]);
            }

            // Important: when specifying initial buffer data like this, the buffer will
            // read from the current DataStream position; we must rewind the stream to 
            // the start of the data we just wrote.
            stream.Position = 0;

            BufferDescription bufferDescription = new BufferDescription();
            bufferDescription.BindFlags = BindFlags.VertexBuffer;
            bufferDescription.CpuAccessFlags = CpuAccessFlags.None;
            bufferDescription.OptionFlags = ResourceOptionFlags.None;
            bufferDescription.SizeInBytes = vertexPositions.Count * Marshal.SizeOf(typeof(Vertex));
            bufferDescription.Usage = ResourceUsage.Default;

            vertices = new Buffer(TextureDrawer.TextureDevice, stream, bufferDescription);

            stream.Close();
        }

        public void Draw()
        {
            TextureDrawer.TextureDevice.InputAssembler.SetInputLayout(layout);
            TextureDrawer.TextureDevice.InputAssembler.SetPrimitiveTopology(PrimitiveTopology.TriangleStrip);
            TextureDrawer.TextureDevice.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(vertices, Marshal.SizeOf(typeof(Vertex)), 0));

            for (int p = 0; p < technique.Description.PassCount; p++)
            {
                pass.Apply();

                TextureDrawer.TextureDevice.Draw(vertexPositions.Count, 0);
            }
        }
    }

This is my second day working with SlimDX so I don't know as much as I'd like and it's probably something simple.

Shader code

Texture2D texture2d;

matrix worldMatrix;
matrix viewMatrix;
matrix projectionMatrix;


SamplerState linearSampler
{
    Filter = MIN_MAG_MIP_LINEAR;
    AddressU = Wrap;
    AddressV = Wrap;
};

struct VS_IN
{
float4 position : POSITION;
float4 color : COLOR;
float2 UV: TEXCOORD0;
};

struct PS_IN
{
float4 position : SV_POSITION;
float4 color : COLOR;
float2 UV: TEXCOORD0;
};


PS_IN VS( VS_IN vertexShaderIn )
{
PS_IN vertexShaderOut = (PS_IN)0;

vertexShaderOut.position = vertexShaderIn.position;
vertexShaderOut.color = vertexShaderIn.color;
vertexShaderOut.UV = vertexShaderIn.UV;

vertexShaderOut.position = mul(vertexShaderIn.position, worldMatrix);
vertexShaderOut.position = mul(vertexShaderOut.position, viewMatrix);
vertexShaderOut.position = mul(vertexShaderOut.position, projectionMatrix);

return vertexShaderOut;
}

float4 PS( PS_IN pixelShaderIn ) : SV_Target
{
    float4 finalColor = texture2d.Sample( linearSampler, pixelShaderIn.UV );
finalColor = float4(1,1,1,1);
return finalColor; 
}

technique10 Render
{
pass P0
{
SetGeometryShader( 0 );
SetVertexShader( CompileShader( vs_4_0, VS() ) );
SetPixelShader( CompileShader( ps_4_0, PS() ) );
}
}

SlimDX With Direct2D and Direct3D11

09 July 2012 - 05:32 PM

So i'm learning SlimDX in C# and have come across a problem.

The main window was being rendered in DX 11 and is working fine, but then I decided to write a HUD class that would use Direct2D.

However when everything is rendered it just rapidly flickers between what Direct2D is rendering and the Direct X 11 window. Is there something i'm supposed to be doing with the rendering targets to meld these together?

PARTNERS