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.

DarkBASIC Professional Discussion / HELP!! Darkbasic shadows look weird!!

Author
Message
Warhead
15
Years of Service
User Offline
Joined: 23rd Feb 2011
Location: USA
Posted: 5th May 2011 08:00
Hey guys,

I'm having a little trouble with darkbasic shadows...

Can someone tell me what to do in order to get these weird shadow "ridges" removed? (See attachment)

As you can see, some "triangles" of shadows are appearing.

Any suggestions?

(Or It would be helpful to get some objects NOT affected by shadows while still retaining the shadow on the terrain...)

Thanks to anyone that helps!

TGC is awesome!!!
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 5th May 2011 16:31
Cute penguins

Looks like it might be a problem with the model. These don't look like the shadow artifacts you get sometimes so I think we can rule that out.

Any chance you can post the model for a looksee? What was it modelled in?

KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 5th May 2011 17:58
Put SET NORMALIZATION ON at the top of the program and see if that helps.

Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 5th May 2011 18:02
You might have to edit the shader itself. Inbeside all the compiler and IDE gubbings, there should be a shader folder and inside that, the shadow shader. There are some values that you can tweak, the most important one being the range - if you extend the shadow start range, it should extend past the polygons and stop them being included in shadow casts. I will see if I can get some more solid info for you, just as soon as I get home.

Health, Ammo, and bacon and eggs!
mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 5th May 2011 18:03
very nice screenshot, dude!
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 5th May 2011 18:53 Edited at: 5th May 2011 18:54
If you look in your DB Pro folder, Compiler, Effects, then you should find the shadow shader (stencilshadow.fx). Open it up, and look for this bit:

// defeat self-shadow zclash
PosView.x += LightVec.x*0.1f;
PosView.y += LightVec.y*0.1f;
PosView.z += LightVec.z*0.1f;

That's what you need to mess around with to fix the issues for your specific models. You will probably just have to adjust this once, as your other models will be similar. I would try increasing that 0.1f to 0.11f, a little bit at a time until it's fixed. There is no guarantee that your shader is the same, because I may have changed that already.

Health, Ammo, and bacon and eggs!
Warhead
15
Years of Service
User Offline
Joined: 23rd Feb 2011
Location: USA
Posted: 6th May 2011 01:44
Reply to baxslash;
-No, the model's fine... (Sure, I suppose I could post some images of the model for a looksee... I'll do that .)

But back to the point, the shadows still look weird.

Reply to KISTech;
-KISTech's SET NORMALIZATION ON didn't really change anything

Reply to Van B;
-The I set to shadow shader's PosView at like all the values between 0.0f to .99f. Didn't change a thing...
What's happening?

TGC is awesome!!!
Warhead
15
Years of Service
User Offline
Joined: 23rd Feb 2011
Location: USA
Posted: 6th May 2011 02:04
Some model evaluation for baxslash;

1st pic: wireframe (848 polygons)

TGC is awesome!!!
Warhead
15
Years of Service
User Offline
Joined: 23rd Feb 2011
Location: USA
Posted: 6th May 2011 02:05
2nd pic - Penguin- solid body

TGC is awesome!!!
Warhead
15
Years of Service
User Offline
Joined: 23rd Feb 2011
Location: USA
Posted: 6th May 2011 02:06
3rd pic - AAAAAAAAHHHH!!

-thanks to everyone that replied!

TGC is awesome!!!
The Slayer
Forum Vice President
16
Years of Service
User Offline
Joined: 9th Nov 2009
Playing: (Hide and) Seek and Destroy on my guitar!
Posted: 6th May 2011 02:38
Loox like a polygon issue on the model to me. You should upload the model so we can examine it and cure it. Heheheheh.
What 3D modelling program do you use?

Cheers

SLAYER RULES! YEAH, MAN!!
Warhead
15
Years of Service
User Offline
Joined: 23rd Feb 2011
Location: USA
Posted: 6th May 2011 07:12
-Hey Slayer!
(thanks for the cheers man!)
(I use Anim8or as my modeling program )


Well, I can almost guarantee that it's not a polygon issue, because this happens with darkbasic primitives too (see attachment)

That is, unless the darkbasic primitives have some weird polygon issue as well .

Here's the code:

