Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //-----------------------------------------------------------------------
- //-- Settings
- //-----------------------------------------------------------------------
- float4 theColorYouWant;
- //---------------------------------------------------------------------
- // Include some common stuff
- //---------------------------------------------------------------------
- #include "mta-helper.fx"
- //-----------------------------------------------------------------------
- //-- Sampler for the new texture
- //-----------------------------------------------------------------------
- sampler Sampler0 = sampler_state
- {
- Texture = (gTexture0);
- };
- //-----------------------------------------------------------------------
- //-- Structure of data sent to the vertex shader
- //-----------------------------------------------------------------------
- struct VSInput
- {
- float3 Position : POSITION0;
- float3 Normal : NORMAL0;
- float4 Diffuse : COLOR0;
- float2 TexCoord : TEXCOORD0;
- };
- //-----------------------------------------------------------------------
- //-- Structure of data sent to the pixel shader ( from the vertex shader )
- //-----------------------------------------------------------------------
- struct PSInput
- {
- float4 Position : POSITION0;
- float4 Diffuse : COLOR0;
- float2 TexCoord : TEXCOORD0;
- };
- //--------------------------------------------------------------------------------------------
- //-- VertexShaderFunction
- //-- 1. Read from VS structure
- //-- 2. Process
- //-- 3. Write to PS structure
- //--------------------------------------------------------------------------------------------
- PSInput VertexShaderFunction(VSInput VS)
- {
- PSInput PS = (PSInput)0;
- //-- Calculate screen pos of vertex
- PS.Position = mul(float4(VS.Position, 1), gWorldViewProjection);
- //-- Pass through tex coord
- PS.TexCoord = VS.TexCoord;
- //-- Calculate GTA lighting for buildings
- PS.Diffuse = MTACalcGTABuildingDiffuse( VS.Diffuse );
- return PS;
- }
- //--------------------------------------------------------------------------------------------
- //-- PixelShaderFunction
- //-- 1. Read from PS structure
- //-- 2. Process
- //-- 3. Return pixel color
- //--------------------------------------------------------------------------------------------
- float4 PixelShaderFunction(PSInput PS) : COLOR0
- {
- //-- Get texture pixel
- float4 texel = tex2D(Sampler0, PS.TexCoord);
- //-- Apply diffuse lighting
- float4 finalColor = texel * PS.Diffuse * theColorYouWant;
- return finalColor;
- }
- //--------------------------------------------------------------------------------------------
- //-- Techniques
- //--------------------------------------------------------------------------------------------
- technique tec
- {
- pass P0
- {
- VertexShader = compile vs_2_0 VertexShaderFunction();
- PixelShader = compile ps_2_0 PixelShaderFunction();
- }
- }
- //-- Fallback
- technique fallback
- {
- pass P0
- {
- //-- Replace texture
- Texture[0] = gTexture0;
- //-- Leave the rest of the states to the default settings
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement