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.

Newcomers DBPro Corner / Question about using shaders

Author
Message
SanBa Games
14
Years of Service
User Offline
Joined: 28th Nov 2009
Location: Silicon Valley
Posted: 3rd Dec 2009 07:22
Hey, I'm sorry for this noob question, but I'm very new to DBP. I was playing around with some shaders and can't seem to figure out how to get them to work. None of them seem to come with any kind of documentation. Is there some common method of implementing all shaders? I've just been loading them, setting object effect, and setting detail mapping on.

Also, I downloaded the relief mapping shader from Nvidia. The texture it comes with has a bumpmap that comes with it that is shaded pink for some reason. I tried using my own texture with my own black and white bumpmap (like most bumpmaps I've dealt with tend to be), but it doesn't work. I can only use the one with the pinkish texture, and there is no documentation anywhere explaining how to make a bumpmap like that for my other textures.

When I load it, I have to set detail mapping to the second pinkish texture, and then it works, but only on the top side of the cube I was testing it on. If you aren't looking at it from the top, you can barely see anything on the cube. Changing the position of the lights doesn't help. What am I doing wrong, and once I figure this out, will I be able to use any shader, or are they all different?

Sanba Games: Because We Can
SanBa Games
14
Years of Service
User Offline
Joined: 28th Nov 2009
Location: Silicon Valley
Posted: 3rd Dec 2009 08:15
Hmm, sorry if there's a way to edit posts, I hate to double post, but I couldn't see if there was a way to do it.

I've kinda figured out how to tweak stuff (for both perform checklist for effect values and also looking in the .fx file with notepad). But for this one, the light position is a constant called float3. I can't figure out how to edit all 3 float values.

Inside the .fx file it says this:
float3 gLamp0Pos : POSITION <
string Object = "PointLight0";
string UIName = "Lamp 0 Position";
string Space = (LIGHT_COORDS);
> = {-0.5f,2.0f,1.25f};

float gTileCount <
string UIName = "Tile Repeat";
string UIWidget = "slider";
float UIMin = 1.0;
float UIStep = 1.0;
float UIMax = 32.0;
> = 8;

I can edit the second one, using set effect constant float 1,"gTileCount",value#

How do I edit the first one so {-0.5f,2.0f,1.25f} = camera x, camera y, camera z? I tried putting it in brackets, parentheses, etc., but I couldn't do it.

Sanba Games: Because We Can
Serial Velocity
16
Years of Service
User Offline
Joined: 24th Aug 2008
Location:
Posted: 3rd Dec 2009 19:00
What you need to do is use a vector4, which is in the 3D Maths section of the docs.

To use it you need to create a vector4 and store it in a variable, this can be done like this:



Now, to use this vector to send stuff to the shader, you will need to set the values with this code:



Finally, use this vector we created to set the parameter of the shader:



At the end of your code, it's wise to delete the vector before you exit, using this code:



Hope this was helpful!

SanBa Games
14
Years of Service
User Offline
Joined: 28th Nov 2009
Location: Silicon Valley
Posted: 5th Dec 2009 06:11
Very helpful, thanks.

There's only one more thing that isn't working out for me: I can't use this shader with any texture but the one that came with it, and there's no variable to change this texture. I looked in the code, and the name of the texture was hardcoded into it, and even changing that didn't seem to help.

Sanba Games: Because We Can
Outscape
16
Years of Service
User Offline
Joined: 23rd May 2008
Location:
Posted: 8th Dec 2009 19:59
Quote: "Hmm, sorry if there's a way to edit posts"


do you see where it says
SanBa Games (your name)
then your Avatar
Joined: Sat Nov 28th 2009
Location: Silicon Valley

well just below that it says edit post



Login to post a reply

Server time is: 2024-11-24 23:55:06
Your offset time is: 2024-11-24 23:55:06