• 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
James Nickerson

Phantom previous texture exists behind updated texture, when sampled

1 post in this topic

My inexperience with DirectX is certainly at fault here, but after several days I'm still mystified by this undesired behavior in my relatively simple 2D application:

Each time I render, I loop through several textures and draw them in a back-to-front order by, for each of them:

1) Calling PSSetShaderResources() to update the shader's single Texture2D resource to the next ShaderResourceView
2) Calling DrawIndex() on the appropriate vertex buffer segment.

I have a simple pixel shader that is really just one basic texture sampling line:
[CODE]ps.color = myOneTexture2D.Sample(samLinear, IN.texcoord0);[/CODE]

I've enabled alpha blending so that the alpha channel controls transparency, and everything is fine with that, [i]except[/i]:

[color=#000080]The Phantom Lingers.[/color]

Which is to say that each sampled texture is for some reason alpha-blended with the previously sampled texture.
So for totally opaque images, it's fine. For the first texture drawn -- such as this opaque double jellyfish I've drawn onto the background -- it's fine:
[attachment=10055:texture1.jpg]

But the second texture (which I've made 50% transparent) drawn onto the scene shows the first texture (the double jellyfish) blended with it. Behind it, you can see a piece of the large background jellyfish previously drawn, which is the only thing that [i]should[/i] be showing behind Snidely Whiplash.
[attachment=10056:texture2.jpg]

A third texture showing fog (also set to 50% transparency) has that entire previous texture (Snidely + the first texture) mixed with it. It again shows the background portion behind it (though you can't see it well here), like I want it to, but also the previous texture, like I don't want it to.
[attachment=10057:texture3.jpg]

------
So can any kind soul take a stab at telling me what's going on, here?

If I create multiple Texture2D resources in the shader, and have a separate one for each texture, then it works fine. The problem is, I want to be able to draw dozens of textures each time I render the scene, and the shader/my hardware doesn't support having, say, 50 different textures with a long sequence of "if (index == 3) texture[3].Sample..." etc.

I can't use TextureArrays because the textures have different dimensions.

I'm sure I'm missing something fundamental in the way shaders and samplers work, but for the life of me I haven't been able to discover it over days of research and experimentation. I know it's happening before the output merger stage, but I can't figure out why the Texture2D resource is apparently not being completely overriden by PSSetShaderResource(), like one would expect, and is instead somehow alpha-blended with it. Or the previous incarnation lingers, and is blended when Sampled? I can't tell, but perhaps one of you generous individuals can!

Many thanks for any insight you can offer.
James
0

Share this post


Link to post
Share on other sites
Belay that! Ignore this post.

If I'd only waited a couple more hours, I could have avoided embarrassing myself by having to reveal that I had a bug my DrawIndexed() parameter calculation that -- you guessed it -- was causing it to draw to quads it wasn't supposed to.

My shame is more than made up for by my relief at finally figuring out my mistake (braindead though it may have been). On the off chance that someone else is having a similar problem and finds this: be it known that the described behavior is [i]not[/i] in any way what directx is supposed to do, and you're probably making a simple mistake somewhere in your scene rendering calls.

James
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