This was even easier to setup than specular highlighting.
I think this is the moment my understanding of how shaders worked kind of "ticked" in my head.
The VS_OUTPUT struct isn't at all needed to be tinkered with to input data into the vertex shader, no, that's part of the parenthesis, I think this is one of my major struggles of understanding.
VS_OUTPUT VS( float4 Pos : POSITION, float3 NormalL : NORMAL, float4 Color : COLOR ) Is LITERALLY a standard function definition.
VS_OUTPUT being the datatype it returns. VS() being the name of the function.
float4 PS( VS_OUTPUT input ) : SV_Target returns just a float4, but calls for the returned data of the vertex shader.
We can modify the struct however we'd like to allow it to take the data.
Doing this, I made the vertex shader share the normal translated to worldspace and the position in world space and such.
This was the "lightbulb" realization moment of how these shaders work. I really struggled at understanding how the data was being read with the buffer and such. I may not fully understand how the constant buffer works yet. But I think it's the order of data it's expecting.
If I have the struct in my .cpp have in order a:
float4
float3
float
float2
Then the constant buffer on the shader will attempt to read the buffer in order as:
float4
float3
float
float2.
Atleast that's what I'm assuming it's doing. I still need to learn this part.
Anyway! Per pixel shading has been accomplished, here is the result:
The normals on the cube are a little weird. I did follow exactly the same normals as given in the tutorial however I don't think they're properly made for my cube unfortunately. However the specular highlight does show on the corners and is more noticeable without colors except the very dim ambient lighting applied.
My main struggle with this was understanding how to pass to the pixel shader the correct data and got stumped on the "normalL" trying do do "input.NormalL" but then after a headscratching moment it was that moment of realising how it all worked. I also struggled to send the colors to the pixel shader, but as you can see I added it in the colors in the end by just simply including it in the struct.
This was even easier to setup than specular highlighting.
I think this is the moment my understanding of how shaders worked kind of "ticked" in my head.
The VS_OUTPUT struct isn't at all needed to be tinkered with to input data into the vertex shader, no, that's part of the parenthesis, I think this is one of my major struggles of understanding.
VS_OUTPUT VS( float4 Pos : POSITION, float3 NormalL : NORMAL, float4 Color : COLOR )
Is LITERALLY a standard function definition.VS_OUTPUT being the datatype it returns. VS() being the name of the function.
float4 PS( VS_OUTPUT input ) : SV_Target
returns just a float4, but calls for the returned data of the vertex shader.We can modify the struct however we'd like to allow it to take the data.
Doing this, I made the vertex shader share the normal translated to worldspace and the position in world space and such.
This was the "lightbulb" realization moment of how these shaders work. I really struggled at understanding how the data was being read with the buffer and such. I may not fully understand how the constant buffer works yet. But I think it's the order of data it's expecting.
If I have the struct in my .cpp have in order a: float4 float3 float float2
Then the constant buffer on the shader will attempt to read the buffer in order as: float4 float3 float float2.
Atleast that's what I'm assuming it's doing. I still need to learn this part.
Anyway! Per pixel shading has been accomplished, here is the result:
https://user-images.githubusercontent.com/57398860/141337571-62a88a5b-7360-47c7-a22b-eb4ea09a34dc.mp4
The normals on the cube are a little weird. I did follow exactly the same normals as given in the tutorial however I don't think they're properly made for my cube unfortunately. However the specular highlight does show on the corners and is more noticeable without colors except the very dim ambient lighting applied.
https://user-images.githubusercontent.com/57398860/141338108-a35b2f9f-d51c-4382-bb20-dff83499f335.mp4
My main struggle with this was understanding how to pass to the pixel shader the correct data and got stumped on the "normalL" trying do do "input.NormalL" but then after a headscratching moment it was that moment of realising how it all worked. I also struggled to send the colors to the pixel shader, but as you can see I added it in the colors in the end by just simply including it in the struct.