Jump to content
  • Advertisement
Sign in to follow this  
SiS-Shadowman

Smoothing Shader Output

This topic is 4504 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i hope this is somehow possible, because whatever i do, the results don't look that good. i've created a sphere, wich is lighted by the sun and the color of the sphere is calculated so: I = Ambient + Diffuse * N.L or in HLSL: Norm = saturate(dot(lightDir, normalize(mul(Normal, matRotation)))); return Norm * tex2D(DiffuseSampler, Tex0); but the results don't look that good, because the border between isn't a straight line that dimmers out, there is an aliasing. and i don't know how i can just "smooth" this border, so it looks good. there must be something, all the games out there are able to do the same... i really need help here

Share this post


Link to post
Share on other sites
Advertisement
Is lightDir definitely normalized? non-unit vectors in lighting calculations usually just make things darker/flatter, but can introduce other artifacts.

I would hazard a guess that something else you're doing is causing the aliasing:

1. What filtering settings are you using? Is POINT being used anywhere?

2. What texture format (input and output) are you using - a low 16bit format or DXTn might hurt

3. What is the source diffuse texture? Crap quality diffuse textures - especially those from lossy compression formats like JPEG can introduce these artifacts

4. What, if any, data is passed down from the VS to the PS? I've had that introduce interpolation errors recently. Usually manifests itself as odd straight lines in the final image.

A screenshot of the errors (imageshack.us) would help people a lot [smile]

hth
Jack

Share this post


Link to post
Share on other sites
i'm now normalizing the lightDir and the result looks perfect. i think i need to read an article about how the dot function works to understand, why this vector needs to be normalized.
when i compare the results ( before vs. after ), this must have definately been the error *g

to the other questions: i'm using normal 24 bit windows .bmp's and every filter for the texture is set to 'linear'
the vertexshader calculates this norm factor, wich is then multiplied with the texture in the pixel shader ( VS Calcs Norm --> PS recieves norm )
i tried to pass the normal straight through to the pixel shader and to do everything in it, but that resulted in crashes :(

but thanks alot :D

Share this post


Link to post
Share on other sites
Quote:
Original post by SiS-Shadowman
i think i need to read an article about how the dot function works to understand, why this vector needs to be normalized.

Here's a good explanation. It's based on a simple identity:

|A||B|Cos(θ) = A·B

Or, in HLSL terms:

length( A ) * length( B ) * cos( θ ) = dot( A, B )

Now, if both 'A' and 'B' are unit vectors length() is equal to 1.0; simple maths therefore makes the equation:

cos( θ ) = dot( A, B )

Therefore you can replace the expensive cos() with a trivial dot() [smile]

If the vectors are not unit length then the assumption does not hold and the results are wrong. Often this will manifest itself in values out of the normal [-1,+1] range, and in the context of graphics/lighting this leads to saturation...

hth
Jack

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!