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 / 3D world studio graphics and darkbasic pro integration

Author
Message
MateiSoft Romania
12
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 12th Jun 2014 18:17
Hey community,

If i create a level in 3D World Studio, i want to apply it some shaders like specular normal mapping. If i apply the shader in darkbasic pro it messes up my level. Is there a way to apply shaders correctly on maps exported from 3D World Studio?

Thank You Community!

Alex Matei CEO
www.alexmatei.com
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 12th Jun 2014 18:50
"Messes up" - What exactly is messing up?

The issue with applying shaders to levels or just generally large, complex structures is that the object can only have one texture when you apply a shader to it.

So if your world has more than 1 texture applied to it in 3D World Studio, you'll have to split the world up into multiple groups of small objects, where every group only requires a single texture.

Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 12th Jun 2014 18:56
I have encountered some discrepancies with 3D World Studio's UV coordinates in the past; but
Quote: "What exactly is messing up?"


If you have exported a light mapped scene; remember that your texture stage zero is occupied by the light maps.

Any shader needs to use the second set of UV coordinates, instead of the first. One UV coordinate is for the light map, the other is for the textures.

3D World studio exports your scenes into limbs; the sides of walls and floors contain different limbs when they use different textures.

TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 12th Jun 2014 19:11
Quote: "3D World studio exports your scenes into limbs; the sides of walls and floors contain different limbs when they use different textures."


If this is the case then you may disregard what I said and simply use "set limb effect" (I think it was called) instead of "set object effect".

If I understand correctly what Chris said about UV coordinates, there are two different sets of UV coordinates you need to read from:

Input/Output structs:


The vertex shader needs to pass both to the pixel shader:


And your pixel shader will have to use them appropriately, according to which texture you're reading from:


MateiSoft Romania
12
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 12th Jun 2014 19:35
Hello, thank you all for responses!

TheComet, so i what code you typed here, i must apply to my fx file?

Alex Matei CEO
www.alexmatei.com
MateiSoft Romania
12
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 12th Jun 2014 19:42
I use evolved's bump mapping here is what i meant with messed up.

Alex Matei CEO
www.alexmatei.com
SamKM
17
Years of Service
User Offline
Joined: 25th May 2009
Location:
Posted: 12th Jun 2014 19:56
I tried making a map with 3d world studio and using it with Evolved's Advanced Lighting shaders, but that didn't turn out well for me either, so I switched over to his MapScape program, and that works awesome! That means ditching the time and effort you out into the 3DWS map, though

The code never bothered me anyway...
MateiSoft Romania
12
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 12th Jun 2014 20:23
So you mean, you exported with the light maps and then applied the shader effect through code in darkbasic?

Alex Matei CEO
www.alexmatei.com
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 12th Jun 2014 20:24
Quote: "TheComet, so i what code you typed here, i must apply to my fx file?"


Basically, yeah. If you post the FX file we can work on it together.

MateiSoft Romania
12
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 12th Jun 2014 20:38
Hey TheComet,

Thank you so very much!

Here is the shader file!

Alex Matei CEO
www.alexmatei.com
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 12th Jun 2014 22:05
Can you also post the section of DBP code that loads the level, textures it, and applies the shader?

MateiSoft Romania
12
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 12th Jun 2014 23:07
Yes indeed!



Alex Matei CEO
www.alexmatei.com
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 13th Jun 2014 00:48
Does this work for you?


(Going off of what Chris said about using stage 1 instead of stage 0).

MateiSoft Romania
12
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 13th Jun 2014 01:01
Hey, the shader works GOOD JOB !!!

However, the shadows and lights baked in 3D WS don't show and other lights like muzzle flashes don't appear i think this is also from the shader, it doesn't accept other external lights, just the shader programmed lights?

Alex Matei CEO
www.alexmatei.com
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 13th Jun 2014 01:14
Quote: "However, the shadows and lights baked in 3D WS don't show"


Are you able to load the baked texture and apply it to the object? I could modify the shader to process light maps as well.

Quote: "it doesn't accept other external lights"


Correct. Once you apply a shader, you must do everything through that shader. You can modify the shader constants LightPosition, LightColor and LightRange to control the shader lights. If you need more than one light, Evolved has an example called "multipass lighting" which supports up to 8 lights I believe.

MateiSoft Romania
12
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 13th Jun 2014 01:17
I am able through the code that i gave to you with texture object ...but if you modify the shader to take lightmaps, the shadows will be present in the scene without the baked lights?

Alex Matei CEO
www.alexmatei.com
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 13th Jun 2014 01:48
Quote: "but if you modify the shader to take lightmaps, the shadows will be present in the scene without the baked lights?"


Are you talking about real-time shadows?

MateiSoft Romania
12
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 13th Jun 2014 02:14
No, the static shadows rendered in 3D WS

Alex Matei CEO
www.alexmatei.com
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 13th Jun 2014 08:57 Edited at: 13th Jun 2014 09:16
Then the answer is yes, they will be visible. Give me a moment...

[EDIT]Untested. Can you post a screen shot of the result? You need to apply the lightmap texture to stage 3 of the object (texture object 5,3,lightmapTexture)


