XNA Creators Club Online
Page 1 of 1 (3 items)
Sort Posts: Previous Next

using specular maps in fixed function pipeline

Last post 05-07-2008 3:57 PM by rnaegele. 2 replies.
  • 05-07-2008 2:28 PM

    using specular maps in fixed function pipeline

    I have a question about using specular maps in the fixed function pipeline.  
    I'm using similar code to what is in the SDK documentation under Specular 
    Light Maps (Direct3D 9).....
    // Set the base texture.
    d3dDevice->SetTexture(0, lptexBaseTexture );
    
    // Set the base texture operation and arguments.
    d3dDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE );
    d3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
    d3dDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
    
    // Set the specular light map.
    d3dDevice->SetTexture(1, lptexSpecLightMap);
    
    // Set the specular light map operation and args.
    d3dDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_ADD );
    d3dDevice->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE );
    d3dDevice->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT );
    
    // Set the RGB light map.
    d3dDevice->SetTexture(2, lptexLightMap);
    
    // Set the RGB light map operation and arguments.
    d3dDevice->SetTextureStageState(2,D3DTSS_COLOROP, D3DTOP_MODULATE);
    d3dDevice->SetTextureStageState(2,D3DTSS_COLORARG1, D3DTA_TEXTURE );
    d3dDevice->SetTextureStageState(2,D3DTSS_COLORARG2, D3DTA_CURRENT );
    
    What I see in game is not exactly what I expect.  The specular values do get 
    added into the texture and the light map is applied over it, but it doesn't 
    appear that the specular highlights are changing as the camera / object moves 
    in relation to the light.  What I'm looking for is a way to add different 
    areas of specularity on the same piece of geometry using the specular map.
    
    My guess is that this sample is intended to be a static specular map, as it 
    doesn't really know about the camera or light because it's just a texture 
    added over the diffuse texture.
    
    Does anyone know if there is a way to do a specular map using the fixed 
    function pipeline, or is this something that can only be done using shaders.
    
    Thanks
    -Rick
  • 05-07-2008 2:38 PM In reply to

    Re: using specular maps in fixed function pipeline

    Yes, that is indeed a static specular map. One possible way to implement a dynamic map would be to have a second set of texture coordinates that are used for the specular map, and then "animate" them according to light positioning. This would probably be highly difficult and processor intensive for complex objects though.

    Also, is a specular map necessary, or can you use the specular material components in your geometry and dynamic lighting?

  • 05-07-2008 3:57 PM In reply to

    Re: using specular maps in fixed function pipeline

    That's what I figured.  I'm actually doing dynamic lighting with specular enabled right now, it looks ok, but I'd like to have greater control over what area gets specularity, as well as avoid some of the visual problems you get when using it with lower polygon models.  Right now you can see some visual artifacts with the specularity that I'd like to get rid of without increasing the polygon count.

    If this is only possible in a pixel shader, if anyone could give me a point in the right direction on how to implement this that would be great.

    Thanks.

Page 1 of 1 (3 items) Previous Next