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 / Scrolling textures on an object while using a shader.

Author
Message
KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 1st Jun 2010 21:20
Logically whether using a shader or not should make no difference, but it seems to. I have a sphere with 3 textures on it, and a shader that makes it look pretty.

When I wasn't using the shader, I had 2 textures and the SCROLL OBJECT TEXTURE command worked fine to make the clouds move.

Now that I'm using a shader, the command seems to have no effect.

Is this related to this OLD bug report?
http://forum.thegamecreators.com/?m=forum_view&t=82091&b=15
or do I need to do something different because I'm using a shader?

Serial Velocity
17
Years of Service
User Offline
Joined: 24th Aug 2008
Location:
Posted: 1st Jun 2010 21:33
Well the best way to probably do this is use a shader, in the pixel shader you should have something like this:



replace it with:



Then add a float constant at the top of the shader called cloudScroll, then in DBP, simply increase this value to scroll the texture across the planet like:



As we are modifying the UV coordinates, remember that if cloudScroll is 0.5, then it will move the clouds half way around the sphere.

Hope this helped

GDKUtilities, a utility library for DarkGDK, avaliable here
KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 1st Jun 2010 22:10 Edited at: 2nd Jun 2010 00:07
I was considering that next, if the response to the SCROLL OBJECT TEXTURE command was not so favorable.

[edit]
Ok, I've played around with the shader for a bit, and can't seem to get it to behave. All I've been able to get out of it is this.

Which is an interesting effect, but not quite what I was after.

It normally looks like this.


Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 2nd Jun 2010 00:22
You might simply be scrolling too fast.

Your problem with scroll object texture rings a bell. I'll look into it.
KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 2nd Jun 2010 00:38
I don't think so, it's adding 0.0001 multiplied by my Time Based Movement factor, which is < 1.0. So the result should be a pretty small increment.

I'll also add that I tried scroll object texture using the stage parameter, to scroll the 2 stages that I need scrolled but that didn't work either.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 2nd Jun 2010 00:42 Edited at: 2nd Jun 2010 01:00
I've just created a simple test program and it seems to work perfectly. Could you do the same so we can all see where the problem lies?

Here's my dba code:



Shader:



Edit

Here's a better example. This scrolls the stage 1 texture but not the stage 0 texture.

dba code:



Shader:



Again it seems to work perfectly. Looks like you might be doing something wrong.
KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 2nd Jun 2010 01:04 Edited at: 2nd Jun 2010 01:05
Hmm.. Well, here's the shader, which probably looks a little familiar to you.



and the DBP code changing the U variable in the shader.



Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 2nd Jun 2010 01:08
What's that got to do with the SCROLL OBJECT TEXTURE command mentioned in your first post? My demos suggest there's nothing wrong it. Where's your demo showing a problem?
Link102
21
Years of Service
User Offline
Joined: 1st Dec 2004
Location: On your head, weeeeee!
Posted: 2nd Jun 2010 01:18 Edited at: 2nd Jun 2010 01:30
Just throwing things out there.
The first planet looks like the uv-x texture coordinate are all set at 0. Only displaying the first row of pixels in the texture, thus stretching it.

KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 2nd Jun 2010 01:34
@GG
Sorry, not enough coffee today. Clearly your demo proves the command works fine with shaders. I'm retracing my code again to see if I can find a reason why the clouds aren't moving.

@Link102
You are right. Clearly not enough coffee today. I had messed up thinking that the values I wanted were between 0.0 and 1.0, but it's actually 1.0 and 2.0. It's working in the shader now.

However, I'm still going to try and track down what was going on with the scroll object texture command.

Duke E
17
Years of Service
User Offline
Joined: 10th Mar 2009
Location:
Posted: 2nd Jun 2010 01:46 Edited at: 2nd Jun 2010 01:48
Made a excerpt from a shader i'm working on.

Runs all on GPU.

Regards
KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 2nd Jun 2010 02:17 Edited at: 2nd Jun 2010 02:28
Quote: "I had messed up thinking that the values I wanted were between 0.0 and 1.0, but it's actually 1.0 and 2.0. It's working in the shader now."


Geez, now I'm quoting myself..

That's not right either, but it's closer.

[edit]
Ok, it was 0.0 to 1.0. I was trying to maintain the wrong amount in the variable and used it wrong in the shader. It's all better now.

