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
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 25th Jan 2008 00:29
Quote: "its a quick fix - only basic control I`m afraid"


Neat and efficient though. A lot of people should find that helpful.

Thanks.
CuCuMBeR
21
Years of Service
User Offline
Joined: 11th Jan 2003
Location: Turkey
Posted: 25th Jan 2008 12:29 Edited at: 5th Feb 2008 08:39
For Linear fog:

[EDIT
I forgot to mention about the camera position vector
here, add this line to the untweaks sextion of your shader file



example:
//-----------------
// un-tweaks
//-----------------
matrix WorldVP:WorldViewProjection;
matrix World:World;
matrix ViewInv:ViewInverse;
vector vCPS : CameraPosition;
[/EDIT

add these 2 lines to the variables section which you may want to change during game play


and then make sure you include the following line to your output structure

an example:
struct output
{
float4 OPosOSITION;
float2 Tex:TEXCOORD0;
float Fog:FOG;
float3 LightVec:TEXCOORD1;
float3 Attenuation:TEXCOORD2;
float3 ViewVec:TEXCOORD3;
};

then, at the vertex output, add this linear fog formula


example:
{
output OUT;
OUT.OPos=mul(IN.Pos,WorldVP);
OUT.Tex=IN.UV*float2(U,V);
float3 WNor=mul(IN.Normal,World); WNor=normalize(WNor);
float3 Wtan=mul(IN.Tangent,World); Wtan=normalize(Wtan);
float3 Wbin=mul(IN.Binormal,World); Wbin=normalize(Wbin);
float3 WPos=mul(IN.Pos,World);
float3x3 TBN={-Wtan,Wbin,WNor}; TBN=transpose(TBN);
float3 LightPos=LightPosition-WPos;
float3 ViewPos=ViewInv[3].xyz-WPos;
OUT.Fog = 1.0f - ( length( IN.Pos - vCPS) / 5000.0f);
OUT.LightVec=mul(LightPos,TBN);
OUT.Attenuation=-LightPos/LightRange;
OUT.ViewVec=mul(ViewPos,TBN);
return OUT;
}

last thing is adding these lines to the pass:


example:


Here are some examples:
Evolved Normal Mapping with Fog
Different Aproach same Idea, Volume Fog
A Sky Shader with Fog under the horizon line This one also has the formula for Hermite Interpolation

There is always one more imbecile than you counted on.
Ian T
21
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Around
Posted: 25th Jan 2008 22:03
Thanks James, Cucumber. Much appreciated
david w
18
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 26th Jan 2008 07:06
Can the shaders here be used in Direct X 9.0 native? Meaning can you load them up as is. Or are they DBP specific?
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 27th Jan 2008 01:59
Quote: "Can the shaders here be used in Direct X 9.0 native? Meaning can you load them up as is."


What do you mean? What is "Direct X 9.0 native"?

Most of my shaders work fine in FX Composer for example, those that don't usually rely on something specific like the object size or location or a real-time image such as those used in various water or bloom/blur shaders.

I assume (but haven't tried) that they can be used in C++ - but I guess again that you would need to set things up correctly in that language, e.g. what is the default setting fot alpablendenable, etc. DBPro does all sorts of things for you behind the scenes - and some of those affect how shaders work. Other applications will set different defaults in general - why ask us, why not ask them?
david w
18
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 27th Jan 2008 04:44
I ask here first because if I am going to be using dbp to prototype then I was thinking perhaps I could just use the shaders here, without having to build new ones. Anyways, it appears that I can't use these shaders as-is with Direct X 9.0 and C++. Well thanks for the help anyways.
david w
18
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 27th Jan 2008 20:51
Well it appears that I was setting up my shaders wrong in DX, So for general knowledge for anyone who may be interested. The shaders here work as-is with direct x.

I know that most people wont be using direct x here, but in case someone was wondering, they do work.

Thank you.
Irradic
18
Years of Service
User Offline
Joined: 1st Jul 2006
Location:
Posted: 5th Feb 2008 19:23
Well once again i need help from the shader gurus. This is about the opacity on hair strands. I posted regarding this before and Green Gandalf tried to help out. The problem was that the normal map shader is only able to render in 2 states, either visible or not visible, which makes the strands look like they have been chewed off.

Now I have found a hair shader in the rendermonkey shader library.
I was trying to view the shader inside darkshader but the object just disappears.
I would be really thankful if someone could make this work in dbpro, i'd even do some 3d modeling service in return.

I have attached the necessary files, which can also be found in the rendermonkey media folder

Attachments

Login to view attachments
Toz
16
Years of Service
User Offline
Joined: 14th Oct 2007
Location: The Netherlands
Posted: 5th Feb 2008 20:09
@Irradic

There was only one little thing wrong with the hair shader: The worldviewprojection matrix wasn't transposed. If I remenbered correctly there was a dbpro command that would fix this. But I couldn't remember it so I changed the shader itself a bit.

I changed:

o.pos = mul(matViewProjection, i.pos);

to

o.pos = mul(i.pos, matViewProjection);

And repeated that for the other 3 vertex passes in the file. This does exactly the same as transposing the matrix.

So here is the fixed shader:

Don't read this, read the above.

Attachments

Login to view attachments
Irradic
18
Years of Service
User Offline
Joined: 1st Jul 2006
Location:
Posted: 5th Feb 2008 21:56
Toz thanks a lot for the help !

So far I only tested it in darkshader and the object is now visible with the textures. I only noticed that the alpha seems to not work correctly, some strands are transparent while on others the black part is visible. I'll try to load it in dbpro tomorrow and see if i'll get the same results.
Thanks again !
Irradic
18
Years of Service
User Offline
Joined: 1st Jul 2006
Location:
Posted: 12th Feb 2008 20:32
I have this weird problem that the object (which is positioned at 0,0,0 inside 3dsMax)jumps to a different position (on height) once the shader is applied. Has that something to do with the matrixview projection ? Before I did the changes mentioned by Toz on a clean version, the object would origin at 0,0,0 but would be displayed stretched/disfigured.
Could somebody test this ? The media is attached to my previous post, the edited shader is attached to Toz post.
Help is much appreciated, thanks
Toz
16
Years of Service
User Offline
Joined: 14th Oct 2007
Location: The Netherlands
Posted: 13th Feb 2008 21:00
Took another look at the shader but there doesn't seem to be anything that would change the position of the object. I don't know how 3dsmax works but the program must send the all the variables (including the matrices) to the shader in order for it to work. So I'm guessing that somewhere in 3dsmax you can set these variables sent to the shader. Look for the matrices and especially the world matrix because that one contains the position, rotation and scale of the object. I hope you can figure it out.

Don't read this, read the above.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 13th Feb 2008 22:01
Irradic

Your problem is probably caused by the shader not using the WorldViewProjection matrix. The shader posted by Toz has the following line



whereas I think you need



That might fix it.

I believe the "World" bit is missing from RenderMonkey because RM assumes that the object's coords are in World coords, i.e. it assumes the World matrix is the identity matrix so it can be left out. [I'm fairly sure I read that somewhere - but I might have imagined it. ]
Irradic
18
Years of Service
User Offline
Joined: 1st Jul 2006
Location:
Posted: 14th Feb 2008 12:17 Edited at: 14th Feb 2008 12:19
Excellent Green Gandalf, that fixed my problem. I was trying to change it to WorldViewProjection earlier but made a couple of mistakes. Changed things I shouldn't have, so it no longer compiled.
But now the object is where it is supposed to be.
Thanks to you and Toz for the help !
Toz
16
Years of Service
User Offline
Joined: 14th Oct 2007
Location: The Netherlands
Posted: 14th Feb 2008 15:46
Quote: "
Your problem is probably caused by the shader not using the WorldViewProjection matrix."


whoops seems I've missed that part. I should have checked that part too, instead of only looking at the vertex passes. But I'm happy to see that Irradic's problem has been solved.

Don't read this, read the above.
Radek Inkom
17
Years of Service
User Offline
Joined: 28th Feb 2007
Location: Poland
Posted: 19th Feb 2008 13:57
Green Gandalf

I try to create fx that will work like ANIMATED SPRITE in DBPro but on plain. I know how to move texture, but how to set UV? How cut 1 texture to 10 parts and show it as animation?

english? it's not my national language
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 19th Feb 2008 23:36
Quote: "I try to create fx that will work like ANIMATED SPRITE in DBPro but on plain. I know how to move texture, but how to set UV? How cut 1 texture to 10 parts and show it as animation?"


Very simple. Work out the UV coords of the top left corner of each sub-image. Probably simplest to do this manually beforehand - unless the image has a large number of sub-images.

Then pass these values to the shader so it adds these to the scaled UV coords of the plain before it does the texture look-up.

For example, suppose your sprite image consists of a 2x2 array of four images. The top left image has UV coords of (0, 0) for its top left corner, the top right image has (0.5, 0), the bottom left has (0, 0.5) and bottom right has (0.5, 0.5).

You will need to scale the plain's UV coords as well.

For example to get the bottom right image you pass (0.5, 0.5) to the shader via a vector4 and read this in the shader as a float2 variable, "offset" say, then the texture lookup would be something like tex2D(sampler0, In.UV*0.5+offset). Your scale factor will depend on how your image is sub-divided.

Let me know if you need more help on this.
david w
18
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 20th Feb 2008 00:13 Edited at: 20th Feb 2008 00:46
@GG or anyone who can


would you be able to add normal mapping to this shader. I dont know if this shader will work with dbp or not. Its very complicated to set-up. Anways, I really would like this shader to have normal mapping in the "technique buildPass" I am sure you know what to do.

I am trying to get excellent graphics working on my new engine and this is a key element.

Thank you.


edit. The shader has normal mapping as a post process already. Its just not very pronounced. perhaps there is some way this can be modified for a more "depth" look.

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: 21st Feb 2008 00:20
david w

I'll try to look at this before the weekend.
david w
18
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 21st Feb 2008 00:51
Ok thank you. Also how interested would you be in developing shaders for my project? I can pay. Its up to you.
Radek Inkom
17
Years of Service
User Offline
Joined: 28th Feb 2007
Location: Poland
Posted: 21st Feb 2008 01:40
Thanks GG

I upload my first version - texture animation.

Maybe You know better solution, my work but I'have a little expiration with fx

FX:


DBPro:

Attachments

Login to view attachments
dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 21st Feb 2008 06:57
Quote: "Maybe You know better solution"


Yes, use a vertex shader for this. You only need to shift the UV data of each vertex once so computing this on the fragment(pixel) shader is a lot of wasted GPU time, especially if the camera is close to the objects, thus they take up a lot of draw time. Remember, for a plane this UV shift calculation is only done 4 times(with a welded plane) in a vertex shader, but on the fragment shader the calculation could be done 1000 times, or more.

Radek Inkom
17
Years of Service
User Offline
Joined: 28th Feb 2007
Location: Poland
Posted: 21st Feb 2008 11:02 Edited at: 22nd Feb 2008 00:12
so, how to do it in VS?

My new VS version:



any way to do it faster?

I've got:
1075 FPS - FX
1068 FPS - no effect
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 22nd Feb 2008 01:42
Quote: "so, how to do it in VS?

My new VS version:"


Looks like you've answered your own question, well done.

Quote: "any way to do it faster?

I've got:
1075 FPS - FX
1068 FPS - no effect"


I've no idea - and can only dream of such performance.

Quote: "Ok thank you. Also how interested would you be in developing shaders for my project? I can pay. Its up to you."


If you're serious use the e-mail button.
david w
18
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 22nd Feb 2008 02:52
sent
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 23rd Feb 2008 01:24
Quote: "The shader has normal mapping as a post process already. Its just not very pronounced. perhaps there is some way this can be modified for a more "depth" look."


That's a very interesting shader - and uses methods I haven't seen before.

I've had a browse through the DX9 SDK docs and think I have some idea what's going on now - but I'd have to do some experimenting to see if I've understood it correctly. The shader seems to use multiple render targets - I know DBP supports intermediate render targets with the extra DLLs and commands that come with Dark Shader, but I'm not too sure about multiple render targets. Shouldn't take too long to find out though.

There are a few things in that shader that don't look right to me - and which might explain the difficulties you are having. Again, I'll get back to you later when I've done some testing - but if I can't test the shader in DBP then there will be a fair bit of uncertainty involved.
david w
18
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 23rd Feb 2008 05:53
I can give you a test program that uses the shader native and the media for it.
Try
19
Years of Service
User Offline
Joined: 16th Aug 2004
Location:
Posted: 24th Feb 2008 12:30
GG,
Intermediate render targets?!!! So... that's why we can't create motion blur, huh? we need multiple render targets, right?

Very interesting indeed...

Cheers,
-Try
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 24th Feb 2008 14:35
Someone in the know told me if we had those - we wouldn't always need to make extra cameras to get alot of effects...

Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 25th Feb 2008 10:23 Edited at: 25th Feb 2008 11:32
Okay, I just got here and haven't read every page of this thread.

I take it that DBP doesn't support environment shaders directly... hence why we need to set up a second camera and render it before the screen cam in order to get effects like Bloom to work. That's just my hypothesis.

Does DarkShader allow you to apply a shader effect to a specific camera if that shader was designed as an environment shader? If not, I think that it should be added in an update (preferably to DBP and not DS ), as that would make environment shading in DBP a helluva lot easier on us.

I just got into writing shaders by hand (since trying to get FX Composer to make DBP compatible shaders wasn't panning out so well) and I have a boat load of questions after looking through some of Evolved's shaders. (Mainly Bloom, which will be my example code here)


1) What kinds of datatypes are these? What can they hold? What are the REAL datatypes of their subvariables, if any?


2) Why are the parentheses of VSTone and PSTone empty when they are defined as having parameters?
3) What is being passed into VSTone and PSTone? Are the "parameters" simply a declaration to be used inside the function? Why couldn't they be declared in the functions like everything else is? Is it because they were defined as structs previously created in the shader file? If they aren't simple declarations of empty structs, then what's being given to them?


4) This is the only texture defined for Bloom, which is understandable. Why can't the shader combine all three techniques to need only a single camera in DBP? Why make everything so complicated?
5) If my understanding of the sample code is correct, then it captures the screen image and passes it to a plain in front of another camera passing it through the Tone technique, then that camera captures the iamge and passes it onto a plain in front of another camera after passing it through the Blur X technique, then that camera captures it and puts onto the plain in front of the real camera after passing it through the BlurY technique. Why is it that the shader can't do all of this in one go? Why are we taking such a round-about manner for this? Why would it be necessary?

[EDIT]

6) Do we get performance increases out of doing it the round-about method? If so, then why don't we seperate BlurXA and BlurXB into two different camera renders as well? Wouldn't that increase performance?

Maybe I'm just getting mad about how complicated shaders are made out to be in DBP. (At least, these environment shaders are...)

[/EDIT]

Thank for being patient and reading this far.


The one and only,
~PlystirE~

Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 25th Feb 2008 11:56
Sounds like you need to get Dark Shader. Among other things it gives you the additional set camera effect command which is useful for things like bloom as you suggest.

If I get time later I'll see if I can answer some of your other questions - but Evolved should really answer many of those himself.
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 25th Feb 2008 12:04
Wow, if DS really has that command, perhaps I should go get it right away! Especially if it'll make Bloom 10x faster.

