Linux_Shines Posted October 9, 2012 Share Posted October 9, 2012 Hello again, today I've wrinkle - how to "install" or rather "script"/"put" shader from other game (example below is from Tom Clancy's H.A.W.x® and alot of shaders) and put there in script? Example 2 shaders from Tom Clancy's H.A.W.x®, whose manipulate an sky: -- This is pixel shader: // Author: amo float4 HDRScale : register(c14); // x = rgb multiplyer, y = 1/x; z = luminance multiplyer, w = 1/z float4 HDRParam : register(c15); // r = SpecMul, g = rgb multiplyer, b = 1/g static const float3 LUMINANCE = float3(0.3086f, 0.6094f, 0.082f); float ComputeLUM(float3 color) { return dot(color, LUMINANCE); } float ComputeBRIGHT(float3 color) { return max(color.r, max(color.g, color.b)); } float3 EncodeRGB10(float3 color) { //return saturate(color * 0.25f); return saturate(color * HDRScale.y); } float3 DecodeRGB10(float3 color) { //return color * 4.0f; return color * HDRScale.x; } float EncodeL10(float lum) { //return saturate(lum * 0.25f); return saturate(lum * HDRScale.w); } float DecodeL10(float lum) { //return lum * 4.0f; return lum * HDRScale.z; } //float4 SunDir : register(c0); //float4 SunColor : register(c1); //float4 ParamsAngle : register(c2); //float4 FogColor : register(c3); sampler2D skyTex : register(s0); struct v2f { float4 Position : POSITION; float2 texCrd : TEXCOORD0; }; float4 main(v2f IN) : COLOR0 { float4 Out = tex2D(skyTex, IN.texCrd); /* float3 norm = normalize(IN.Pos); float d = dot(norm, SunDir.xyz); d = saturate((d-ParamsAngle.x)*ParamsAngle.y); d = d*d; Out.rgb += SunColor.rgb*d*SunColor.w; */ Out.rgb = EncodeRGB10(Out.rgb); return Out; } /* float4 Out = float4(0, 0, 0, 1); float3 GeneralColor = float3(0.45f, 0.55f, 1); float3 DarkestColor = float3(0.20f, 0.30f, 0.9); float3 HorizontalColor = float3(0.8f, 0.77f, 1); float3 SunColor = float3(0.6f, 0.6f, 0.45f); float3 norm = normalize(IN.Pos); float dotNS = dot(norm, SunDir.xyz); float d = saturate((dotNS-ParamsAngle.x)*ParamsAngle.y); d = d*d; Out.rgb = GeneralColor; Out.rgb = lerp(Out.rgb, SunColor, d); float darkFactor = 1 - abs((dotNS)); Out.rgb = lerp(Out.rgb, DarkestColor, sqrt(darkFactor)); float Height = norm.y + FogColor.w/ParamsAngle.w; float HorHeightStart = 1.0f; float HorHeightEnd = 0.0f; float horizFactor = saturate((Height - HorHeightStart)/(HorHeightEnd - HorHeightStart)); Out.rgb = lerp(Out.rgb, HorizontalColor, horizFactor); float FogHeightStart = 0.1f; float FogHeightEnd = 0.0f; float FogFactor = saturate((Height - FogHeightStart)/(FogHeightEnd - FogHeightStart)); Out.rgb = lerp(Out.rgb, FogColor.rgb, FogFactor); Out.rgb = EncodeRGB10(Out.rgb); return Out; */ and this is Vertex Shader: #pragma pack_matrix(row_major) float4x4 wvpMatrix : register(c0); float4 Params : register(c4); struct a2v { float4 Position : POSITION; }; struct v2f { float4 Position : POSITION; float3 Normal : NORMAL; }; v2f main(a2v IN) { v2f OUT; float4 position = 1; position.xyz = normalize(IN.Position.xyz) * Params.w; OUT.Position = mul(wvpMatrix, position); OUT.Normal = normalize(IN.Position.xyz); return OUT; } I'm seriously dunno anything about shaders and copying from other games will be not good idea, because every game is other (probably visit on Microsoft site will be help for learn about High Level Shader Language), but the question is - how to convert or something these shaders to MTA format/type, and it's possible? Link to comment
Ren_712 Posted October 26, 2012 Share Posted October 26, 2012 IF it is HLSL (and the code clearly shows) I guess you could apply that. If the effect consists of both vertex and pixel shader you have to combine it into a one effect file. Plus some variables, etc (understanding what they represent) And what this effect is applied to. Of course you have to understand some basic c++ and hlsl to know what to do.So it's no copy file , paste file matter. Mta wiki has some info on applying shader effects. A lot of great info youll find here: http://digitalerr0r.wordpress.com/tutorials/ Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now