Hi all,
When I modded the source code for my MDC cue version of Milkdrop, I began with the code for rendering Custom Messages as a starting point for rendering the Karaoke text(s). I was able to simplify the code quite a bit since the Karaoke lyrics are always rendered as the same size, color (except when prompt triggers color change), font face and screen placement.
After creating quite a few Karaoke examples, I've come to NOT like the semi-translucency of the text. This isn't something you can set with the milk2_img.ini native formatting keys for messages, and it's only noticeable under certain color-combinations, too.
I am somewhat familiar with alpha transparency and blending modes for 2D graphics, but the directX and pixel-shading stuff is still not on my tool belt. Every combo I have tried has led to worse results: either the words are opaque but so dim they can't be seen; the background of the text portion is also solid like a reactangle. I've tried combos of D3DRS_SRCBLEND, D3DRS_DESTBLEND, D3DRS_BLENDONE, BLENDZERO, etc - but I was shooting in the dark.
Here's what (I think) is the relevant code. Any help would be fantastic. Again, I'm just looking to have the text render as solid - while it's being drawn as an overlay. Not even sure if this is possible - I don't want to break how the text blends with the background art if I can help it.
Thanks, DC
When I modded the source code for my MDC cue version of Milkdrop, I began with the code for rendering Custom Messages as a starting point for rendering the Karaoke text(s). I was able to simplify the code quite a bit since the Karaoke lyrics are always rendered as the same size, color (except when prompt triggers color change), font face and screen placement.
After creating quite a few Karaoke examples, I've come to NOT like the semi-translucency of the text. This isn't something you can set with the milk2_img.ini native formatting keys for messages, and it's only noticeable under certain color-combinations, too.
I am somewhat familiar with alpha transparency and blending modes for 2D graphics, but the directX and pixel-shading stuff is still not on my tool belt. Every combo I have tried has led to worse results: either the words are opaque but so dim they can't be seen; the background of the text portion is also solid like a reactangle. I've tried combos of D3DRS_SRCBLEND, D3DRS_DESTBLEND, D3DRS_BLENDONE, BLENDZERO, etc - but I was shooting in the dark.
Here's what (I think) is the relevant code. Any help would be fantastic. Again, I'm just looking to have the text render as solid - while it's being drawn as an overlay. Not even sure if this is possible - I don't want to break how the text blends with the background art if I can help it.
I've attached a pic of the kind of blending/bleaching I am talking about. It just makes text really hard to read when there is a bright background and lots of motion going on. Notice in the second image how the normally black shadow has become a light magenta color. That really kills the relief effect the makes the text easy to see.code:
//There's this code in milkdropfs.cpp\RenderFrame()
lpDevice->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP);
lpDevice->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP);
lpDevice->SetSamplerState(0, D3DSAMP_ADDRESSW, D3DTADDRESS_WRAP);
lpDevice->SetSamplerState(1, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP);
lpDevice->SetSamplerState(1, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP);
lpDevice->SetSamplerState(1, D3DSAMP_ADDRESSW, D3DTADDRESS_WRAP);
lpDevice->SetRenderState( D3DRS_SHADEMODE, D3DSHADE_GOURAUD );
lpDevice->SetRenderState( D3DRS_SPECULARENABLE, FALSE );
lpDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );
lpDevice->SetRenderState( D3DRS_ZENABLE, FALSE );
lpDevice->SetRenderState( D3DRS_ZWRITEENABLE, FALSE );
lpDevice->SetRenderState( D3DRS_LIGHTING, FALSE );
lpDevice->SetRenderState( D3DRS_COLORVERTEX, TRUE );
lpDevice->SetRenderState( D3DRS_FILLMODE, D3DFILL_SOLID );
lpDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );
lpDevice->SetRenderState( D3DRS_AMBIENT, 0xFFFFFFFF ); //?
lpDevice->SetRenderState( D3DRS_CLIPPING, TRUE );
// stages 0 and 1 always just use bilinear filtering.
lpDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
lpDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
lpDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);
lpDevice->SetSamplerState(1, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
lpDevice->SetSamplerState(1, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
lpDevice->SetSamplerState(1, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);
// note: this texture stage state setup works for 0 or 1 texture.
// if you set a texture, it will be modulated with the current diffuse color.
// if you don't set a texture, it will just use the current diffuse color.
lpDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
lpDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
lpDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TEXTURE);
lpDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
lpDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );
lpDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE );
lpDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
//*** HERE'S WHERE I'VE PUT THE MOST EFFORT
//... and there's this code in milkdropfs.cpp\RenderStringToTitleTexture()
lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, false);
//to actually draw the text to the texture
m_supertext.nFontSizeUsed = m_d3dx_mdcFont->DrawTextW(
NULL, m_supertext.szTextW, -1, &rect,
DT_CENTER | DT_VCENTER | DT_NOCLIP | DT_WORDBREAK,
m_supertext.bPrompt ? 0xFFBBBBBB : 0xFF5555FF);
Thanks, DC
Comment