• 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
Michael Anthony Wion

Textured quads in DirectX10/11 [SlimDX]

4 posts in this topic

[u]Since my application will be rendering thousands of textured quads per frame[/u], I figured I might finally make more use of the GPU to preserve CPU speeds... So I've made the move up to the land of shaders and all the shiny new features of D3D10 and 11, so that I can truly put my graphics card to the test.
So far, I've been able to render a fullscreen quad using a triangle strip and a basic vertex & pixel shader... so naturally the next step would be to slap a texture on there. From my understanding, this would be the pixel shader's job, correct? You would pass texture data and UV coords to the pixel shader (instead of a color), and it would light the vertices based on the pixel colors of the texture data?

Anywho... after researching several tutorials (and poking at code in both C++, C# and VB), the only working examples of what I'm going for were found in unmanaged C++.
SlimDX aids me in the managed world, as it's mostly identical to unmanaged D3D. But I can't figure out the proper way to set up a resource chain capable of sending mutable texture info to the shader, and how to modify it's contents during each frame. The example I was porting used [i]BasicEffect[/i], [i]BasicTechnique[/i], and [i]GetVariableByName()->AsShaderResource[/i] to set it up, but the only managed examples I can find use [i]ShaderByteCodes [/i]instead.

Peek at this unmanaged tutorial see what I mean: [url="http://takinginitiative.net/2008/11/29/directx-10-tutorial-3-textures/"]http://takinginitiat...ial-3-textures/[/url]
With all these differences, I've stumbled into a "chicken or the egg" paradox, and I'm not sure where to go from here.

[b][u]TL;DR:[/u][/b]
Does anyone have a barebones example of setting up a resource chain to load and manipulate 2D texture info in an HLSL shader?
0

Share this post


Link to post
Share on other sites
How exactly are you trying to manipulate texture info, here. That's not usually something you'd need to do in the context of what you describe.

Unless, of course, you're trying to bind textures to the shader-- that's pretty straightforward. In the unmanaged world, give the PSSetShaderResources() method a look; you'll need to figure out the slot of the texture/buffer/whatever by examining the shader's reflection information.
0

Share this post


Link to post
Share on other sites
Oh sorry, I should've mentioned that this is for a managed project (SlimDX). I understand how it works in the unmanaged world, but not so much in C# and VB.
And yes I'm trying to assign a texture to a quad. In D3D8 this was simple, and didn't appear to be any different for D3D9, but now I'm trying to understand how to do it using shaders in D3D10 and D3D11 using a managed language. Moreover, I'm trying to understand how the textured quad can be manipulated in the shader model (things like scaling, transformations, and changing texture coordinates for sprite animations) from a managed language. It appears in C++ that these variables are manipulated more directly than what would be allowed in C# and VB, and if there's no good means of doing so without a great loss of CPU power than I don't see much point in even having managed D3D.
0

Share this post


Link to post
Share on other sites
In that case, looks like [url="http://slimdx.org/docs/#T_SlimDX_Direct3D11_PixelShaderWrapper"]this[/url] is what you're after, and [url="http://slimdx.org/docs/#M_SlimDX_Direct3D11_PixelShaderWrapper_SetShaderResource"]this[/url] method in particular. As mentioned, you're going to need to figure out the resource index (parameter #2) by looking at the shader reflection info, some information [url="http://www.gamedev.net/topic/617453-slimdx-shaderreflection/"]here[/url].

Constants are going to work in a very similar fashion, except you're going to be reflecting and setting constant buffers instead of shader resources. A good example of this would be offsets or scale values for a sprite card (though if you're atlasing/instancing it may be beneficial to send this in a vertex attribute stream for better batch efficiency) or any other time you want to send 'parameters' to the 'function' the shader(s) describe. Most of the actual mathy bits of that are going to take place in the shader anyways, you can freely refer to managed or unmanaged documentation and adapt the app-side function calls to your needs.
0

Share this post


Link to post
Share on other sites
Yeah I was afraid of that. Since speed and efficiency are my top priorities here, I've started porting the render loop into a C++/CLI library. No more SlimDX, just raw DX10.
This means loads of more work (especially in dealing with crossing native/managed boundaries), but better access and execution to whatever D3D objects need attention.
I was really hoping to get this done sooner, but I figured it would eventually come to this. Now the only real problem is dissecting the design so it works well in C# and VB, which I'll probably end up having to do more than once.

Thanks for the help.
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