Blending modes in c++ (Direct2D) -
i trying blend 2 images using direct2d latest direct2d supports effects , blending options. avoid using latest version due compatibility issues.
with being said, there way recreate blending mode (hard-light) in direct2d without effects class , still keep hardware accelerated.
if not, purely software side rendering adversely affect performance?
how can access pixels in d2d , pixel pixel manipulations?
thank you
first, version of directx using?
1- can write own shaders , change rendering pipeline use shaders, may lot of work if you've never done before. this link discusses rendering pipeline in dx11, , this link discusses in dx 9. look @ if you're working in dx9.
2- purely software manipulation outstandingly slow, unless one-time manipulation. if it's shading or lighting you're trying do, software rendering out of question. heavily depends on number of images , size of each image. mean, if you're doing on tiny 16x16 images per frame, possible. if you're talking 128x128 per frame going lot, because manipulating in-memory graphics involves locks , critical sections, it's time-consuming process.
3- heavily depends on version of dx you're using , how you're going things, check msdn's api reference articles on directx this. guarantee little googling can find this.
at request, here's pseudo-code pixel shader blend 2 images:
// shader file start sampler2d firstimage sampler2d secondimage ps_output evenblendpixelshader( float4 position : position0, float4 color : color ) float4 firstsample = firstimage( position ) float4 secondsample = secondimage( position ) float4 output = 0; output.x = (firstsample.x + secondsample.x) / 2; output.y = (firstsample.y + secondsample.y) / 2; output.z = (firstsample.z + secondsample.z) / 2; output.w = (firstsample.w + secondsample.w) / 2; return { position, output }
the idea sample given pixel each image using sampler. average values between 2 , return result.
also check out article on pixel shaders.
Comments
Post a Comment