Jump to content

  • Log In with Google      Sign In   
  • Create Account


how to simulate the specular calculation using 'SetTextureStageState'


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 tcige   Members   -  Reputation: 206

Like
0Likes
Like

Posted 21 June 2013 - 10:41 AM

yes it is easy to accomplish it using pixel shader, but i want to try it with SetTextureStageState

 

i find if setting D3DRS_SPECULARENABLE, the specular calculation is as follows

 

(vertex's diffuse + vertex's specular) * (texture's color + vertex's specular)

 

i have tried different parameters and stages of SetTextureStageState, but still unsolved



Sponsor:

#2 belfegor   Crossbones+   -  Reputation: 2559

Like
1Likes
Like

Posted 21 June 2013 - 10:59 AM

I think you must set more things to see FFP specular, here is example:

//Turn on lighting and set an ambient value
    d3d9device->SetRenderState( D3DRS_SPECULARENABLE, TRUE );
    d3d9device->SetRenderState( D3DRS_LIGHTING, TRUE );
    d3d9device->SetRenderState( D3DRS_AMBIENT, D3DCOLOR_COLORVALUE( 0.2f, 0.2f, 0.2f, 1.0f ) );

    //Create a simple DX directional light
    D3DLIGHT9 light0;
    ZeroMemory( &light0, sizeof(D3DLIGHT9) );
    light0.Type = D3DLIGHT_DIRECTIONAL;
    light0.Direction = D3DXVECTOR3( 0.5f, -0.8f, 0.7f );
    light0.Diffuse.r = 0.8f;
    light0.Diffuse.g = 0.8f;
    light0.Diffuse.b = 0.8f;
    light0.Diffuse.a = 1.0f;
    light0.Specular.r = 1.0f;
    light0.Specular.g = 1.0f;
    light0.Specular.b = 1.0f;
    light0.Specular.a = 1.0f;

    //Set the light
    d3d9device->SetLight(0, &light0);
    d3d9device->LightEnable(0, TRUE);

    //Create a white material
    D3DMATERIAL9 WhiteMtrl;
    ZeroMemory( &WhiteMtrl, sizeof(D3DMATERIAL9) );

    WhiteMtrl.Diffuse.r = 1.0f;
    WhiteMtrl.Diffuse.g = 1.0f;
    WhiteMtrl.Diffuse.b = 1.0f;
    WhiteMtrl.Diffuse.a = 1.0f;
    WhiteMtrl.Specular.r = 1.0f;
    WhiteMtrl.Specular.g = 1.0f;
    WhiteMtrl.Specular.b = 1.0f;
    WhiteMtrl.Specular.a = 1.0f;
    WhiteMtrl.Power     = 8.0f;

    d3d9device->SetMaterial(&WhiteMtrl);

Edited by belfegor, 21 June 2013 - 11:06 AM.


#3 tcige   Members   -  Reputation: 206

Like
0Likes
Like

Posted 21 June 2013 - 11:10 AM

 

I think you must set more things to see FFP specular, here is example:

//Turn on lighting and set an ambient value
    d3d9device->SetRenderState( D3DRS_SPECULARENABLE, TRUE );
    d3d9device->SetRenderState( D3DRS_LIGHTING, TRUE );
    d3d9device->SetRenderState( D3DRS_AMBIENT, D3DCOLOR_COLORVALUE( 0.2f, 0.2f, 0.2f, 1.0f ) );

    //Create a simple DX directional light
    D3DLIGHT9 light0;
    ZeroMemory( &light0, sizeof(D3DLIGHT9) );
    light0.Type = D3DLIGHT_DIRECTIONAL;
    light0.Direction = D3DXVECTOR3( 0.5f, -0.8f, 0.7f );
    light0.Diffuse.r = 0.8f;
    light0.Diffuse.g = 0.8f;
    light0.Diffuse.b = 0.8f;
    light0.Diffuse.a = 1.0f;
    light0.Specular.r = 1.0f;
    light0.Specular.g = 1.0f;
    light0.Specular.b = 1.0f;
    light0.Specular.a = 1.0f;

    //Set the light
    d3d9device->SetLight(0, &light0);
    d3d9device->LightEnable(0, TRUE);

    //Create a white material
    D3DMATERIAL9 WhiteMtrl;
    ZeroMemory( &WhiteMtrl, sizeof(D3DMATERIAL9) );

    WhiteMtrl.Diffuse.r = 1.0f;
    WhiteMtrl.Diffuse.g = 1.0f;
    WhiteMtrl.Diffuse.b = 1.0f;
    WhiteMtrl.Diffuse.a = 1.0f;
    WhiteMtrl.Specular.r = 1.0f;
    WhiteMtrl.Specular.g = 1.0f;
    WhiteMtrl.Specular.b = 1.0f;
    WhiteMtrl.Specular.a = 1.0f;
    WhiteMtrl.Power     = 8.0f;

    d3d9device->SetMaterial(&WhiteMtrl);

 

not using light, i have set D3DRS_LIGHTING to FALSE 

 

only vertex's diffuse, specular and texture



#4 belfegor   Crossbones+   -  Reputation: 2559

Like
1Likes
Like

Posted 21 June 2013 - 11:32 AM

SetTextureStageState is used for setting "textures states", how can you expect to see speculars if you don't have light?


Edited by belfegor, 21 June 2013 - 11:33 AM.


#5 tcige   Members   -  Reputation: 206

Like
0Likes
Like

Posted 21 June 2013 - 11:46 AM

SetTextureStageState is used for setting "textures states", how can you expect to see speculars if you don't have light?

 

there is 'D3DFVF_SPECULAR' and 'D3DTA_SPECULAR', and that does not matter

 

i just want 'SetTextureStageState' do two add operation respectively, and modulate two results






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS