Soooo, Shaders! (.VSH/.PSH)

Timbab

Administrator
Staff member
Administrator
Moderator
Joined
Oct 6, 2010
Messages
1,057
Location
Magna Germania
It's about time we start busting the doors down on the shaders, too bad we don't have anyone really experienced in HLSL, I'm doing my best right now and it's slowly turning into logic in my head, but I'm suffering!

At the moment I'm trying to figure out how to throw a blur effect on the fog used by the View Range slider. I looked through both sets of shader files, twice, but didn't find anything that actually modifies the stupid fog. I used no_lighting.vsh and bad_vertex_shader.psh to figure out where the shaders are really being used (I made a ton of copies of them, renamed them to the other shader files, so I get the same effect of the ones I listed on the other ones, thus I get a bright pink surface on whatever used the .psh for example).

In the end, I did find something about the fog, it's actually in the vertex functions.inc, a small function for where the fog should be created (distance to player), but that's it. It's pretty frustrating, I thought I got somewhere.

The odd thing about it is, there is no trace of the function in the pixel shaders anywhere, so the pixel shader isn't using it, yet it's everywhere in the .vsh files, some bump maps (If I remember correctly) and other crap as an output. This is why at first I thought it's not gonna be the fog I'm talking about, but I know better now.

I talked to someone on IRC who knows a tad of HLSL, but not too much, if it was possible, because that was my first idea, to copy the function over to the pixel functions.inc, then toy with the 2d_blur.psh perhaps and apply it to the fog, but he said it wasn't possible because the pixel shader doesn't see it, but I'm not sure, he wondered how the fog is even made in the first place if it's not used by the pixel shaders.

I just hope it's not hidden away, I mean how the hell did the ILM guy achieve this then:


I've been asking about help on different forums, some interesting stuff but nothing final yet, after today's 'revelations', I might get better help, we'll see.

Otherwise, I don't get how shadows are modified either, anything I did with shadowvolume didn't really do anything, perhaps it needs to specifically be in asm, my 'test' files I used were in HLSL.

While looking for the fog, I did stumble on some obvious but I thought interesting things, I didn't look into all the spec files, and this is just a first impression, some of it might be wrong, I'll update it over the next few weeks:




.VSH - Tested by replacing it with: no_lighting.vsh

water_pass - controlls water waves/lights/movement
stars - controlls brightness (keeps them fully sized I believe) needs further checking out
terrain_dot3_vs20_blend - controls ground lighting
procedural_clouds - controls procedural cloud (duh) lighting... but I'm not 100% sure
gradient_sky - controls the 'filter' for the sky and the horizon, it has a 'fog' effect
cloudlayer - controls cloud movement, maybe shading like I wrote for procedural
e_planet_cloud - might control cloud shading, needs to be checked again
a_simple - Controls lighting on trees, some clothing and other stuff
2d - handles some interface 'coloring', like above and below the loading screen image, and other weird stuff

.PSH - Tested by replacing it with: bad_vertex_shader.psh

