Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / I HATE the shadow shading commands (with a passion!)

Author
Message
prasoc
16
Years of Service
User Offline
Joined: 8th Oct 2008
Location:
Posted: 17th Aug 2009 14:09
Here is the code I am using (all the code does is make 50 boxes and a plane to put the boxes on, and then it applies stencil shadows)



I can NEVER get the commands to work (even on simple objects! Damned if I can try and get more complex things to work).

Is there anything wrong with what I am doing?


Your signature has been erased by a mod

Attachments

Login to view attachments
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 17th Aug 2009 14:43
Try reducing the range of the shadow, keep it as short as you can without it looking stunted.

Also, use the dbSetShadowClipping command, it will help with some shadows being clipped at cetain places and angles.

Also, you will need to make sure that Stencilshadow.fx (for non-bones models, there is another for bones/animated models) is in the project's folder, its one of the 6 .fx files that GDK uses for it's "native" shader functions like shadow shading and reflection shading and the like...

If you dont have them, let me know, I have them in a folder underneath my projects folder so I can get at them when I need them, ill put them in an archive and post them here if you like
You shuld be able to find them in one of the tutorial directories that come with GDK.

If it ain't broke.... DONT FIX IT !!!
prasoc
16
Years of Service
User Offline
Joined: 8th Oct 2008
Location:
Posted: 17th Aug 2009 15:07 Edited at: 17th Aug 2009 15:26
Ye I have them in my folder, ill try the shadowclipping and the range

EDIT: it is completely messed up. Could you try the code (it needs no external media apart from the .fx files and see if you have the same problem

EDIT2: If I set it so it is from the CPU rather than the GPU, it works much better (if i turn off the stencil shadows for the plane), but the problem is if you go around the back of the boxes, you can see z-fighting still


Your signature has been erased by a mod
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 17th Aug 2009 15:57
Oh if you have Z fighting issues, check you camera range.... make sure the minimum camera range is the largest value you can possible have it rather than low...

Search on google about Z-Fighting for explanations as to why, its got to do with how the ZBuffer works, based on the depth of the buffer versus the camera angle and range.. its a pretty complex subject to explain, but simply to solve...

In extreme cases(like in my terrain engine when its displaying massive terrains and you have the need for a long range at the same time as things are happening close to the camera) you can setup a 2 camera system, with one camera's range set to something like 1-500.0 and camera 2's range to 500.1 - max ... this help to elimate zfighting aswell in shadows over large distances...

Ill try your code now aswell and post bak if I notice anything

If it ain't broke.... DONT FIX IT !!!
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 17th Aug 2009 16:22
Here is you code all fixed up and working, from a point of view of casting shadows properly lol... make sure the stencilshadow.fx is in the folder...

I modified it to make smaller objects, yours were a little too large, shadows dont like really large flat polygon faces, they tend to make unnatural looking shadows, best to keep things as small a scale as you can...I also added a moving light, you cant have shadows if you dont have a light to cast them

In DarkGDK, Light 0 is the only shadow casting light(although I think dbpro has a command to change this im not sure, ive never had any luck casting hardware stencil shadows from anything other than light 0 in GDK) You can emulate multiple shadow casting lights though by setting up some simple render targets and moving the light to different postions between render target fastsyncs and the final scene render, that way it looks like you have more than one light casting a shadow... I have a cool demo of GDK primitives casting 3 shadows each and moving around here somewhere, if you are interested let me know and ill dig it out.




I have included in a 7k zip file the 6 FX shaders that come with GDK, I know these ones are working as they work for me no worries, if you think there could be a chance yours have become corrupt or modified sometime, try these ones to see if it makes a difference.... its strange that you can get software shadows to work but not hardware, when you have the shader file there.... software shadows are usually the ones that perform badly..

If it ain't broke.... DONT FIX IT !!!

Attachments

Login to view attachments
prasoc
16
Years of Service
User Offline
Joined: 8th Oct 2008
Location:
Posted: 17th Aug 2009 16:39 Edited at: 17th Aug 2009 16:43
That's insane Thanks a bunch. It looks really cool! (Works perfectly here too ) For that render target light position, I don't really need the code for it, I'll make do with 1 light for the moment


Your signature has been erased by a mod

Login to post a reply

Server time is: 2024-11-20 17:35:12
Your offset time is: 2024-11-20 17:35:12