xna-4.0


Particle System: XNA Framework HiDef profile does not support alpha blending on Vector4 textures


I found this great tutorial on making a particle system in XNA:
http://www.catalinzima.com/tutorials/4-uses-of-vtf/particle-systems/
The problem is that its written for an older version of xna and xna 4.0.
In the DoPhysicsPass method I get this exception:
XNA Framework HiDef profile does not support alpha blending or ColorWriteChannels when using rendertarget format Vector4.
Here is the method that is blowing up
private void doPhysicsPass(string technique, RenderTarget2D resultTarget)
{
GraphicsDevice.SetRenderTarget(temporaryRT);
GraphicsDevice.Clear(Color.White);
spriteBatch.Begin();
physicsEffect.CurrentTechnique = physicsEffect.Techniques[technique];
if (isPhysicsReset)
{
physicsEffect.Parameters["positionMap"].SetValue(positionRT);
physicsEffect.Parameters["velocityMap"].SetValue(velocityRT);
}
physicsEffect.CurrentTechnique.Passes[0].Apply();
spriteBatch.Draw(randomTexture, new Rectangle(0, 0, particleCount, particleCount), Color.White);
spriteBatch.End(); //<----- Exception thrown here
GraphicsDevice.SetRenderTarget(resultTarget);
spriteBatch.Begin();
physicsEffect.CurrentTechnique = physicsEffect.Techniques["CopyTexture"];
physicsEffect.CurrentTechnique.Passes[0].Apply();
spriteBatch.Draw(temporaryRT, new Rectangle(0, 0, particleCount, particleCount), Color.White);
spriteBatch.End();
}
Here is the initialization of randomTexture:
velocityRT = new RenderTarget2D(GraphicsDevice, particleCount, particleCount, false,
SurfaceFormat.Vector4, DepthFormat.None);
Can anyone offer some suggestions how to fix this?
First of all, are you sure you're setting the effect on the SpriteBatch correctly? I'm not sure you are. It looks like you've converted the tutorial, which is using the old pre-4.0 way of applying custom render settings (details).
I suspect you either need to be passing SpriteSortMode.Immediate to Begin (note that this will disable batching), or passing in your effect (probably after setting CurrentTechnique).
The second issue is simply explained by the exception. You need to disable alpha blending and ColorWriteChannels. I suspect that ColorWriteChannels is actually disabled anyway (the default). To disable alpha blending, try passing BlendState.Opaque to SpriteBatch.Begin (AlphaBlend is the default).
I've not tried updating the tutorial to XNA 4.0 myself - but I'm pretty sure that fixing either one or both of these things will fix your problem.

Related Links

Pass variables to another class?
Xna Game referencing Game in update
XNA game studio simple sprite animation
XNA phase management
How to check BoundingSphere for one ModelBone?
MonoGame: Some VertexColorPosition dissappear while drawing user primitives(DrawUserPrimitives)
Testing XNA 4.0 games On the XBOX 360 without paying $100 [duplicate]
Detecting clicks in a non-rectangular shape
What's a good way to optimise rendering a 2D tile game in XNA?
How to make 3D racing game with XNA? [closed]
How to correctly accelerate a rotated 3d model in XNA?
What's the difference between world and view for purpose of camera?
Vertexbuffer Getdata VertexPositionNormalTexture
Converting from 3.1 to 4.0… gamestates
XNA large coordinates and float precision
Trying to make Gaussian Blur stronger/blurrier - XNA 4.0 HLSL

Categories

HOME
ms-access
osgi
image
hive
homebrew
react-virtualized
include
read-eval-print-loop
rdf
retrofit
azure-media-services
multiple-records
virtualization
session-variables
python-unittest
adobe-analytics
usergrid
ef-migrations
connection-string
text-rendering
viewport
emulator
graphicsmagick
kvc
fifo
strncpy
ejabberd-module
libssl
nouislider
avcapturesession
android-kernel
nssegmentedcontrol
jmonkeyengine
devextreme
automake
multilingual
theano.scan
unspecified
opshub
total-commander
convertapi
long-polling
jsch
fault
errordocument
imanage
mcafee
iso8601
vtigercrm
synchronous
specrun
cubes
color-picker
angular-cache
grails-tomcat-plugin
file-writing
disque
lua-5.1
pagedlist
qgraphicsview
cakephp-3.1
tableau-online
key-management
geonetwork
html-helper
doskey
monomac
c18
quantlib-swig
qt-faststart
limejs
html-editor
funscript
doh
mod-auth
coercion
android-sdk-2.1
sudzc
rescale
iweb
backcolor
pascal-fc

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App