God I hate Evolved's shader code. Is so inconsistent and the variable names are retarded.

MateiSoft Romania
12
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 13th Jun 2014 17:22
Hey TheComet,

Very funny what you are saying about the shader ) lol.

This is my code to activate the shader:



However, it doesn't anymore show the map, it shows a blank screen and my weapon, but the map not.

Alex Matei CEO
www.alexmatei.com
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 13th Jun 2014 17:46
Black screen usually means the shader has syntax errors. I forgot a semi-colon. Here's the updated one:



Also, don't you mean this?


Otherwise you'd just be re-texturing the same object over and over. That doesn't make much sense.

MateiSoft Romania
12
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 13th Jun 2014 18:12
Hey,

Still the same story, blank screen with not map.

Am i doing something wrong in the code? The map has multiple lightmaps so i loaded and applied them.



Alex Matei CEO
www.alexmatei.com
MateiSoft Romania
12
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 13th Jun 2014 18:15
Updated code :



Alex Matei CEO
www.alexmatei.com
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 13th Jun 2014 18:26 Edited at: 13th Jun 2014 18:26
In the pixel shader, change:

to


If you don't have a black screen anymore, then there's something wrong with the way UV coordinates are extracted or with the way the lightmap texture is sampled.

If the screen is still black, insert this into your DBP code after your "load effect" command and tell me what the output is:


MateiSoft Romania
12
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 13th Jun 2014 18:44
No shader errors now, thank you for beeing pacient with me, really, i having some troubles with limbs though, for testing i programmed as object not limbs like in this code: (some shadows are shown but the lights not)



You said that the correct method is to make this map as limb...but how? i tried with make limb and trying to make mesh from object but errors are given. Again, thank you for your help and patience, i will put you in my game's credits

Alex Matei CEO
www.alexmatei.com
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 13th Jun 2014 19:05
Quote: "You said that the correct method is to make this map as limb...but how? i tried with make limb and trying to make mesh from object but errors are given."


Chris said earlier that 3D World Studio already does this for you:
Quote: "3D World studio exports your scenes into limbs; the sides of walls and floors contain different limbs when they use different textures."


So you'll have to find a way to apply the individual lightmap textures to their corresponding limbs (on stage 3).

The code you have here seems wrong to me


because every time you call texture object you replace the texture that was previously on the object with a new texture, meaning that after that code is executed, your object will only be textured with image 461 (on stage 3).

Let's try something different. Here's another version of the shader:


This time, in DBP, don't manually apply the lightmap textures. Instead only texture the world on stages 1 through 3:



Lightmaps are on stage 0 and should automatically be loaded by DBP if you exported the object correctly.

Quote: " Again, thank you for your help and patience, i will put you in my game's credits"


Heh, thanks! Thank you for sticking up with this whole trial-and-error process. If I wouldn't be at work I would be able to actually test the things I say before launching them at you.

MateiSoft Romania
12
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 13th Jun 2014 22:23
Hey TheComet,

Definetly ensured a place in the credits, it works now perfectly!!!

Now, the external lights will never work ? Like, i have muzzle flashes and flash light and i can seems to make them work.


Again, thank you very very much for your help!

Alex Matei CEO
www.alexmatei.com
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 13th Jun 2014 23:26 Edited at: 13th Jun 2014 23:26
The flash light and muzzle flash need to be implemented into the shader as well. Maybe it'll be easier if you just upload the entire project.

MateiSoft Romania
12
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 14th Jun 2014 00:19
I don't feel like uploading the project here.

Do i need to make a custom light in the shader and through DBPRO code to attach it in real time and do the same code in DBPRO as i did with the standard lights to appear and disappear?

Alex Matei CEO
www.alexmatei.com
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 14th Jun 2014 00:21
What were you using for the muzzle flash effect and the flashlight before you started using shaders?

MateiSoft Romania
12
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 14th Jun 2014 00:24




Alex Matei CEO
www.alexmatei.com
MateiSoft Romania
12
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 14th Jun 2014 20:28
For collision with the map exported you know how to do it?

Thank You!!!

Alex Matei CEO
www.alexmatei.com
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 14th Jun 2014 20:59 Edited at: 14th Jun 2014 21:02
I wouldn't recommend using real-time lights for a muzzle flash. They're kind of expensive. Instead, do something with a plain object positioned at the tip of the gun, and play around with the screen's lighting directly.

As to collision, see sparky's collision plugin and the this example to get you started.

MateiSoft Romania
12
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 15th Jun 2014 03:18
TheComet,

Thank you very much for your time and for your help man! You are on credits, you helped me so well! Thank you!

Game development will evolve much faster with people like you helping games taking shape much faster when the main developer is stuck!

Alex Matei CEO
www.alexmatei.com
MateiSoft Romania
12
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 16th Jun 2014 21:47
Hey TheComet,

Do you know why i have an invisible wall in this code? Its a collision code. It works fine only the invisible wall problem!

Thank You!



Alex Matei CEO
www.alexmatei.com

Login to post a reply

Server time is: 2026-07-05 17:55:32
Your offset time is: 2026-07-05 17:55:32