#Light_ambient;

2 messages · Page 1 of 1 (latest)

icy violet
#

i do not the get ambient lighting to work.
are there something that is missing.

struct S_L //Spotlight
{
    DirectX::XMFLOAT3 pos;     
    DirectX::XMFLOAT4 Light_ambient;  
    float range;                
    DirectX::XMFLOAT3 dir;      
    float cone;                
    DirectX::XMFLOAT3 att;      
    float k;                
    DirectX::XMFLOAT4 diffuse; 

};
bool spotlight(ID3D11Device* device, ID3D11Buffer*& constentBuffer_spotlight) {

    S_L light{};

    light.Light_ambient = DirectX::XMFLOAT4(1.0f, 1.0f, 1.0f, 1.0f);
    light.k = 0.05f;

    D3D11_BUFFER_DESC BufferDesc_matrix;
    BufferDesc_matrix.ByteWidth = sizeof(S_L);
    BufferDesc_matrix.Usage = D3D11_USAGE_IMMUTABLE;
    BufferDesc_matrix.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
    BufferDesc_matrix.CPUAccessFlags = 0;
    BufferDesc_matrix.MiscFlags = 0,
    BufferDesc_matrix.StructureByteStride = 0;

    D3D11_SUBRESOURCE_DATA data_1;
    data_1.pSysMem = &light;
    data_1.SysMemPitch = 0;
    data_1.SysMemSlicePitch = 0;

    HRESULT hr = device->CreateBuffer(&BufferDesc_matrix, &data_1, &constentBuffer_spotlight);
    return !FAILED(hr);

}
Texture2D texture1;
SamplerState Sampler;

struct PixelShaderInput
{
    float4 position : SV_POSITION;
    float3 normal : NORMAL;
    float2 UV : UV;
    float4 World_pos : world_pos;
       
};

cbuffer S_L : register(b0) //Spotlight
{
    float3 pos;     
    float4 Light_ambient; 
    float range;    
    float3 dir;     
    float cone;     
    float3 att;    
    float k;        
    float4 diffuse; 
};

float4 main(PixelShaderInput input) : SV_TARGET
{
    
    float4 c = Light_ambient * k;
    
    float4 sampling = texture1.Sample(Sampler, input.UV) * c;
    return sampling;    
}
tidal kilnBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.