@GG
I can't find in my code why scroll object texture isn't working. By all measures it should work the way I have it written. I know the code is executing, I know the values given to the command are valid, and the correct object but it just wont budge the texture. Very strange.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 2nd Jun 2010 12:50 Edited at: 2nd Jun 2010 12:50
Could you post or email the project to me? I'll have a look at it - 3.5 eyes are are better than two.

Have you checked that you're using the scrolled UV coords and not one of the other sets?

Edit Which update are you using? I'm using U7.5beta13.
KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 2nd Jun 2010 18:24
LOL, probably more like 2.5. I'm legally blind.
Having a 28 inch widescreen monitor helps though.

The project is 11,464 lines. I don't know if you would really want to sift through all of that.

I'm using U7.4, I haven't dipped into 7.5 yet as this version seems pretty stable for this project, and I don't necessarily want to break anything. I'm also still using BlueIDE.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 2nd Jun 2010 18:33
Quote: "I don't know if you would really want to sift through all of that."


I doubt I'd need to sift through all of it. A bigger problem is likely to be any plug-ins that you might be using. I'm happy to have a go though.

One more thing to check: does your object actually have the UV coords you're trying to scroll?
KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 2nd Jun 2010 18:39
It's actually just a DBP sphere with the 3 textures applied to stages 0-2. Nothing special there really.

I'll email you the code.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 2nd Jun 2010 18:42 Edited at: 2nd Jun 2010 18:45
But does the sphere have the extra 2 sets of UV coords added to its FVF format? If it really is a DBP sphere as you seem to suggest then it will only have stage 0 coords. Have you confused texture stages with UV coordinate stages?

Edit By the way, my earlier snippets work fine with U7.4.
KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 2nd Jun 2010 18:49 Edited at: 2nd Jun 2010 19:27
No, I get the difference. When texturing the sphere for use with the shader I'm just using,

texture object Obj, 0, Img1
texture object Obj, 1, Img2
texture object Obj, 2, Img3

So I guess the answer is no, I'm not specifying anything to do with the UV coordinates.

[edit]
Where when I wasn't using the shader for the clouds, I was using,

set blend mapping on Obj, 0, Img1, 3, 24
set blend mapping on Obj, 1, Img2, 3, 4
set blend mapping on Obj, 2, Img3, 3, 4

grabbing the UV from stage 0 for the other stages.. Hmm...

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 2nd Jun 2010 19:39
I couldn't see anything wrong with your project code - but I did notice one thing with the shader you posted earlier (you forgot to email me the shader you were trying to use ). The shader uses the same UV coords for all three textures (base, alpha map and normal map) so would you notice the scrolling? I guess you would.

The only thing I couldn't check was the actual runtime value of factor# - if this is stuck at zero then the scrolling won't do anything of course.

Quote: "grabbing the UV from stage 0 for the other stages.. Hmm..."


That should be correct - it's what the above mentioned shader does.

Could you post or email the shader you are trying to use so I can be sure we haven't got our wires crossed?
KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 2nd Jun 2010 20:05
It's the same one as posted above. Here it is again. I've since modified it to use the shader to do the scrolling, which is working, but this is what I was using while using the scroll object texture command.



Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 2nd Jun 2010 20:20
I've reproduced your problem using that shader with a modified version of my earlier demo. I should be able to track down the problem now ...
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 2nd Jun 2010 20:52
Found the problem - and it's back in Lee's court I think.

The scrolling will work if you use the extra DontRecalculateExtraData flag (or whatever it's called) on the load effect command. But this means you can't easily get tangents and binormals which you need for normal mapping.

I really don't see why scroll object texture should need this flag set - in fact I don't really see the need for it at all. Looks like a crude quick fix for an unrelated problem to me.
KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 2nd Jun 2010 21:13 Edited at: 2nd Jun 2010 21:21
I had a feeling I wasn't doing anything wrong.

I'll stick with scrolling the texture in the shader since it will likely be faster than the DBPro command anyway, but thanks again for your help. I'm glad I was able to help uncover a potential bug.

In fact, in honor of all the help you've provided me and others, there's a green planet in Worlds Apart Online in the Solan system that I have renamed Gandalf.



Please don't take offense that it's a gas giant.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 2nd Jun 2010 21:27
I'm honoured.

Quote: "Please don't take offense that it's a gas giant."


I won't attempt to explain why that is strangely apposite at this point in time.

Login to post a reply

Server time is: 2026-07-25 16:20:21
Your offset time is: 2026-07-25 16:20:21