Check My Normal Calculations functions? Please?

Started by
10 comments, last by mynameisnafe 11 years, 2 months ago

im a lazy guy, so i haven't read the entire code section, but if stuff turns up black when it shouldn't, go slow at first.

this means:

  • first, directly output all your inputs as color (in this case, esp. the normals) and check if they have sane values (represented as colors in the framebuffer) you might want to pack them before outputting them (something like (normal+1)/*0,5), so you get the full range.
  • after that, output every step of your lighting, and do a check if it is as expected
  • also, don't forget to check constants, that can mess up things too
  • have a very simple model handy for this, where results are easily predictable (i use cubes and spheres)

you can also always use something like nsight or so for error checking, but i got kinda used not to use those, because they don't like me and have more issues with my code than me (especially with stream output/transform feedback, they love failing on those).

hope this helps,

tasche

Thats some pretty sound advice dude, ta muchly. smile.png However you lost me a bit with "first, directly output all your inputs as color (in this case, esp. the normals) and check if they have sane values (represented as colors in the framebuffer) you might want to pack them before outputting them
(something like (normal+1)/*0,5), so you get the full range."

So you mean use my normals as colours? frag_colour = normal.xyz?

Also, what's this doing ( x) / * 0 ?

Thanks again dude smile.png

yep, exactly. something along the lines of:


cbuffer 
{
     float4 something;
}

struct vsIn
{
     float4 position;
     float4 normal;
     float2 tex;
}

struct psIn 
{ 
    float4 position; 
    float4 normal; 
    float2 tex;
} 

psIn vsmain(vsIn input)
{
    psIn output;
    ...some vertex manipulations...
    output.position = finalPos;
    output.normal = rotatedNormal;
    output.tex = input.tex;
}

float4 psmain : SV_TARGET
{
    float4 ret;
    ...some cool lighting done here...
    return ret;
}

now just before you 'return ret;' you insert:


ret = input.normal;

for example. if that is already messed up, pass the normal from the vertex shader untouched (may have to add an extra var using the texcoord semantic in psIn), and output that first.


psIn vsmain(vsIn input)
{
    psIn output;
    ...some vertex manipulations...
    output.position = finalPos;
    output.normal = input.normal;     //<----change to this
    output.tex = input.tex;
}

use this for quick and dirty 'judged-by-eye' tests

Also, what's this doing ( x) / * 0 ?

that was just another way to show you how typos work. was meant to be (normal+1)*0.5. this moves normal component values from -1,1 range to 0,1 which can be viewed as rgb.

good luck finding your errors!

Advertisement

good luck finding your errors!

Thanks :)

I agree I should be doing this in DirectX ;)

that was just another way to show you how typos work. was meant to be (normal+1)*0.5. this moves normal component values from -1,1 range to 0,1 which can be viewed as rgb.

I see :)

Okay, onwards!

Thanks again :)

This topic is closed to new replies.

Advertisement