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.

Dark GDK / Evolved Flashlight + Normalmapping Shader

Author
Message
Gunslinger
12
Years of Service
User Offline
Joined: 29th May 2007
Location:
Posted: 3rd Sep 2012 23:41 Edited at: 3rd Sep 2012 23:42
Hello,
currently i'm porting evolveds DBPro material import of his material edtor to DarkDGK.

http://www.evolved-software.com/materialeditor/materialeditor

But i've got a problem for my project.
If i load up the map with normal mapping shaders, i can't use his flashlight shader :/

Is anybody here who can write HLSL Shader and could combine this 2 shaders?
Would be really great, i've allready tried it, but the object just gets invisible.

NormalMapping.fx:


Flashlight.fx:
Hawkblood
9
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 4th Sep 2012 18:21
Evolved has a multi-light normal mapping fx. It can handle 6 lights and 1 flashlight. You can modify the code to handle as many lights as you want, but if you go too high, it will be slow. Most of the time I only use 2 or 3 lights at a time and it works great.

The fastest code is the code never written.
Gunslinger
12
Years of Service
User Offline
Joined: 29th May 2007
Location:
Posted: 5th Sep 2012 16:56
Where? Can you send me a link?

Would be awesome!

(i'm only using 4 lights + flashlight), but i need that in combination with normal mapping, thats the problem
Hawkblood
9
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 5th Sep 2012 16:59
http://www.evolved-software.com/shaders/bumpmapping

The fastest code is the code never written.
Gunslinger
12
Years of Service
User Offline
Joined: 29th May 2007
Location:
Posted: 5th Sep 2012 17:03
If i want to use the flashlight shader, i have to add the flashlight shader to a surface.
If i do that, i can't use the normal mapping shader on the same surface.

Or did i misunderstand something?
Hawkblood
9
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 5th Sep 2012 18:37

There are 6 point lights and 1 flashlight possible with the way it's written. Take a look at the code. You don't need anything more than this unless you want more lights. In your game, you will have to specify the light positions for the point lights and the flashlight. I've never used the flashlight portion of this, but from the code it looks like it just points straight out from the camera in the direction the camera is looking. I assume you know how to use an fx. If not, let me know, and I'll try to explain.

The fastest code is the code never written.
Gunslinger
12
Years of Service
User Offline
Joined: 29th May 2007
Location:
Posted: 5th Sep 2012 19:09
Ahhh i got the old NM Shader, that's 2.0 with the flashlight included!
Alright, thank you very much!
Hawkblood
9
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 5th Sep 2012 19:48
No problem. Remember, you can cut down the number of lights or make more passes to accomodate more lights.

The fastest code is the code never written.
Gunslinger
12
Years of Service
User Offline
Joined: 29th May 2007
Location:
Posted: 6th Sep 2012 15:43 Edited at: 6th Sep 2012 16:58
Hm wierd, on the site is just the old shader, and your posted shader code doesn't work :/

e/ Well, it is working, but reall weird. Is there an example for the 2.0 flashlight shader?

Edit2: Ah okay, it's working different now.

new one:
float3 FLightPosition={150.0f,150.0f,0.0f};
float FLightRange=1000.0f;
float3x3 FLightAngle;

old one:
matrix LightProjMatrix;

edit3: No Clue how to use it. How do i pass a float3x3?
Hawkblood
9
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 6th Sep 2012 17:56
Not sure, never used the FL. Did you try changing it to a matrix and sending FLightAngle as a matrix?
Quote: "void dbSetEffectConstantMatrix ( int effectID, string constantName, Matrix4* matrix4 )
"

This is the command in 2.0, but I think it's similar to the one in 1.0.... The "Matrix4" is a 2.0 structure, so 1.0 will have an integer as a reference number refering to a db matrix type. I hope someone with 1.0 is reading this so they can help out. I completely got rid of 1.0 when I converted to 2.0.

It's possible the float3x3 is synonimous with a matrix because a rotation matrix only used 3x3 of the 4x4 in a normal matrix.... What's the worst that could happen? You try to use it as a matrix and your computer bursts into flames, causing a massive fire that destroys your neighborhood.....

The fastest code is the code never written.
Gunslinger
12
Years of Service
User Offline
Joined: 29th May 2007
Location:
Posted: 6th Sep 2012 18:33
NormalMaps + Lights is working.
But the Flashlight isn't :<
Tried it with a matrix, doesn't work.

Could you try it? Would be really great.
Here you'll get Flashlight 1
http://www.evolved-software.com/shaders/lighting
Hawkblood
9
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 6th Sep 2012 22:01
I don't even have 1.0. It wouldn't help you if I did and it was successful......
Looked at what you sent me. You're not useing what I sent you. You're using another .fx. I've never used the one you sent the link to.
DBP adds some of the .fx parameters for you, but I don't know if it adds the view matrix as a rotation matrix. To be safe, send each of these parameters each frame:
Quote: " matrix WorldVP:WorldViewProjection;
matrix World:World;
matrix ViewInv:ViewInverse;
matrix ViewMat={0.5,0,0,0.5,0,-0.5,0,0.5,0,0,0.5,0.5,0,0,0,1};
"

I'm pretty sure DBP sends the "WorldViewProjection" each frame, but I am not sure it sends the "ViewInverse" or the "World" (which may actually be set to "identity" if sent). So you will have to at least send the "ViewInverse" to make the flashlight work. It won't hurt to send them all (except the "World") once per frame. The "World" matrix is used for each of the objects in the scene, so I'm certain it is sent by DBP regardless. The "ViewMat" is the View Matrix and I'm sure it's sent as well. I would start out by sending all but the "World" first and cut them down from there. I hope it works, because I don't have 1.0 and I have stopped using 2.0 also in favor of pure DX/C++. I have used Evolved's "Multipass Lighting" fx with DX/C++ and it works, but I discovered what I described earlier, that DBP sends info to an fx automatically, but it may not send all the info an fx needs for something like the flashlight. If it sounds like I'm rambling, I'm sorry. I've been "out with the guys" if you know what I mean, and I'm not even sure of what I'm typing.....

The fastest code is the code never written.
Gunslinger
12
Years of Service
User Offline
Joined: 29th May 2007
Location:
Posted: 7th Sep 2012 06:48 Edited at: 7th Sep 2012 06:50
I linked you the old flashlight example to show you how the old one worked. I'm using the FX you posted above. (Normal Mapping 2.0, not the old Flashlight)

Well, i'm doing it like this atm:



but it doesn't work.
I don't know how to send that "ViewInverse", i don't even know what that is

Sorry.
Hawkblood
9
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 7th Sep 2012 12:10
Sorry. I don't have 1.0 with me and downloading from where I am would take a few days. Yea, the internet here is SLOOOOOOOW. Look through the documentation for something like "view matrix". You should find a command that will copy the info from DX's view matrix for the camera to a DBP matrix4 (the math "matrix" not the terrain "matrix"). There should also be something like dbInverseMatrix4(..) in the docs as well, so search for that.

There's no reason to use
Quote: "dbSetVector4(1,dbCameraPositionX()-10,dbCameraPositionY()-10,dbCameraPositionZ()-10);"
with -10 on each of the position values. Just take out the -10.
I'm assuming that this part:

is to get the angle for the flashlight..... Right? You should be able to take out all of this if you find the "dbGetViewMatrix" (or whatever the command is. I don't think you will have to use the inverse matrix because, as I mentioned earlier, DBP fills in most of the info for you. I only mentioned it because I wasn't sure if it did. I think if you send the view matrix to "FLightAngle", it will work.

Another way to test the flashlight is to put it at a static position and make an identity matrix to put into "FLightAngle". Be sure that a wall is directly behind the flashlight's position (in the +Z direction) because the default "direction" for an identity matrix is looking directly down the Z axis in the positive direction. Go ahead and set the brightness for your flashlight to something you are sure to see.

One more thing. You are setting "dbSetEffectTechnique(..)" to something with "FL" in it like "Ambient_FL" or "Light1_FL", right? If you don't set the technique, it will default to the first one in the list.

The fastest code is the code never written.
Gunslinger
12
Years of Service
User Offline
Joined: 29th May 2007
Location:
Posted: 7th Sep 2012 12:59 Edited at: 7th Sep 2012 13:09
Okay, "dbSetEffectTechnique(..)" fixed the Problem, had forgotten this

fixed the Angle with ViewMatrix & InverseMatrix.

Dude, thank you sooooo much for your help!
Really, thank you
Good job.

edit/ Just one small problem left.
I've got on the edges of the "ViewMatrix" small white lines. Barely to see. You know why?
Hawkblood
9
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 7th Sep 2012 15:53
Quote: "I've got on the edges of the "ViewMatrix" small white lines"

Can you show me? I don't have a clue what you mean.....

The fastest code is the code never written.
Gunslinger
12
Years of Service
User Offline
Joined: 29th May 2007
Location:
Posted: 7th Sep 2012 16:23 Edited at: 7th Sep 2012 16:26
(Click to get the full size)





and here i changed the view, to see it better. The Edges of the (matrix?) are white.

Hawkblood
9
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 8th Sep 2012 02:30
I think I know what this is. It uses cubic lighting and the edges of the image have artifacts. Take a look at the image and make sure it's not .jpg. If it is, make your own and use .png or something better than .jpg for the flashlight image.

The fastest code is the code never written.
Gunslinger
12
Years of Service
User Offline
Joined: 29th May 2007
Location:
Posted: 8th Sep 2012 08:24
Allready checked that, it's not that
Hawkblood
9
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 8th Sep 2012 09:40
Try your flashlight in a completely darkened room. Also, are you using cubic lighting for the rest of it as well?

The fastest code is the code never written.
Gunslinger
12
Years of Service
User Offline
Joined: 29th May 2007
Location:
Posted: 9th Sep 2012 11:12
Think so, yes. Same shader.
Hawkblood
9
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 10th Sep 2012 16:49
Did you try a completely dark room with 1 flashlight? I am thinking it might be a bleed-over from the other lights.

The fastest code is the code never written.

Login to post a reply

Server time is: 2019-08-22 09:48:48
Your offset time is: 2019-08-22 09:48:48