iPanda Posted January 21, 2014 Share Posted January 21, 2014 Hi guys. Need help. I have black and white shader .fx file. BUT! I want to make an exception for black and white effect. For example, the whole world is black and white, except machinery - they left their old colors. Must use engineRemoveShaderFromWorldTexture, but I do not know how to do it to me. shader.lua file (engineRemoveShaderFromWorldTexture - don`t work) local screenX, screenY = guiGetScreenSize() local screenSource = dxCreateScreenSource(screenX, screenY) local blackWhite = dxCreateShader( "data/blackwhite.fx" ) addEventHandler("onClientPreRender", getRootElement(), function() if ( blackWhite ) then dxUpdateScreenSource( screenSource ) dxSetShaderValue( blackWhite, "screenSource", screenSource ) engineRemoveShaderFromWorldTexture( blackWhite, "vehicle" ) dxDrawImage( 0, 0, screenX, screenY, blackWhite ) end end ) shader.fx file // // blackwhite.fx // texture screenSource; sampler TextureSampler = sampler_state { Texture = ; }; float4 PixelShaderFunction(float2 TextureCoordinate : TEXCOORD0) : COLOR0 { float4 color = tex2D(TextureSampler, TextureCoordinate); float value = (color.r + color.g + color.b) / 3; color.r = value; color.g = value; color.b = value; return color; } technique BlackAndWhite { pass Pass1 { PixelShader = compile ps_2_0 PixelShaderFunction(); } } Link to comment
Ren_712 Posted January 21, 2014 Share Posted January 21, 2014 As i see it, you should skip getting screensource. Plus, should pass vertex colors. I mean if don't want to make a screen space effect, but texture effect. addEventHandler( "onClientResourceStart", resourceRoot, function() -- Create shader local shader, tec = dxCreateShader ( "shader.fx" ) if not shader then outputChatBox( "Could not create shader. Please use debugscript 3" ) else outputChatBox( "Using technique " .. tec ) -- Apply shader to all world textures engineApplyShaderToWorldTexture ( shader, "*" ) end end ) And the shader code is: //--------------------------------------------------------------------- // Include some common stuff //--------------------------------------------------------------------- #include "mta-helper.fx" //--------------------------------------------------------------------- // Sampler for the main texture //--------------------------------------------------------------------- sampler Sampler0 = sampler_state { Texture = (gTexture0); }; //--------------------------------------------------------------------- // Structure of data sent to the vertex shader //--------------------------------------------------------------------- struct VSInput { float3 Position : POSITION0; 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 = MTACalcScreenPosition ( VS.Position ); // 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 { float4 texel = tex2D(Sampler0, PS.TexCoord) * PS.Diffuse; float gray = (texel.r + texel.g + texel.b)/3; float4 finalColor = float4(gray, gray, gray, texel.a ); return finalColor; } //------------------------------------------------------------------------------------------ // Techniques //------------------------------------------------------------------------------------------ technique grayTextures { pass P0 { VertexShader = compile vs_2_0 VertexShaderFunction(); PixelShader = compile ps_2_0 PixelShaderFunction(); } } Link to comment
iPanda Posted January 22, 2014 Author Share Posted January 22, 2014 As i see it, you should skip getting screensource. Plus, should pass vertex colors. I mean if don't want to make a screen space effect, but texture effect. addEventHandler( "onClientResourceStart", resourceRoot, function() -- Create shader local shader, tec = dxCreateShader ( "shader.fx" ) if not shader then outputChatBox( "Could not create shader. Please use debugscript 3" ) else outputChatBox( "Using technique " .. tec ) -- Apply shader to all world textures engineApplyShaderToWorldTexture ( shader, "*" ) end end ) And the shader code is: //--------------------------------------------------------------------- // Include some common stuff //--------------------------------------------------------------------- #include "mta-helper.fx" //--------------------------------------------------------------------- // Sampler for the main texture //--------------------------------------------------------------------- sampler Sampler0 = sampler_state { Texture = (gTexture0); }; //--------------------------------------------------------------------- // Structure of data sent to the vertex shader //--------------------------------------------------------------------- struct VSInput { float3 Position : POSITION0; 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 = MTACalcScreenPosition ( VS.Position ); // 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 { float4 texel = tex2D(Sampler0, PS.TexCoord) * PS.Diffuse; float gray = (texel.r + texel.g + texel.b)/3; float4 finalColor = float4(gray, gray, gray, texel.a ); return finalColor; } //------------------------------------------------------------------------------------------ // Techniques //------------------------------------------------------------------------------------------ technique grayTextures { pass P0 { VertexShader = compile vs_2_0 VertexShaderFunction(); PixelShader = compile ps_2_0 PixelShaderFunction(); } } Where and how do I use the engineRemoveShaderFromWorldTexture? Link to comment
Ren_712 Posted January 23, 2014 Share Posted January 23, 2014 engineApplyShaderToWorldTexture ( shader, "*" ) engineRemoveShaderFromWorldTexture ( shader, "sometexturename" ) use shader_tex_names resource to find the texture names that you want to remove Link to comment
Gallardo9944 Posted January 23, 2014 Share Posted January 23, 2014 dxSetShaderValue( blackWhite, "screenSource", screenSource ) This already means you're setting this to the player screen. You're shadering the screen texture, not the vehicles or anything, so trying to remove it from an object won't work cause it's not applied to any object. You should apply it to all the textures, except vehicle ones. That would be pain in the rear end though. Link to comment
iPanda Posted January 23, 2014 Author Share Posted January 23, 2014 engineApplyShaderToWorldTexture ( shader, "*" )engineRemoveShaderFromWorldTexture ( shader, "sometexturename" ) use shader_tex_names resource to find the texture names that you want to remove dxSetShaderValue( blackWhite, "screenSource", screenSource ) This already means you're setting this to the player screen. You're shadering the screen texture, not the vehicles or anything, so trying to remove it from an object won't work cause it's not applied to any object. You should apply it to all the textures, except vehicle ones. That would be pain in the rear end though. You have misunderstood me. Your shader replaces only the texture areas and all. I want everything to be black and white, except for: plamyani, fire, flag, osescheniya and shadows - they ostalis unchanged (colored). Generally, the shaders in the game "The Saboteur". How to make this function? Link to comment
Gallardo9944 Posted January 23, 2014 Share Posted January 23, 2014 I haven't misunderstood you. It's not "my shader". You have to set the shader to world objects, excluding the ones you want. Screen source shader will shaderize the screen, not the elements. Link to comment
iPanda Posted January 23, 2014 Author Share Posted January 23, 2014 I haven't misunderstood you. It's not "my shader". You have to set the shader to world objects, excluding the ones you want. Screen source shader will shaderize the screen, not the elements. Is there a table of the elements, which can be assigned using engineRemoveShaderFromWorldTexture? Link to comment
Ren_712 Posted January 23, 2014 Share Posted January 23, 2014 engineApplyShaderToWorldTexture ( shader, "*" )engineRemoveShaderFromWorldTexture ( shader, "sometexturename" ) use shader_tex_names resource to find the texture names that you want to remove dxSetShaderValue( blackWhite, "screenSource", screenSource ) This already means you're setting this to the player screen. You're shadering the screen texture, not the vehicles or anything, so trying to remove it from an object won't work cause it's not applied to any object. You should apply it to all the textures, except vehicle ones. That would be pain in the rear end though. You have misunderstood me. Your shader replaces only the texture areas and all. I want everything to be black and white, except for: plamyani, fire, flag, osescheniya and shadows - they ostalis unchanged (colored). Generally, the shaders in the game "The Saboteur". How to make this function? You can not exclude elements from a screensource (unless you are talking about screen depth). That is why i proposed a 'to texture effect' not screen space effect. The texture list that fits perfectly is in the resource shader_flashlight_test Also you will find the solution to apply shaders with vertex lighting - look at the ped effect. To make it look good enough you will have to make separate effects for peds, vehicles and world objects. You can't do much for coronas - changing their texture colours seems impossible. At least when i tried it. Link to comment
iPanda Posted January 25, 2014 Author Share Posted January 25, 2014 engineApplyShaderToWorldTexture ( shader, "*" )engineRemoveShaderFromWorldTexture ( shader, "sometexturename" ) use shader_tex_names resource to find the texture names that you want to remove I have two questions: 1. How to replace the color of the sky using shaders and his client file? (not using setSkyGradient) 2. How to replace the player skin model, if I replaced them with a new model? Link to comment
Ren_712 Posted January 25, 2014 Share Posted January 25, 2014 engineApplyShaderToWorldTexture ( shader, "*" )engineRemoveShaderFromWorldTexture ( shader, "sometexturename" ) use shader_tex_names resource to find the texture names that you want to remove I have two questions: 1. How to replace the color of the sky using shaders and his client file? (not using setSkyGradient) 2. How to replace the player skin model, if I replaced them with a new model? 1. You can't. All you can do is create a spheric object and apply effect to it's texture. You can also mess with the cloud textures, but it won't give you much. 2.You mean skin texture ? Create shader for "ped". Then apply shader to world texture. An example: http://www.solidfiles.com/d/64ae35feab/golden_ped.zip Link to comment
iPanda Posted January 25, 2014 Author Share Posted January 25, 2014 engineApplyShaderToWorldTexture ( shader, "*" )engineRemoveShaderFromWorldTexture ( shader, "sometexturename" ) use shader_tex_names resource to find the texture names that you want to remove I have two questions: 1. How to replace the color of the sky using shaders and his client file? (not using setSkyGradient) 2. How to replace the player skin model, if I replaced them with a new model? 1. You can't. All you can do is create a spheric object and apply effect to it's texture. You can also mess with the cloud textures, but it won't give you much. 2.You mean skin texture ? Create shader for "ped". Then apply shader to world texture. An example: http://www.solidfiles.com/d/64ae35feab/golden_ped.zip How do I create such a shader? http://www.gamer.ru/system/attached_ima ... 537243.jpg Link to comment
Ren_712 Posted January 25, 2014 Share Posted January 25, 2014 I have two questions: 1. How to replace the color of the sky using shaders and his client file? (not using setSkyGradient) 2. How to replace the player skin model, if I replaced them with a new model? 1. You can't. All you can do is create a spheric object and apply effect to it's texture. You can also mess with the cloud textures, but it won't give you much. 2.You mean skin texture ? Create shader for "ped". Then apply shader to world texture. An example: http://www.solidfiles.com/d/64ae35feab/golden_ped.zip How do I create such a shader? http://www.gamer.ru/system/attached_ima ... 537243.jpg oCain shader pack for enb had sin_city post process effect. With minor alterations it would work for mta. http://playmods.blogspot.com/2013/06/gt ... hader.html 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