Yes I would like it if Evolved were here to explain some of this, but it would seem that he doesn't frequent these forums as of late.

I have been fiddling with the shader, and I got it to directly run through all the passes in one go as I wanted, but it looks like utter crap, and I think i know why.

The "screen" texture needs to be updated after each technique has been used... I'm willing to bet that this is why Evolved used so many cameras... to update the screen texture for each technique and to prevent the next technique from overwriting what the previous one has already placed onto the screen. (Which is what I've been getting... the BlurY technique is creating an overwrite effect on the BlurX)

Do you think there is a way to create a new texture inside a pixel shader function that could be used by another pixel shader function that'll be called in the next pass?

That sounds like what this would need in order to look good while still doing it all in one technique.


The one and only,
~PlystirE~

dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 25th Feb 2008 16:15 Edited at: 25th Feb 2008 16:20
Quote: "1) What kinds of datatypes are these? What can they hold? What are the REAL datatypes of their subvariables, if any?"


http://msdn2.microsoft.com/en-us/library/bb509647(VS.85).aspx

With, I believe all of these data-types you aren't required to use all components, i.e. for a float4 like COLOR(should be colour!!) you can just use float2 if you don't require all 4 components, but be aware that certain semantics such as COLOR use saturated values(clamped to 0.0-1.0), whereas UV/W etc aren't.

