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
aXeon
16
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 11th Oct 2007 16:05
Well, when I remove the line that sets a float in the shader,
'set effect constant float', or vector, doesnt matter, then it
works. But when i un-commment them again, they just crash.

I'm using the lastest forceware drivers btw.
My gfx card = Geforce 8600GTS - 256mb.

- : aXeon Essentials : -
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 11th Oct 2007 17:50
Quote: "Edit2 Which DBP upgrade are you using? You should use the latest U6.6b if you are using shaders. Some early versions won't work correctly with shaders."


If that isn't the cause of the problem I have no idea what's causing it.
aXeon
16
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 11th Oct 2007 20:16
Solved it.
Update 6.6b has a bug.
Downgraded to 6.5 and everything is working just fine x3

- : aXeon Essentials : -
Irradic
17
Years of Service
User Offline
Joined: 1st Jul 2006
Location:
Posted: 11th Oct 2007 23:45 Edited at: 12th Oct 2007 00:29
Quote: "@Irradic

Hi! Welcome back.


Quote: "I've been trying since to create a simple background blur shader."

How far did you get? You could approach the problem in various ways. If you can be sure the background really is further away then simple distance based blur applied to all objects might be simplest to implement - but is bound to be heavy computationally because it will probably require multiple passes. If you have Dark Shader then the new DBPro commands and extra shader support that come with it enable you to write more efficient full-screen and blur shaders.


Quote: "Just tested Mike Inels Shader which can be found pretty much in the middle of this page (I attached it anyway). It does have motion blur but would it be possible to add distance blur to it ? The shader has some other quiet useful stuff in it."

Yes, that's a nice shader which implements several useful features - and implements a form of blur quite efficiently. You could probably adapt that quite easily. My guess is that you just need to calculate the BlurX, BlurY and BlurZ values in the vertex shader before using them. If I recall correctly, Mike's demo dba code passes these values to the shader as zero when the object/camera is not moving - you just need to replace that with distance based code in the shader (I think ). Definitely worth a try anyway."

Unfortunately I don't own Darkshader.
I took a look at Inels shader code, but so far I wasn't able to get a static blur. The blur only occurs when you move the camera. I'll try again in a while since I just got home from work. Thanks GG
Edit: I've been playing with the blurx,y,z values, i've been able to blur the whole screen. But how would I go now about offsetting the blur to the distance ? Keeping the motionblur for all objects when moving the camera but having a distance blur. At the moment i'm using a certain blur value + blur value which comes from the camera movement. This equals to a full screen blur with additional motion blur. Do you have any ideas ? Thanks
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 12th Oct 2007 01:29
@aXeon

Quote: "Solved it.
Update 6.6b has a bug.
Downgraded to 6.5 and everything is working just fine x3"


