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 / Pixel shader for smooth lighting?

Author
Message
Image All
19
Years of Service
User Offline
Joined: 30th Dec 2005
Location: Home
Posted: 14th Feb 2006 00:17 Edited at: 14th Feb 2006 00:17
Hi

I made my stickman walk around on my world (yay ) but the lighting sucks. I need to use a pixel shader to make the light show smoothly on him, instead of this bloody gradient business, but I don't see any command for this in DBP. Is there something I'm not seeing, another command perhapse, or do I have to download a bloody DLL to make this kind of pixel shading work?

(example of light on my stickman with the default Vertex Shader)


Thnx for any help

FunkyStickmen: Battle of the Races (1%)
Preston C
22
Years of Service
User Offline
Joined: 16th May 2003
Location: Penn State University Park
Posted: 14th Feb 2006 00:46 Edited at: 14th Feb 2006 00:48
First, I haven't used Dark Basic Pro in what must be ages, so bare with me.

In order to load a shader, you would use the following code:


Where "Bleh.fx" is the shader you want to load, and then you apply it to the object you want.

What you are looking for, to make the shading of your Stickman smoother, doesn't necessarily require shaders; if you had more polygons in the sphere for his head you would get better shading, and chances are you wouldn't have as bad of a performance hit as if you had used a shader (albiet, depending on the shader, the hit would be barely noticable on newer systems).

However, if you are looking on using shaders properly, I would suggest reading The Ultimate Shader Thread 2.0. Inside is documentation on how to use a shader properly, links to example shaders, etc, etc.

Hope that helps.

AMD64 X2 3800+ | 1 GB Ram | NVIDIA GeForce 6800 128MB
MSVC++ .Net 2003 | Wings3D | CharacterFX | Gimp v2.0
Formerly NWC_Omega
Milkman
19
Years of Service
User Offline
Joined: 30th Nov 2005
Location: United States
Posted: 14th Feb 2006 00:53
You don't need shaders for this kind of thing...

"set object smoothing num,50" should do the trick

formerly xMik
Image All
19
Years of Service
User Offline
Joined: 30th Dec 2005
Location: Home
Posted: 14th Feb 2006 02:35 Edited at: 14th Feb 2006 02:46
Quote: "What you are looking for, to make the shading of your Stickman smoother, doesn't necessarily require shaders; if you had more polygons in the sphere for his head ..."


-_-.... That would be an unnecessary increase in polycount, and a waste. I'm not looking to add effects or a high polycount, I want to make my comp compute the lighting against every pixel of the faces which make the stickman's head, not by calculating the light which hits each vertex and adding a gradient from lighter to darker based on which vertices are light and which aren't. See here Plus I just tried increasing the polycount...it makes him look like an old geezer

@xMilk: That command is for making dull-looking flat polygon models smoothed, using per-vertex lighting which is what I'm trying to escape here o_O

FunkyStickmen: Battle of the Races (1%)
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 14th Feb 2006 12:44
Woah - that's horrible! Looks like you have either set the specularity up to the max, or you have a light source right next to his head. Either tone down the specularity by reducing the rgb value, or increase the value of set object specular power, or decrease the diffuse rgb value. A normal low poly sphere should look like this under normal lighting:



Increasing the number of polygons will obviously improve the smoothness.

Preston C
22
Years of Service
User Offline
Joined: 16th May 2003
Location: Penn State University Park
Posted: 14th Feb 2006 16:04 Edited at: 14th Feb 2006 16:43
Image, what I told you is the (or rather one) correct way to do things. You want phong shading or something similar. An effect file will get you what you want, they are basically vertex shaders and pixel shaders combined. The thing is you just have to find an effect file and appropriate media which will do that for you.

I would suggest taking a look in the link I provided for you. Inside are explanations on how to use shaders in your Dark Basic Pro programs, and several quality example shaders programmed by several members of the forums (and a few trash ones by me, but one of which is similar to the effect you want).

Other solutions to your problem could be using Dark Basic Pro's Sphere Mapping and Cube Mapping commands with specially prepared textures to simulate what you want and disabling lighting for your object. People have used the sphere mapping commands to do cartoon shading before, using a similar sphere map used for that with a smoother color blending would give you what you want easily. I can post an example of a sphere map like that when I get home (posting from a school PC at the moment).

Take your pick, you have several choices available to you.

Also, I would suggest you take a look at the help files included with Dark Basic Pro, either, to find commands to do what you want done. If I recall correctly there are even commands that will set a pixel shader or vertex shader onto your object seperately, as well with examples to go with them; their names are self explanitory, not hard to find. But just like with the effects, and every other method I just described, you need a proper shader or textures to achieve the effect you want.

AMD64 X2 3800+ | 1 GB Ram | NVIDIA GeForce 6800 128MB
MSVC++ .Net 2003 | Wings3D | CharacterFX | Gimp v2.0
Formerly NWC_Omega
Matinuker
21
Years of Service
User Offline
Joined: 25th Mar 2004
Location:
Posted: 14th Feb 2006 16:48 Edited at: 14th Feb 2006 16:49
You could just, when you make the sphere, set the
Rows and Columns up really high

It would probably make it smooth but
the poly count would be really high.

Edit: Ah, skipped a post or two. Sorry