water_pass - controls the water surface (on/off, movement?)
vertex_color - controls sun light hue if you look at it, also controls some UI colors
texren_copy_c1a1 - facial shading, not sure what else
terrain_dot3_ps20_blend - Handles something on the ground textures
gradient_sky - What it sounds like, handles the sky color/shader (above the clouds)
h_color2_pp_ps20 - handles lighting on some pieces of clothing, like artisan shirt
cloudlayer - Not 100% sure what it does, but it controls the whole cloudlayer
a_specmap_pp_ps20 - Handles some random static objects, some roofs
a_emismap_ps20 - Handles lighting on some windows
a_envmask_specmap_ps20 - Handles other windows
a_modulate - Handles trees (foilage) and things in the sky (planets/StarDestroyers)
a_simple - Handles trees (wood), creatures, flags, random static objects
a_spec_pp_ps20 - Handles some roofs, bluefrog, I'd imagine random stati stuff
a_alpha_envmask - Street lights (not the glow though, it just shows the actual light itself)
a_detail_specmap_ps20 - Handles lighting on crafting stations
a_alpha_pp_ps20 - Handles some structure textures and tree foilage (not sure what's different to a_modulate yet)


Note: If you look into them, most files are in pairs of 3. As far as I know, they're split into different qualities, here is an example:

a_2blend.vsh - Written in ASM, lowest quality
a_2blend_vs11.vsh - Written in VS1.1, medium quality ?
a_2blend_vs20.vsh - Written in VS2.0, best quality

I hope this will get some brainstorming going on, we have to do this already, it's been long enough.


Edit: Just so it's 'on file'; Old GDC .pdf about SWG rendering and the shader: http://developer.amd.com/media/gpu_assets/D3DTutorial06_jgrills.pdf
 

Kayliaah

Relic
Joined
Aug 30, 2010
Messages
322
You've been busy since the other day, or night I don't even remember I was completely dead to be honest, I've messed with the files a bit myself and managed to get a weird glow that fades in and fades out on the ground terrain, pretty lame as I was going for specular lighting, this is pretty much a failure as I see it lol.

Although today I decided to take another look at the NGE terrain shaders (the ones that always made me crash instantly without helpful crash log) and this time, no crash.

So I have a diffuse, CN normal map (NGE ones, no idea why SOE used those shits), and a specular map, now I have to find a way to fix the second crash that happens with the effect file, how freaking annoying.

I remember there was a "super shader" in the files somewhere (I don't remember the name sadly) which I think has diffuse, emissive and specular, and support for a second palette but I'm not sure, I don't remember if it's PreCU or NGE, that sucks.
 

Timbab

Administrator
Staff member
Administrator
Moderator
Joined
Oct 6, 2010
Messages
1,057
Location
Magna Germania
Nice timing, was just about to post.

UGH, whenever I edit a .psh, nothing freaking happens, even if I fubar the code or remove it even. In the hex, the PEXE seems to overwrite it, or use it to skip the code entirely and use the archived one.

If I used 2d_blur as a template, it used the normal 2d_blur, if I used 2d_bloom, it used the normal bloom. At least it didn't crash though? Lol. Fuck, why...

A moderator at a different forum said the blur shader seems like the right kind for a DoF effect, I just need to access the depth buffer to change offsets for pixels, why oh why doesn't anyone I can actually talk to know HLSL in depth, anywhere.


Anyway, crash with the effect file? You mean the .eft? Interesting though, I'll have a look.

EDIT: I just realized, it's probably possible to do multiple passes if I read the .eft files correctly, meaning, DoF, real one, might actually be possible, same with HDR, but I NEED SOMEONE WITH HLSL SKILLS, else it'll take a while for me to gain 'em.

EDIT2: Haven't gotten multipass shading to work yet, the .eft didn't crash me with a second node added for it, but it's not working in game either. I do know some files like water use multiple passes, so it has to be possible.

Also, I've finally managed to get the .psh compiler to work, but it's not spitting out the right files, but I guess it's something at least, perhaps with time.

A few things I've found out to day; I'm pretty sure cloud movement is handled by the .vsh/.psh files, height isn't and that's pretty annoying. Stars and the heighmap must be hardcoded somewhere, or SOMETHING that I'm not seeing. I don't see how it's possible to fix the 1 pixel stars what so ever, the only thing you can do is use other shaders or modify the originals a bit so they give the illusion of being bigger, flicker, are brighter, etc, etc.

I'm really not further with the depth of field of the ILM guy though, it's still a complete mystery. Sometimes I think it's bloom, other times that it's blur, perhaps both, but how he got the distance to be affected on a large scale, I don't know. It feels like he used the fog, or how fog gets controlled to set it to the player distance.

Perhaps you have to pull the sky_gradient up with the same idea of how the fog gets set at a distance, then use the pixel shader to blur the crap out of it... I'll have to see later when the servers are up again.
 

Kamara

New Member
Joined
Jan 14, 2012
Messages
3
This is a little something I stumbled across and thought it might come in handy to you all. I have a great deal of respect for the work you all do and I hope in some way it will be useful.

http://amd-dev.wpengine.netdna-cdn.com/wordpress/media/2012/10/D3DTutorial06_jgrills.pdf
 

Vidi

Member
Joined
Sep 3, 2012
Messages
45
I pulled these links from some prior research on SWGANH regarding shaders. I hope they help.

https://web.archive.org/web/20070108123205/http://ati.amd.com/developer/ShaderX2_IntroductionToHLSL.pdf

http://developer.download.nvidia.com/shaderlibrary/webpages/shader_library.html
 

eqsanctum

Member
Joined
Mar 26, 2015
Messages
153
Archive pdf saved and available for future reference at

http://www.eqsanctum.com/page/swgdx9sl
[hr]
Kamara said:
This is a little something I stumbled across and thought it might come in handy to you all. I have a great deal of respect for the work you all do and I hope in some way it will be useful.

http://amd-dev.wpengine.netdna-cdn.com/wordpress/media/2012/10/D3DTutorial06_jgrills.pdf
Hosted copy at http://www.eqsanctum.com/page/swgoogc
 

kurdt

New Member
Joined
Oct 11, 2010
Messages
4
https://github.com/kurdtkobain/swgPSH

written in c#(fast prototyping) if someone wants to port to c++ go for it.

psh files are in a custom container that contains the source and the compiled binary.
Code:
byte[4] { 0x46, 0x4F, 0x52, 0x4D } //"FORM"
byte[4] FileSize-0x08 //int (!!reverse array based on Endianness)
byte[8] { 0x50, 0x53, 0x48, 0x50, 0x46, 0x4F, 0x52, 0x4D } //"PSHFORM"
byte[4] FileSize-0x14 //int (!!reverse array based on Endianness)
byte[8] { 0x30, 0x30, 0x30, 0x30, 0x50, 0x53, 0x52, 0x43 } //"    PSRC"
byte[4] PSRCSize //int (!!reverse array based on Endianness)
byte[PSRCSize-1] //Shader source
byte[1] {0x00} //always 0x00
byte[4] { 0x50, 0x45, 0x58, 0x45 } //"PEXE"
byte[4] PEXESize //int (!!reverse array based on Endianness)
byte[PEXESize] //Compiled shader

files are Big-endian
my c# reads Little-endian by default so i had to reverse the ints
even thou the game is dx9c the max shader version it can use is 2.0b.
the way the program works is you compile your HLSL to a file with fxc.exe from dx sdk then call my program in the command line.
"swgPSH.exe <hlsl source> <compiled shader> <output psh>".
since i don't know HLSL i messed around changing values and it works.
 

TyroneSWG

New Member
Joined
Nov 4, 2016
Messages
14
So, do effects alter the texture in any way? I made new shader files, and used the h_alpha (something) one. but still cannot seem to get the shaders right.

 

levarrishawk

Member
Joined
Dec 15, 2012
Messages
61
TyroneSWG said:
So, do effects alter the texture in any way? I made new shader files, and used the h_alpha (something) one. but still cannot seem to get the shaders right.

.eft effects will alter the way the textures in the shader are displayed by the client, yes.
 
Top Bottom