Quote: "4) This is the only texture defined for Bloom, which is understandable. Why can't the shader combine all three techniques to need only a single camera in DBP? Why make everything so complicated?"


For the sake of efficiency, in the case of tone mapping and the blur passes using for bloom, this is all done in the fragment(pixel) shader, when drawing this the quad in the case of bloom that's being rendered is drawn from left to right, the down a pixel and so on, let's say I was drawing the first pixel, I apply tone mapping to this, then blur X instantly there is a problem, X blur requires me to sample left and right, but to the right those pixels haven't been toned yet, thus I'd either have to tone every sample I take(lots of wasted GPU cycles), or I could do away with tone.

Great now we don't have the sampling issue so we can just combine X and Y blur into one pass right? No. Because let's say I render a scene that has a one pixel dot in the middle and say my blur passes blur by 5 pixels each way. If I used a single pass, then as I scanned through the image I'd only be sampling to the left and right(by 5 pixels) as well at up and down, now as this one pixel is only a single pixel, with X and Y blur my final blurred image will end up being a big + sign because the only time the samples will sample this single pixel is when the current pixel being drawn is above or below the pixel by 5px or less, or to the left or right side, with a distance of also 5px. This would look highly undesirable. So if you use 2 passes, doing 5 samples on either side per pass(the same as the single pass scenario) when combined we are effectively doing the job of 100 samples per pixel if we only used a single pass. I'll explain it using the above scenario, I have a single pixel, as I render my quad and sample the rendered texture I will only sample my one pixel if I'm within 5px distance only on the X axis, this will result in me having a - or a 10pixel horizontal line, then if I then do a vertical blur pass I now have essentially 10 lit pixels which can be blurred up and down by 5 pixels, so I end up with one bright pixel in the middle and a nice box of a glow around it.

