Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


useing alpha as a color

This topic is 5130 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I want to use the alpha chanel in a spec map as a modulator for an environment map. how shal this be done? this is what I have currently
bool set_stage_for_env_mapped(){
	if(current_render_state == ENV)return true;
	if(SPECMAP < 0){
	//	Error(LOCATION, "trying to set stage when there is no specmap");

		return false;

//	D3DXMATRIX world;

	D3DXMATRIX world(
		Eye_matrix.vec.rvec.xyz.x, Eye_matrix.vec.rvec.xyz.y, Eye_matrix.vec.rvec.xyz.z, 0,
		Eye_matrix.vec.uvec.xyz.x, Eye_matrix.vec.uvec.xyz.y, Eye_matrix.vec.uvec.xyz.z, 0,
		Eye_matrix.vec.fvec.xyz.x, Eye_matrix.vec.fvec.xyz.y, Eye_matrix.vec.fvec.xyz.z, 0,
		0, 0, 0, 1);

	GlobalD3DVars::lpD3DDevice->SetTransform(D3DTS_TEXTURE1, &world);

	d3d_SetTextureStageState( 2, D3DTSS_RESULTARG, D3DTA_CURRENT);
	d3d_SetTextureStageState( 1, D3DTSS_RESULTARG, D3DTA_CURRENT);
	d3d_SetTextureStageState( 0, D3DTSS_RESULTARG, D3DTA_CURRENT);

//	d3d_SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_SPECULAR);

	d3d_SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
	d3d_SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
//	d3d_SetTexture(0, SPECMAP);

	d3d_SetTexture(1, cube_map);
	d3d_SetTextureStageState( 1, D3DTSS_RESULTARG, D3DTA_CURRENT);

	d3d_SetTextureStageState( 1, D3DTSS_COLORARG1, D3DTA_CURRENT);
	d3d_SetTextureStageState( 1, D3DTSS_COLORARG2, D3DTA_TEXTURE);
	d3d_SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_MODULATE2X);
//	d3d_SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_PREMODULATE);

	d3d_SetTextureStageState( 2, D3DTSS_COLOROP, D3DTOP_DISABLE);
	d3d_SetTextureStageState( 3, D3DTSS_COLOROP, D3DTOP_DISABLE);

	current_render_state = ENV;
	return true;
stage 0 has a spec map that has just been used in a multipass specular lighting thingy, stage 1 has a cube map, currently it''s modulateing the cube map with the color of the spec map , and I want to use the alpha of the spec map instead (also if there is a way to use the specmap''s color * it''s alpha to modulate the cube map I''d like to know that as well) Bobboau, bringing you products that work... in theory

Share this post

Link to post
Share on other sites
Take a look at D3DTA_ALPHAREPLICATE - it''s a texture argument modifier flag that copies what''s in the ALPHA channel into the R,G and B channels of COLOR.

Alternatively, when you have hardware support, there are operations such as D3DTOP_MODULATEALPHA_ADDCOLOR

Simon O''Connor
Game Programmer &
Microsoft DirectX MVP

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!