• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
jdub

[D3D11] My quad won't draw.. not sure why

4 posts in this topic

I am trying to draw a simple textured, 2D bitmap on the screen.  Looking at it through PIX, the quad makes it through the vertex and pixel shader stages but doesn't end up drawn on the final window.  I thought it might be that I hadn't hooked in a render target, but I have.  I modified the code for the pixel shader to just draw the quad with one solid color because I thought that maybe it had something to do with my texture loading/passing to the shader.  Now, I'm not really sure what else could be going on here.

 

Here's the shader code:

 

/////////////////////////////////////////////////
// GLOBALS
/////////////////////////////////////////////////
SamplerState SampleType;
Texture2D Texture;

cbuffer WorldBuffer
{
	matrix World;	
};

cbuffer ProjectionBuffer
{
	matrix Projection;
};

cbuffer ViewBuffer
{
	matrix View;
};

cbuffer LightConstantBuffer
{
	float3 LightDir;
	float4 LightColor;
	float padding;
};

struct VS_INPUT
{
	float4 Position : POSITION;
	float2 TexCoord : TEXCOORD0;
	float3 Normal : NORMAL; //world space normal
};

struct PS_INPUT
{
	float4 Position : SV_POSITION;
	float2 TexCoord : TEXCOORD0;
	float3 Normal : NORMAL; //view-space normal
};

PS_INPUT VShader(VS_INPUT input) 
{
	PS_INPUT output = (PS_INPUT)0;
	
	input.Position.w = 1.0f;

	output.Position = input.Position;
	output.TexCoord = input.TexCoord;	
	
	return output;
}

float4 PShader(PS_INPUT input) : SV_TARGET
{
	return float4(1.0f,1.0f,.5f,1.0f);
} 


Here's my initiallization code for directX:

public D3DPipeline(RenderForm renderForm)
        {
            SwapChainDescription swapChainDescription = new SwapChainDescription()
            {
                BufferCount = 1,
                Usage = Usage.RenderTargetOutput,
                OutputHandle = renderForm.Handle,
                IsWindowed = true,
                ModeDescription = new ModeDescription(1600, 900, new Rational(60, 1), Format.R8G8B8A8_UNorm),
                SampleDescription = new SampleDescription(1, 0),
                Flags = SwapChainFlags.AllowModeSwitch,
                SwapEffect = SwapEffect.Discard
            };

            SlimDX.Direct3D11.Device device;
            Result result = SlimDX.Direct3D11.Device.CreateWithSwapChain(
                DriverType.Hardware,
                DeviceCreationFlags.Debug,
                new FeatureLevel[] { FeatureLevel.Level_11_0 },
                swapChainDescription,
                out device,
                out this.swapChain);

            this.Device = device;

            if (!result.IsSuccess)
            {
                throw new Exception();
            }

            if (!this.Device.Factory.SetWindowAssociation(renderForm.Handle, WindowAssociationFlags.None).IsSuccess)
            {
                throw new Exception();
            }

            this.Context = Device.ImmediateContext;
            this.viewport = new Viewport(0.0f, 0.0f, 1600, 900, 0.0f, 1.0f);

            Resource11 renderTargetTexture = Resource11.FromSwapChain<Texture2D>(this.swapChain, 0);
            this.renderTargetView = new RenderTargetView(this.Device, renderTargetTexture);
            this.Context.OutputMerger.SetTargets(this.renderTargetView);

            this.Context.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList;

            SamplerDescription sampleDescr = new SamplerDescription();
            sampleDescr.Filter = Filter.MinMagMipLinear;
            sampleDescr.AddressU = TextureAddressMode.Wrap;
            sampleDescr.AddressV = TextureAddressMode.Wrap;
            sampleDescr.AddressW = TextureAddressMode.Wrap;
            sampleDescr.MipLodBias = 0.0f;
            sampleDescr.MaximumAnisotropy = 1;
            sampleDescr.ComparisonFunction = Comparison.Always;
            sampleDescr.BorderColor = Color.White;
            sampleDescr.MinimumLod = 0;
            sampleDescr.MaximumLod = float.MaxValue;

            this.samplerState = SamplerState.FromDescription(this.Device, sampleDescr);

            this.Context.PixelShader.SetSampler(this.samplerState, 0);

            this.Context.Rasterizer.SetViewports(new Viewport{ 
                Height = renderForm.Height,
                Width = renderForm.Width,
                MaxZ = 1.0f,
                MinZ = 0.0f,
                X = 0.0f,
                Y = 0.0f
            });

            Vector3 viewPos = new Vector3(0.0f, 5.0f, 0.0f);
            Vector3 viewTarget = new Vector3(2.0f, 5.0f, 2.0f);
            Vector3 viewUp = new Vector3(0.0f, 1.0f, 0.0f);

            this.view = Matrix.LookAtLH(viewPos, viewTarget, viewUp);
            this.setView(view);

            this.projection = Matrix.PerspectiveFovLH(0.523598776f, 1600 / 900, 1.0f, 1000.0f);
            this.setProjection(projection);
            
            //set the rasterizer
            RasterizerStateDescription newStateDescr = new RasterizerStateDescription();
            newStateDescr.CullMode = CullMode.None;
            newStateDescr.FillMode = FillMode.Solid;
            
            RasterizerState newState = RasterizerState.FromDescription(this.Device, newStateDescr);
            this.Context.Rasterizer.State = newState;
        }

public void InitShaders(ShaderBytecode vShaderBytecode, ShaderBytecode pShaderBytecode)
        {
            this.vShader = new VertexShader(this.Device, vShaderBytecode);
            this.pShader = new PixelShader(this.Device, pShaderBytecode);

            this.Context.PixelShader.Set(pShader);
            this.Context.VertexShader.Set(vShader);

            InputElement[] inputElements = 
            { 
                new InputElement("POSITION", 0, Format.R32G32B32_Float, 0), 
                new InputElement("TEXCOORD", 0, Format.R32G32_Float,0),
                new InputElement("NORMAL", 0, Format.R32G32B32_Float, 0) 
            };

            this.Context.InputAssembler.InputLayout = new InputLayout(this.Device, ShaderSignature.GetInputSignature(vShaderBytecode), inputElements);
        } 

Here's the relevant rendering code:

            context.PixelShader.SetShaderResource(this.textureRsrcView, 0);

            context.InputAssembler.SetVertexBuffers(0, this.vBufferBinding);
            context.InputAssembler.SetIndexBuffer(this.iBuffer, SlimDX.DXGI.Format.R16_UInt, 0);
            context.DrawIndexed(6, 0, 0); 

Sorry guys.  I know it's a lot of code but I'm stumped here and could really appreciate some help.

 

THanks!

 

0

Share this post


Link to post
Share on other sites

Try turning off backface culling in the rasterizer in case you're winding the vertices of your quad backwards.

 

            var rsd = new RasterizerStateDescription()
            {
                CullMode = CullMode.None,
                DepthBias = 0,
                DepthBiasClamp = 0.0f,
                FillMode = FillMode.Solid,
                IsAntialiasedLineEnabled = false,
                IsDepthClipEnabled = false,
                IsFrontCounterclockwise = false,
                IsMultisampleEnabled = true,
                IsScissorEnabled = false,
                SlopeScaledDepthBias = 0.0f
            };

            RasterizerState rs = RasterizerState.FromDescription(device, rsd);
            context.Rasterizer.State = rs;
0

Share this post


Link to post
Share on other sites

Don't I do that with this line?

 

RasterizerStateDescription newStateDescr = new RasterizerStateDescription();
            newStateDescr.CullMode = CullMode.None;
            newStateDescr.FillMode = FillMode.Solid;
0

Share this post


Link to post
Share on other sites

Don't I do that with this line?

 

RasterizerStateDescription newStateDescr = new RasterizerStateDescription();
            newStateDescr.CullMode = CullMode.None;
            newStateDescr.FillMode = FillMode.Solid;

 

Doh, I didn't see that in your code.

0

Share this post


Link to post
Share on other sites

Try to set the z element of each quad vertex  to 0.1f or higher instead of 0.

I had same problem with ati graphic card and this solution worked for me.

smile.png

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0