|sdw||How 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?|
|VBBR||I really don't know, but I think you could ask masterbooda, it seems his 2D engine uses blending and DX7...|
|Spodi||You can check out how the DDraw/D3D hybrid engine works that's on Lucky's site (http://rookscape.com/vbgaming).|
|sdw||Thnx 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 Coleman||There 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.|
|sdw||I 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?|
|EACam||So, you're talking about Additive color blending? Good luck, I've never seen it done. The closest I've seen is alpha ONE blending.|
|sdw||From 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?|
|masterbooda||I'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...
|EACam||You 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 Coleman||Actually, 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.
|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 :)
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?
|EACam||I'm not sure what you mean about ColorOp modulate ????
What's teh difference between ARGB and RGBA? Wich should I use?|
|Eric Coleman||ColorOp 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.
|EACam||Cool...I try it.
So what's the difference between RGBA and ARGB?|
|VBBR||The 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. [:)]|
|EACam||Ok, 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 Coleman||Actually, 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.|
now i have another thing to worry about. [;)]
i spose trial and error is the key.|
|sdw||there really isn't a lot of info about this on the net :\|
Ok, how do I do that then?
I'm sorry, my engine was designed in directx 8, and I used the specular to brighten the colors...
|sdw||Nevermind, I guess it helps to enable the specular.|