[rem load all effects
cartooned = free_effect()
load effect "media/fx/cartooned.fx",cartooned,0
make light 1
position light 1,10000,10000,10000
set shadow position 1,0,0,0
delete light 1

for penguin = 1 to 18
if object exist(player+penguin)=1
texture object player+penguin, 0, cartooned_shade
texture object player+penguin, 1, cartooned_edge
texture object player+penguin, 2, cartooned_tex
set object effect player+penguin,cartooned
set shadow shading on player+penguin,-1,1000,1
endif
next penguin]


Also, I use Blitzterrain renderer and the U77 Update. Could these be of any influence to the shadow rendering?

thanks!
-Warhead

TGC is awesome!!!
Daniel wright 2311
User Banned
Posted: 6th May 2011 08:00
Warhead

This is what we call inverted faces, you cant tell the diffrence unless you use a shader on each face. You need to face all your faces out ward. I use 3ds max for most all things but what I do to turn my faces out ward is I use MilkShape 3D , there is a tool at the top to invert all faces or if you just select the face you want to turn around then just that face will be inverted to the front with the same tool. I hope this helped you out some.

my signature keeps being erased by a mod So this is my new signature.
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 6th May 2011 10:35 Edited at: 6th May 2011 10:36
Quote: "I use 3ds max for most all things but what I do to turn my faces out ward is I use MilkShape 3D , there is a tool at the top to invert all faces or if you just select the face you want to turn around then just that face will be inverted to the front with the same tool."

I seem to remember 3DS Max has a tool for that too but you need to be in the face sub-level of the object to select individual faces...

If this is happening to DBP primitives as shown it's unlikely it's a problem with the model. What shaders are you using in the game? Maybe there's a conflict? Are you using bump mapping or anything else?

Duke E
17
Years of Service
User Offline
Joined: 10th Mar 2009
Location:
Posted: 6th May 2011 10:59
I think there might be something wrong with the shader stencil shadows in U77.
Try my bug test code from a while back in this post: http://forum.thegamecreators.com/?m=forum_view&t=154980&b=15

That code works with the CPU shadows but not shader stencil shadows.
However if one sets CPU shadows and changes the box to a sphere (Make Object sphere 1,10,10,10) you see artifact self shadows on the right side.

Regards
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 6th May 2011 11:40
The last time I used shadows (only last week, Score100 in the latest newsletter) - I was able to use a simplified mesh for the shadow cast because it's a dice game, and that seems to help deal with this problem. The objects have a bump and specular shader plus the shadow shader, and look fine.

I'm wondering though, if it is a normals problem, if you could just use negative values in the shader offset, might be worth a try seeing as it'd be quick to test.

I'm sure that if you upload the model, someone will be able to figure out the shadows on it - why not make a little demo with just the shadowed penguin, then let us try and fix it that way.

Health, Ammo, and bacon and eggs!
Warhead
15
Years of Service
User Offline
Joined: 23rd Feb 2011
Location: USA
Posted: 7th May 2011 05:57
Hey guys!

Well, actually, using Van B's advice, I finally got it to work!!

What I basically did was change the values in the shader,

// defeat self-shadow zclash
PosView.x += LightVec.x*0.1f;
PosView.y += LightVec.y*0.1f;
PosView.z += LightVec.z*0.1f;

from 0.1f to 25.0f.

The only reason why it didn't change a thing the first time was because I changed the values in "stencilshader.fx", instead of "stencilshaderBONE.fx". Geez, I feel like such a noob now (which I am, without doubt ).

Thanks everyone! This really helped! TGC and TGC forums is awesome!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

YAY!!

(By the way, if anyone's interested, I intend to release a beta of the game I'm making with my penguins in about, eh, two weeks!)

See ya folks then!

Cheers,
~Warhead

TGC is awesome!!!
revenant chaos
DBPro Master
19
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 7th May 2011 07:57
The only times that I have encountered problems like that are when the model is way too big. How tall (in DBPro units) are those penguins?

Another thing to note is: if you copy those shadow shaders into your application's main directory, your program will use the that copy instead of the one that is packed into the exe. That is helpful because you don't need to modify the original copy to test changes.

Login to post a reply

Server time is: 2026-07-10 16:13:04
Your offset time is: 2026-07-10 16:13:04