BasicEffect Alpha value handled incorrectly?

I was working on my editor and needed a simple ground plane.

So I threw one in using BasicEffect with a single light source , the sun.

And I got this…

Not what I was expecting at all.

After a lot of debugging I found that the problem was caused by a single line of code which I had copied from an example in these forums.

basicEffect.Alpha = 255;

This of course is wrong, BasicEffect.Alpha is a float so should be 0-1

Setting it to 1 gave me the expected display (not very good but good enough for what I need :smiley: )

{hmmm can’t add a second image, says it is bigger than 4M when it is less than 2}

Anyway looks like we need to clamp the alpha value on BasicEffect

Sigh.

It looks like fog is broken as well.

I just added three lines of code

        fx.FogEnabled = true;
        fx.FogStart = 7000;
        fx.FogEnd = 15000;

It looks like it is using the unprojected z coordinate

Yes , looking in Lighting.fxh I can see

vout.FogFactor = ComputeFogFactor(position);

position is the untransformed input position, which is obviously wrong

Maybe this will help.

short story,

MG is using the shaders published by microsoft on their XNA catalog. Today you can find those shaders here.

XNA produced different results on Desktop that what it produced on WindowsPhone7 & 8.

The results of MG look like the Phone version of XNA, therefore the shaders that Microsoft made available are more likely the ones they used on the phone.

Here is a semi- official post on the blog of the XNA designer about the optimizations they did to get the shaders run on the phone.
Quote: “One place we slightly changed the final output is the fog equation. Previous versions used distance fog, which is computed from the distance between camera and vertex. We now use depth fog, which only considers how far in front of the camera each vertex is, ignoring any sideways offset. The visual difference is subtle, but depth fog is much cheaper to evaluate.”

I suppose they changed the final output on other places too. In the first post somebody has given the changes they did to the shaders to fix the over-saturation.

Yes I looked at them.

I have dropped BasicEffect and just written my own shader. In my case it was my own stupidity that caused the visual effect you can see in the video. It’s vertex fog, I only had four vertices all should have been fully fogged. My shader does the fog calculation in the pixel shader.

But the code does still look wrong,

It’s passing the input position on to the fog calculation when it should be passing the view space position.

The optomisation is to do a dot product with the position and a fog vector to calculate the fog value

Not a bad optomisation, but it should be in view space so you have a depth, not in object space

What are you using for capture?

Sorry, don’t understand why this question is relevant.

The bug is clearly there in the source code.

Just a question.

:grin:We sure have a lot of them don’t we? :smiley:

I use the nvidia built in screen / video grabbers

Why not just use your systems inbuilt recorder? It works wonders and you capture just the window you want, look at gaming in settings for capture settings and just press Windows Key + G to record.

Seems capturing desktop is a bit more difficult now though, shame… used to be straight forward. I think when they removed broadcasting, they forgot to leave capturing the desktop lol…

Just saying.

Keep up that awesome work though!