fodev.net

FOnline Development => 3D Development => Topic started by: Johnnybravo on August 23, 2011, 08:57:13 pm

Title: Shaders and effects
Post by: Johnnybravo on August 23, 2011, 08:57:13 pm
Well summer is not really friendly to development or work in general, but I realised some people would probably like to already try doing some stuff so I won't delay it any further due to less relevant technical details.

First off you will need to grab the effect (http://pastebin.ca/2077908), save this as arbitary plain text file in your client/effects directory ( I use 3D_SPecularMapping.fx )
You will also need to add following structure to your IOStructures.inc (this is text file as well)
Code: [Select]
struct VsToPs_3DNormal
{
float4 Position     : POSITION;
float2 TexCoord     : TEXCOORD0;
float3 Normal       : TEXCOORD1;
};
Note - by chance this is exactly the same as 3DTangent and I'll reuse it correctly when I'm done with that, so this is just the part of WIP version and might be changed eventually, but I'm aware this is duplicate in this form :d.

When you are done with this, you shouldn't need to worry about effects themself, but if you want to edit them, turn of your client, delete effects cache (D3D allows saving shaders as binary data, saving some time, however nobody checks for anything, so you have to empty it to have them recompiled). If you cannot notice the effect, or have no shadows, check out fonline log file to see the error during compilation.

Now you need to use this effect. I expect some external definitions from fo3d file in my WIP version, so you should add it to your file
Here's example how to use effect, as well as to pass required value to your file
Code: [Select]
Effect 3D_SpecularMapping.fx
EffDef Floats Specular_Power 16.0

Model Armor_APA.x

And now one last thing - you need to specify specular texture to actually see anything, since texture 0 is already used by default shaders for diffuse part, and texture 1 for normal map, this shader uses texture 2 for specular maps.
So just append
Code: [Select]
texture 2 <path> after texture 0 definitions and it'll correctly load.

Little tip to creating such texture: Transparency is calculated using normals on model, so you'r texture is supposed to cover whole model, and not just be diffuse texture with highlights painted on it. It's added on already calculated colors, so black parts will not actually darken anything, but just have no reflection appearing on it.
For metalic surface playing with levels should be enough, but for the best result you might want to actually paint the metal as if it was lit from every side.

Have fun with it, and post if you got any problem or questions, I'll add some effects and their variation later, and I'll answer questions about any effects, not just specular reflection, so if you got any idea feel free to ask.
Title: Re: Shaders and effects
Post by: Luther Blissett on August 23, 2011, 09:19:34 pm
Awesome! I'm excited like a child at Christmas :)

Going to try and test this tonight. If it works, expect a few screenshots later.

[edit] Totally works :)

Example text files stuff :

In "_FOHuman.fo3d" :

The old one I had attached was written like so :
Code: [Select]
# Body
Layer 3
[...]
Value 27 Root Attach Armor_%anim%_ncr_patrol.x Texture 0 Armor_male_ncr_patrol.png

That is roughly "make ~param 0 153 27 give me that model with that texture".

The shiny one is written like so :
Code: [Select]
# Body
Layer 3
[...]
Value 29 Root Attach Armor_male_ncr_patrol.fo3d

That is roughly "make ~param 0 153 29 give me whatever that fo3d file is".

Then the Armor_male_ncr_patrol.fo3d file contains :

Code: [Select]
Effect 3D_SpecularMapping.fx
EffDef Floats Specular_Power 16.0

Model Armor_male_ncr_patrol.x

Texture 0 Armor_male_ncr_patrol.png
Texture 2 Armor_male_ncr_patrol_spec.png

Texture 0 being the same as previous, texture 2 being the specular map. My example one is rubbish, so I won't post a screenshot, but trust me when I say it works.

