Jump to content
  • Advertisement
Sign in to follow this  
abdellah

shadow shader

This topic is 1345 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

hello all

please don't answer me if you :

1/ doen't interest by the question;

2/ if you are not concentrating;

3/ no hazardeuos answers;

 

this is my opinion, is it correct :

 

the picture below describes a method to draw shadow in 3D space using a simple technique, if we have the P as a point light AND we have the vertices of the object  as N (example = teapot) AND we have the vertices of the shadowed object as M (example = floor or plane),

 

if (dot(NP, NM) == -1)

the vertex M is in shadow

else

the vertex M is not in shadow

 

(we all know the vertices NP & NM must be normalized) & using the floor() function of HLSL because the dot() function gives us a value like -0.999999 so we down to the least integer (i mean floor(dot(NP, NM)) == -1).

Edited by abdellah

Share this post


Link to post
Share on other sites
Advertisement

This technique would only work with solid objects with a convex profile, right? It seems like something as simple as a torus wouldn't shadow correctly.

Share this post


Link to post
Share on other sites

You'll need some kind of a tolerance since testing == 1.0 with floats will not produce many shadowing values. I'm not sure why would you want to use just point shaped occluders.

 

However, I don't really see how this algorithm would work on GPU - practically, for each pixel in the viewport you'll access a list of points (in the pixel shader), and then calculate if the point occludes the pixel or not - it will be highly inefficient when the amount of points gets bigger. 

 

A traditional shadow map or stencil shadows will be much more efficient (and they work on triangles instead of points). 

 

Cheers!

abdellah you really should again focus on the kaunas's post. What exactly are you trying to do - do you have really some special situation that the algorith would work well for you? Generally, the idea is not good, because:

You will be checking each vertex of all the shadow recievers (or do you really have just one?) against all vertices of all possible shadow casters (or do you really have just one?). That's not really efficient and it's quite hard to achieve, because when you are drawing a certain vertex (you are in its vertex shader), you don't have information about other vertices - unless you pass them to the shader somehow.

Also a very important thing to keep in mind - a vertex will be in shadow only if it there is some vertex of the shadow caster PRECISELY on the line between the said vertex and the point light. In fact you have just a bunch of point occluders with infinitely small size (ideal points), casting shadows in infinitely thin lines on another set of infinitely small point receivers. What are the odds that you will ever get a single shadow?

Share this post


Link to post
Share on other sites

Don't think about it because i am taliking too much without reaching any results.

(because i use vbNET & Managed DirectX , so the ressources , is verry low (= 0),  & especially when i see the people use the C++ native & DirectX11 , so i hide from pasting my code , also, my code of HLSL, is verry logic.

Share this post


Link to post
Share on other sites

Shadow map rendering is still better than the algorithm your proposed - you'll be using much less computing resources. Shadow mapping has been around for a long time already and isn't an issue for any GPU younger than 10 years. 

 

Cheers!

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!