Hi,
I hope this is the right forum...
I've been working on a mod for SWGEmu, but I'm having extreme problems with the shaders. I'm totally inexperienced when it comes to HLSL and some of it seems to be in ASM.
What I mainly want to do is add depth of field if possible (It should be, a guy on an old mod forum said it was possible by modding the psh/vsh files), probably in the fog .vsh, but I'm not sure. Another thing is understanding the possibilities with the given files.
If anyone could take a few moments and look at it, I would be extremely grateful, I've been trying to figure this stuff out for hours and been researching, but with not too much progress. I've uploaded all of the psh/vsh and their .inc files, including 3 pastebin samples of it.
2d_blur.psh - http://pastebin.com/0g9NcTPx
fog.inc (Vertex) - http://pastebin.com/9F9MpQeZ
skybox.vsh - http://pastebin.com/AazHRpdg
The zip - http://www.putlocker...9C28E8269766107
Thanks in advance!
.vsh / .psh - HLSL/ASM Shaders - SWGalaxies - Totally lost
Started by Timbab, Jun 17 2012 04:21 PM
3 replies to this topic
#1
Posted 17 June 2012 - 04:21 PM
#2
Posted 20 June 2012 - 11:47 AM
As far as I can tell from this (slide 9), you need a special tool to compile the pixel shaders. Do you have that? If you do, or can work around that limitation, then there may be hope. The next problem, is finding a suiteable DoF technique. This old ATI technique is from 2004, a year after the game was released, so its requrements might fit what the game provides. It does however require a focal point, and I'm not sure you could provide that
"Stupid bug! You go squish now!!" - Homer Simpson
#3
Posted 20 June 2012 - 04:34 PM
Keep in mind that if you can only modify shaders, you are restricted in what you can do because you can't add additional render targets, draw calls, etc; that will severely limit the kinds of image effects you can achieve with this type of hacking. For DoF particularly I expect this would be a tricky constraint to work with.
reedbeta.com - developer blog, OpenGL demos, and other projects
#4
Posted 22 June 2012 - 07:09 AM
Hey, thanks for the replies. I was gonna mention that pdf, but you found it already. 
Good that you mention the compiler, I do have it, two actually, a new version (9 something) and one the one from 2004 (Used in some of the newer shaders in the game), and I can compile the files, but I don't get the files I want, for example if I copy the exact code clean from the 2d_blur.psh with out the added compiler bytes and compile, I get this (It looks screwed, cause it's in hex):
I'll attach 2 pics so you can see it in hex.
Instead of this (original)
In cmd I'd open up fxc.exe and use this command: fxc /T ps_2_0 /Fo 2d_blur.psh 2d_blur.cpp, does anyone know what I'm doing wrong? I might have to add the form in manually, but regardless, the code won't even show up.
The .vsh I can edit as far as I know, fully, as it compiles on the fly. I've already tried some stuff with minor successes, but nothing major yet, I'm sure I could and can modify the .psh files once I can compile it in the right way. But I also talked to someone who manually managed to get new .psh files working ages ago, but he can't remember correctly how he did it, so it IS possible.
@Reedbeta, what do you limit to 'only shaders'? Right now I can edit their functions.inc, it also has 'module' .inc files, and well also the .psh(Soon hopefully) and vsh files. Outside of that, I found out I might be able to make multi passes work by editing the .eft (Effect files that link to the psh/vsh), I do know some things in game, like water, use multiple passes. I've attached all the shaders in the .zip above though, in case you want to check out what I mean.
Couldn't I use the player position/character as a focal point, somehow?
For instance, I found that part of the fog distance to the player that's used for the view distance (Though I found out too that in the end I can't modify it, at least not the normal fog for it), is calculated with this:
Couldn't you do something similar with a blur/DoF like effect? It doesn't have to be 100% DoF, a faux one would do too.
Look at this for example, a modder achieved the following a few years ago, he never said how he did it exactly, he just said this:
"It also allows for camera blurring when focal on "centric" objects. "
"Nothing. Didn't touch sandstorms or fog. The only exception is that the draw distance now has a parameter in the Vertex/Pixel shader files that can force Depth of Field on some cards - but that won't affect sandstorms or natural in-game fog."
http://forum.modsour...ttach=925;image
http://forum.modsour...ttach=929;image
Just as a reference, here is the original game with view distances 0%, 50% and 100%.
http://img528.images...eenshot0447.jpg
http://img526.images...eenshot0448.jpg
http://img194.images...eenshot0449.jpg
Any ideas would be fantastic, thanks in advance!
Edit: Got the compiling and importing fixed now.
Curious, is it hard converting .fx files into .psh and .vsh? I've been trying some stuff, but no real luck so far.
Good that you mention the compiler, I do have it, two actually, a new version (9 something) and one the one from 2004 (Used in some of the newer shaders in the game), and I can compile the files, but I don't get the files I want, for example if I copy the exact code clean from the 2d_blur.psh with out the added compiler bytes and compile, I get this (It looks screwed, cause it's in hex):
I'll attach 2 pics so you can see it in hex.
ÿÿþÿ-CTABÿÿxDHX"hs0«userConstants««ps_2_0Microsoft (R) HLSL Shader Compiler 9.29.952.3111Q @@@€@€° B€ä°ä €ä° ä € ä €ä€ ä°€ä€U 䰀䀪 ä°B€ä€ä B€ä€ä B€ä€ä B€ä€ä €ä€ ä €ä€ä ä€€ä€ ä 䀀ä€ä 䀀ä€ä 䀀ä€ÿÿhttp://img854.images...05/62536327.png
Instead of this (original)
FORM?PSHPFORM?0000PSRC?//hlsl ps_2_0
#include "pixel_program/include/pixel_shader_constants.inc"
#include "pixel_program/include/functions.inc"
sampler s0 : register(s0);
float4 main
(
in float2 textureCoordinates : TEXCOORD0
)
: COLOR
{
float4 result = 0.0f;
float2 textureCoordinateOffsets = 0.0f;
for (int i = 0; i < 16; ++i, textureCoordinateOffsets += userConstants[16].xy)
result += tex2D(s0, textureCoordinates + textureCoordinateOffsets) * userConstants[i];
return result;
}
PEXE?????-CTAB??xDHXhs0?userConstants??ps_2_0Microsoft (R) D3DX9 Shader Compiler 4.09.00.1126Q?`ApAQ? A0A@APAQ??@?@AAQ?@@@?@?@???? ?????????????????U??????????????????????????U???????????????????????B
? ????B ?????B?????B?????B?????B?????B?????B?????B?????B?????B?????
?
?? ?? ? ????
?????
?? ???????????????????
??????????????????????????????????????????U??????????????????????????U???B?????B?????B?????B?????B?????????????????????????????????????????????
http://img9.imagesha...19/12675741.pngIn cmd I'd open up fxc.exe and use this command: fxc /T ps_2_0 /Fo 2d_blur.psh 2d_blur.cpp, does anyone know what I'm doing wrong? I might have to add the form in manually, but regardless, the code won't even show up.
The .vsh I can edit as far as I know, fully, as it compiles on the fly. I've already tried some stuff with minor successes, but nothing major yet, I'm sure I could and can modify the .psh files once I can compile it in the right way. But I also talked to someone who manually managed to get new .psh files working ages ago, but he can't remember correctly how he did it, so it IS possible.
@Reedbeta, what do you limit to 'only shaders'? Right now I can edit their functions.inc, it also has 'module' .inc files, and well also the .psh(Soon hopefully) and vsh files. Outside of that, I found out I might be able to make multi passes work by editing the .eft (Effect files that link to the psh/vsh), I do know some things in game, like water, use multiple passes. I've attached all the shaders in the .zip above though, in case you want to check out what I mean.
Couldn't I use the player position/character as a focal point, somehow?
For instance, I found that part of the fog distance to the player that's used for the view distance (Though I found out too that in the end I can't modify it, at least not the normal fog for it), is calculated with this:
float calculateFog(float4 vertexPosition_o)
{
float4 position_w = mul(vertexPosition_o, objectWorldMatrix);
float3 viewer_w = cameraPosition_w - position_w;
float viewerDistanceSquared = lengthSquared(viewer_w);
return 1.0 / exp(viewerDistanceSquared * fog.w);
}
Couldn't you do something similar with a blur/DoF like effect? It doesn't have to be 100% DoF, a faux one would do too.
Look at this for example, a modder achieved the following a few years ago, he never said how he did it exactly, he just said this:
"It also allows for camera blurring when focal on "centric" objects. "
"Nothing. Didn't touch sandstorms or fog. The only exception is that the draw distance now has a parameter in the Vertex/Pixel shader files that can force Depth of Field on some cards - but that won't affect sandstorms or natural in-game fog."
http://forum.modsour...ttach=925;image
http://forum.modsour...ttach=929;image
Just as a reference, here is the original game with view distances 0%, 50% and 100%.
http://img528.images...eenshot0447.jpg
http://img526.images...eenshot0448.jpg
http://img194.images...eenshot0449.jpg
Any ideas would be fantastic, thanks in advance!
Edit: Got the compiling and importing fixed now.
Curious, is it hard converting .fx files into .psh and .vsh? I've been trying some stuff, but no real luck so far.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