If you comment out the "texture 2" line (or if the line just didn't exist) then there is no specular map, so it assumes "all non-shiny". The improved light and shadow still works in this case.

[edit 2] If you put the Effect and Effectdef lines at the top of the base human fo3d file, it applies the lighting setup to the base model. This is currently with no specular texture included but as mentioned, the light / shadow is there.
(http://img801.imageshack.us/img801/4496/shaders02.png)
In my opinion it's beginning to look awesome already.
Title: Re: Shaders and effects
Post by: Karpov on August 24, 2011, 12:04:23 am
Johnny Bravissimo!
It is amazing.

Also, great job Luther, keep up your experiments  ;).

ok ok, I have to test this, bye.
Title: Re: Shaders and effects
Post by: Johnnybravo on August 24, 2011, 03:50:02 am
Quote
[edit 2] If you put the Effect and Effectdef lines at the top of the base human fo3d file, it applies the lighting setup to the base model. This is currently with no specular texture included but as mentioned, the light / shadow is there.
It's because I've changed some parameters to make it feel more like on sprites, and when there's no specular power defined, specular will be skipped at minimal loss.
Though it'll make better sense to just add extra effect for those who want to use it that way.

Oh and feel free to mod "eye" vector ( should be relative position of camera, normalized )
and "LightDir" vector (obvious from name), changing "eye" will result on different specular highlights, changing lightdir will change everything.
You might also want to try higher ambience as I might have lowered it way too much.
That is if you want to play around with simple things ( don't forget to clear your chache each time you change it, server don't need restart ).

By the way, thanks for bluesuit comparsion, seems like this will need better filtering and perhaps bigger resolution of textures.
Not sure how'd normal map improve it (it definetly would though, but would probably require quite high resolution to do more than just to form the chest/pelvis details), but the main problem now is that it looks blurry.

As for normal maps, not sure if it works because did not see it working, but no reason for it to not work. There's some statement for calculating tangent space and shader is already included in base repositary. It would be quite easier to work it out if there was enough [english] documentation. But considering the difficulty of creating this layer it shouldn't be priority at the moment.

BTW: check out VB female, it has quite awesome model job, and especialy smoothing is well done, when shaded per pixel it's pretty smooth even without any normal map.
Title: Re: Shaders and effects
Post by: Luther Blissett on August 25, 2011, 03:23:16 pm
It's because I've changed some parameters to make it feel more like on sprites, and when there's no specular power defined, specular will be skipped at minimal loss.
Though it'll make better sense to just add extra effect for those who want to use it that way.

Well ultimately, the base models need better light/shadow than their default - I believe the original settings will have been for the Van Buren models, and your settings seem to work much better on the base models, even without the shiny stuff. In bluesuit screenshot above, it's already much closer to the original sprites (I've tested a lot of the other base skins too, and though not yet perfect, it's starting to look great).

It may be possible to add a "universal normal map" to all of the base model textures, as they are all based off the same model - so if the effect was added with normal map into VbMaleStrong.fo3d, then all base models should use it - with the 0 layer diffuse map being selectable as it currently is... I think.

In this case though, there are only a couple of clothing layers which would use specular - the NCR longcoat trooper has metal chest plates for example. I'm not sure if there are any others. If there's only this one, then I may as well remake the NCR longcoat model, and make the metallic chest plate part of the armour model instead of a clothing texture, therefore leaving all clothing textures as non-metallic.

You mention "Though it'll make better sense to just add extra effect for those who want to use it that way." - does it use up processing power to calculate the specular stuff without a texture 2 layer? i.e. if we use this full effect on non-shiny materials, are we wasting processing? If so, would it be possible to adapt this to just use diffuse and normal maps, with the improved lighting and shadow you've set up?

Quite difficult to explain, but I mean "should we have two different 3D effects", like :

1) Default effect for all 3D models. Uses diffuse map (layer 0) and normal map (layer 1). Uses the improved lighting and shadow settings you've developed.

2) Everything as above, with the addition of specular map (layer 2) to be used on metallic armours.

If the unused specular layer doesn't use up extra processing, is there any reason you can think of to not just use Effect #2 on all the models?
Title: Re: Shaders and effects
Post by: Johnnybravo on August 25, 2011, 09:47:49 pm
Quote
does it use up processing power to calculate the specular stuff without a texture 2 layer
AFAIK "if(statement)" is not that costy on GPU, so it should be fine, but as I said, it'd probably make sense to just make it without this, to avoid some confusion and perhaps little FPS gain.

Quote
1) Default effect for all 3D models. Uses diffuse map (layer 0) and normal map (layer 1). Uses the improved lighting and shadow settings you've developed.
Normal map would not work for default because you need to specify game to calculate tangent space for given model. If you load just normal map effect by for example renaming files, you will get nasty artifacts instead of base lighting as one would expect.
But making default effect using per-pixel lighting calculation would probably work.

I cannot tell what is the best but should be easy to try different stuff. people might sound like overkill for small undetailed models - but also keep in mind they are still small so you have not much pixels to calculate anyway.

Well to be honest, best would be just to have 2 effects for 3D

Default and NormalMapped, where default will have techniques for vertex and per-pixel lighting (with specularity based on data from fo3d) and normal map would just add one technique ( because vertex lighting does not make any sense in this case :d).
Every other effect would be fancy stuff (glass, stealthboy,... whatever you can think of and might use in Fallout, like fancy glowing ghouls hehe :d).
But this will require some additions to game engine so script interface might ineract with techniques.

Normal maps for every model is not good idea because even such small objects will probably require about 512x512 to look good (compression decreases quality rapidly, and filtering is important factor as well).

Oh and in case people are interested in "pixelization", that would be better to have models rendered to texture and use that one as sprite, because artificialy adding it per fragment basis might not look that right.
Title: Re: Shaders and effects
Post by: Surf on August 25, 2011, 09:55:57 pm

Oh and in case people are interested in "pixelization", that would be better to have models rendered to texture and use that one as sprite, because artificialy adding it per fragment basis might not look that right.

What do you mean with that?
Title: Re: Shaders and effects
Post by: Johnnybravo on August 25, 2011, 10:47:01 pm
It's simplier to have engine do it :d.
Since 2000s graphics hardware can just render directly into texture (think like dynamicly creating sprites), so you setup scene for your model, render it to texture in original dimensions ( I have no idea how big fallout sprites are, but you guys should know ), and then just resize it to fit game screen. This will have the same effect as having small sprites - eg. blurred out/pixelizated details like face on sprites.
It should be also quite cheap, because it wouldn't eat much GPU memory in that small dimensions, and you wouldn't stress GPU with complex fragment shader aproximating detail loss. Instead all you do is just map that texture on quad.

It is possible that some old hardware does not support render to texture, but that wouldn't support PS either.
And the best thing is that players will be able to chose their own settings that fit them the best.

