Jump to content

Vehicle Tints


Recommended Posts

tinted.fx

technique car_tint_window
{
    pass P0
    {
		DepthBias = 0.0000;
		AlphaBlendEnable = FALSE;
		SrcBlend = SRCALPHA;
		DestBlend = INVSRCALPHA;
    }
}

// fallback method
technique fallback
{
    pass P0
    {
        // do normal drawing
    }
}

tinted.lua

local theShader = dxCreateShader("tinted.fx", 1, 200, true)
function tintedWindows()
  for k,vehicles in ipairs(getElementsByType("vehicle")) do
    if getElementData(vehicles, "tinted") == true then
      engineApplyShaderToWorldTexture(theShader, "vehiclegeneric256", vehicles)
      engineApplyShaderToWorldTexture(theShader, "hotdog92glass128", vehicles)
      engineApplyShaderToWorldTexture(theShader, "okoshko", vehicles)
    else
      engineRemoveShaderFromWorldTexture(theShader, "vehiclegeneric256", vehicles)
      engineRemoveShaderFromWorldTexture(theShader, "hotdog92glass128", vehicles)
      engineRemoveShaderFromWorldTexture(theShader, "okoshko", vehicles)
    end
  end
end

Right now the tint colour is black, how can I change it into another colour?

Link to comment

I don't know anything of .fx but viewing this https://wiki.multitheftauto.com/wiki/Shader_examples#Texture_name i can create the .fx of what you need.
Here is the .fx and the .lua:


float4 Color;

technique car_window_tint
{
  pass P0
  {
    MaterialAmbient = Color;
    MaterialDiffuse = Color;
    MaterialEmissive = Color;
    MaterialSpecular = Color;
  }
}
local theShader = dxCreateShader("tinted.fx", 1,200, true)
dxSetShaderValue(theShader, "Color", 255/255,0/255,0/255,50/255) -- Here is the Red,Green,Blue and Alpha. All need to be from 0 to 1 that is why i divide for 255

function tintedWindows()
  for k,vehicles in ipairs(getElementsByType("vehicle")) do
    if getElementData(vehicles, "tinted") == true then
      engineApplyShaderToWorldTexture(theShader, "vehiclegeneric256", vehicles)
      engineApplyShaderToWorldTexture(theShader, "hotdog92glass128", vehicles)
      engineApplyShaderToWorldTexture(theShader, "okoshko", vehicles)
    else
      engineRemoveShaderFromWorldTexture(theShader, "vehiclegeneric256", vehicles)
      engineRemoveShaderFromWorldTexture(theShader, "hotdog92glass128", vehicles)
      engineRemoveShaderFromWorldTexture(theShader, "okoshko", vehicles)
    end
  end
end

Sorry for the basic english. :v

Link to comment
16 minutes ago, saygoodbye said:

I don't know anything of .fx but viewing this https://wiki.multitheftauto.com/wiki/Shader_examples#Texture_name i can create the .fx of what you need.
Here is the .fx and the .lua:



float4 Color;

technique car_window_tint
{
  pass P0
  {
    MaterialAmbient = Color;
    MaterialDiffuse = Color;
    MaterialEmissive = Color;
    MaterialSpecular = Color;
  }
}

local theShader = dxCreateShader("tinted.fx", 1,200, true)
dxSetShaderValue(theShader, "Color", 255/255,0/255,0/255,50/255) -- Here is the Red,Green,Blue and Alpha. All need to be from 0 to 1 that is why i divide for 255

function tintedWindows()
  for k,vehicles in ipairs(getElementsByType("vehicle")) do
    if getElementData(vehicles, "tinted") == true then
      engineApplyShaderToWorldTexture(theShader, "vehiclegeneric256", vehicles)
      engineApplyShaderToWorldTexture(theShader, "hotdog92glass128", vehicles)
      engineApplyShaderToWorldTexture(theShader, "okoshko", vehicles)
    else
      engineRemoveShaderFromWorldTexture(theShader, "vehiclegeneric256", vehicles)
      engineRemoveShaderFromWorldTexture(theShader, "hotdog92glass128", vehicles)
      engineRemoveShaderFromWorldTexture(theShader, "okoshko", vehicles)
    end
  end
end

Sorry for the basic english. :v

Another person that uses :v, >:v

Link to comment
  • 7 years later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...