Also the reason why so many cameras are used is because if you have camera 1 render the main scene to texture, you then texture a quad with this camera render target but you can't use the same camera to render this quad because what the camera is rendering is being outputted to the image you're rendering. Or at least I believe that's the issue last time I tested(I recall getting nothing but a black output). But either way using multiple cameras makes the code easier to understand, as you can just associate specific cameras with specific shader passes.

Quote: "5) If my understanding of the sample code is correct, then it captures the screen image and passes it to a plain in front of another camera passing it through the Tone technique, then that camera captures the iamge and passes it onto a plain in front of another camera after passing it through the Blur X technique, then that camera captures it and puts onto the plain in front of the real camera after passing it through the BlurY technique. Why is it that the shader can't do all of this in one go? Why are we taking such a round-about manner for this? Why would it be necessary?"


Answered above.

Quote: "6) Do we get performance increases out of doing it the round-about method? If so, then why don't we seperate BlurXA and BlurXB into two different camera renders as well? Wouldn't that increase performance?"


Answered above also, but using 3 cameras is far less efficient than using a single one, but there isn't much that can be done about it. Ideally there would be some variant of the Sync command that you could specify a single object ID to render, or a range, because most multiple camera techniques are very slow in any realistic(non tech-demo) game, because the sync command(even fastsync and with excluded objects) adds considerable drag to the render performance.

Also another issue with most DBPro implementations of bloom and other post-processing(full-screen) effects is that you must render the scene to a second camera(i.e. render the complete visible scene twice) just to get the same general output. Some of evolved's latest demos(and my own bloom one) got around this by using camera 1 to render the scene using the display mode resolution and applying the last bloom pass(blur y) to a quad that camera 0 renders. So all-in-all you only end up rendering your complete scene and a few quads which is great, however doing this adds some limitations. For instance DBP currently lacks any native AA enabling feature, however you can force the GPU drivers to override these settings via your display control panel, but this doesn't affect camera to image render targets so you can't hope to get AA in your scene. There are other issues too, like some people's GPUs don't support non-square textures, this means you can't set camera 1 to render to the display mode(viewport) resolution, but you can get around this by rounding up or down to the nearest multiple of 2 size, but this could result in impaired visual quality(for smaller RTs) or loss of performance(larger RTs).


