IDirect3DDevice9* device;
IDirect3DPixelShader9* vertexShader;
IDirect3DPixelShader9* pixelShader;
IDirect3DVertexDeclaration9* vertexDeclaration;
device->CreateVertexDeclaration(description, &vertexDeclaration);
...
rr::RRBuffer* vertexBuffer = object->illumination.getLayer(0);
IDirect3DVertexBuffer9* d3dBuffer = ...;
...
device->SetPixelShader(vertexShader);
device->SetPixelShader(pixelShader);
device->SetVertexDeclaration(vertexDeclaration);
device->SetStreamSource(0, ...);
device->SetStreamSource(1, d3dBuffer, ...);
device->DrawPrimitive...
device->SetStreamSource(1, nullptr, 0, 0);
device->SetStreamSource(0, nullptr, 0, 0);
Using ambient value in HLSL vertex shader: void vertexShader(in float3 iAmbientLight: COLOR1,
..., out float3 oAmbientLight: COLOR1)
{
...
oAmbientLight = iAmbientLight;
}
Using ambient value in HLSL pixel shader: void pixelShader(in float3 iAmbientLight: COLOR1,
..., out float4 oColor: COLOR)
{
...
oColor = ... + materialColor * float4(iAmbientLight,0);
}