Does anyone know if there is a way to tell visual studio to check for me doing dumb things like the following and give me a error or warning when working on a shader file ?.
float TL = float2(x * 0.0f, y * 0.0f);
float TM = float2(x * 1.0f, y * 0.0f);
float TR = float2(x * 2.0f, y * 0.0f);
float ML = float2(x * 0.0f, y * 1.0f);
float MM = float2(x * 1.0f, y * 1.0f);
float MR = float2(x * 2.0f, y * 1.0f);
float BL = float2(x * 0.0f, y * 2.0f);
float BM = float2(x * 1.0f, y * 2.0f);
float BR = float2(x * 2.0f, y * 2.0f);
this bug lasted for hours and hours because i didn’t type float2 xxx = float2( …
Btw…
I think i have the coolest prototype shader working that i may have ever made.
To hell with fancy effects who needs those anyways.
I can print float values out as ascii characters in the pixel shader lol.
I personally have a visual studio External Tool defined to run 2MGFX. Then I have a keybinding to run the external tool. Pressing that keybinding automatically compiles the shader with 2MGFX. When failing, 2MGFX returns an error list which can be easily browsed with F4 or whatever key you have assigned to “next error”
Problem is more subtle then that.
float a = float2(1.0f,2.0f);
doesn’t error or anything the compiler is perfectly fine with that and just evaluates it as.
a = float(1.0f);
but i didn’t intend to do that, i just was typing fast, then copy pasted the first one a bunch of times in a row.
id always like a vs compiler warning to show up when i do that.
O:\xxxx\Forward.fx(101,8-27): warning X3206: implicit truncation of vector type
It’s a warning and doesn’t prevent compiling though, maybe this is the source of the problem, 2MGFX is complaining but for some reason MGCB is not outputting the warning.
Ya its not outputting a warning for me either, that’s what i would expect to see the truncation warning.
Maybe i should post a issue for it on github that cost me hours to debug that.
Well i still have to finish this but i might as well hotdog, i have the hard part done to say the rest is cake.
check it out.
So the weird looking numbers on the bottom are actually purely drawn on a pixel shader as a straight up function without even a texture for the characters. They are all line drawn characters basically im taking each digit out of the value then drawing it as if it were a character with lines in a switch.
The value being printed is the x mouse position. I could actually do this with ascii characters as well.
the method on the shader looks like this.
// display the value of the ForceLocation X component. in this case that's the mouse x.
float valuetotest = ForceLocation.x;
float2 drawToPosition = float2(10.0f, 600.0f);
currentColor = FuncDrawValue(valuetotest, curpixel, currentColor, drawToPosition, lineSize, lineColorWhite);
but their is needless to say a bunch more going on under that function.
The lines circle and dots at the line points ends are also generated on the shader.
When i get the decimals in and signs and stuff ill prolly post it up.
I took a second look at the fix and had refine a few things. Here is the commit with the needed changes and here is the custom build SDK installer from my MG repo.
The build contains the Line number fix by KakCAT among a number of other fixes.
By clicking on the Error/Warning on the VS tab it will go to the right line in the editor.
Added bonus: The framework libraries are ‘almost’ Garbage free!
A must have for shader editing in VS is HLSL Tools by Tim Jones.