• Content count

  • Joined

  • Last visited

Community Reputation

130 Neutral

About Cirno

  • Rank
  1. 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.
  2. Hi everyone. I am working on a particle system with HLSL on XNA Framework. The properties of the particles are stored in several textures. Now I find it hard to initialize a particle(set its property at the beginning or reset its property when it is added to the stage again). It is not easy to get a random number in HLSL and setting the color of a single pixel(to reset the property of a new-added particle) in a texture is inconvenient.So are there any other good solutions? Thanks.
  3. Hi everybody~ My English is not good, so I may describe the problem not so clearly, but I will try my best... I am now trying to play ogg sound in XNA.OGGSharp maybe a good choice but I don't know how to loop the sound(or repeat playing the sound?).In addition, I heard that there are tags in ogg files to tell when to start/end the loop, but I don't know where they are stored in the file.I looked into the code of OGGSharp and found there are some data read and stored from the ogg file.But I am not familiar with the structure of the file so I don't know what to get. Here is the source code of OGGSharp Thank you~~
  4. [quote name='Tsus' timestamp='1336056899' post='4937114'] 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. } [/quote] Thanks very I understand the 'ping-pong' technique:)
  5. [quote name='Tsus' timestamp='1335960753' post='4936740'] 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. [/quote] 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)...
  6. [quote name='Adam_42' timestamp='1335454570' post='4935106'] Large arrays in a shader won't work. For anything big you need to use a texture or render target. [/quote] Thanks.. I looked up some documents and articles and haven't found ways for textures to save pixels in HLSL..
  7. [quote name='Tsus' timestamp='1335448331' post='4935068'] 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. Cheers! [/quote] Thanks all the same.. And there is a 3D particle example for XNA in MSDN..but maybe it lacks some....extendability....?
  8. [quote name='Tsus' timestamp='1335426957' post='4934990'] Hi! The code compiles just fine, but I think in practice it won’t help you much. You need a vertex shader. Otherwise the rasterizer has no idea, where to invoke the pixel shader. In case you want the pixel shader to be invoked for every pixel, you have to render a quad covering the whole viewport. For this you can pass in the vertices of the quad in post-clipping space ([-1,-1]..[1,1]) and let the vertex shader directly output them unchanged. Cheers! [/quote] Thanks very much~ but actually a vertex shader can be left out..i wrote a pass without a vertex shader before and it works well.. A friend told me that maybe the compiling error is caused by a structure(or an array?).. [CODE] typedef struct ScreenL { float4 Pixels[SCREEN_SIZE.x]; }ScreenLine; typedef struct ScreenD { ScreenLine Lines[SCREEN_SIZE.y]; }ScreenData; [/CODE] (#define SCREEN_SIZE int2(800, 480)) i thought the structure has nothing to do with the compiling..but he changed the 'SCREEN_SIZE' and the error disappeared.. why the structure caused the compiling seems that the structure has nothing to do with compiling? i want to write a GPU particle system, and need a structure to save the data of the texture consisting of all particles.So what type of structure should i use?
  9. hi everybody..i am a beginner to HLSL and i met with a problem that the compiler says 'There was an error compiling expression'. here is some of the code [CODE] float4 PassTest(float2 coord:TEXCOORD) : COLOR0 { return float4(0, 0, 0, 0); } technique Main { pass P0 { PixelShader = compile ps_2_0 PassTest(); //the error is in this line? } } [/CODE] i do not know what may cause this..and some HLSL code written before can work well... my English is poor ,so if it is not described clearly enough, please point out...thanks.~