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 / Color "Highlight" on an object

Author
Message
Gunslinger
19
Years of Service
User Offline
Joined: 29th May 2007
Location:
Posted: 14th Mar 2012 20:04
Hello,
i got an textured object. Now i want to color it, but with 50% (so, the texture is still 50% visible.)

No clue how i can make this...
i tried to create a bitmap, set bitmap fade to 50, create an image out of it and set it to the object. Doesn't work. (As a 2nd texture)
Tried to load a texture with 50% alpha, apply it as another texture to the object, doesn't work.
Tried it with object transparency, doesn't work.

How the hell can i do this :X

thanks
Fallout
23
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 14th Mar 2012 20:12 Edited at: 14th Mar 2012 20:13
You want to look at the light commands, such as set object diffuse. They control how an object interacts with the light in your scene. So an object with a diffuse of rgb(255,0,0) will be completely red, but will still exhibit the features of your texture.

Try set object diffuse objNum,rgb(255,128,128). Not sure how that'll look off the top of my head. Also try the set object emissive and specular commands.

Edit: Sorry, I've got red on the brain (too much blood)!

Gunslinger
19
Years of Service
User Offline
Joined: 29th May 2007
Location:
Posted: 14th Mar 2012 23:42 Edited at: 14th Mar 2012 23:43
Hmm doesn't work
SET OBJECT AMBIENCE does a "little bit" like i want to, but not really...
And if i apply a shader on the object, the effekt is gone.
Do i have to rewrite the shader and add that effect into it? ( I never wrote a shader, and i don't think i can do that. )

Edit: I want it like that: http://s.uvlist.net/l/y2008/07/52148.jpg
Fallout
23
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 15th Mar 2012 00:30
Is that dungeon keeper? I would imagine they have a different texture for selected tiles and just re-texture the object. That'd be the easiest solution and probably the one I'd use. Otherwise, did you try the SET OBJECT EMMISIVE command? Unlike diffuse, that'll provide it's own glow, although that may also be affected by applying a shader.

Ramon156
14
Years of Service
User Offline
Joined: 13th Jul 2011
Location: Netherlands
Posted: 15th Mar 2012 09:32
I do agree with Fallout. Simply have the object change between 2 textures. That would be easy.

You can make a shader and apply it to the texture, or draw a semi-transparent texture over the area you want to be highlighted.

Using shaders is the probably the "best" way of doing it.
Gunslinger
19
Years of Service
User Offline
Joined: 29th May 2007
Location:
Posted: 15th Mar 2012 10:50
Hmm no clue how to write such a shader. Is it alot of work? Can somebody do that? :x
basjak
16
Years of Service
User Offline
Joined: 16th Apr 2010
Location: feel like signing up for mars
Posted: 15th Mar 2012 13:18
I don't know what copy of DBpro you've got but if it is dark studio then you should have dark shader with it.
http://www.thegamecreators.com/?m=view_product&id=2078


will this command work with you?:
"Set blend mapping on objno,imgno, mode". where mode = [1 - 11]
Ramon156
14
Years of Service
User Offline
Joined: 13th Jul 2011
Location: Netherlands
Posted: 15th Mar 2012 14:27 Edited at: 15th Mar 2012 14:40
I have no clue either and it's a pain in the to find a good tutorial that's up-to-date with no "this page cannot be found" errors!

http://developer.download.nvidia.com/shaderlibrary/webpages/shader_library.html

For free shaders.

I forgot to add this site :
http://www.facewound.com/tutorials/shader1/
A little tutorial on how to edit shaders, maybe you can just add allot of color.r * 3 into your FX file, I don't know, try it
mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 15th Mar 2012 14:32 Edited at: 15th Mar 2012 17:56
Here is a shader for ya (hope it works as i cant test it now, i did it AFAIR)

just save it and load as .fx file, also you need to send Highlight float values (a.k.a. 1 vector with 3 values) from your game to shader - thats all!

Gunslinger
19
Years of Service
User Offline
Joined: 29th May 2007
Location:
Posted: 15th Mar 2012 16:00
Quote: "also you need to send Highlight float values (a.k.a. 1 vector with 3 values) from your game to shader - thats all!"


Thanks, but no clue what that means
mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 15th Mar 2012 16:10 Edited at: 15th Mar 2012 16:14
I have no access to DBP now . See SET EFFECT CONSTANT FLOAT in Help. You just need to send your highlight value to shader as RGB data (three integer values). Shader have Highlight variable, it's name you should use in DBP.
Gunslinger
19
Years of Service
User Offline
Joined: 29th May 2007
Location:
Posted: 15th Mar 2012 16:54
Doesn't work for me, object is getting invisible.
mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 15th Mar 2012 17:14 Edited at: 15th Mar 2012 17:52
1. You can choose to use * or + to highlight object
2. Shader has RGB range 0.0-1.0 instead of 0-255 (so 0.5 is like 128)

Now THIS shader works fine:

Gunslinger
19
Years of Service
User Offline
Joined: 29th May 2007
Location:
Posted: 15th Mar 2012 22:38
Okay, now that shader works for me too!
Thank you very much!
mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 16th Mar 2012 16:11
But I must admit that now object has no lighting... i can add lighting if you want.
Gunslinger
19
Years of Service
User Offline
Joined: 29th May 2007
Location:
Posted: 16th Mar 2012 16:13
Sure, if you want to
But great work anyway!
Ramon156
14
Years of Service
User Offline
Joined: 13th Jul 2011
Location: Netherlands
Posted: 16th Mar 2012 16:13
How do you get the shader to work with DBPro exactly?

I've saved the shader code as mrHandy posted with notepad to an FX file "Test.FX"

Before the main loop.




My English and DBPro skill is not good enough to understand what's being said in the "set effect constant float" example.
mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 17th Mar 2012 08:58
@Ramon156
Quote: "SET EFFECT CONSTANT float 1,"N",100"

can you remind me how to transfer float3?
like
SET EFFECT CONSTANT float 1,"N",{100,25,53}


@Gunslinger
Gunslinger
19
Years of Service
User Offline
Joined: 29th May 2007
Location:
Posted: 17th Mar 2012 14:44
Thank you mrHandy, going to try it later

Do you have time for another shader?

I could need one that "highlights" the edges of an object.
like this:
http://www.worldofleveldesign.com/categories/3d_modeling/images/maya-beginner-basics/001-maya-beginner-basics-08.jpg

(The Green)

Would be cool if you could do this
Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 17th Mar 2012 15:03
Quote: "I could need one that "highlights" the edges of an object.
like this:"

that effect can't be done in dx9 shaders

Gunslinger
19
Years of Service
User Offline
Joined: 29th May 2007
Location:
Posted: 17th Mar 2012 15:17
Are you sure? Dungeon Keeper 2 is 13 Years old (dx6) and they did it.
Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 17th Mar 2012 18:33 Edited at: 17th Mar 2012 18:37
vertex shaders were introduced in dx8 so yeah, i'm sure. whatever they did, they didn't do it with shaders.

Effect in maya is also not done with shaders, it's just a series of 3D lines rendered around an object

Gunslinger
19
Years of Service
User Offline
Joined: 29th May 2007
Location:
Posted: 17th Mar 2012 20:40
Hmmm any idea how i can realize this?

Maybe clone the object, texture it with that "highlights" and resize it a lil bit bigger...

Got a better idea?
Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 17th Mar 2012 21:37 Edited at: 17th Mar 2012 21:42
Quote: "Maybe clone the object, texture it with that "highlights" and resize it a lil bit bigger..."

i'm quite sure that won't work. Using scaling technique you can achieve highlight that is used in blender. But for that you will need commands for disabling and enabling writing to the color buffer and several others. Dbpro doesn't have any of them and there aren't plugins that have them so without switching to DarkGDK that is impossible to do. And even then you would need to render each object manualy (without the use of sync command). The most closer you can get to that is using a cartoon shader and that is possible in both dbpro and DarkGDK and is very easy to do.

Quote: "Hmmm any idea how i can realize this?"

Yes, but it won't be easy.
First: you have to know that in that maya screenshot you posted above the object (box) is constructed out of quads. Maya objects have a list of polygons. Each polygon have a list of vertices and edges. Using that edge list one can construct a list of 3D lines that represent that edges and then render them on top of an object.
So, if you want to do that in dbpro you first need an edge list. If you render all the edges it's the same thing as if you rendered object in wireframe mode (is that what you want?).
In wireframe mode all the triangle edges are rendered. If you don't want that then you'll have to specify what exactly do you want. In order to render only quad outline as in the maya screenshot you'll have to make your objects out of quads (dbpro only supports triangles so you'll have to keep that data in an array and make your object manualy and not using MAKE OBJECT commands)

