Color blending
sdwHow do I blend a color with a surface? I am using directdraw7/d3d7. My idea was to make a second surface with the same dimensions, fill it with the color i want, then alphablend it over the original surface. Any quicker/easier ways to do this?
VBBRI really don't know, but I think you could ask masterbooda, it seems his 2D engine uses blending and DX7...
SpodiYou can check out how the DDraw/D3D hybrid engine works that's on Lucky's site (http://rookscape.com/vbgaming).
sdwThnx for the quick replies. Yeah I turned my engine into a dd7/d3d7 hybrid thanks to the tutorial on lucky's site by matt as Spodi mentioned, but the color blending it demonstrated there isn't exactly what I want. I need the blending to get me some brighter colors. How'd you do it masterbooda?
Eric ColemanThere are also two different hybrids on this site you might want to look at. Check out the Files section, D3Dfor2D.zip and direct5d.zip. You might also want to look into using different materials to get different color effects.
sdwI looked at the example by Carl Warwick and compared it with the one from Lucky's site. They both use DX.CreateD3DTLVertex for the vertices and this thing takes an argument to modify the color. However, after playing around with it for an hour, I have come to the conclusion that the color value specified there will not make the texture any brighter, it will only darken/tint the texture. Look into different materials to get different color effects?
EACamSo, you're talking about Additive color blending? Good luck, I've never seen it done. The closest I've seen is alpha ONE blending.
sdwFrom what I understand the vbDABL dll will colorblend things for me. I've never got it to work successfully myself but is that an option I should consider taking?
masterboodaI'm sorry, my engine was designed in directx 8, and I used the specular to brighten the colors... but I do believe if you can create a mask of the image, that is pure white, or the brighter color, then overlay it over the original, and by Changing the alpha of the overlay, you can give it the effect of brightening, but this will probably create some overhead... Also, from what I do remember of d3d7(sorry, have had my head burried int dx8 too long)... you can change the values you pass to the device on how the texture is drawn, and by messing with that and the alpha... you can brighten it up.... just try every combonation there is and adjust the alpha to see what it does... this is what I did, and You can do some really neat effects... DaBooda Out...
EACamYou cannot brighten with alpha...sorry. It isn't additive blending...i've tried. But the specular thing might work. How did you do that DaBooda?
Eric ColemanActually, you can achieve an additive blend with alpha blending. All you need to do is set the correct blend modes, SrcAlpha for the source and One for the destination. To increase colors, you would blend a non-black color over the target surface. This color increase only increases color saturation, not luminosity. You can achieve the latter by using a gamma ramp, but that effects the entire image. [img]http://www.vbgamer.com/msgboard/uploaded/Eric Coleman/200453103513_psysblend.jpg[/img]
EACamReally? Cool. In my app tho, alpha one blending only works if I set alphaone to both the dest and the src. And then the alpha one is kind of constant. I can't set an amount of alpha one like i can for regular alpha. Is that normal?
Almar Joling
quote:
Originally posted by EACam
Really? Cool. In my app tho, alpha one blending only works if I set alphaone to both the dest and the src. And then the alpha one is kind of constant. I can't set an amount of alpha one like i can for regular alpha. Is that normal?
Use ColorOp modulate and set the alpha component of the vertex color (D3DXColorARGB(128,255,255,255) or something)? Not sure if that's what you mean :)
EACamI'm not sure what you mean about ColorOp modulate ???? What's teh difference between ARGB and RGBA? Wich should I use?
Eric ColemanColorOp and AlphaOp determine how vertex color and texture colors are blended together. For example, if you set your colorOp to modulate, that effectively multiplies texture color time vertex color. If you have a grayscale texture, then you can adjust the output color by adjusting the vertex colors. If your texture is blue, RGB(0,0,1), and your vertex color is red, RGB(1,0,0), then the output would be black. 1*0, 0*0, 0*1. If the color is gray, RGB(.5, .5, .5) and a vertex color is green, (0,1,0), then the final color would be RGB( 0, .5, 0). There are also alpha operations, which allows you to use different effects for combining the alpha from a vertex color with the alpha in a texture. Look at this screenshot, the red, green, and blue color variations are controlled by adjusting the color value of the vertices. The bottom row show variations in the Alpha component of the vertex colors. The smiley face is created from alpha values in the texture. [img]http://www.strategon.com/gladiator/testscreenshot.jpg[/img]
EACamCool...I try it. So what's the difference between RGBA and ARGB?
VBBRThe position of the "A" [:D]. Well, pratically it's, if the function comes in the order ARGB then you put it in the order, Alpha, Red, Green, Blue. If it's RGBA then you put it Red, Green, Blue, Alpha. Pretty obvious. [:)]
EACamOk, so it doesn't matter which i use? If i have Color As Long then I can just say Color = D3DColorRGBA(R, G, B, A) or Color = D3DColorARGB(A, R, G, B) and both will work? Cool.
Eric ColemanActually, the byte order is different, and I think you need to make sure that the byte order of the colors you use is the same as the surface that you're using them on.
VBBR...since a Long is 4 bytes, then the bytes would be A R G B in this order, or R G B A, in this order. It really depends on WHAT you are applying the color on.
EACamok... now i have another thing to worry about. [;)] i spose trial and error is the key.
sdwthere really isn't a lot of info about this on the net :\
sdw
quote:
I'm sorry, my engine was designed in directx 8, and I used the specular to brighten the colors...
Ok, how do I do that then?
sdwNevermind, I guess it helps to enable the specular.