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 / Shaders for Rotating Objects

Author
Message
LightningSky
16
Years of Service
User Offline
Joined: 22nd Feb 2010
Location:
Posted: 19th Jun 2010 10:54
I have been banging my head against the wall regarding these shaders over the past few days and no matter how I apply the shader values, once the planet object is drawn, the lighted side rotates around with the object. I cannot get a stationary light to work on a rotating object with any of the shaders. Which is bizarre because one of the samples has exactly what I am trying to do, however, I can't duplicate it's results.

I've gotten the SET BUMP MAPPING ON statement to actually look like a bump map now, however, it ignores the lights in the scene regardless of how I dress up the bump map image. Here's my code, once again. I'm obviously doing something wrong, but I just don't see it.



I realize I'm asking this question again, but maybe the issue is that I'm trying to apply the wrong type of shader based on the object I'm needing to highlight? I.E a planet? This seriously can't be this difficult, right?

TIA

- A man from nowhere, prophesized to fail, blazed beyond the brightest of them all.
Duke E
17
Years of Service
User Offline
Joined: 10th Mar 2009
Location:
Posted: 19th Jun 2010 13:01
Can be the light range that is too short, i believe it is set here: "set effect constant float 10,"LR_1",50". You "sun" is at 200,0,0 and the planet is 5 wide. Depends on how the shader interprets the light ranges though.

Regards
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 19th Jun 2010 13:29 Edited at: 19th Jun 2010 13:55
As I've said before, the problem is in the shader not your dba code.

I was going to fix it for you after your earlier post but I've been very busy recently. You might be able to find another bumpmapping shader which works - several have been posted on the forum at various times.

Edit

I hope we're talking about the same shader. Assuming we are then you need to change every occurrence of the calculation of L0 in the shader from



to



For example, for the first occurrence replace the line



with the line



Post back if you still have problems - with your edited version of the shader (just so we know we're talking about the same shader).
LightningSky
16
Years of Service
User Offline
Joined: 22nd Feb 2010
Location:
Posted: 21st Jun 2010 23:17
Thanks Gandalf, I'll give this a try this evening. I believe we are talking about the same shader, it came from the Ultimate Shader Pack.

I can't wait to get this right.

I'll report back tonight what happens.

- A man from nowhere, prophesized to fail, blazed beyond the brightest of them all.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 22nd Jun 2010 00:41
Looking forward to hearing how you get on.

The suggestions I made were, hopefully, a quick fix to get things working. A bit more work may be needed to optimise the calculations - I say "may be" deliberately because the shader compiler is good at spotting optimisations anyway.

Main thing though is to get something working for you - we can fiddle with it later.
LightningSky
16
Years of Service
User Offline
Joined: 22nd Feb 2010
Location:
Posted: 22nd Jun 2010 10:24
Made the adjustment, and when applied to the planet object the planet disappears. Unpon inspection maybe we are talking about different shaders. I noticed the WorldInv variable did not exist in the shader coding. Here's the shader:



When I changed WorldInv (which you had added) to World then my planet came back, but the lighting was still not working.

Perhaps I missed something when going through the shader code? I went through and changed all of the LO = statements to teh new code in your post.

- A man from nowhere, prophesized to fail, blazed beyond the brightest of them all.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 22nd Jun 2010 22:32
Oops! My fault - I forgot to tell you to add the declaration.

I should have given you the complete working shader I was using.

Here it is:

LightningSky
16
Years of Service
User Offline
Joined: 22nd Feb 2010
Location:
Posted: 23rd Jun 2010 06:28
Beautiful, absolutely beautiful.

Being new at this I guess I really need to dig in and understand how shaders work. I wish there was better documentation on how to get the standard commands to work. It's difficult to know where to spend one's time when there is so much to learn.

Thank you Gandalf for all the work you do on this site. I know this just one of many items I'm sure I'll be asking questions about. If you know of a good reading source for a good overview on shaders I'd like to know.

Now, to play around with the bump mapping so it doesn't look too "bumpy".

- A man from nowhere, prophesized to fail, blazed beyond the brightest of them all.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 23rd Jun 2010 22:30
Glad you got it working (and sorry again for my earlier oversight).

Quote: "If you know of a good reading source for a good overview on shaders I'd like to know."


Have a look at the first post on the following thread (it's a "sticky" near the top of this board). The information is somewhat out of date but should give you somewhere to start from. There are lots of books around on shaders and I found it extremely useful to browse through a couple and play with their examples when I was starting out - but you might be able to find comparable sources on-line now. I now tend to rely on the MS DX9 SDK docs but they're not much help for beginners - although you could look at some of their tutorials.

Learning to write shaders

Quote: "Now, to play around with the bump mapping so it doesn't look too "bumpy"."


There are two main ways of fixing that - either add an adjustable variable plus a bit of code to the shader or modify the normal maps. Post back if you're having problems on that.

Login to post a reply

Server time is: 2026-07-25 08:13:45
Your offset time is: 2026-07-25 08:13:45