That is this particular effect would look the best if it was done on software level using render targets, instead of rellying on post-processing. It needs engine change however.

Here is some example, though probably not the best one because of 512x512 scene on 640x480 screen looks sharp.
http://www.paulsprojects.net/opengl/rtotex/rtotex.html
Title: Re: Shaders and effects
Post by: Surf on August 25, 2011, 10:57:15 pm
Ah, ok - I totally misunderstood you then. I thought you were suggesting to render all the 3d anims etc again to 2d sprites and pixelate them there then. ;)

Indeed, players being able to adjust the pixelisation (or disable) would be the best. If that is what you are aiming for, then all power to you and keep up the good work!
Title: Re: Shaders and effects
Post by: Luther Blissett on August 26, 2011, 09:59:43 pm
I haven't managed to get anything out of the Normal maps yet - I've tried a lot of different things, but seem to be getting no results with any. Have you managed to get anything working with this?
Title: Re: Shaders and effects
Post by: Johnnybravo on August 26, 2011, 11:18:06 pm
Try to add  'CalculateTangentSpace' in your fo3d along with using normal map effect.
Here's example in documentation
Code: [Select]
Model    Box.3ds
CalculateTangentSpace
Subset 0 Texture 0 DED.tga
Subset 0 Texture 1 DEN.tga
Subset 1 Texture 0 DrD.tga
Subset 1 Texture 1 DIntrN.tga
Subset -1 Effect 3D_NormalMapping.fx
I did not check what format is normal map in, but expect it to be quite the same as in every other game.
Just find some random normal map on internet and slap it on box model, or any other surface where it would be apparent.
EDIT: and no sorry haven't tried it yet.
Title: Re: Shaders and effects
Post by: Karpov on August 27, 2011, 04:45:13 pm
Here is a demo video for those who haven't seen this in action yet.

http://www.youtube.com/watch?v=_vCQhklJpvE (http://www.youtube.com/watch?v=_vCQhklJpvE)

I've been tinkering with ambient color and light direction. I got some nice outdoor/sunlight shading. It needs to be set in every model you want it to appear, but if somehow it could be set globally, it could be a great feature, like different light setups during the day. Anyway, shaders are very good, thumbs up to the author.
Title: Re: Shaders and effects
Post by: Luther Blissett on August 27, 2011, 05:23:52 pm
Johnnybravo - I will have a look at this, see if I can get something to work
Karpov - Very good - much clearer example with a video than screenshots. Regarding global effects, there must be some sort of default effect applied to the models, as they had a basic light and shadow working to begin with - I wonder if this could be replaced, or if you can find the file that "points to" the default shader, to "point it" to the path of the new one instead? Also agreed, thumbs up for this work - very important step forward.
Title: Re: Shaders and effects
Post by: Johnnybravo on August 27, 2011, 06:12:48 pm
API supports it, so that it shouldn't be problem to propagate some functions to script so that modders can play with it.
Unfortunately as far as I understand community behind engine is the russian part related to TLA server.
Might be a little harder to make related requests.

But it could be nice if script could chose techniques (I might want to have something else than a model + shadow, like ghost effect or lower detailed lighting to make game faster on ancient hardware (like stuff as old as GeForce 3/4 might have hard time calculating it all, anything older does not even have shaders to begin with :d)) and propagate variables.
There might be some more interesting things like lights (dunno how D3D deals with it, but GL has related structures available without need to propagate anything).

As the matter of fact it'd be probably the best to set light 0 structure for global illumination (sun and stuff - directional lighting that is already there) and have other lights used for dynamic (point) lighting.

However scripters should always be aware that scenery WILL be 2D, so changing global light direction will be highly contraproductive.

EDIT: Thanks for the vid Karpov, really nice showcase, it makes MA appear much better than even I expected.
Title: Re: Shaders and effects
Post by: Karpov on August 27, 2011, 09:05:08 pm
You are right, the scenery and buildings would not change , it would look weird. Anyway, your shader seems to improve a lot the looks of non shiny surfaces too.
I changed the standard shader as suggested by Luther, so now all models use this one. Take a look.

(http://img163.imageshack.us/img163/2766/shaders8.jpg)

In my opinion , the new one looks much better. What do you guys think?
Also the skin is mapped, just a bit of shine over the body, and some more on the head.

As for the global illumination, I used ambient color with a blueish tint. Of course, it's not the same as an additional light, but it softens the dark shadows.
Title: Re: Shaders and effects
Post by: Luther Blissett on August 27, 2011, 09:21:43 pm
Definitely looks much better (and closer to sprite lighting) than the old default. No doubt about it. Can you stand him next to a sprite, so we can compare closer? Maybe a shirtless, next to a tribal or something like this.
Title: Re: Shaders and effects
Post by: SmartCheetah on August 28, 2011, 12:14:08 am
Wow, it looks really good now! I'm amazed how much shaders can change! *.*
I bet we would have to change some textures and models to make them more complex (to get more shadows on eg. metal armor chest piece)
Title: Re: Shaders and effects
Post by: Luther Blissett on August 28, 2011, 02:01:06 am
We will probably need to adjust most of the textures once these have been finalised. Most will probably be quick tweaks, but a few might need some heavy changes. Obviously if the game engine shadows are now much better, we can rely a bit less on "old school style" painted-on shadowing. I don't know if the models would need changing so much, but we'll see how things start to look when this has been tested on all the current ones. The metal armour detail can probably be adjusted through tweaking the specular map
Title: Re: Shaders and effects
Post by: Surf on August 28, 2011, 09:56:05 am
One thing I noticed, is that almost all of the models are a bit too bright compared to the original critters. This can be easily solved though. ;) And yes, going the oldschool method and planting some drawn shadows here and there seems to be the best solution for this. 's looking really good already!
Title: Re: Shaders and effects
Post by: TommyTheGun on August 28, 2011, 10:19:56 am
You are right, the scenery and buildings would not change , it would look weird. Anyway, your shader seems to improve a lot the looks of non shiny surfaces too.
I changed the standard shader as suggested by Luther, so now all models use this one. Take a look.