That is very weird - unless your U6.6b upgrade was faulty (upgrades get corrupted sometimes apparently when users install them - although I haven't experienced this myself except when I did the wrong thing ).

Might be worth trying to reinstall U6.6b.

@Irradic

Sounds like you've made good progress.

Quote: "At the moment i'm using a certain blur value + blur value which comes from the camera movement. This equals to a full screen blur with additional motion blur."


I assume it's the "certain blur value" that you'd like to change. A simple option is to work with the Z coordinate in "view" space - larger Z values being further away from the camera as measured straight ahead with 0 being right next to the camera.

You could try something along the following lines:

1. define three new floats in the "tweaks" part of the shader, i.e. nearZ, farZ and blurMax;
2. define a float4x4, WV say, with the WorldView semantic in the header part of the shader;
3. in the vertex shader define a float, "depth" say, as "mul(In.Position, WV).z" (assuming the input position is called position in the shader);
4. again in the vertex shader calculate the distance based blur value using something like "distBlur = smoothstep(nearZ, farZ, depth) * blurMax;";
5. then use distBlur in place of your current "certain blur value".

You may need to experiment with the nearZ, farZ and blurMax values.

The shader intrinsic function "smoothstep" returns 0 if depth is less than nearZ, 1 if depth is greater than farZ, and linearly interpolates between 0 and 1 for values in between.

Good luck.
Irradic
17
Years of Service
User Offline
Joined: 1st Jul 2006
Location:
Posted: 12th Oct 2007 23:57 Edited at: 13th Oct 2007 01:27
@GG

Thanks for the advice. I will see what I can do with that information. I'll keep you posted. Thanks !

edit:
ok i've been trying to implement the code but i'm encountering an "expect token" error at the line
Quote: "distBlur=smoothstep(NearZ,FarZ,depth)*blurMax"
.
If I place "float" infront of "distBlur" the shader does compile. However I guess it's a wrong thing to do, since "distblur always returns the value 0, whatever my value under NearZ,FearZ etc are.
Would you mind taking a look ? I have attached the fx file. Thanks a lot.

Attachments

Login to view attachments
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 13th Oct 2007 23:28
Just recently I got DarkSHADER - I figured it was about time I learnt how these shader things worked.

I've started with limb alpha levels, since there have been queries lately about the DLL that does this.

I started with a pixel shader as this seemed to be the easiest place for me to start. I didn't hit any problems that stopped me for long, and now I've got myself a shader that does what I need it to do - or near enough to not matter too much.

It occurred to me that if I were to do this as a vertex shader instead, then it would be a more efficient use of the GPU. It can't be much different, right? Well, that's what I told myself anyway - it didn't turn out that way, so I think I need some assistance.

Pixel shader question:
When disabling the pixel shader it seems to cause the texture to disappear with it. Currently I'm switching to a 'do nothing' technique instead. Is there a better way?

Vertex shafer question:
All I get is an invisible object in DBPro, and a black object in DarkSHADER. How did I get this so wrong?

Any help with getting it working would be appreciated.

Utility plugins collection and
http://www.matrix1.demon.co.uk for older plug-ins and example code

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: 14th Oct 2007 02:31
@IanM

Just seen your query. No time to look now - but will definitely do so tomorrow (er, I mean later today, ).

Couple of quick comments for now:

1. If you can push calculations out of the pixel shader into the vertex shader it usually pays - but some calculations cause a loss of image quality (as long as the calculations can be linearly interpolated in the pixel shader you'll be OK).

2. Not sure about completely disabling the pixel shader. I'm 60% sure it can be done but most attempts of mine result in failure along the lines you've described so I don't usually try. Your query has prompted me to clarify my knowledge of this - but not tonight. (I'm supposed to be switching off and going to bed ... )

Great to see you having a go at shader stuff.
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 14th Oct 2007 16:17
Quote: "If you can push calculations out of the pixel shader into the vertex shader it usually pays"

That was my thought too. It's simply got to be faster carry out an operation on 6 vertices than it is to carry out that same operation on 1000's of pixels.

Anyway, I look forward to seeing what you come up with, and if you can find where I went wrong.

Utility plugins collection and
http://www.matrix1.demon.co.uk for older plug-ins and example code
aXeon
16
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 14th Oct 2007 16:34
@Green Gandalf:

I was wondering if you could help me 'combine' 2 shaders with eachother as one shader.

I dont know if that's possible since I dont really know alot about shaders...
Anyway, here are the two that I want combined:

VertexFur: (Lights can be removed if possible)


And: Refraction.


I'd like to have this working since I'm trying to create a camera-portal effect as they are in Half-Life 2.
Using the same effect for forcefields.

- : aXeon Essentials : -
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 14th Oct 2007 22:20
@IanM

Had a quick play with your problem and come up with the attached demo. It's a very basic shader which is supposed to texture an object and use alphablending. It consists of two techniques:

1. alpha blending using a vertex and pixel shader combined;
2. simple texturing without a pixel shader (this seems to need UV coords from the vertex shader, and also the sampler[0] effect state to be set in the pass).

Both techniques use the same vertex shader - but only the variables UV and pos are needed in the simple texturing technique.

I haven't yet managed to achieve alpha blending without using the pixel shader. I think it can be done by setting other "effect states" in the pass (like the "sampler[0]" state in the demo) - but I haven't worked out which yet. I suspect these will somehow have to be linked to the output variables from your vertex shader. Paul Johnston can probably tell you.

I confess to being a bit puzzled because I thought I had an alpha demo working without the pixel shader in Dark Shader - but it wouldn't show the alpha fading in DBPro. Another question for Paul I guess.

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: 14th Oct 2007 22:34
@Irradic

Just noticed your edit - sorry.

Couple of points:

1. I think you need WorldView for the depth calculation not WorldViewProjection.
2. You haven't used the variable distBlur anywhere in your code - I was expecting you to combine it with the motion blur variables, BlurX, BlurY and BlurZ.

But, more importantly, I think I forgot that Mike's shader is a full-screen shader (it seems to be at a second quick glance). That might mean my suggestions were wrong anyway. Will have a closer look.
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 15th Oct 2007 15:02
Thanks for looking at that GG, but that still uses a pixel shader. I think I've found a few leads on why it's not as simple as I'd hoped it'd be, and that may suggest a fix for my problem - if I ever get it sorted out I'll let you know.

Utility plugins collection and
http://www.matrix1.demon.co.uk for older plug-ins and example code
Irradic
17
Years of Service
User Offline
Joined: 1st Jul 2006
Location:
Posted: 15th Oct 2007 17:30
Thanks GG. I didn't really know what I'm doing, unfortunately I didn't have the time yet to learb more about hlsl.
I didn't get anywhere with Inels shader so I used Evolveds DOF shader for now. I gave near and far fixed values, so it wouldn't auto focus since I only need the blur for the distance.
Only downpoint is that I have to implement the second shader code in every other shader and objekt that is supposed to be affecting by the blur.
Unfortunately by implementing DOF I have lost the bloom which I used for the neon signs. Last time I researched I read something about impostors ? It was a shader with dof and bloom using impostors, I only understood that the person was using the alpha channels to decrease the amount of rendertargets. Did sound quiet interesting.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 15th Oct 2007 19:51 Edited at: 15th Oct 2007 20:50
@IanM

Got your problem sorted. My previous demo was very close. The attached demo shows two objects with the same shader applied. One has an alpha technique applied by default, the other doesn't. Neither technique uses a pixel shader.

To make it obvious what is being affected in the pixel processing stage I've modulated the colour to pick out the green component of the image AND apply the alpha setting.

You might like to note the vital bits:

1. the use of COLOR0 in the vertex shader to pass the modulating factor;

2. the use of the following in the alpha technique:



I've left in several effect states (but commented out) which I thought might be needed - but don't seem to be. They may be default settings or totally irrelevant. Not sure which since I can't find any decent relevant documentation ( ) - I've been working using a combination of guesswork and the DX9 SDK docs plus one or two sample shaders I found in a book. [Actually, I find guesswork is usually more productive than trying to understand the MS DX9 docs. ]

I'd like to thank you for raising this question because it's forced me to extend my understanding of effect states. I have a MUCH clearer idea of what to look for now.

Edit

OUCH! Basic idea worked - but did you spot the error? I'm sure you can fix it now though.

Attachments

Login to view attachments
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 15th Oct 2007 22:41
Error? Nope.

It's still not quite right though - as soon as you try to add vertex colours, it all goes wrong ... but I think I know why his time

I found this that you might find interesting:

(not from Microsoft DX docs, but from the X3D ISO docs - http://www.web3d.org/x3d/specifications/ISO-IEC-19775-Amendment1-X3DAbstractSpecification/Part01/shaders_hlsl.html)

As soon as you try to deal with the diffuse component, the pipeline appears to butt out and leave all of the colour transformations to you - including the effects on the colour of lighting & normals.

That's far too much work for me at this stage, so I think it's best to leave it for now and switch back to pixel shaders - they appear to be much more predictable.

Utility plugins collection and
http://www.matrix1.demon.co.uk for older plug-ins and example code
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 16th Oct 2007 00:25
Quote: "That's far too much work for me at this stage, so I think it's best to leave it for now and switch back to pixel shaders - they appear to be much more predictable."


Which is what I decided some time back. Virtually all of my shaders have both a vertex and a pixel shader and I don't make much use of things like effect states. However, I think your query is a good example of what I'm missing. Not sure about the impact on performance though.

Quote: "Error? Nope."


Depends how you read my previous post (having just re-read it ). I intended the "no alpha" technique to just reproduce the texture. It doesn't because I used the same vertex shader so the default (and hidden) effect states still modulate the RGB component with the COLOR0 variable in the pixel processing stage. The attached fx file is a simple way of fixing that (non) error.

Quote: "It's still not quite right though - as soon as you try to add vertex colours, it all goes wrong ... but I think I know why his time "


Good. And your solution?

Quote: "I found this that you might find interesting:"


Thanks for that. Actually, I've always assumed that you need to take control of everything when you use a shader - but that isn't quite true as the present example shows (because the defaults might happen to be what you need).

Attachments

Login to view attachments
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 16th Oct 2007 00:46
Quote: "Good. And your solution?"

None at this time - I think that I know *what* is required (transform the vertex diffuse colour using lights & vertex normals), but I don't have the experience with shaders to carry it out yet.

I'm finding that a combination of the DX9 Programmable Graphics Pipeline book and the DX docs together are usable. Appendix C for HLSL, and now Appendix D for the effect states (once you used them, it became a little clearer what part 2 of this appendix was about).

Utility plugins collection and
http://www.matrix1.demon.co.uk for older plug-ins and example code
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 16th Oct 2007 13:16 Edited at: 16th Oct 2007 13:18
Do you mean this book?

Gray, Kris. Microsoft DirectX9 : programmable graphics pipeline.

That's one of the books I was using - I adapted one of the examples for your problem (plus a lot of experimenting ).

Quote: "and now Appendix D for the effect states (once you used them, it became a little clearer what part 2 of this appendix was about)."


I'm sure you're right (even if we're not talking about the same book). It's amazing how much clearer these things become once you've got just ONE example working.

I'll have a go at your vertex colouring problem as well for my own benefit at least.

Quote: "None at this time - I think that I know *what* is required"


Ditto.

I'd expect you to make quick progress with this because I'd guess you know far more about the DX graphics pipeline than I do.

[Edited some confusing quote tags ]
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 16th Oct 2007 15:06
Yup, that's the book. It's just so annoying that to learn anything from it you have to dig through half a book of assembly rather than HLSL - it distracts from the important bits.

Utility plugins collection and
http://www.matrix1.demon.co.uk for older plug-ins and example code
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 16th Oct 2007 16:43
Quote: "It's just so annoying that to learn anything from it you have to dig through half a book of assembly rather than HLSL - it distracts from the important bits."


Indeed.

It would be nice if someone took the trouble to show how all those "effect states", "texture states", "render states", etc, could be used in an HLSL shader. Most shader books I've seen only mention a few of the obvious ones like ALPHABLENDENABLE and CULLMODE - and even then I find a certain amount of inspired guesswork is called for.
Red Ocktober
20
Years of Service
User Offline
Joined: 6th Dec 2003
Location:
Posted: 17th Oct 2007 02:52
hey GG... another question... i think you did something similar a ways back, so this shouldn't be too to much...

how would i add lightmapping to your fog/normal map shader...

i'm using gile[s] and i think it reserves stage 1 for the lightmap in a .dbo object...

thx in advance...

--Mike
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 17th Oct 2007 13:38
@Red Ocktober

I'll put your query in the queue - shader issues have suddenly come to life again.

I also haven't forgotten your earlier query about including shadows in the fog shader - I need to set aside some time to understand it properly myself first. But I will try to get to it ...

While we're on the topic of the fog shader, I've made some tentative improvements. The most recent version that you've seen has a couple of faults:

1. if you move the camera around so it turns upside down then the fog scrolls the wrong way, i.e. it always moves up the screen;

2. it probably wasn't easy to apply in an "open" terrain environment - the demo scene was a closed box where I could easily stop various parameters getting out of a valid range.

I have a partial solution to point 1 which seems to work OK as long as the FPS is not too low (it's a bit jerky on my ailing dinosaur of a PC, but looks fine on my slightly faster laptop). It was more awkward to sort that one out than I expected - I've probably missed something simple that I could use.

I think I've solved point 2 by calculating the fog in the shader rather than using a fog look-up texture - there is a slight hit on performance compared to the latest one on the Ultimate Shader thread but is still noticeably faster than the original version I posted ages ago. However, it should be much easier to apply to general terrain scenes. But I haven't tested that yet ... (been distracted by other things, of course ).

It's about time I cleaned up the new demo and posted it. This weekend perhaps? Then I can try a terrain demo.
Red Ocktober
20
Years of Service
User Offline
Joined: 6th Dec 2003
Location:
Posted: 17th Oct 2007 15:40
yup... you seem to be the single clearing house for shader issues lately... forgive me for adding to the burden, i'm just spread too thin to properly wrap my head around shader coding at the moment...

no apologies for delays necessary... i know how it can be...


so far, your fog and bump mapping shader is working fine in an open terrain and water scene... and i've got the camera range really out there (120000)...



now, i'd really like to add a realtime soft shadow effect to the mix... but in the interim, and possibly as a permanent alternative, the ability to integrate lightmapping into the current shader seems to be a minimal effort, and effective solution... especially when compared to adding realtime (hard or soft) shadowing...

i don't want to burn you out though... i know that this stuff can be really time consuming as well as cause severe migranes at times


just something to keep in mind when the opportunity arrives...

thx...

--Mike
Chris K
20
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 18th Oct 2007 11:31
Shadow Mapping is real time.

Soft shadows are pretty hard, I have some good shadowing code but it's not on this computer which is annoying...

-= Out here in the fields, I fight for my meals =-
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 18th Oct 2007 23:26
@Red Ocktober

Thanks for the feedback - and the image.

Looks like I've solved a non-existent problem with my fog shader. Either that or I need to get you to write my terrain version of the demo of my shader.

Anyway, applying lightmapping should be fairly easy - even if I need your PC (or anyone's really apart from mine) to test it.

At the moment I'm puzzling over creating a bump and horizon mapping shader which should include normal bump mapping and self-shadowing. With luck it'll run on my PC as well. I looked up "horizon mapping" in Google and I found references which said it was far too slow and complicated. I don't believe them. We'll see.
Visigoth
19
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 19th Oct 2007 05:10
@Ian,
Saw your posts. You CAN do all your coloring, lighting, and texturing in a vertex shader only. But you still need the pixel shader. Its the design of the video card. Once you leave the fixed function pipeline, and go into the programmable pipline, all model info first passes through the vertex shader, then its passed out to the pixel shader, and then out to the rasterizer. Just do all your vertex coloring and lighting, etc in the vertex shader, but make sure you pass out the color semantic. Then, in the pixel shader, just assign the output color of the pixel shader to the input color of the vertex shader. In my Rendermonkey thread, there are some effects that demonstrate this. By default, there is no color info on DBPro objects. Also, once you apply an effect, the builtin lights in DBPro are ignored. If you apply an effect, you have to color and light it in your effect, OR, texture the object, then use the 0 texture flag on Load Effect.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 19th Oct 2007 14:52
@Visigoth

Quote: "But you still need the pixel shader"


Not strictly true - you can use the fixed function pipeline for either part, i.e. you can have a vertex shader without a pixel shader and vice versa. You just need to set various effect states. You are of course limited in what you can do if you omit one of the shader steps.

For example, you can do all your lighting calculations in the vertex shader - and use the result without a pixel shader. But you'll generally get better results using per-pixel lighting via a pixel shader.
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 19th Oct 2007 15:20
That's what we've been experimenting with on and off over the past few days - I think we're getting closer. There's no pixel shader code in what I had last night, just setting up the texture stage effects to produce the correct results using the pixel pipeline.

@GG, I noticed an updated version in my inbox via webmail - I'll it until tonight to check it because for some reason it's screwing up the shader text.

Utility plugins collection and
http://www.matrix1.demon.co.uk for older plug-ins and example code
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 19th Oct 2007 18:14
Quote: "because for some reason it's screwing up the shader text."


Perhaps it doesn't like my suggested corrections?
Inspire
17
Years of Service
User Offline
Joined: 23rd Dec 2006
Location: Rochester, NY
Posted: 19th Oct 2007 22:48
Quote: "Looks like I've solved a non-existent problem with my fog shader."


Where is this fog shader? I've read through this thread before, but I haven't seen it.

Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 19th Oct 2007 22:56 Edited at: 19th Oct 2007 22:57
Quote: "Where is this fog shader? I've read through this thread before, but I haven't seen it."


The link is given in one of my posts on this thread around 31 August 2007.

It's a re-worked version of one I posted last year on a thread entitled something like "A dynamic misty smoke or fog ...". A search for "dynamic" should find it - but the new one is faster.
Inspire
17
Years of Service
User Offline
Joined: 23rd Dec 2006
Location: Rochester, NY
Posted: 20th Oct 2007 20:17
Thanks man, I'll take a look.

Visigoth
19
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 20th Oct 2007 20:18
@GG.
Ok, thanks, I haven't got to render states yet. I know they are there, just haven't messed with them yet.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 20th Oct 2007 22:11
@Everyone

I've just posted another shader demo on the WIP/Ultimate Shader Pack thread:

http://forum.thegamecreators.com/?m=forum_view&t=79849&b=8&p=7

It's a first working version of my "bump mapping with self-shadowing" shader. It uses the horizon mapping technique - the horizon maps are pre-calculated DDS volume textures. Let the bug-spotting begin.

@Visigoth

Quote: "I haven't got to render states yet. I know they are there, just haven't messed with them yet."


I've only just started getting to grips with them myself - mainly as a result of a gentle nudge from IanM.
Visigoth
19
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 21st Oct 2007 07:55 Edited at: 21st Oct 2007 07:57
@GG
For What its worth-
I figured out what and why the Rendermonkey .fx exports crap out on some effects. It was real simple, actually. Apparently, DBPro can't or won't handle more than one matrix of the same semantic into a shader. RM outputs effect files with individual shaders. Included in these shaders are matrix variables to the matrixs. If all you do is modify the output .fx file to declare the matrix at the top of the file, and reference it in each shader, all works good. Name mangling for vertex shaders, pixel shaders, and techniques does not seem to have any bad effect.
Mike Inel
21
Years of Service
User Offline
Joined: 14th Feb 2003
Location: Sa upuan ko po...
Posted: 26th Oct 2007 12:34 Edited at: 26th Oct 2007 14:23
Whoa! That was like magic! That's a really cool shader, GG!

Btw, this was one of my probs ever since i had no clue about hlsl...
I think all pixel-based normalmap shaders creates obvious seems in the edges of the UV map of the object. I attached a pic...
I'm able to see this to all Evolved's and GG's normalmap shaders... (including the newest)
I tried vertex-based, and i'm not satisfied... T.T

Any ideas how to fix this?

Edit:
All primitive objects created using dbpro doesn't have seems. My models created in 3dmax always have seems... -.-
And I always thought it was an exporting issue... I tried not applying the shader and the seems are gone.

Attachments

Login to view attachments
Mike Inel
21
Years of Service
User Offline
Joined: 14th Feb 2003
Location: Sa upuan ko po...
Posted: 26th Oct 2007 14:22 Edited at: 27th Oct 2007 05:22
Well, i just can't brag in here and whine my problem...
So, um, here's a skin shader i'm working on... (See attachment)
It's just a revised Evolved's normalmap 2.0 shader though...
But there you'll see at the back the seem i'm trying to say...

Edit:
It seems that almost all normalmap shaders creates seems, including the vertex-based and those that came from DarkShader...
There is one that doesn't make seems, "StandardFX.fx" from 3dsmax9.

But it uses the command "NormalCalc" that i'm not familiar and doesn't work with DBPro...
-_-'

Attachments

Login to view attachments
Mike Inel
21
Years of Service
User Offline
Joined: 14th Feb 2003
Location: Sa upuan ko po...
Posted: 27th Oct 2007 15:33
Ahh, wait... There IS one from DarkShader that doesn't makes seems... The "Normal Mapping.dbs" itself... (i'm obviously not looking much...)
I hope this will solve my problem... I've rebuilt my skin shader 3 times now and hope this will be my last cuz i'm getting a bit tired of it...

Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 27th Oct 2007 20:05
Hi Mike

I'm at the DBP convention at the moment. Had a quick look at your "seams" problem and couldn't reproduce it - but I'll have another look when I get a chance.

Does sound as if you're on the way to sorting it out yourself though.
Mike Inel
21
Years of Service
User Offline
Joined: 14th Feb 2003
Location: Sa upuan ko po...
Posted: 28th Oct 2007 02:07
Quote: "Had a quick look at your "seams" problem and couldn't reproduce it "

Any .x models will produce seems i think...
And yeah, i think i solved my problem...
I'll post my skin shader when it's finished, but it requires PS3.0 as i made alot of instructions... -.-'
(But hey, what's the purpose of the latest GPUs if you'll not gonna use it? Heheh...)

Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 28th Oct 2007 02:12
Quote: "I'll post my skin shader when it's finished, but it requires PS3.0 as i made alot of instructions"


Shame I won't be able to test it.

But the time to upgrade my PC is rapidly approaching ...
Mike Inel
21
Years of Service
User Offline
Joined: 14th Feb 2003
Location: Sa upuan ko po...
Posted: 28th Oct 2007 06:45 Edited at: 28th Oct 2007 06:46
Here's the new skin shader... (See download attachment)
I didn't made all features usable in the dbpro code though... Use DarkShader to see them all...
It's quite slower than the older one, but at least the seems are gone!
(I'm soooo happy!!!)
Well, for those who doesn't have PS3 (and xbox360, jk) here's a shot:

Anyone can use it w/o credit... (I don't mind... It's not that great anyway...)

Attachments

Login to view attachments
Chris K
20
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 29th Oct 2007 11:04
It's really good, but still slightly off, I can't place it... I think perhaps it needs less shine and more "glow".

Nice work.

-= Out here in the fields, I fight for my meals =-
Mike Inel
21
Years of Service
User Offline
Joined: 14th Feb 2003
Location: Sa upuan ko po...
Posted: 30th Oct 2007 00:34
Well, it can be adjusted!
This is the list of tweakables of the shader (and is the reason why it became PS3)


jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 31st Oct 2007 22:14
@Green Gandalf's Quote:
Quote: "Note that in HLSL you need to use the "==" operator rather than "=" if you want to test equality (I guess the reason is that "=" is used as the assignment operator which is a different operation from "=" used in testing equality - whereas DBP, and some other languages, use the same operator for both operations ). "


This is valid in C++ and MIGHT work in HSLS:



What happens is the ASSIGNMENT operator (single equal) assigns the result of "bMyFunction" to the variable bResult.... BUT THAT - returns the RESULT of the ASSIGNMENT - so I actually can kill two birds with one stone



Double Equal ( == ) tests equality - but the Assignment operator in decent languages - ACTUALLY returns the Value it assigned to a variable like a function - so you can use the value that internall is on the STACK TWICE in what looks like one statement. Used correctly - though doesn't always make the most readble code - it can save clock cycles if put into use regularly. With shaders - this little cpu cycle tricks could help overall FPS.

Just an obscure fact that many are not aware of.

Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 31st Oct 2007 23:05
Your observations are good ones.

Not sure about your final comment about shaders though - the FX compiler is quite clever and the alternatives might compile to the same thing. Will try it and report back.
Alsan
18
Years of Service
User Offline
Joined: 20th May 2005
Location: Germany - Nähe Kassel
Posted: 2nd Nov 2007 16:06 Edited at: 2nd Nov 2007 21:46
Moin,

I have a problem getting a shader from Mental Mill to work in DBPro.

It works great with primitives and simple stuff, but when I try to apply it to a UVMapped model it simply resets all UV data. :/

First of all, this is how it looks like in Mental Mill:



And in DBPro:



I also tried to texture the model in DBPro, but I get the same result.

Any help would be greatly appreciated, the shader is attached!

(I hope this hadn't been asked two pages before ^^)

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: 2nd Nov 2007 16:50
@Alsan

I'd guess it's the same problem as discussed here:

http://forum.thegamecreators.com/?m=forum_view&t=117175&b=1

Let us know how you get on and I'll have a closer look if you're still stuck. There seem to have been several queries along these lines recently.
Alsan
18
Years of Service
User Offline
Joined: 20th May 2005
Location: Germany - Nähe Kassel
Posted: 2nd Nov 2007 17:52 Edited at: 2nd Nov 2007 21:46
Thanks.

I messed around with texturing the object in Dark Basic and tried converting the FVF of the object (I thought it maybe had only one texture stage). As I tried nearly every optional flag of "LOAD EFFECT" and the other commands I'm quite sure the problem is inside the shader.

Unfortunately I'm not into HLSL and thus can't fix it myself. :/

Login to post a reply

Server time is: 2024-05-03 12:02:43
Your offset time is: 2024-05-03 12:02:43