Image All
19
Years of Service
User Offline
Joined: 30th Dec 2005
Location: Home
Posted: 14th Feb 2006 17:02
@Ric: I'll try adjusting the diffuse, which is the only one I altered, but it's confusing cuz everything looks better and smoother in MilkShape o_O

@PrestonC: I guess I'm more noobish than I thought I expected what I consider "Effects" to be something like fire or something, cuz there was this one LOTR game commentary video I found or something, and they were talking about how they added a "fire effect" to the big black demon guy's limbs in the mine place thingy. 0.o

@Matinuker: I don't generate the sphere in DBP, it's a textured mesh, which is modeled with the rest of the body, and it has a mouth.

FunkyStickmen: Battle of the Races (1%)
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 14th Feb 2006 21:28
Try texturing it with a plain yellow image. I find textured objects light MUCH better than non-textured...

Image All
19
Years of Service
User Offline
Joined: 30th Dec 2005
Location: Home
Posted: 15th Feb 2006 00:39
I did...


but I'll bet the problem is that I set the Diffuse value to 255,255,255

FunkyStickmen: Battle of the Races (1%)
Milkman
19
Years of Service
User Offline
Joined: 30th Nov 2005
Location: United States
Posted: 15th Feb 2006 01:06
Image All, did you even try the 'set object smoothing' command? it smooths out an object's normals and makes the lighting appear a whole lot better...

formerly xMik
Image All
19
Years of Service
User Offline
Joined: 30th Dec 2005
Location: Home
Posted: 15th Feb 2006 03:21
I did try that - no it didn't work. That command (as I've said earlier) uses per-vertex shading to make things look smooth; the problem I have here is with per-vertex shading, becuase it makes the edge of the shadow look all ridged and ugly b][/b]O

FunkyStickmen: Battle of the Races (1%)
Agent Dink
21
Years of Service
User Offline
Joined: 30th Mar 2004
Location:
Posted: 15th Feb 2006 20:43
Well, natively DBP does not offer pixel based lighting, you need a shader for that. I *think* there is a pixel lighting shader in Ultimate Shader Thread. Your best bet though for speed is to adjust the diffuse settings, and smoothing values.

www.badpicsofmatt.tk
www.silver-dawn.net
Catalyst
21
Years of Service
User Offline
Joined: 6th Sep 2003
Location:
Posted: 15th Feb 2006 21:03 Edited at: 15th Feb 2006 21:06
If this in particular is what you need it for, I say tessellate the geometry. Higher poly count isn't going to be hurting that much, you'd be amazed how quickly a shader can hurt on certain cards.

But, if you want per-pixel lighting, I'd rate your two best options at being a phong lighting model (as suggested already), or normal map. Both will give you per-pixel, though phong won't really round out the object. Normal mapping is great on things that are already pretty round and need to be more round, you can make it look very smoothly rounded. Now, your problem with that is it's going to force you into shader lighting. They don't use DBPro lights. They don't use the lights your environment reacts to. They only use lights built into the shader. So if you want a point light, it better have a point light built into it. And if you want to have two point lights...better have two. Basically you need to make sure the shader is set up to support everything you would possibly want the lights to do...then set up all the shader lights along with the DBPro lights so that it looks like your character and environment are responding to the same lights.

Make sense?

EDIT: What kind of lights are you using anyway? Looking at the outer curve of the sphere, doesn't seem like it should be that bad. Are you using spot lights by any chance?
Image All
19
Years of Service
User Offline
Joined: 30th Dec 2005
Location: Home
Posted: 15th Feb 2006 22:19 Edited at: 15th Feb 2006 22:25
I'm just using the regular old Ambient light. I haven't toyed with making my own yet

As for the shader stuff, now that I know I can't just use lights in DBP...that sucks! :[/b]O

I can't alter the geometry, because as I've told all of you, he has a mouth. It's textured geometry, meaning there's a real indent there. If I up the polycount on his head, three things will happen:
1) His mouth will look worse
2) The part of the texture for his eyes will be streached
3) He will look like a shrivled old man



Dangit, altering the diffuse doesn't work. DBP is ignoring the diffuse value I put in his head material. That means I have to set limb diffuse manually! But I don't know how to get the numbers of the limbs b]
O I can get them, I just can't see them.

FunkyStickmen: Battle of the Races (1%)
Image All
19
Years of Service
User Offline
Joined: 30th Dec 2005
Location: Home
Posted: 16th Feb 2006 09:17 Edited at: 16th Feb 2006 09:19
Quote: "But I don't know how to get the numbers of the limbs b][/b]O I can get them, I just can't see them."

*hint hint*

FunkyStickmen: Battle of the Races (1%)
Legendx
20
Years of Service
User Offline
Joined: 13th Jan 2005
Location:
Posted: 17th Feb 2006 07:10
what you should do is get the model looking all smooth and stuff with nice lighting in your modelling prog then bake the texture/render to texture so that your texture has the lighting built in...this does mean the lighting wont be dynamic/real time, but is that gonna be a big issue for you in this game? If all you need is a nice looking shaded sphere then definately texture baking is the way to go, that's what i do...

Login to post a reply

Server time is: 2025-06-06 17:31:31
Your offset time is: 2025-06-06 17:31:31