[edit, didn't read the last page]

Quote: "Sounds like you need to get Dark Shader. Among other things it gives you the additional set camera effect command which is useful for things like bloom as you suggest."


Does this not just force a quad with a shader in-front of the designated camera? Something which could easily be done without the plug-in?

Quote: "Especially if it'll make Bloom 10x faster."


Why would it? My aforementioned idea to render a single object(the RT object) would be the only way to really speed up shaders like bloom, but rendering a single object isn't everything, as if you're only rendering a quad you could do away with the ZBufer for that scene which would likely speed up rendering quite a bit.

Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 25th Feb 2008 20:11
Quote: "Sounds like you need to get Dark Shader. Among other things it gives you the additional set camera effect command which is useful for things like bloom as you suggest."

Quote: "Does this not just force a quad with a shader in-front of the designated camera? Something which could easily be done without the plug-in?"


No. Additional functionality is provided as well. For example, intermediate render targets are included with the camera effect commands so you can do things like blurring more efficiently by separating the blur into two passes. The first pass can do vertical blurring - and then the resulting image is blurred again by a horizontal pass. This requires an intermediate render target, i.e. an intermediate image, which doesn't seem to be possible without the camera effect commands that come with Dark Shader. The reason for the efficiency gain is clear if you consider blurring a grid of 5x5 points, i.e. 25 points altogether. If you do it all in one go you'll have about 25 multiplications and 25 additions. If you do a vertical pass you'll need about 5 mults and 5 adds, and a similar number if you follow this with a horizontal pass, giving a total of 10 mults and 10 adds. This saving is helpful when you are blurring/blooming the whole screen.
mr Handy
16
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 27th Feb 2008 15:54 Edited at: 4th Mar 2008 10:06
I need help with mixing Evolved's shaders - soft shadows and deferred shading v1.
Problem is that soft shadows has built-in normals, and its too hard for me to replace it with parallax, that built-in in deferred. Agrh... No, i want to have one deffered soft shadowed shader... Yes... Soft shadows, by its geniuns code, makes buggy dbpro shadows looks like unbuggy =) and defferred is must in my engine and any engine, by the way! Although, i tried to make additional settings in deferred to control specular power.

A door is a door is a door. Even a swinging one. =0
mr Handy
16
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 27th Feb 2008 15:59 Edited at: 4th Mar 2008 10:05
I've made shader i want. It's was easy, but, heh, it costs 2 weeks of staring to shader codes

A door is a door is a door. Even a swinging one. =0
Radek Inkom
17
Years of Service
User Offline
Joined: 28th Feb 2007
Location: Poland
Posted: 12th Mar 2008 10:56
Green Gandalf:

You have made a fx Water Bumpmapper v1.0e



our game require P.S. ver. 1.3 maximally, Your fx use P.S 2.0
I try to change it

Can You help me? Is it possible to use 1.0 or 1.3 P.S for it?

I use it for a sea - attached.

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: 12th Mar 2008 14:51
@Radek Inkom

Your demo crashes my PC!

I'll try to find time to adapt the shader for PS1.3 - I think I have a working PS1.3 bumpmapping shader somewhere so I might be able to adapt it. PS1.3 and PS1.4 both have various restrictions which might make the conversion difficult. I'll give it a go though.

It took me some time to find that shader on my system - I've filed it under a completely different name. I need to clean up my files a bit ...
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 12th Mar 2008 15:18
I got all blue backdrop... BUT HIGH FPS! LOL

Radek Inkom
17
Years of Service
User Offline
Joined: 28th Feb 2007
Location: Poland
Posted: 12th Mar 2008 15:25 Edited at: 12th Mar 2008 15:26
Quote: "Your demo crashes my PC!"


Why? Is it a FX bug?
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 12th Mar 2008 20:46
Quote: "Quote: "Your demo crashes my PC!"

Why? Is it a FX bug? "


