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 / [STICKY] Learning to write Shaders

Author
Message
nruser
16
Years of Service
User Offline
Joined: 22nd Dec 2007
Location: Serbia
Posted: 16th Aug 2011 17:59
here is complete project with media try using both models and shaders to see the problem, both shaders produce strange artifact in the middle of the model or even worse, the head model and textures are mine that i used for testing.

Attachments

Login to view attachments
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 19th Aug 2011 13:21
Had a quick look at this. Are you having problems with both models or just the head? I could see obvious "seam" problems with the head model but not with the other one (although I'm not convinced either model reacts correctly to the light).

For the head model I suspect the mirroring of the UV coordinates is the problem although I'm not sure. A possible reason is that the UV coordinates will switch from a left-handed system to a right-handed system as you cross the seam and this could be causing problems with the calculation of tangents and binormals which I guess assume one or the other.

If that is the cause then a fix might be possible although I rather doubt it since tangents and binormals are calculated by the engine not by the shader or your DBPro code. A better solution would be to use a mirrored image with UV coordinates to match. Then any seam problems should disappear. I'll try to find time to look into it more closely over the next few days.
david w
18
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 21st Aug 2011 23:59
I previously posted about normal calcualtion in this shader.
I really want to know if I am doing it correctly.
Can anyone look over the code and just verify?

nruser
16
Years of Service
User Offline
Joined: 22nd Dec 2007
Location: Serbia
Posted: 22nd Aug 2011 02:30
@Green Gandalf
i have problems with the head model primarily, i tried to have uv's that are not mirrored but seam is then visible at the back of the head

the second model is the model of quake4 marine body and it uses original textures from the game, i ahve noticed that it has problems with the light and with height map
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 22nd Aug 2011 17:33 Edited at: 22nd Aug 2011 17:36
Just spent 2 hours going through every shader demo. Wow, some great stuff in here!!!

My next project will have about 600 ants in it. I was wondering if a fairly decent computer can handle 600 shiny, normal mapped ants. What do you think? What's the fastest shader for that?

I made them very low poly.. probably less than 700. Spent 3 days making them look good, manually moving all of the points.

nruser
16
Years of Service
User Offline
Joined: 22nd Dec 2007
Location: Serbia
Posted: 28th Aug 2011 22:55
just small update, i have fixed my problem with the shaders, for some reason i needed to apply normalize.dds cube map from ultimate shader pack to my models
Chris Ritchie
18
Years of Service
User Offline
Joined: 7th Jan 2006
Location: Norn Iron
Posted: 30th Aug 2011 21:12 Edited at: 30th Aug 2011 21:34
Hey guys, first off let me say I know nothing about shader programming so I was wondering if one of you guru's could give me some help.
I recently download Evolved's fantastic tree shader off his site.
The shader works well with my trees but I was wondering would there be any way to add extra alpha commands so that not only do the leaf models have transparency but also the leaves them selves be transparent. I originally used "set alpha mapping on" to fade the trees in and out but obviously with the shader handling the rendering this no longer works. So what im asking is could a scaleable transparency be added instead here's the shader.

Hoping someone can help here thanks.





Lead programmer ULIDIA
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 31st Aug 2011 22:30
Hi All, Sorry I've been a bit quiet recently. Just been very busy with domestic matters - and still will be for a while so here's just a few quick comments for now.

david w I hope to find time to look at your issue "soon" (but not that soon I'm afraid ).

nruser Yes. Some of Evolved's shaders use a normalization map to normalize 3D vectors - it reduces the arithmetic instruction count needed. On older hardware that speeded things up a bit but I understand that modern graphics cards work better if the shader does the necessary maths itself rather than do a texture look-up. I think I read that in an NVidia paper somewhere. You could just use a normalize command in the shader instead of the texture lookup.

Chris Ritchie The short answer is "yes". Hopefully someone will have time to give you a detailed answer before I get a chance to look at it.
spudnick
13
Years of Service
User Offline
Joined: 30th Nov 2010
Location:
Posted: 2nd Sep 2011 21:40
Hello shader experts
Im on a quest to get some help on a shader that is in Dark Shader program.
its called a Scrolling shader, for those who don't have it here is code.


As people who has DS that this shader scrolls a texture, wich is fine.
But what i would like is for it to basicly scroll back and forth, meanining the direction from left to right in a loop or right to left wich ever, but as standard in DS is that you have 2 slide bars that cordinates the scroll either up down left right or combo.

An i just would like it to make a left and right movement Example move left or right for 1 sceond and then reverse.

So then i could use it for making items look like their moving from left and right like they are swaying.

Would be most greatfull for any help. Thanks

I'am not GOD but i can make you see again by taking my fingers out of your eyes and i can make you walk again by taking your beer away, but if you take my beer you will not walk again
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 3rd Sep 2011 08:27
Hi spudnick, hows this?
spudnick
13
Years of Service
User Offline
Joined: 30th Nov 2010
Location:
Posted: 3rd Sep 2011 11:33 Edited at: 3rd Sep 2011 15:09
Thank you revenant chaos.

That works perfect.

i only had to change the speed and distance settings to suite my needs

I'am not GOD but i can make you see again by taking my fingers out of your eyes and i can make you walk again by taking your beer away, but if you take my beer you will not walk again
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 4th Sep 2011 11:07
Hi Chris Ritchie, is this what you are looking for (demo attached)? If you want I could make a version which automatically fades with distance.

Attachments

Login to view attachments
Chris Ritchie
18
Years of Service
User Offline
Joined: 7th Jan 2006
Location: Norn Iron
Posted: 4th Sep 2011 15:36
@ revenant chaos

Thanks man that worked perfectly. I would love to see one with distance fading, I think with that I could put a tick next to my trees and call them done . Thanks again for the help.


Lead programmer ULIDIA
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 4th Sep 2011 17:34
Ok Chris, here is a version which automatically fades over a distance. It has "tweakable" variables to adjust the distance at which the fade starts and the fade's range.

Attachments

Login to view attachments
Chris Ritchie
18
Years of Service
User Offline
Joined: 7th Jan 2006
Location: Norn Iron
Posted: 5th Sep 2011 00:05
@ revenant chaos

Outstanding work man, this is exactly what I was looking for. I can now finally say my trees are finished, many thanks.


Lead programmer ULIDIA
spudnick
13
Years of Service
User Offline
Joined: 30th Nov 2010
Location:
Posted: 5th Sep 2011 20:46
Hello, me again

I have a code for my entity in fpsc that is Dynamic

But i was wondering if a normal bump map and be implemented into the fx code, so i can then use a bump map!

Is it possible.
Thank you very much if a wizard can help

I'am not GOD but i can make you see again by taking my fingers out of your eyes and i can make you walk again by taking your beer away, but if you take my beer you will not walk again
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 6th Sep 2011 00:26
@david w

Just had a look at that shader. Although it has my name in the header the rest of the shader looks like it's developed a life of its own.

Anyway, the first thing I noticed was this (I've removed commented or blank lines):



At least three problems there (plus a query):

(1) The final bracket in each of the first four lines is in the wrong place, i.e. the blending weight should be applied to the whole of the previous expression like this



(you might be able to simplify the calculations a bit as well but that's merely an optimization issue and the compiler might do that for you anyway).

(2) The normal vector should only be a float3 not a float4. You can keep the fourth component but you will need to be careful how you do the calculations. For example, unless the fourth component is zero (which I doubt), normalization of the float4 will give the wrong answer. I'd work with float3 throughout.

(3) Since you are normalizing the final result there is no need for the averaging step (not really an error just potentially inefficient if the compiler doesn't detect it).

(4) I don't know what the penultimate line is supposed to be doing.

Hope this helps.
david w
18
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 6th Sep 2011 07:55
That you GG, I implemented your suggested changes. Everything seems to be working better, I even made it so the detail map is not stored in the alpha channgel anymore and changed it so the detail map is a combination of all the maps, look much better and more realistic.

BTW, the line is so you can output to a depth map and then reconstruct position based on the value stored in the map. For lighting you need another shader and a combination of all the maps produced by your scene.

Everything has been modified for deferred shading output, however you could modify and make it single pass again.

Here is a picture for your viewing enjoyment.

BTW, thanks for all the help.

Attachments

Login to view attachments
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 6th Sep 2011 13:11
Glad that helped.

Quote: "BTW, the line is so you can output to a depth map and then reconstruct position based on the value stored in the map. For lighting you need another shader and a combination of all the maps produced by your scene."


I'm not sure we're talking about the same thing. I was talking about this line which doesn't involve position:



If that line works then I'm probably missing something obvious.

Sounds like you're getting deferred shading working the way it's supposed to. I guess you're using C++/Dark GDK since I don't think that method will work in DBPro. Is that correct?
david w
18
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 6th Sep 2011 23:38
Oh ya, lol I guess that line is different than what I thought. Well it does work, its a TBN (tangent,binormal,normal) array/Matrix, I was normalizing against the normal stored at that location.

Your correct, because you can't output like that in DBP that I know of, you need to be able to specify multiple render targets for simultaneous output - need directX low level access - unless TGC adds support in the future. In DBP you need to render multiple times (multiple cameras - multiple passes) to get the same effect, because you can only output to one camera/target at a time.
bergice
16
Years of Service
User Offline
Joined: 5th Jun 2007
Location: Oslo,Norway
Posted: 4th Oct 2011 15:50
Hey, I have been trying to get shaders to work in DarkGDK for a while now, I haven't had any issues with them in DBP however but when I try to use them here they never work. For example if I use the shader posted on the first page:



And use this code to apply the effect:



The object will be invisible.

Any ideas whats wrong? (I have Shader 3.0 model by the way)
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 11th Oct 2011 14:11 Edited at: 11th Oct 2011 14:40
Quote: "Any ideas whats wrong?"


No.

I've just worked through the GDK Shader-Beginner () tutorial and used your shader instead of the one used in the tutorial and it works perfectly:



Perhaps you need to work through those tutorials too.

If that doesn't work perhaps you have a GFX card issue?

Edit Just had a quick look at the GDK board. Which version of VS are you using? I see that some forum members have had problems using PS1 shaders with the more recent version. See if the problem goes away if you change this



to this:

Attachments

Login to view attachments
bergice
16
Years of Service
User Offline
Joined: 5th Jun 2007
Location: Oslo,Norway
Posted: 11th Oct 2011 16:35
You are god!

I love you, here are some hearts to express my love .

Apparently the reason it didn't work was because of the 1.1 compiling.

I have no idea why but I don't care.

And for some information I use Visual C++ Express 2008 Edition and my graphics card is a GeForce GTX 570.


Again thanks! Now I can try to implement pixel lighting for my game.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 11th Oct 2011 19:09
Quote: "And for some information I use Visual C++ Express 2008 Edition and my graphics card is a GeForce GTX 570."


That's weird. I use Visual C++ Express 2008 Edition with a GeForce GTX 585 and the shader works with both PS1 and PS2.

Quote: "I have no idea why but I don't care."


Same here.

Glad you got it working - and now I know how to use the GDK as well.
bergice
16
Years of Service
User Offline
Joined: 5th Jun 2007
Location: Oslo,Norway
Posted: 26th Oct 2011 02:36
I have 2 more questions. Lets say I want to do cubemapping on an object which already has a light rendering effect applied to it, how do I do that?

And if I want to have bumpmapping for my light shader, how can I do this without having to load a separate effect for every texture?
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 27th Oct 2011 13:06
Quote: "Lets say I want to do cubemapping on an object which already has a light rendering effect applied to it, how do I do that?"


Have a look at the attached demo and see if you can work out how the cubemapping is done. Post back if you need more help or explanations.

Quote: "how can I do this without having to load a separate effect for every texture?"


Why would you need a separate effect for each texture? Not sure I understand what you mean. Do you mean "without having separate normal maps for each texture"?

Attachments

Login to view attachments
bergice
16
Years of Service
User Offline
Joined: 5th Jun 2007
Location: Oslo,Norway
Posted: 29th Oct 2011 16:23 Edited at: 29th Oct 2011 16:32
Quote: "Quote: "Lets say I want to do cubemapping on an object which already has a light rendering effect applied to it, how do I do that?"

Have a look at the attached demo and see if you can work out how the cubemapping is done. Post back if you need more help or explanations."


Thanks, I will have a look at that demo then.

[Edit] Thanks, but the problem is I already have a Pixel Lighting effect applied to the objects, but I don't know how to keep the pixel light and have cube mapping reflections applied to the objects as well. Would I need to have an extra technique in the effect?

Quote: "Quote: "how can I do this without having to load a separate effect for every texture?"

Why would you need a separate effect for each texture? Not sure I understand what you mean. Do you mean "without having separate normal maps for each texture"? "


My editor works so that each segment of the map is divided into 1 mesh per texture, and I have a format which processes the segment data. So I have to load an effect for each texture because each shader can only have 1 texture and 1 normal map.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 29th Oct 2011 18:20
Quote: "Thanks, but the problem is I already have a Pixel Lighting effect applied to the objects, but I don't know how to keep the pixel light and have cube mapping reflections applied to the objects as well. Would I need to have an extra technique in the effect?"


That's why I suggested you look at the shader code to see how it's done. You wouldn't need an extra technique unless you wanted to retain the option without cubemapping.

Quote: "Quote: "Quote: "how can I do this without having to load a separate effect for every texture?"

Why would you need a separate effect for each texture? Not sure I understand what you mean. Do you mean "without having separate normal maps for each texture"? "

My editor works so that each segment of the map is divided into 1 mesh per texture, and I have a format which processes the segment data. So I have to load an effect for each texture because each shader can only have 1 texture and 1 normal map."


The short answer is that I don't know how your editor works and hence can't advise on what is or is not possible.

In DBPro, for example, you can have the same normal mapping shader for several quite different objects as long as they share the same effect constants such as light position, colour, etc (and with a bit of trickery you can get round that restriction). I can't help you with other applications or editors.
nruser
16
Years of Service
User Offline
Joined: 22nd Dec 2007
Location: Serbia
Posted: 2nd Nov 2011 16:30
is there a way to make doom3 shadows (sharp edges on shadows) with evolved's or any other shader, evolved's shadow mapping shader makes different shadow for when used on objects
bergice
16
Years of Service
User Offline
Joined: 5th Jun 2007
Location: Oslo,Norway
Posted: 6th Nov 2011 21:13 Edited at: 6th Nov 2011 21:15
Quote: "The short answer is that I don't know how your editor works and hence can't advise on what is or is not possible.

In DBPro, for example, you can have the same normal mapping shader for several quite different objects as long as they share the same effect constants such as light position, colour, etc (and with a bit of trickery you can get round that restriction). I can't help you with other applications or editors. "


Ah, my mistake then. I thought you could only assign 1 of each texture in a shader.



Quote: "That's why I suggested you look at the shader code to see how it's done. You wouldn't need an extra technique unless you wanted to retain the option without cubemapping."


Okay, I got it now. I changed it so it looks like this:



Is this a good way to do it?
And how can I add point lights or spot lights to the shader now that the lighting is rendered with a directional light?

And finally, will it lag considerably more if I assign the effect to more objects, or does it only use resources on pixels?
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 9th Nov 2011 12:55 Edited at: 9th Nov 2011 13:06
[Edit2 Sorry for delay, I've been away from the forum for a few days. ]

Quote: "Is this a good way to do it?"


Looks OK to me except possibly for one detail. I would apply the lighting to the Texture variable before lerping it with the Cube variable, i.e something like this:



However, if your method gives the result you want don't change it.

Quote: "And how can I add point lights or spot lights to the shader now that the lighting is rendered with a directional light?"


Do you mean you want an extra light? If so, then you just need to add the appropriate calculations to your original lighting formula, i.e. change this float4 expression



to something like this



where PositionalLight is calculated in a similar way to your Light variable. The main difference is that the point light direction needs to be calculated per pixel. For example, I would pass something like a PositionalLightDirection variable from the vertex shader, i.e. something like



and normalize it in the pixel shader before using it.

[Edited original message because of a foul-up in the original posting. ]
bergice
16
Years of Service
User Offline
Joined: 5th Jun 2007
Location: Oslo,Norway
Posted: 10th Nov 2011 03:24
Ok, thanks for the response.

Yeah, I thought the cubemapping looked kind of bland. It looks much better now, so thanks.

I will experiment with the light a little and see if I can get that to work as well.

If I add normal mapping to the shader as well how many objects can I render with the shader before it starts lagging? Will it help if I have LOD meshes for them so they render normally if they are further away?
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 10th Nov 2011 19:00
Quote: "If I add normal mapping to the shader as well how many objects can I render with the shader before it starts lagging? Will it help if I have LOD meshes for them so they render normally if they are further away?"


Hard to say precisely. A lot depends on your target hardware of course.

Normal mapping tends to be heavy on the pixel shader which means that the total number of bumpmapped pixels on the screen will be more important than the number of objects (unless they are very high poly). It probably would be a good idea to use LOD objects which render normally when distant - to reduce both vertex and pixel processing. As you imply, bump mapping is wasted on distant objects.

I suggest you experiment a bit.

Post back if you need help with the positional light.
nruser
16
Years of Service
User Offline
Joined: 22nd Dec 2007
Location: Serbia
Posted: 17th Nov 2011 21:18
can somebody make a shader that does parallax mapping but also uses specular texture for creating specular highlights?
david w
18
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 18th Nov 2011 08:22
Evolveds already does this, you just have to change the SpecularIntensity value to read from the specular texture. Simple implementation I'm sure you can handle it based on my explantion, good luck.
nruser
16
Years of Service
User Offline
Joined: 22nd Dec 2007
Location: Serbia
Posted: 19th Nov 2011 18:50
this is from evolveds shader


and this is from one that i am using


the shader that i use uses diffuse, height, normal, specular, and emissive maps, but specular map causes seams

how can i fix this???
david w
18
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 20th Nov 2011 06:30
What are the sampler states for you SpecTex texture. I'm assuming that is the one you are sampling for the specular texture that you want to apply to the mesh. I suggest using WRAP and not CLAMP becuase the specular texture should be just basically an overlay on top that controls the "shine" for each part of the mesh.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 20th Nov 2011 11:48
Other way around surely?

Those code snippets don't tell us anything about the cause of the seams - or where they are. Screenshots and/or code would help.
Inflictive
14
Years of Service
User Offline
Joined: 16th Jun 2009
Location: Altis
Posted: 21st Nov 2011 01:43
Hi, I am in need of a shader which supports both normal mapping and specular mapping. I have this one from dark shader which supports both, but it requires the object to have bones. I have posted the code below, can someone please modify it so it doesen't use or require bones? Btw please keep the slider stuff because I want to still be able to customize it in dark shader. Thanks!



Your signature has been erased by a mod - Please reduce it to (600x120) maximum size
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 21st Nov 2011 21:42 Edited at: 21st Nov 2011 21:45
Hi there...I don't know where to make this question . Time ago ..about two years, I bought DarkShader, and every attempt using the program , gave up trying. I thought that if I saw my model in Darkshader preview, and export example code, the model was ready to use, as it must be, but all I get, is a piece of code with some dds files and a Normal Mapping.dbs that appears complete black when I compile the code. What should I do to export correctly??

I appreciate any help. Attached my problem

Cheers.

I'm not a grumpy grandpa

Attachments

Login to view attachments
david w
18
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 21st Nov 2011 21:49
I have to agree with GG on this, its to difficult to determine the cause of your seams without additional information. I would like to help but without your shader code at the very least it is just going to be us stabbing in the dark for solutions.

@inflictive studios, I think you are trying for something similar to nruser. I think it would be simpler to just make a new shader that does normal mapping with specular highlights (from a specular map). Could you please provide a sample project that has the shader + code + bone model(that works with your shader). So I can make your stuff work in a way that is compatable with what you currently have.
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 21st Nov 2011 21:54
@david w
Sorry...I'm a fool...my example is above.

Cheers.

I'm not a grumpy grandpa
david w
18
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 21st Nov 2011 23:12
Maybe I overlooked it, anyways I'm stepping through it now so hopefully I will have something for you soon.
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 21st Nov 2011 23:17
@david w Thanks.

At the moment, what I can do, is just use shader that other people do changing and renaming textures.

Cheers.

I'm not a grumpy grandpa
david w
18
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 22nd Nov 2011 01:38
Ok chafari I think I have basically what you are looking for. I commented some stuff out because one function was missing and I don't have the slider modifiers here. I hardcoded some values in but you can change them from inside DBP. Also I commented out the multiple lights but you just need to uncomment that part to make them work again. Also you need to put the array stuff back in for lightcolor and position.

Attachments

Login to view attachments
david w
18
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 22nd Nov 2011 01:38
Here is a screenShot of the final result I came up with.

Attachments

Login to view attachments
Inflictive
14
Years of Service
User Offline
Joined: 16th Jun 2009
Location: Altis
Posted: 22nd Nov 2011 02:58
@david w

I don't see how you could use anything else for the shader. The shader code, posted above, is from dark shader. I believe the reason the shader requires bones is so on an animated model, it would pdate the lighting correctly. I just want someone who knows hlsl to remove the part with the bone updates so it works with non-boned models, but not as well with boned and animated ones. Thanks.

Your signature has been erased by a mod - Please reduce it to (600x120) maximum size
Inflictive
14
Years of Service
User Offline
Joined: 16th Jun 2009
Location: Altis
Posted: 22nd Nov 2011 03:01
@david w

I haven't tried to put it in a project or anything yet, i'm just trying to get it looking right in dark shader. I'm using the built-in sphere primitive and some maps for planet earth I got off the internet to test it out and it doesen't work beause the sphere primitive doesen't have bons.

Your signature has been erased by a mod - Please reduce it to (600x120) maximum size
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 22nd Nov 2011 03:41
@david w Thanks for your help. This piece of code I posted before, was the code that Darksaders export....so I can't figure out how can we manage the program with this poor code from Darkshader.

This is the example code from Darkshader that is supposed to work with the exported example.

Quote: "rem Initialise
sync on
sync rate 0

rem Load model and shader effect
load object "cube.dbo",1
autocam off
load effect "Normal Mapping.dbs",1,1
set object effect 1,1

do
rem Draw main camera
sync mask %001 : sync
loop"


Thanks again, and I will try again .

Cheers.

I'm not a grumpy grandpa
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 22nd Nov 2011 16:22
Chafari

I can't get it to work either - even with a complete version of the code suggested by the DS Help/Help Contents/Exporting/Passing Lights To a Shader file.

In fact the command you are supposed to use with that shader, i.e.



gives a compiler "parameter mismatch" error and there seems to be no simple way of finding out what the mismatch is.

I'm sure it worked once - but I get the same error with both U6.7 and U7.7.

If you need only a few positional lights, 2 or 3 say, it might be simpler to declare each light separately and unroll the for loops. Alternatively, and more in keeping with the existing shader, you could pass the relevant data using matrices, i.e. using



That way you could pass position details for four lights per matrix and similarly for their colours.

I'm sure us two grumpy grandpas should be able to work this out between us. Are you interested?

Login to post a reply

Server time is: 2024-04-20 01:48:20
Your offset time is: 2024-04-20 01:48:20