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

Is there a Texture1D in XNA?
Particle System: XNA Framework HiDef profile does not support alpha blending on Vector4 textures
How to unset texture data in XNA 4.0
Detecting a Key Press in XNA 4.0?
How to add a start (splash) screen in XNA 4.0?
My program is being reported as a high-level security threat by AVG?
How to add an end screen in XNA 4.0?
Texture2D is way oversized in XNA 4.0?
How to set xna's TextureFilter to Point
Why doesnt my xna pixel shader turn this texture blue?
How to calibrate kinect skeleton data to video feed?
XNA game studio4.0 using c#
How to add collision detection in a 2D car game in XNA?
Texturing a terrain causes Windows Phone to crash (without an exception) or Models are not drawn afterwards
compiling and deploy window mobile phone platform games into xbox360 game platform with XNA 4.0
'Expected class, delegate, enum, interface,or struct' in XNA 4.0?

Categories

HOME
compiler-construction
cloud
urbancode
oracle11g
azure-data-factory
angular-material
layout
android-4.4-kitkat
yahoo-oauth
analysis
twitter-bootstrap-4
jpeg
ravendb
echarts
contact
vifm
metatrader4
static-libraries
hex-editors
hapi
contextmenu
dbext
custom-wordpress-pages
tokenize
orleans
graphicsmagick
realex-payments-api
trading
angular2-aot
sparse-matrix
su
dynamic-featured-image
pingfederate
libuv
objectanimator
google-cloud-nl
unboundid
gsoap
nameservers
google-cloud-endpoints-v2
pim
geopositioning
language-concepts
atl
normal-distribution
revolution-slider
simplexml
bitbucket-pipelines
libvpx
reportbuilder
ansible-playbook
webdriver-manager
elasticsearch-plugin
azure-ml
lumberjack
tasker
janrain
android-mediaprojection
fakeiteasy
arena-simulation
netcdf4
sas-jmp
angular2-meteor
wptoolkit
scorm
cubic-spline
skeleton-css-boilerplate
avconv
appcompat
prolog-setof
rails-routing
pebble-watch
quartz-composer
eventkit
messenger
angular-strap
visual-c++-2008
deadbolt-2
removechild
log4c
url-masking
player
python-stackless
livequery
independentsoft
vhd
collapse
python-3.2
libressl
deis
appfabric-cache
unity3d-gui
remobjects
dundas
facebook-graph-api-v2.4
pick
gadt
angularjs-ng-click
java-metro-framework
preferences
seaside
meteor-velocity
viadeo
ora-00911
back-stack
chronoforms
hamiltonian-cycle
dice
pysimplesoap
fireworks
libc++
joyent
yetanotherforum
sudzc
gamequery
database-management
compiler-specific
xetex
sector
msdev
grid-system
ugc

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App