Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Jakypant's GTA online crew color converter. sRGB to linear.
- // Use: place this text into a textfile and give it a .fx ending.
- // Apply it as a directX shader in 3ds max or other software that renders .fx shaders.
- // sample the color you want and place it in the 'target color' colorpicker.
- // the color your object turns out is what you wanna use as your hex on socialclub. I use photshop to sample it.
- string ParamID = "0x003"; //use DXSAS compiler
- /************ Matrixes imported from application **************/
- float4x4 WorldViewProjection : WorldViewProjection;
- float4x4 WorldInverseTranspose : WorldInverseTranspose;
- float4x4 ViewInverse : ViewInverse ;
- float4x4 World : World;
- float4x4 WorldViewProjectionInverse : WorldViewProjectionInverse;
- /************* Interface Tweakables. ****************/
- //color pickers
- float4 targetColor : TargetColor
- < string UIName = "The crew color I want: ";> = {0.25f, 0.25f, 0.25f, 1.0f};
- /****************************************************/
- /********** CG SHADER FUNCTIONS *********************/
- /****************************************************/
- int uv : Texcoord
- <
- int Texcoord = 0;
- int MapChannel = 1;
- string UIType = "None";
- >;
- // input from application
- struct app2vertexShader
- {
- float4 position : POSITION;
- float2 uv : TEXCOORD0;
- float3 tangent : TANGENT;
- float3 binormal : BINORMAL;
- float3 normal : NORMAL;
- };
- // output to fragment program
- struct vert2pixel
- {
- float4 position : POSITION;
- float2 uv : TEXCOORD0;
- float3 eyeVec : TEXCOORD1;
- float3 lightVec : TEXCOORD2;
- float3 worldNormal : TEXCOORD3;
- float3 worldTangent : TEXCOORD4;
- float3 worldBinormal : TEXCOORD5;
- float4 screenPos : TEXCOORD6;
- float3 posPos : TEXCOORD7;
- };
- //************ Lights *******************************/
- float4 light1Pos : POSITION
- <
- string UIName = "Light Position";
- string Object = "PointLight";
- string Space = "World";
- int refID = 0;
- > = {100.0f, 100.0f, 100.0f, 0.0f};
- float4 light1Color : LIGHTCOLOR
- <
- int LightRef = 0;
- > = { 1.0f, 1.0f, 1.0f, 0.0f };
- /****************************************************/
- /************* Vertex Shader. ***********************/
- /****************************************************/
- vert2pixel vertexShader(app2vertexShader In, uniform float4 lightPosition)
- //vert2pixel vertexShader(app2vertexShader In)
- {
- vert2pixel Out; //create the output struct
- Out.worldNormal = mul(In.normal, WorldInverseTranspose).xyz; //put the normal in world space pass it to the pixel shader
- Out.worldTangent = mul(In.tangent, WorldInverseTranspose).xyz; //put the tangent in world space pass it to the pixel shader
- Out.worldBinormal = mul(In.binormal, WorldInverseTranspose).xyz; //put the binormal in world space pass it to the pixel shader
- float3 worldSpacePos = mul(In.position, World); //put the vertex in world space
- Out.lightVec = lightPosition; //create the world space light vector and pass it to the pixel shader
- Out.uv.xy = In.uv.xy; //pass the UV coordinates to the pixel shader
- Out.eyeVec = ViewInverse[3].xyz - worldSpacePos; //create the world space eye vector and pass it to the pixel shader
- Out.position = mul(In.position, WorldViewProjection); //put the vertex position in clip space and pass it to the pixel shader
- Out.screenPos = Out.position;
- Out.posPos = In.position.xyz;
- return Out;
- }
- /***************************************************/
- /************* Pixel Shader. ***********************/
- /***************************************************/
- float3 linRGB(float3 sRGB) //converts input sRGB to linear.
- {
- float3 lRGB = sRGB * (sRGB * (sRGB * 0.305306011 + 0.682171111) + 0.012522878);
- return lRGB;
- }
- float3 sRGB(float3 linRGB) //converts linear RGB into sRGB.
- {
- float3 S1 = sqrt(linRGB);
- float3 S2 = sqrt(S1);
- float3 S3 = sqrt(S2);
- float3 sRGB = 0.662002687 * S1 + 0.684122060 * S2 - 0.323583601 * S3 - 0.0225411470 * linRGB;
- return sRGB;
- }
- float4 pixelShader (vert2pixel In,uniform float4 lightColor) : COLOR
- {
- float4 C;z
- C.rgb = linRGB(targetColor);
- C.a = 1.0;
- return C;
- }
- /************* Teqniques. ****************************/
- technique alphaTest
- {
- pass one
- {
- //VertexShader = compile vs_3_0 vertexShader(light1Pos); //here we call the vertex shader function and tell it we want to use VS 1.1 as the profile
- VertexShader = compile vs_3_0 vertexShader(light1Pos);
- ZEnable = true; //this enables sorting based on the Z buffer
- ZWriteEnable = true; //this writes the depth value to the Z buffer so other objects will sort correctly this this one
- CullMode = none; //this enables backface culling. CW stands for clockwise. You can change it to CCW, or none if you want.
- AlphaTestEnable = false;
- AlphaFunc = less;
- AlphaRef = 0x00000001;
- AlphaBlendEnable = true; //This disables transparency. If you make it true, the alpha value of the final pixel shader color will determine how transparent the surface is.
- //SrcBlend = one;
- SrcBlendAlpha = one;
- DestBlendAlpha = one;
- StencilEnable = True;
- PixelShader = compile ps_3_0 pixelShader(light1Color); //here we call the pixel shader function and tell it we want to use the PS 2.0 profile
- }
- }
Add Comment
Please, Sign In to add comment