(http://img163.imageshack.us/img163/2766/shaders8.jpg)

In my opinion , the new one looks much better. What do you guys think?
Also the skin is mapped, just a bit of shine over the body, and some more on the head.

As for the global illumination, I used ambient color with a blueish tint. Of course, it's not the same as an additional light, but it softens the dark shadows.

Most accurate word I can find for it right now is "Amazing"... I'm still thinking of the right word though.
Title: Re: Shaders and effects
Post by: barter1113 on August 28, 2011, 09:05:28 pm
GREAT! (SHOUT)
Title: Re: Shaders and effects
Post by: Johnnybravo on August 28, 2011, 10:21:20 pm
Quote
I bet we would have to change some textures and models to make them more complex (to get more shadows on eg. metal armor chest piece)
http://en.wikipedia.org/wiki/Normal_mapping
Title: Re: Shaders and effects
Post by: Johnnybravo on September 09, 2011, 08:30:24 pm
Can anyone please dump Fallout palette here in readable format?
I'd like to start working on some effects that Fallout enthusiasts will want.
(and it should be possible to apply it on 2D as well, if anyone wants to have lowcolor interface for some reason instead of hires one, if that ever gonna exist :S)
Title: Re: Shaders and effects
Post by: baaelSiljan on September 10, 2011, 12:41:31 pm
Can anyone please dump Fallout palette here in readable format?
I'd like to start working on some effects that Fallout enthusiasts will want.
(and it should be possible to apply it on 2D as well, if anyone wants to have lowcolor interface for some reason instead of hires one, if that ever gonna exist :S)

here it is described:

http://falloutmods.wikia.com/wiki/Working_with_palettes (http://falloutmods.wikia.com/wiki/Working_with_palettes)
http://modguide.nma-fallout.com/#Graphics005 (http://modguide.nma-fallout.com/#Graphics005)
Title: Re: Shaders and effects
Post by: Bartosz on September 15, 2011, 11:22:07 am
Unfortunately as far as I understand community behind engine is the russian part related to TLA server.
Might be a little harder to make related requests.

Not at all, just state what's needed, if something hinders the 3d development, it needs to be considered and improved.
Title: Re: Shaders and effects
Post by: Luther Blissett on September 15, 2011, 08:39:00 pm
Whilst you mention it (off topic to main thread, sorry) - two things that have come up in conversation recently were :
a) Ability to "refresh assets" in 3D engine i.e. reload models and textures without having to quit and restart the program.
b) Some information about or control of the connection between action and animation - i.e. currently the enemy receives damage from the 1st frame of the animation, so is damaged / killed before the punch is thrown or gun is lifted to shoot.

These might both be "big asks", but I see "B" as something that's probably necessary before the 3D stuff can really be considered playable. Perhaps if there was a way to assign the "shot event" to occur at a specific point in the animation, this would be quite easy to solve. There may of course be some other way of solving this.

"A" isn't necessary for a playable engine, but could make testing and development a lot quicker.
Title: Re: Shaders and effects
Post by: Bartosz on September 16, 2011, 09:41:04 am
(...)

