Jump to content

  • Log In with Google      Sign In   
  • Create Account


tcige

Member Since 10 Apr 2013
Offline Last Active Jun 27 2013 08:38 PM

Posts I've Made

In Topic: how to simulate the specular calculation using 'SetTextureStageState'

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


In Topic: how to simulate the specular calculation using 'SetTextureStageState'

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


In Topic: why 'COLOR1' can not be used between vertex output and pixel input

17 June 2013 - 12:38 PM

It should. But it may be clamped to [0, 1], and it probably of lower precision than the TEXCOORD semantics.

 

In what range is the data your passing?

 

Also: when you say something "doesn't work", you need to describe how it doesn't work. Fails to compile? Doesn't produce the expect result (in that case, what it the result?)

 

i use pixel shader to process light, passing vertex's normal and position

 

it works correctly if position is 'TEXCOORD1', but if position is 'COLOR1' it always be black


In Topic: light processing should be done in vertex or pixel shader

17 June 2013 - 08:12 AM

If you want per-pixel lighting you have to do it in the pixel shader.  

 

To do this you need at least the pixel normal and light direction vector for each light used.  You can calculate the light vector if you pass position and have the light positions as a uniform, and you must pass the normal vector as input as well.

 

Yes, what you describe is the standard way.

 

by the way, what is per-pixel lighting, does it exactly mean processing light in pixel shader

 

i find doing this way does not need to subdivide vertex triangles any more, so cpu usage lowers a lot


In Topic: light processing should be done in vertex or pixel shader

17 June 2013 - 05:57 AM

If you want per-pixel lighting you have to do it in the pixel shader.  

 

To do this you need at least the pixel normal and light direction vector for each light used.  You can calculate the light vector if you pass position and have the light positions as a uniform, and you must pass the normal vector as input as well.

 

Yes, what you describe is the standard way.

 

it is strange pixel shader use 'TEXCOORD' for non-texture usage, why not define another general input semantics


PARTNERS