Scripting Moderators ds1-e Posted April 3, 2019 Scripting Moderators Share Posted April 3, 2019 Hey, i'm not experienced with shaders so i have a problem on my way. I don't know can i apply screenSource for this shader texture, something is wrong because i have black screen instead of shader. texture gTexture0 < string textureState="0,Texture"; >; sampler Sampler0 = sampler_state { Texture = (gTexture0); }; Link to comment
Scripting Moderators ds1-e Posted April 3, 2019 Author Scripting Moderators Share Posted April 3, 2019 (edited) And one more problem. How can i mix shader effect in one result? I mean that if one shader works, second don't wanna work. local screenWidth, screenHeight = guiGetScreenSize() local firstShader = dxCreateShader("shader.fx") local secondShader = dxCreateShader("shader2.fx") local screenSource = dxCreateScreenSource(screenWidth, screenHeight) function onClientRender() dxUpdateScreenSource(screenSource) dxDrawImage(0, 0, screenWidth, screenHeight, firstShader) dxDrawImage(0, 0, screenWidth, screenHeight, secondShader) end addEventHandler("onClientRender", getRootElement(), onClientRender) Edited April 3, 2019 by majqq Link to comment
Scripting Moderators ds1-e Posted April 3, 2019 Author Scripting Moderators Share Posted April 3, 2019 (edited) To make things simpler, and focus on main problem. - I have shader which change colors of player screen. - I have second shader which blur player screen. - After applying both shaders, only one works. So i need solution: - Maybe i make it wrong? Or there's possibility to get result: - Use first shader, get result. - Use second shader on result from first shader. Edited April 3, 2019 by majqq Link to comment
XaskeL Posted April 4, 2019 Share Posted April 4, 2019 input "shader" to "shader" for blur and output result "dxDrawImage(...,shader)" local grayShdr = ... dxSetShaderValue(grayShdr, "ScreenSource", screen); local blur = ... dxSetShaderValue(blur, "ScreenSource", grayShdr) dxDrawImage(..., gray) or use pass0, pass1 in shader 1 Link to comment
Scripting Moderators ds1-e Posted April 4, 2019 Author Scripting Moderators Share Posted April 4, 2019 6 hours ago, XaskeL said: input "shader" to "shader" for blur and output result "dxDrawImage(...,shader)" local grayShdr = ... dxSetShaderValue(grayShdr, "ScreenSource", screen); local blur = ... dxSetShaderValue(blur, "ScreenSource", grayShdr) dxDrawImage(..., gray) or use pass0, pass1 in shader Hey, thanks for answer. But didn't really understand what i should to do. Can you explain it better? Link to comment
XaskeL Posted April 4, 2019 Share Posted April 4, 2019 14 minutes ago, majqq said: Эй, спасибо за ответ. Но я не совсем понял, что мне делать. Можете ли вы объяснить это лучше? give me full code Link to comment
Scripting Moderators ds1-e Posted April 4, 2019 Author Scripting Moderators Share Posted April 4, 2019 21 minutes ago, XaskeL said: give me full code local screenWidth, screenHeight = guiGetScreenSize() local firstShader = dxCreateShader("shader2.fx") local secondShader = dxCreateShader("shader.fx") local screenSource = dxCreateScreenSource(screenWidth, screenHeight) local blurAmount = 50 local uvAmount = 400 local blendAmount = 6 function onClientRender() dxUpdateScreenSource(screenSource) dxSetShaderValue(firstShader, "colorAmount", 0.50) dxSetShaderValue(firstShader, "coloredTexture", screenSource) dxDrawImage(0, 0, screenWidth, screenHeight, firstShader) dxSetShaderValue(secondShader, "ScreenSource", result) dxSetShaderValue(secondShader, "OverlayTexture", result) dxSetShaderValue(secondShader, "BlurStrength", blurAmount) dxSetShaderValue(secondShader, "UVSize", screenWidth - uvAmount, screenHeight - uvAmount) dxSetShaderValue(secondShader, "Blend", blendAmount) dxDrawImage(0, 0, screenWidth, screenHeight, secondShader) end addEventHandler("onClientRender", getRootElement(), onClientRender) Link to comment
Scripting Moderators ds1-e Posted April 5, 2019 Author Scripting Moderators Share Posted April 5, 2019 On 04/04/2019 at 19:57, XaskeL said: give me full code Hey, so can you help me with it? Link to comment
Scripting Moderators ds1-e Posted April 5, 2019 Author Scripting Moderators Share Posted April 5, 2019 Looks like solved. If someone else would have same problem use: dxUpdateScreenSource(screenSource, true) -- second argument should be true After applying shader with dxDrawImage. Link to comment
XaskeL Posted April 5, 2019 Share Posted April 5, 2019 local screenWidth, screenHeight = guiGetScreenSize() local firstShader = dxCreateShader("shader2.fx") local secondShader = dxCreateShader("shader.fx") local screenSource = dxCreateScreenSource(screenWidth, screenHeight) local blurAmount = 50 local uvAmount = 400 local blendAmount = 6 function onClientRender() dxUpdateScreenSource(screenSource) dxSetShaderValue(firstShader, "colorAmount", 0.50) dxSetShaderValue(firstShader, "coloredTexture", screenSource) --dxDrawImage(0, 0, screenWidth, screenHeight, firstShader) dxSetShaderValue(secondShader, "ScreenSource", firstShader) dxSetShaderValue(secondShader, "OverlayTexture", result) dxSetShaderValue(secondShader, "BlurStrength", blurAmount) dxSetShaderValue(secondShader, "UVSize", screenWidth - uvAmount, screenHeight - uvAmount) dxSetShaderValue(secondShader, "Blend", blendAmount) dxDrawImage(0, 0, screenWidth, screenHeight, secondShader) end addEventHandler("onClientRender", getRootElement(), onClientRender) 1 Link to comment
Scripting Moderators ds1-e Posted April 5, 2019 Author Scripting Moderators Share Posted April 5, 2019 8 minutes ago, XaskeL said: local screenWidth, screenHeight = guiGetScreenSize() local firstShader = dxCreateShader("shader2.fx") local secondShader = dxCreateShader("shader.fx") local screenSource = dxCreateScreenSource(screenWidth, screenHeight) local blurAmount = 50 local uvAmount = 400 local blendAmount = 6 function onClientRender() dxUpdateScreenSource(screenSource) dxSetShaderValue(firstShader, "colorAmount", 0.50) dxSetShaderValue(firstShader, "coloredTexture", screenSource) --dxDrawImage(0, 0, screenWidth, screenHeight, firstShader) dxSetShaderValue(secondShader, "ScreenSource", firstShader) dxSetShaderValue(secondShader, "OverlayTexture", result) dxSetShaderValue(secondShader, "BlurStrength", blurAmount) dxSetShaderValue(secondShader, "UVSize", screenWidth - uvAmount, screenHeight - uvAmount) dxSetShaderValue(secondShader, "Blend", blendAmount) dxDrawImage(0, 0, screenWidth, screenHeight, secondShader) end addEventHandler("onClientRender", getRootElement(), onClientRender) Didn't worked. debugscript says it needs a texture, but got shader. Anyway thanks for trying to help, i already solved it. @XaskeL Link to comment
Scripting Moderators ds1-e Posted April 15, 2019 Author Scripting Moderators Share Posted April 15, 2019 (edited) bump. Still wanna get to work last one shader. texture gTexture0 < string textureState="0,Texture"; >; How i should apply shader value for it? I don't have any idea, how i could do it. This is from mta-helper.fx: //------------------------------------------------------------------------------------------ // textureState (partial) - String value should be a texture number followed by 'Texture' //------------------------------------------------------------------------------------------ texture gTexture0 < string textureState="0,Texture"; >; texture gTexture1 < string textureState="1,Texture"; >; texture gTexture2 < string textureState="2,Texture"; >; texture gTexture3 < string textureState="3,Texture"; >; Edited April 15, 2019 by majqq Link to comment
Ren_712 Posted April 15, 2019 Share Posted April 15, 2019 (edited) look into shader examples on wiki, mainly shader_bloom to see how to set texture for dxDrawImage. Edited April 15, 2019 by Ren_712 1 Link to comment
Scripting Moderators ds1-e Posted May 14, 2019 Author Scripting Moderators Share Posted May 14, 2019 On 16/04/2019 at 00:43, Ren_712 said: look into shader examples on wiki, mainly shader_bloom to see how to set texture for dxDrawImage. bump. I was looking into it, and there is a lot of function, so i'm not even sure where i should start looking for. 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