Question

Very very new to DirectX, trying to just mess with this tutorial I got to learn how things work. Figured out what controlled the color of the triangle it drew, and I find it to be extremely weird.

Here's why: -when I change the variables (which is a float) the left side number at all, NOTHING happens. I can change it to 40000000 or 4 or 3 or 400000000 or 10 or 9 NOTHING changes at all.

-when I change the variable from a positive to negative, or vice versa, it DOES change the color.

-when I change any of the variables to 0.0f, it changes the color.

So I'm really trying to figure out the logic for this, I mean, how can the variable number NOT affect it's color value? Here's some code that will hopefully make my question make more sense.

SimpleVertexShader.hlsl

 float4 SimplePixelShader(PixelShaderInput input) : SV_TARGET
    {
        // Draw the entire triangle yellow.
        return float4(4.0f, 0.0f, 2.0f, 6.0f);
    }

Main.cpp

auto vertexShaderBytecode = reader->ReadData("SimpleVertexShader.cso");
        ComPtr<ID3D11VertexShader> vertexShader;
        DX::ThrowIfFailed(
            m_d3dDevice->CreateVertexShader(
                vertexShaderBytecode->Data,
                vertexShaderBytecode->Length,
                nullptr,
                &vertexShader
                )
            );
Was it helpful?

Solution

return float4(4.0f, 0.0f, 2.0f, 6.0f);

you are returning the pixel color, and the valid input range for a color is [0.0 - 1.0], if the value was out of this range, it will be truncated to this range

for values < 0.0, it was treated as 0
for values > 1.0, it was treated as 1

That's why you didn't see any change when you update the values bigger than 1.0

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top