Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Member Since 15 Aug 2005
Offline Last Active Dec 22 2014 06:53 PM

#5145135 Let's say 3 2D Textures and a TextureCube walk into a bar?

Posted by xycsoscyx on 07 April 2014 - 12:44 PM

Since you're not setting textures, but instead shader resource views, it would be fine to add it as part of your array.  I assume you already create a shader resource view for all textures (2d and cube)?  If you did want to separate it then your second call isn't correct though.  The first parameter is the starting stage to set, the second is the number of resources, and the third is the array of resources.  In your second call you are setting 0 resources in the first stage.  It should really be more like this:




This will set the next stage after the array, and set 1 resource.  Again though, as long as you create resources views for all textures, then you can set them all in the array and call PSSetShaderResource only once.

#5036866 Why do it the easy way?

Posted by xycsoscyx on 26 February 2013 - 04:09 PM

How about something akin to what I find in some of my companies legacy code:



ASSERT(isActive); // We should never be inactive so lets just assert in debug, it'll be fine in release

return TRUE;

#4951183 Reflection and Clipping Plane

Posted by xycsoscyx on 20 June 2012 - 06:59 PM

I'm not sure the specifics with XNA, but here's a good tutorial which explains stencil shadows in XNA. The operations are the same and the tutorial seems to explain some of the general stencil ideas and what it does.


The basic idea is that the stencil buffer is part of your depth buffer, when you create your device and specify a depth buffer format, you specify one that includes a stencil channel. You can then render into that just like you do the depth/color buffers, but you can also do tests against the values as well. When you render the stencil, you basically just render your water to create it's shape in the stencil buffer. Then when you render your reflections, you test against that shape to see if you should render a pixel or not, only pixels inside your stencil (inside the water shape) will pass the test and be drawn.

#4951173 Reflection and Clipping Plane

Posted by xycsoscyx on 20 June 2012 - 06:42 PM

One simple way would be to use the stencil buffer. Before you draw your reflections, make a stencil of the water (so render the water plane like you normally would, only writing to the stencil buffer), then when you render your reflections, only draw in the stencil area.