tjakal

GTA online crew color converter

Aug 14th, 2019
1,163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.37 KB | None | 0 0
  1. // Jakypant's GTA online crew color converter. sRGB to linear.
  2. // Use: place this text into a textfile and give it a .fx ending.
  3. // Apply it as a directX shader in 3ds max or other software that renders .fx shaders.
  4. // sample the color you want and place it in the 'target color' colorpicker.
  5. // the color your object turns out is what you wanna use as your hex on socialclub. I use photshop to sample it.
  6.  
  7. string ParamID = "0x003"; //use DXSAS compiler
  8.  
  9. /************ Matrixes imported from application **************/
  10.  
  11. float4x4 WorldViewProjection : WorldViewProjection;
  12. float4x4 WorldInverseTranspose : WorldInverseTranspose;
  13. float4x4 ViewInverse : ViewInverse ;
  14. float4x4 World : World;
  15. float4x4 WorldViewProjectionInverse : WorldViewProjectionInverse;
  16.  
  17. /************* Interface Tweakables. ****************/
  18.  
  19. //color pickers
  20.  
  21. float4 targetColor : TargetColor
  22. < string UIName = "The crew color I want: ";> = {0.25f, 0.25f, 0.25f, 1.0f};
  23.  
  24.  
  25. /****************************************************/
  26. /********** CG SHADER FUNCTIONS *********************/
  27. /****************************************************/
  28.  
  29. int uv : Texcoord
  30. <
  31. int Texcoord = 0;
  32. int MapChannel = 1;
  33. string UIType = "None";
  34. >;
  35.  
  36. // input from application
  37. struct app2vertexShader
  38. {
  39. float4 position : POSITION;
  40. float2 uv : TEXCOORD0;
  41. float3 tangent : TANGENT;
  42. float3 binormal : BINORMAL;
  43. float3 normal : NORMAL;
  44. };
  45.  
  46. // output to fragment program
  47. struct vert2pixel
  48. {
  49. float4 position : POSITION;
  50. float2 uv : TEXCOORD0;
  51. float3 eyeVec : TEXCOORD1;
  52. float3 lightVec : TEXCOORD2;
  53. float3 worldNormal : TEXCOORD3;
  54. float3 worldTangent : TEXCOORD4;
  55. float3 worldBinormal : TEXCOORD5;
  56. float4 screenPos : TEXCOORD6;
  57. float3 posPos : TEXCOORD7;
  58. };
  59.  
  60. //************ Lights *******************************/
  61.  
  62. float4 light1Pos : POSITION
  63. <
  64. string UIName = "Light Position";
  65. string Object = "PointLight";
  66. string Space = "World";
  67. int refID = 0;
  68. > = {100.0f, 100.0f, 100.0f, 0.0f};
  69.  
  70.  
  71. float4 light1Color : LIGHTCOLOR
  72. <
  73. int LightRef = 0;
  74. > = { 1.0f, 1.0f, 1.0f, 0.0f };
  75.  
  76.  
  77. /****************************************************/
  78. /************* Vertex Shader. ***********************/
  79. /****************************************************/
  80.  
  81. vert2pixel vertexShader(app2vertexShader In, uniform float4 lightPosition)
  82. //vert2pixel vertexShader(app2vertexShader In)
  83. {
  84. vert2pixel Out; //create the output struct
  85. Out.worldNormal = mul(In.normal, WorldInverseTranspose).xyz; //put the normal in world space pass it to the pixel shader
  86. Out.worldTangent = mul(In.tangent, WorldInverseTranspose).xyz; //put the tangent in world space pass it to the pixel shader
  87. Out.worldBinormal = mul(In.binormal, WorldInverseTranspose).xyz; //put the binormal in world space pass it to the pixel shader
  88. float3 worldSpacePos = mul(In.position, World); //put the vertex in world space
  89. Out.lightVec = lightPosition; //create the world space light vector and pass it to the pixel shader
  90. Out.uv.xy = In.uv.xy; //pass the UV coordinates to the pixel shader
  91.  
  92. Out.eyeVec = ViewInverse[3].xyz - worldSpacePos; //create the world space eye vector and pass it to the pixel shader
  93. Out.position = mul(In.position, WorldViewProjection); //put the vertex position in clip space and pass it to the pixel shader
  94. Out.screenPos = Out.position;
  95. Out.posPos = In.position.xyz;
  96.  
  97. return Out;
  98. }
  99.  
  100. /***************************************************/
  101. /************* Pixel Shader. ***********************/
  102. /***************************************************/
  103.  
  104.  
  105. float3 linRGB(float3 sRGB) //converts input sRGB to linear.
  106. {
  107. float3 lRGB = sRGB * (sRGB * (sRGB * 0.305306011 + 0.682171111) + 0.012522878);
  108. return lRGB;
  109. }
  110.  
  111. float3 sRGB(float3 linRGB) //converts linear RGB into sRGB.
  112. {
  113. float3 S1 = sqrt(linRGB);
  114. float3 S2 = sqrt(S1);
  115. float3 S3 = sqrt(S2);
  116. float3 sRGB = 0.662002687 * S1 + 0.684122060 * S2 - 0.323583601 * S3 - 0.0225411470 * linRGB;
  117.  
  118. return sRGB;
  119. }
  120.  
  121. float4 pixelShader (vert2pixel In,uniform float4 lightColor) : COLOR
  122. {
  123. float4 C;z
  124. C.rgb = linRGB(targetColor);
  125.  
  126. C.a = 1.0;
  127. return C;
  128. }
  129.  
  130. /************* Teqniques. ****************************/
  131.  
  132.  
  133. technique alphaTest
  134. {
  135. pass one
  136. {
  137. //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
  138. VertexShader = compile vs_3_0 vertexShader(light1Pos);
  139. ZEnable = true; //this enables sorting based on the Z buffer
  140. ZWriteEnable = true; //this writes the depth value to the Z buffer so other objects will sort correctly this this one
  141. CullMode = none; //this enables backface culling. CW stands for clockwise. You can change it to CCW, or none if you want.
  142. AlphaTestEnable = false;
  143. AlphaFunc = less;
  144. AlphaRef = 0x00000001;
  145. 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.
  146. //SrcBlend = one;
  147. SrcBlendAlpha = one;
  148. DestBlendAlpha = one;
  149. StencilEnable = True;
  150. 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
  151. }
  152. }
Add Comment
Please, Sign In to add comment