Gunslinger
19
Years of Service
User Offline
Joined: 29th May 2007
Location:
Posted: 17th Mar 2012 22:52 Edited at: 17th Mar 2012 23:03
Well, cloning objects does it. At the moment... if it's too slow i'll have to think about something different.



Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 17th Mar 2012 23:13
Quote: "Well, cloning objects does it. At the moment... if it's too slow i'll have to think about something different."

yeah, i forgot what was this thread about. I thought you need this for any type of object but you need it only for a box. It will work fast, don't worry

mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 18th Mar 2012 11:51
Quote: "that effect can't be done in dx9 shaders"

LOL joke of the month
everything can be done in dx9

Then about highlighting an object edges... there is two good ways to do that:
1. screen space edge detection shader. Perfect but you need shader skills.
2. classic way: slightly bigger clone with inverted normals. Scaling object is good only if it is box or sphere. If it is complicated object, you should make a clone of it in 3d edtior using some kind of "shell"-type modifiers.

I can try to make a shader for complicated clone object if you have not got such 3d editor.
Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 19th Mar 2012 00:12
Quote: "LOL joke of the month
everything can be done in dx9"

it really isn't. The vertex shader isn't aware of other poly vertices and to pull that effect you need to be aware of that. Google nVidia wireframe shader (it is directx 10 only and can't be converted)

Quote: "2. classic way: slightly bigger clone with inverted normals. Scaling object is good only if it is box or sphere. If it is complicated object, you should make a clone of it in 3d edtior using some kind of "shell"-type modifiers.
"

it seems he only needs this for box object so the method he choose is good enough

mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 19th Mar 2012 09:20
Quote: "nVidia wireframe shader"

Uh huh, so "set object wireframe" needs DX10. Right.
Quote: "it really isn't."

If you can't - other can.

You could try to point me at DX11 geometry tesselation or geometry instancing, but it is some exotic that must be in a new version of DX to make sense of it.

@Gunslinger
Quote: "Well, cloning objects does it. At the moment... if it's too slow i'll have to think about something different.
"

You just need to make 1 clone of current object - it cant be slow!

Although, you should try SET WIREFRAME OBJECT on clone.
Millenium7
21
Years of Service
User Offline
Joined: 13th Dec 2004
Location:
Posted: 19th Mar 2012 09:42
why is this such a big problem? i've seen a DBPro project use it before. As was already mentioned dungeon keeper 2 has it, neverwinter nights does it, xiii does it

I don't personally have the solution, but to say that some of these techniques are DX10/11 exclusive is just LOL
mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 19th Mar 2012 10:01 Edited at: 19th Mar 2012 10:03
Quote: "but to say that some of these techniques are DX10/11 exclusive is just LOL "

Yep, joke of month

So let me write again all ways to highlight an object:
1. Screen-space shader. Complicated but powerful.
2. Regular shader A : highlight whole body
3. Regular shader B : highlight edges using fresnel method
4. Clone object, invert its normals and upscale a bit - edges
5. Regular shader for cloned object that extrudes it's poly's a bit and inverts 'em - edges
Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 19th Mar 2012 10:06
Quote: "Uh huh, so "set object wireframe" needs DX10. Right."

I meant the wireframe rendering as show in the screen shot above. The screenshot shows wireframe rendering in maya. If you look at it you will see that triangles aren't rendered in wireframe, quads are. It is quad wireframe rendering -> that in you want it done in shader needs dx10 and he asked for a shader. In maya that is done with 3d lines which of course doesn't need dx10. You ushould really google it, i'm not making stuff up. SET OBJECT WIREFRAME renders triangles and that wasn't the thing i was talking about.

Quote: "I don't personally have the solution, but to say that some of these techniques are DX10/11 exclusive is just LOL "

As written in the first part of this post i was talking about rendering outlines of quads inside the shader which can't be done in dx9. I wasn't talking about regular wireframe rendering.


And as i stated before i missunderstood the OP original intentions. I thought he wants to render quad outlines as in screenshot he provided but he only wants to render box edges so his solution is good enough, he doesn't need fancy shaders nor dx10

mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 19th Mar 2012 10:26 Edited at: 19th Mar 2012 10:28
Quote: "quads are"

Not quads only - world doesn't made of same size boxes. On this picture you can see that such "highlighting" of objects is not suitable for game design. Only middle thingie looks good. Because it's for 3d artist, not gamer. Anyway, DB's wireframe mode will suck in game too, I used it for debugging levels. (notice: wireframing is not in my (see upper) methods list)

Login to post a reply

Server time is: 2026-07-10 08:48:12
Your offset time is: 2026-07-10 08:48:12