Old 24th July 2016, 18:20   #1
dickchuck
Junior Member
 
Join Date: Jan 2011
Posts: 17
Looking to mod source to make Text render solid

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.
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);


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.

Thanks, DC
Attached Thumbnails
Click image for larger version

Name:	blending.png
Views:	171
Size:	97.7 KB
ID:	52490   Click image for larger version

Name:	blending2.png
Views:	195
Size:	426.6 KB
ID:	52491  
dickchuck is offline   Reply With Quote
Old 17th December 2017, 04:35   #2
skalamondre
Junior Member
 
Join Date: Dec 2017
Posts: 5
This is a pretty old thread however my text doesn't seem to look like that. It looks solid. Did you check the fade setting in the milk2_img.ini? The fade is the amount of time the text takes to fade in. Setting it to 0 should produce solid text instantly.
skalamondre is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Visualizations > MilkDrop > MilkDrop Development

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump