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 25 Apr 2012
Offline Last Active Jul 01 2013 07:32 PM

Posts I've Made

In Topic: Initializing particles in a particle system

24 May 2013 - 07:15 AM

 applying an offset to the texture coordinates used to look it up based on time

This is the point. I thought that a 'random' texture can only give one pixel a particular 'random' value, but with the offset we can 'generate' some random values for a pixel.

In Topic: need help with "There was an error compiling expression"

04 May 2012 - 09:49 PM

bool ping = true;
RenderTarget2D positionsPing;
RenderTarget2D positionsPong;

Draw() {
if (ping) { // Pong -> Ping
// Bind texture positionsPong
// Bind render target positionsPing
else { // Ping -> Pong
// Bind texture positionsPing
// Bind render target positionsPong
// Bind rendertarget 0. (Unbind render target)
ping = !ping; // Toggle ping pong.

Thanks very much..now I understand the 'ping-pong' technique:)

In Topic: need help with "There was an error compiling expression"

03 May 2012 - 04:47 AM

You can write to a texture by creating a RenderTarget2D and binding it to the pipeline. The pixel shader then writes its results to the texture somewhere hidden in the RenderTarget2D class. Since RenderTarget2D inherits from Texture2D (if i recall correctly) you just read from it as from any other texture. In XNA a RenderTarget2D is so to say a texture you can write to.

Maybe it is because I don't know how to draw on a Texture2D object in HLSL..if the drawing code is in XNA(and the HLSL code only computes the particle positions), it seems not to have made full use of HLSL..
Also, binding the texture to the pipeline may cause some strange problems, for example, if a rander target is current render target of the graphics device, sampling on that render may get strange color(when I was trying to write an additive color mixing type)...

In Topic: need help with "There was an error compiling expression"

02 May 2012 - 02:08 AM

Large arrays in a shader won't work. For anything big you need to use a texture or render target.

I looked up some documents and articles and haven't found ways for textures to save pixels in HLSL..

In Topic: need help with "There was an error compiling expression"

02 May 2012 - 02:06 AM

Did you take a look at the ParticlesGS sample in the DxSDK? If you don’t dependent on Dx9 it might be easier and faster to use the stream output instead of textures to store the state of the particles.
Edit: Alright, irrelevant for you because of XNA.


Thanks all the same..
And there is a 3D particle example for XNA in MSDN..but maybe it lacks some....extendability....?