I have no idea - but I don't think it is your code.

Some shaders crash my PC for no obvious reason - the DX9 shader compiler is usually reliable so I suspect there's a hardware or driver fault on my PC or graphics card somewhere (the PC is very old now, but the GFX card is a bit newer). I haven't heard of anyone else having this problem with successfully compiled shaders so I guess it's my system.

One of my early shaders had a coding error which was passed by the shader compiler - and gave very strange results (vertices were moved around even though the shader didn't touch the vertices!). Took quite a while to track that one down.

Quote: "I got all blue backdrop... BUT HIGH FPS! LOL"


I got just clouds and sky plus blue backdrop - until I turned the camera to face the other way. (The demo crashes when I press "3" or try to exit. )
Radek Inkom
17
Years of Service
User Offline
Joined: 28th Feb 2007
Location: Poland
Posted: 13th Mar 2008 00:34
Quote: "I have no idea - but I don't think it is your code. "


Uffff........

Now it's more clear demo with not camera controlling
I attache screenshot with comments too.

I use nVidia GF 7300GT Super that support PS and VS 3.0 but I can`t use it in our game SoI need PS 1.x shader for morze.fx

I have a small problem with niebo.fx too. Our old Radeon (we use it for tests) support VS 1.3, but clouds dont`t want move , I don`t want move it using texture scroll in app. Just a little problem

Attachments

Login to view attachments
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 13th Mar 2008 00:52
Radek Inkom
17
Years of Service
User Offline
Joined: 28th Feb 2007
Location: Poland
Posted: 13th Mar 2008 01:02
Nothing wrong with scrolling, just it`s more easy to use fx and forget about it And it's not problem with timing in app loop, just GPU timing.
I use fx files for moving grass, trees, flowers, waves, so clouds must move too
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 13th Mar 2008 01:25
Thanks for the new demo - it works fine.

Quote: "I have a small problem with niebo.fx too. Our old Radeon (we use it for tests) support VS 1.3, but clouds dont`t want move , I don`t want move it using texture scroll in app. Just a little problem"


I couldn't see a problem. I changed it to use VS1.1/PS1.3 (which I think is what you intended) and it seems to work fine.

Quote: "SoI need PS 1.x shader for morze.fx"


It will need several changes to make it work in PS1.3 - and might not even be possible. I'll think about it.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 13th Mar 2008 12:56
@Radek Inkom

I think the shader will have to be completely re-designed for PS1.3. But I'll give it a try anyway.

Also, must it be PS1.3 or will PS1.4 be OK?
Radek Inkom
17
Years of Service
User Offline
Joined: 28th Feb 2007
Location: Poland
Posted: 13th Mar 2008 17:02 Edited at: 13th Mar 2008 17:06
@Green Gandalf

I check it using GET MAXIMUM PIXEL SHADER VERSION() for the Radeon, and result is 1.39 so I'm not sure.

This is ATI Radeon 9250 model
DirectX 8.1

I find it in Internet:
Pixel Shader Support 1.4
Vertex Shader Support 1.0

So we are home It's PS 1.4 enough.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 13th Mar 2008 20:07
@Radek Inkom

1.39??

With luck - you might get both PS1.3 and PS1.4.
Radek Inkom
17
Years of Service
User Offline
Joined: 28th Feb 2007
Location: Poland
Posted: 14th Mar 2008 00:06
@Green Gandalf

Maybe it's an DBPro joke :
"ATI Radeon 9250? It almost support PS1.3! Almost makes difference "

Maybe it`s almost graphic card. Oh, forgive me ATI It`s just only old model.
But it`s minimal requirement for our game.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 16th Mar 2008 17:16
Radek Inkom

Your shader request is proving difficult.

Basic normal bump mapping takes up virtually all the available instruction slots for PS1.3/PS1.4. As a result I can't get the additional distorted effect that you wanted. Scrolling seems to be working OK though. I'll try to find time to post a clean demo later.

[I posted a PS1.3 bump mapping shader earlier on this thread (c. 8th June 2007?) but it has a fault in it.]

Login to post a reply

Server time is: 2024-07-08 23:32:48
Your offset time is: 2024-07-08 23:32:48