Forwarded it to appropriate instance;)
Title: Re: Shaders and effects
Post by: Jimmy BoyX on October 15, 2011, 12:50:43 pm
Wow new shaders look amazing.
Title: Re: Shaders and effects
Post by: barter1113 on November 12, 2011, 06:51:27 pm
nothing new?
Title: Re: Shaders and effects
Post by: Johnnybravo on November 12, 2011, 11:05:40 pm
Not really, there is not much to be done at this moment anyway. If I ever get idea how to add some dithering, I will post it (just index lookup looks shit and not even worth it).
OFC if there is anything particular you need, just ask.
Title: Re: Shaders and effects
Post by: barter1113 on November 13, 2011, 09:40:45 am
Johnyybravo ok - good luck. I wish to have a knowledge and do something... :(
Title: Re: Shaders and effects
Post by: SmartCheetah on November 13, 2011, 10:57:12 am
Johnyybravo ok - good luck. I wish to have a knowledge and do something... :(
It's not hard to check any of existing tutorials on the internet and learn something. Knowledge is in your arms reach :> Maybe it's perfect time to make deep relationship with her?
Title: Re: Shaders and effects
Post by: Johnnybravo on November 13, 2011, 09:11:42 pm
Actually the language itself is mostly subset of C, so it's fairly simple. However 3D graphics are always about fairly complicated mathematical operations.
Title: Re: Shaders and effects
Post by: Lizard on November 14, 2011, 12:47:01 pm
Actually the language itself is mostly subset of C, so it's fairly simple. However 3D graphics are always about fairly complicated mathematical operations.

Is it Light-C and are you talking about idealised, only-in3d-graphics plenoptic geometrical functions, Johnny?
Title: Re: Shaders and effects
Post by: Johnnybravo on November 14, 2011, 03:22:14 pm
Not really, but the most vector/matrix operations make people more busy than remembering and understanding syntax and semantics of language, even though they met the former at school already while are new to later.
Also take note that shaders are not limited with their usefulness to 3D graphics, it's possible to operate with sprites as well. For example it's possible to shift colors on bluesuit and make it redsuit without touching sprites or breaking non-cloth parts (eg. extract blue dominant pixels and make them red).

By the way, from SVN log it's apparent Fonline is going to have windows specific libs replaced by portable ones, and D3D is going to be replaced by OpenGL. This also means there will be GLSL rather than HLSL.
For 3D developers it shouldn't really make much if any difference though.
Title: Re: Shaders and effects
Post by: Lizard on November 14, 2011, 05:39:20 pm
I think it would make a difference, if it would allow alpha channels. Forgive if i ask, but does FOnline support the alpha channels at the moment, did i missed something, perhaps?
Title: Re: Shaders and effects
Post by: Johnnybravo on November 14, 2011, 06:19:46 pm
You already have support for those. Samplers give you RGBA, so you might use it as you desire. And yes people did some testing and PNGs with transparency were loaded correctly, and I have no doubts that TGA will not cause any problems either.
Title: Re: Shaders and effects
Post by: Karpov on November 26, 2011, 02:28:39 am
Yes, in fact I used alpha channels for the muzzleflash effect, in TGA format.
Title: Re: Shaders and effects
Post by: baaelSiljan on December 15, 2011, 02:02:38 pm
do You know if it is possible to apply some kind pixelisation on model?

I'm trying to achieve somekind of dirty look and pixelisation I've found textures are stretched when squared, first square pixel I get when I used 512x256 and it also have some kind of smoothing (what is wrong for fallout 2 but good for fallout 3 ;> )

(http://rudo-brody.pl/uploads/2011-12-15_1402.png)

on this image in "how it should look like" i didn't reflect model shape, but it is general idea
Title: Re: Shaders and effects
Post by: Johnnybravo on December 15, 2011, 02:21:43 pm
Idea is to buffer render the first in low resolution and then scale it using 'nearest' filter. One should just ask nicely cvet to do it :>.
Title: Re: Shaders and effects
Post by: Lexx on December 15, 2011, 05:31:36 pm
This should be done with shaders, not on texture. The zoom-in stuff is a bit more complicated, as far as I've heard, but should be possible as well.
Title: Re: Shaders and effects
Post by: Johnnybravo on December 16, 2011, 12:47:27 am
Rendering object smaller than it should be and then rescaling it just by texture mapping functions is the fastest way.
For shader approach you'd need to approach whole scene as a texture to pixelizate it, which I'm not sure if possible at this moment.
Title: Re: Shaders and effects
Post by: baaelSiljan on December 16, 2011, 01:53:55 am
I thought more about postprocessing or something:

(http://rudo-brody.pl/uploads/2011-12-16_0153.png)

(http://rudo-brody.pl/uploads/2011-12-16_1253.png)

Do You think it is possible to add such postprocessing ?

interesting:

http://www.geeks3d.com/20110408/cross-stitching-post-processing-shader-glsl-filter-geexlab-pixel-bender/ (http://www.geeks3d.com/20110408/cross-stitching-post-processing-shader-glsl-filter-geexlab-pixel-bender/)
http://www.geeks3d.com/20091009/shader-library-night-vision-post-processing-filter-glsl/ (http://www.geeks3d.com/20091009/shader-library-night-vision-post-processing-filter-glsl/)

pixelization:
http://www.geeks3d.com/20101029/shader-library-pixelation-post-processing-effect-glsl/ (http://www.geeks3d.com/20101029/shader-library-pixelation-post-processing-effect-glsl/)

posterization:
http://www.geeks3d.com/20091027/shader-library-posterization-post-processing-effect-glsl/ (http://www.geeks3d.com/20091027/shader-library-posterization-post-processing-effect-glsl/)
Title: Re: Shaders and effects
Post by: SmartCheetah on December 16, 2011, 03:18:28 pm
Imho it should be optional. I - for example - Don't like staring at pixels, especially with option to zoom in. It ruins my immersion. If I want ol' good 2d pixelized Fallout 2 I just run Fo2.exe from my desktop.
Title: Re: Shaders and effects
Post by: Lexx on December 16, 2011, 04:21:18 pm
If it's done via shaders, it is optional. Everyone can write and use their own shaders or no shaders at all, because it's client side.
Title: Re: Shaders and effects
Post by: baaelSiljan on December 16, 2011, 08:36:28 pm
If it's done via shaders, it is optional. Everyone can write and use their own shaders or no shaders at all, because it's client side.

And here comes question (cause I'm noob in this matter) - how to apply custom shaders?

friday, friday, fun, fun... posterization applied into game as hlsl shader :)

(http://rudo-brody.pl/uploads/2011-12-16_2035.png)

but need to be fixed more, and gamma should be set correctly..

simpliest wat to do that is add this code to 3D_SpecularMapping.fx and 3D_Default.fx to end of

Code: [Select]

PSNormal


   function before line:

Code: [Select]

return output;


Code: [Select]

float3 transformedColor = output.rgb; // by mistake I placed here output.xyz

// set number of colors
float numberOfColors = 12;

// set gamma
float gamma = 0.5;

transformedColor = pow(transformedColor, gamma);
transformedColor = transformedColor * numberOfColors;
transformedColor = floor(transformedColor);
transformedColor = transformedColor / numberOfColors;
transformedColor = pow(transformedColor,1.0/gamma);
output.rgb = transformedColor;



and now noise (it may be hard):

(http://rudo-brody.pl/uploads/2011-12-16_2110.png)


HOOOAH!!!

first successfull run with noise

(http://rudo-brody.pl/uploads/2011-12-16_2148.png)

(http://rudo-brody.pl/uploads/2011-12-16_2157.png)

http://rudo-brody.pl/uploads/2011-12-16_2159.mp4 (http://rudo-brody.pl/uploads/2011-12-16_2159.mp4)

nightvision fun :P
(http://rudo-brody.pl/uploads/2011-12-16_2249.png)

more work with shaders more fun :D
(http://rudo-brody.pl/uploads/2011-12-16_2254.png)

tomorrow I will place here fully functional and refactored code
Title: Re: Shaders and effects
Post by: Karpov on December 16, 2011, 10:43:38 pm
Oh, that's great. Good work
Title: Re: Shaders and effects
Post by: Johnnybravo on December 16, 2011, 10:55:28 pm
What do you use for the noise? Bitmap? Noise function? Or you just calculate it for every pixel?

Posterization filter gets quite some nice low color image, kudos for that :d. (though it's not correct, because this would better be with a palette lookup, but that's just slow for realtime anyway so I guess this is good enough).
Title: Re: Shaders and effects
Post by: baaelSiljan on December 16, 2011, 10:57:43 pm
Code: [Select]
float rand(float2 co)
{
return frac(sin(dot(co.xy ,float2(12.9898,78.233))) * 43758.5453);
}

float noise(float2 co)
{
return rand(floor((co * 500.0) + (8.0*co)));
}

that's noise :) it is multipled per color (r,g,b) in pixel shader

better posterisation than nothing, it works very similar and looks very similar to pallette cut
Title: Re: Shaders and effects
Post by: Luther Blissett on December 17, 2011, 05:35:14 am
This looks very promising! The texture on that coat could also be improved a little both tonally and in terms of the colour range (I made it, so I assume the comment won't offend anyone). It was made before the specular shaders were implemented, so includes a lot of "painted on" highlight and shadow, which is now a little too "old school" now we have the engine responding to lighting.

If the original .PSD file would be useful for your testing, I can send that along. Otherwise, feel free to redo / improve the texture as necessary :)
Title: Re: Shaders and effects
Post by: barter1113 on December 17, 2011, 09:32:32 am
OMG baaelSiljan very nice. I love nightvision shader i know it is for fun but looks promising and it is good idea :D Very good.
Title: Re: Shaders and effects
Post by: Lizard on December 17, 2011, 10:51:01 am
Most impressive!
Title: Re: Shaders and effects
Post by: LagMaster on December 17, 2011, 11:15:40 am
oooooooooooooommmmmmmmmmmmmmmmmmmmmmmmmgggggggggggggggggggg


epic!!!!!!!!!!
Title: Re: Shaders and effects
Post by: baaelSiljan on December 17, 2011, 03:17:41 pm
This looks very promising! The texture on that coat could also be improved a little both tonally and in terms of the colour range (I made it, so I assume the comment won't offend anyone). It was made before the specular shaders were implemented, so includes a lot of "painted on" highlight and shadow, which is now a little too "old school" now we have the engine responding to lighting.

If the original .PSD file would be useful for your testing, I can send that along. Otherwise, feel free to redo / improve the texture as necessary :)

It looks most falloutish :) I love this coat! But fun with adjusting I will left to You, I just created some shader effects ;)
Title: Re: Shaders and effects
Post by: baaelSiljan on December 17, 2011, 04:05:27 pm
    DIRTY SHADERS 0.2


   BEWARE:

   May cause error when quiting game (I don't know why).

Code: [Select]

  DIRTY SHADERS 0.2
  -----------------

  POLARYZATION AND NOISE:

  Add those values to FO3D model:
 
    float NumberOFColors
      number of colors for polarization filter
   
    float Gamma
      gamma option for polarization filter, play with it to get best result 
   
   
    float AddNoise
      noise amount - 0.0 to 1.0 (more than 1.0 can be passed but looks ugly) 
 
 
  example:
 
  EffDef Floats NumberOFColors 8
  EffDef Floats Gamma 0,6
  EffDef Floats AddNoise 1,0
 


Change log:

  0.2
    removed mip mapping so textures should look more ugly and dirty and pixelated ;)
 
  0.1
    initial shaders

example code IMO best for coat:

Code: [Select]

   EffDef Floats NumberOFColors 12
   EffDef Floats Gamma 0,8
   EffDef Floats AddNoise 0,4


    EFFECT:

   (http://rudo-brody.pl/uploads/2011-12-17_1541.png)
   (http://rudo-brody.pl/uploads/2011-12-17_1544.png)

   Please check it and play with it and get fun.. I'm waiting for your changes and opinions.


Title: Re: Shaders and effects
Post by: LagMaster on December 17, 2011, 04:49:21 pm
now we got a way to make 3D look like original fallout, no more need for the hated(but i whant it original) comment topics
Title: Re: Shaders and effects
Post by: Surf on December 17, 2011, 05:00:35 pm
Amazing progress baael - looks even better than I expected! :)
Title: Re: Shaders and effects
Post by: LagMaster on December 17, 2011, 05:52:41 pm
sr for spam post, but found a small problem

the shadow is not pixelated
Title: Re: Shaders and effects
Post by: baaelSiljan on December 17, 2011, 06:10:10 pm
sr for spam post, but found a small problem

the shadow is not pixelated

yeah, working on it
Title: Re: Shaders and effects
Post by: Johnnybravo on December 17, 2011, 07:14:33 pm
Yeah, guess it should not be opaque black in original full color either.
Title: Re: Shaders and effects
Post by: Opera on December 19, 2011, 03:24:37 pm
http://rudo-brody.pl/uploads/2011-12-17_1544.png

I'm impressed. It fits the environment perfectly and looks very much like a 2D sprite. Any chance to see Leather Jacket, Metal Armor and Combat armor with these shaders using also 100% zoom?
Title: Re: Shaders and effects
Post by: baaelSiljan on December 19, 2011, 04:00:54 pm
I'm impressed. It fits the environment perfectly and looks very much like a 2D sprite. Any chance to see Leather Jacket, Metal Armor and Combat armor with these shaders using also 100% zoom?

Thanks :) It is quite tricky now, it shouldn't be in such shader. We are thinking about that, we know how to do that, but my last information is that we need to ask Cvet for some help with processing handle. I think posterization should stay on model, but pixelization should be on top of 3d layer on view projection.
Title: Re: Shaders and effects
Post by: Luther Blissett on January 04, 2012, 06:25:43 pm
Look like another good opportunity to play a Where's Wally (http://en.wikipedia.org/wiki/Where%27s_Wally%3F) style "spot the 3D model".

(http://img109.imageshack.us/img109/350/whereswally20120401copy.png)

You'll be able to spot it, but it certainly blends in quite nicely. It may work even better for someone with a newer graphics card with antialiasing etc. Looks nice here too :

(http://img830.imageshack.us/img830/6002/combatleathersiljan.png)

Combat Leather jacket has certainly never looked so "sprite-like" to me so far. He's not perfect, but he doesn't stick out horribly. To my eyes, he looks like he belongs there.

Note that I also got the program crash upon exiting, and it seemed to slow things down a little (again, the slow graphics card I think). Other than that, this is an exciting development - keep up the good work!

Title: Re: Shaders and effects
Post by: barter1113 on January 04, 2012, 07:36:05 pm
OH FUCK! First screenshot without zoom is very nice :D Holy shit very good.
Title: Re: Shaders and effects
Post by: Graf on January 04, 2012, 08:35:50 pm
I should say, that I wasn't been able to find it out without of a zoom, which is very, very good result. Moreover, it even took me about 10-15 seconds of peruse looking, to find out the 3D model. Wow, it's all I can say.
Title: Re: Shaders and effects
Post by: Lexx on January 04, 2012, 10:00:40 pm
I saw it fast because the skin seems to be a bit overblended, imo. :) But the combat leather jacket dude is extremely good (though, it's sticking out a bit as well due to the fine details- the original critters aren't that detailed).
Title: Re: Shaders and effects
Post by: TommyTheGun on January 05, 2012, 02:17:50 am
Well... It was pretty easy to spot the weakest link... Still - when it comes to me, its only because the colours are different... Meh... I mean - the difference beteen the fallout colours palette is obvious. Other than that - its awesome.
Title: Re: Shaders and effects
Post by: LagMaster on January 05, 2012, 06:51:25 am
the first pic saw it first time when i was tired, didn't saw shit even with zoom, but now i know who is 3D, only cuz of the hair looking a bit diferent and clean black
Title: Re: Shaders and effects
Post by: lisac2k on January 05, 2012, 08:06:55 am
The combat leather jacket looks fantastic, if you ask me. I would probably never be able to reach such a good model myself (well, at least not without many months of training and modeling). I can only clap my hands and ask for more, because I'm* a greedy human like everyone else.

*at least when it comes down to leather jackets in FOnline
Title: Re: Shaders and effects
Post by: baaelSiljan on January 05, 2012, 11:20:13 am
 ;D I'm very happy, this is trick, but


:)
Title: Re: Shaders and effects
Post by: TommyTheGun on January 05, 2012, 01:02:35 pm
Quote
but end and beginning of year is hard for me to keep business working so i need to work much much more in my job

We all do, bro... We all do... Yet some of us are able to find some time to spare on the whole 2,5d project and others (like me) don't ;).  Keeping in mind, there are not so many people working on it right now, the progress is awesome if you ask me.

I dont know shit about shaders, effects and that sort of stuff - but does "pallette cut" mean effect which forces models (textures?) to use the original Fallout (in that particular case ofcourse) pallete only? If its something completely different, then is there a way to make such effect or does it need to be done at the texture stage?

Also - im terribly sorry for such a nooblike questions.
Title: Re: Shaders and effects
Post by: baaelSiljan on January 05, 2012, 01:26:23 pm
I dont know shit about shaders, effects and that sort of stuff - but does "pallette cut" mean effect which forces models (textures?) to use the original Fallout (in that particular case ofcourse) pallete only?

close..

like it is in original fallout:

 modeled -> textured -> rendered -> applied palette on rendered sprites (i dont remember no. of colours)

in FOnline is realtime 3d rendering, so we should lower colour number of all 3d models at once, or for every single one, but it should be done on top of rendering (postprocessing) same as pixelisation, and there is a problem with textures, some may look great, some may look odd, cause You loose details, and in order to get it good looking You need to do some tricks with contrasted areas etc.


Title: Re: Shaders and effects
Post by: TommyTheGun on January 05, 2012, 01:36:00 pm
I see... Then again - you can only start working on textures when you see them on the model with right effects applied, right? Or is there any way to easly stimulate such an effect for example in Photoshop or Blender? [I mean - for example in Photoshop - using some filter, whatsoever, to see how the model (taken for example from blender's redner) would look like with Fallout pallette put on. That way you can see what parts of texture need to be redone/tweaked.]

Not sure if making myself clear, or just writing hard to understand for anyone else nonsense... (Oh! You can put Fry's picture in here)
Title: Re: Shaders and effects
Post by: baaelSiljan on January 05, 2012, 01:59:07 pm
You just need to keep it in mind, result will be always best visible in game.

Exactly, this means that You need to do some things better visible, cause 2px line on 512^2 texture would not be visible on postprocessed element, so if You want it to be visible You must play with contrast and size etc. But wait with heavy processing of textures until it will work good, Dirty Shaders got variables to set values, cause right now any model and texture may work in different way with it, You just need to optimise those values for Your work.
Title: Re: Shaders and effects
Post by: Luther Blissett on January 05, 2012, 03:10:49 pm
I saw it fast because the skin seems to be a bit overblended, imo. :)

[...]i know who is 3D, only cuz of the hair looking a bit diferent and clean black

[...]its only because the colours are different... Meh... I mean - the difference beteen the fallout colours palette is obvious.[...]

It's good to try this little trick from time to time I think. I knew it wasn't perfect - but putting it up there in a "spot the 3D model" competition is a fun way to spot the little things that need adjusting :)

So, looking at this, we know that these things need looking at :
- Skin brightness, colour etc (combination of adjusting texture and adjusting effects & shaders)
- This hair model doesn't quite match the sprite, but it is perfectly fine as a hair model. So we make another one which is slightly different (adjust model and texture)
- The leather jacket brightness and colour (adjusting texture, effects, shaders)
- Overall colours are different (adjusting textures, effects, shaders)

On the subtlest level of the leather jacket texture, I would say it's a slightly blue-black, compared to the brown-black of the sprite next to her. Someone could fix this with a simple "hue shift" in photoshop i.e. "-2 towards the red spectrum".

For the skin, I would say it's slightly too pink and slightly too light, so this could perhaps be fixed by slightly lowering the brightness and slightly shifting the hue to a more brown/orange shade. I do think though that the female leather jacket is only a few small alterations away from being "almost perfect".

Some of the other models and textures are a lot further off. Now we've had such developments in shaders and lighting etc, it may be a good time to start looking over these older models again and tweaking them until they can be "Where's Wally" pictures too.

Little things like adjusting the shade of brown on the metal armour trousers could literally be done with minimal knowledge of photoshop and a 3D compatible SDK set up (adjust brightness and hue, save, reload, look at it, close it, repeat) - but it would take some time. The metal armour itself will be one of the most difficult, because of trying to get the shiny effect just right, but there's definitely some basic texture work which anyone could have a go at.

The combat leather jacket looks fantastic, if you ask me. I would probably never be able to reach such a good model myself (well, at least not without many months of training and modeling). I can only clap my hands and ask for more, because I'm* a greedy human like everyone else.

That's lovely to hear - it was the first armour model I did for Fonline. After registering about a year ago, I made a power fist, shotgun, then asked if it was okay if I tried to do an armour :) It really looks so much better now than when it was first tested, and I haven't changed a thing on it myself. Proof of the excellent work on the lighting and shading and effects I think.
Title: Re: Shaders and effects
Post by: baaelSiljan on January 05, 2012, 05:42:31 pm
"-2 towards the red spectrum".

Dirty Shaders already do it :)

Great way would be some sandbox application to preview model with shaders and option to reload model and texture.
Title: Re: Shaders and effects
Post by: barter1113 on January 08, 2012, 06:39:58 pm
Dirty shaders? :)
Title: Re: Shaders and effects
Post by: baaelSiljan on January 08, 2012, 09:13:51 pm
Dirty shaders? :)

http://fodev.net/forum/index.php?topic=18263.msg164356#msg164356 (http://fodev.net/forum/index.php?topic=18263.msg164356#msg164356)
Title: Re: Shaders and effects
Post by: Jimmy BoyX on February 01, 2012, 03:50:14 pm
New progress ?
Title: Re: Shaders and effects
Post by: baaelSiljan on February 10, 2012, 05:56:57 pm
no, sorry economic and tax apocalypse in my own business