greentumbleweed Posted March 3, 2021 Share Posted March 3, 2021 presume i have 163 of these, some with smaller tables ect, functions: addEvent('pp',true) addEventHandler('pp', root, function() if setting == 1 then terrain = dxCreateTexture('shader/low/1.png',"dxt5",true) elseif setting == 2 then terrain = dxCreateTexture('shader/medium/1.png',"dxt5",true) elseif setting == 3 then terrain = dxCreateTexture('shader/img/1.png',"dxt5",true) end if terrain then shader = dxCreateShader("shader/fx/shader.fx") dxSetShaderValue(shader, 'Tex0', terrain) local grass = {'sw_sandlod','desstones_dirt1','desertgryard256','grasspatch_64hv','desertgryard256lod','grasstype5_4','desgrasandblend','desgrasandblend_lod','grasslod','redcliffroof_la','grasstype4','sw_sandgrasslod','sw_sand','whitesand_256','dirtblendlitlod','des_dirt2gygrasslod','brngrss2stonesb','lodslgrass01','des_grass2dirt1','des_grass2dirt1lod','des_scrub1lod','des_grass2scrublod','rocktbrn128bllod','des_dirt2lod','des_dirt2grasslod','desgrassbrnlod','des_dirt1lod','des_yelrocklod','golf_fairway2','grassgrn256','lodgrass_128hv','pavementhexagon','desgrassbrnsnd','forestfloor256','forestfloor256lod','forestfloor256mudblend','grasslong256','des_dirt2stones','hiwayinsideblend1_256','greyground2sand','grasstype4_staw','grassshort2long256','grassdeep256','grasstype3dirt','grassdeep256','grass_lawn_128hv','tenniscourt1_256','hiwayinsideblend2_256','hiwayblend1_256','desegravelgrassroadla','dirtblendlit','sl_sfngrssdrt01','sl_sfngrass01','golf_greengrass','golf_fairway3','golf_fairway1','golf_heavygrass','golf_hvygras_cpark','grass_dirt_64hv','pavebsandend','grass_dry_64hv','grassdeadbrn256','sjmlahus28','sjmscorclawn3','grasstype510','grasstype510_10','roadblend:O','brngrss2stones','grasstype4-3','grasstype3','grasstype5_desdirt','dirtkb_64hv','desertgryard256grs2','des_dirt2grass','des_dirt1','grass','des_dirt1_glfhvy','des_dirt1_grass','grass_128hv','ffbranch_mountdirt','desmud2forstfloor','forestfloorblend','cw2_mountdirt2forest','con2sand1b','con2sand1a','desgrassbrn_grn','des_dirt2gygrass','ws_traingravelblend','sw_sand','newcrop3','sjmscorclawn','dirtgaz64b','bow_church_grass_gen','grasstype10_4blend','desertstones256forestmix','grifnewtex1x_las','grassdry_128hv','grass4dirtytrans','hedge1','sw_grass01d','sfn_rockhole','sfncn_rockgrass3','sfn_grass1','des_dirtgrassmixbmp','grasstype4_forestblend','grasstype4_10','grasstype10','des_dirtgrassmix_grass4','grass4dirty','dt_road2grasstype4','bow_church_grass_alt','grasstype4blndtodirt','desgreengrass','yardgrass1', 'grassgrnbrn256', 'des_grass2scrub', 'des_scrub1_dirt1b', 'des_scrub1_dirt1a', 'vgs_rockbot1a', 'vgs_rockmid1a', 'des_ripplsand','des_dirtgravel','des_roadedge2','des_panelconc','des_oldrunwayblend','grasstype5','grasstype5_dirt','desgrassbrn','hiway2sand1a','hiwaygravel1_256','hiwaygravel1_lod','des_oldrunway','grass4_des_dirt2','forestfloorbranch256','forestfloor3','des_dirt2grgrass','forestfloor3_forest','forestfloor_sones256','sw_sandgrass','sw_sandgrass4','sw_rockgrassb2','des_dirt2 trackl','des_dirtgrassmixb','des_dirtgrassmixc','desertstones256grass','desmuddesgrsblend','hiwayinsideblend3_256','desgrassbrn_lod','des_scrub1_lod','desgreengrasslod','grasstype7','sandgrndlod','concretedust2_lod','bow_church_grass_lod','des_dirt1_lod','vgsecoast02_lod','vgsecoast05_lod','vgs_rockbot1a_lod','vgn_ground8_lod','vgn_ground10_lod','vgn_ground3_lod','grassdry_lod','5af8d285','brickred'} for i=1, #grass do engineApplyShaderToWorldTexture(shader, grass[i]) end end end ) any idea on how i could speed up the loading of shaders on switching from low, medium, or high? Link to comment
Moderators IIYAMA Posted March 3, 2021 Moderators Share Posted March 3, 2021 1 hour ago, greentumbleweed said: any idea on how i could speed up the loading of shaders on switching from low, medium, or high? Isn't updating the shader value enough? Instead of creating a new shader and (re)applying it to all textures. Link to comment
greentumbleweed Posted March 3, 2021 Author Share Posted March 3, 2021 you can reduce resolution with: local scaleValue = screenY / devScreenY and it will all so reduce impact for lower end pc? Link to comment
Moderators IIYAMA Posted March 3, 2021 Moderators Share Posted March 3, 2021 1 hour ago, greentumbleweed said: and it will all so reduce impact for lower end pc? That is for scaling absolute values to relative values, making sure that the dx-effects are the same size on every screen (without stretching). It will not be helpful in your cause: reducing resolution for performance gain. Link to comment
Scripting Moderators ds1-e Posted March 3, 2021 Scripting Moderators Share Posted March 3, 2021 5 hours ago, IIYAMA said: Isn't updating the shader value enough? Instead of creating a new shader and (re)applying it to all textures. Sadly it isn't, you need create replacement shader for every texture (no idea why it's like that though). 1 Link to comment
Moderators IIYAMA Posted March 3, 2021 Moderators Share Posted March 3, 2021 21 minutes ago, majqq said: Sadly it isn't, you need create replacement shader for every texture (no idea why it's like that though). Hmm, I didn't know that. In that case the only thing he can do is pre-loading: local terrainTexture = {} addEventHandler("onClientResourceStart", root, function () terrainTexture.low = dxCreateTexture('shader/low/1.png',"dxt5",true) terrainTexture.medium = dxCreateTexture('shader/medium/1.png',"dxt5",true) terrainTexture.high = dxCreateTexture('shader/img/1.png',"dxt5",true) shader = dxCreateShader("shader/fx/shader.fx") end) local grass = {'sw_sandlod','desstones_dirt1','desertgryard256','grasspatch_64hv','desertgryard256lod','grasstype5_4','desgrasandblend','desgrasandblend_lod','grasslod','redcliffroof_la','grasstype4','sw_sandgrasslod','sw_sand','whitesand_256','dirtblendlitlod','des_dirt2gygrasslod','brngrss2stonesb','lodslgrass01','des_grass2dirt1','des_grass2dirt1lod','des_scrub1lod','des_grass2scrublod','rocktbrn128bllod','des_dirt2lod','des_dirt2grasslod','desgrassbrnlod','des_dirt1lod','des_yelrocklod','golf_fairway2','grassgrn256','lodgrass_128hv','pavementhexagon','desgrassbrnsnd','forestfloor256','forestfloor256lod','forestfloor256mudblend','grasslong256','des_dirt2stones','hiwayinsideblend1_256','greyground2sand','grasstype4_staw','grassshort2long256','grassdeep256','grasstype3dirt','grassdeep256','grass_lawn_128hv','tenniscourt1_256','hiwayinsideblend2_256','hiwayblend1_256','desegravelgrassroadla','dirtblendlit','sl_sfngrssdrt01','sl_sfngrass01','golf_greengrass','golf_fairway3','golf_fairway1','golf_heavygrass','golf_hvygras_cpark','grass_dirt_64hv','pavebsandend','grass_dry_64hv','grassdeadbrn256','sjmlahus28','sjmscorclawn3','grasstype510','grasstype510_10','roadblend:O','brngrss2stones','grasstype4-3','grasstype3','grasstype5_desdirt','dirtkb_64hv','desertgryard256grs2','des_dirt2grass','des_dirt1','grass','des_dirt1_glfhvy','des_dirt1_grass','grass_128hv','ffbranch_mountdirt','desmud2forstfloor','forestfloorblend','cw2_mountdirt2forest','con2sand1b','con2sand1a','desgrassbrn_grn','des_dirt2gygrass','ws_traingravelblend','sw_sand','newcrop3','sjmscorclawn','dirtgaz64b','bow_church_grass_gen','grasstype10_4blend','desertstones256forestmix','grifnewtex1x_las','grassdry_128hv','grass4dirtytrans','hedge1','sw_grass01d','sfn_rockhole','sfncn_rockgrass3','sfn_grass1','des_dirtgrassmixbmp','grasstype4_forestblend','grasstype4_10','grasstype10','des_dirtgrassmix_grass4','grass4dirty','dt_road2grasstype4','bow_church_grass_alt','grasstype4blndtodirt','desgreengrass','yardgrass1', 'grassgrnbrn256', 'des_grass2scrub', 'des_scrub1_dirt1b', 'des_scrub1_dirt1a', 'vgs_rockbot1a', 'vgs_rockmid1a', 'des_ripplsand','des_dirtgravel','des_roadedge2','des_panelconc','des_oldrunwayblend','grasstype5','grasstype5_dirt','desgrassbrn','hiway2sand1a','hiwaygravel1_256','hiwaygravel1_lod','des_oldrunway','grass4_des_dirt2','forestfloorbranch256','forestfloor3','des_dirt2grgrass','forestfloor3_forest','forestfloor_sones256','sw_sandgrass','sw_sandgrass4','sw_rockgrassb2','des_dirt2 trackl','des_dirtgrassmixb','des_dirtgrassmixc','desertstones256grass','desmuddesgrsblend','hiwayinsideblend3_256','desgrassbrn_lod','des_scrub1_lod','desgreengrasslod','grasstype7','sandgrndlod','concretedust2_lod','bow_church_grass_lod','des_dirt1_lod','vgsecoast02_lod','vgsecoast05_lod','vgs_rockbot1a_lod','vgn_ground8_lod','vgn_ground10_lod','vgn_ground3_lod','grassdry_lod','5af8d285','brickred'} addEvent('pp',true) addEventHandler('pp', root, function() if setting == 1 then terrain = terrainTexture.low elseif setting == 2 then terrain = terrainTexture.medium elseif setting == 3 then terrain = terrainTexture.high end if terrain then if not shader then shader = dxCreateShader("shader/fx/shader.fx") end dxSetShaderValue(shader, 'Tex0', terrain) for i=1, #grass do engineApplyShaderToWorldTexture(shader, grass[i]) end end end) Link to comment
greentumbleweed Posted March 3, 2021 Author Share Posted March 3, 2021 (edited) 5 hours ago, IIYAMA said: Hmm, I didn't know that. In that case the only thing he can do is pre-loading: local terrainTexture = {} addEventHandler("onClientResourceStart", root, function () terrainTexture.low = dxCreateTexture('shader/low/1.png',"dxt5",true) terrainTexture.medium = dxCreateTexture('shader/medium/1.png',"dxt5",true) terrainTexture.high = dxCreateTexture('shader/img/1.png',"dxt5",true) shader = dxCreateShader("shader/fx/shader.fx") end) local grass = {'sw_sandlod','desstones_dirt1','desertgryard256','grasspatch_64hv','desertgryard256lod','grasstype5_4','desgrasandblend','desgrasandblend_lod','grasslod','redcliffroof_la','grasstype4','sw_sandgrasslod','sw_sand','whitesand_256','dirtblendlitlod','des_dirt2gygrasslod','brngrss2stonesb','lodslgrass01','des_grass2dirt1','des_grass2dirt1lod','des_scrub1lod','des_grass2scrublod','rocktbrn128bllod','des_dirt2lod','des_dirt2grasslod','desgrassbrnlod','des_dirt1lod','des_yelrocklod','golf_fairway2','grassgrn256','lodgrass_128hv','pavementhexagon','desgrassbrnsnd','forestfloor256','forestfloor256lod','forestfloor256mudblend','grasslong256','des_dirt2stones','hiwayinsideblend1_256','greyground2sand','grasstype4_staw','grassshort2long256','grassdeep256','grasstype3dirt','grassdeep256','grass_lawn_128hv','tenniscourt1_256','hiwayinsideblend2_256','hiwayblend1_256','desegravelgrassroadla','dirtblendlit','sl_sfngrssdrt01','sl_sfngrass01','golf_greengrass','golf_fairway3','golf_fairway1','golf_heavygrass','golf_hvygras_cpark','grass_dirt_64hv','pavebsandend','grass_dry_64hv','grassdeadbrn256','sjmlahus28','sjmscorclawn3','grasstype510','grasstype510_10','roadblend:O','brngrss2stones','grasstype4-3','grasstype3','grasstype5_desdirt','dirtkb_64hv','desertgryard256grs2','des_dirt2grass','des_dirt1','grass','des_dirt1_glfhvy','des_dirt1_grass','grass_128hv','ffbranch_mountdirt','desmud2forstfloor','forestfloorblend','cw2_mountdirt2forest','con2sand1b','con2sand1a','desgrassbrn_grn','des_dirt2gygrass','ws_traingravelblend','sw_sand','newcrop3','sjmscorclawn','dirtgaz64b','bow_church_grass_gen','grasstype10_4blend','desertstones256forestmix','grifnewtex1x_las','grassdry_128hv','grass4dirtytrans','hedge1','sw_grass01d','sfn_rockhole','sfncn_rockgrass3','sfn_grass1','des_dirtgrassmixbmp','grasstype4_forestblend','grasstype4_10','grasstype10','des_dirtgrassmix_grass4','grass4dirty','dt_road2grasstype4','bow_church_grass_alt','grasstype4blndtodirt','desgreengrass','yardgrass1', 'grassgrnbrn256', 'des_grass2scrub', 'des_scrub1_dirt1b', 'des_scrub1_dirt1a', 'vgs_rockbot1a', 'vgs_rockmid1a', 'des_ripplsand','des_dirtgravel','des_roadedge2','des_panelconc','des_oldrunwayblend','grasstype5','grasstype5_dirt','desgrassbrn','hiway2sand1a','hiwaygravel1_256','hiwaygravel1_lod','des_oldrunway','grass4_des_dirt2','forestfloorbranch256','forestfloor3','des_dirt2grgrass','forestfloor3_forest','forestfloor_sones256','sw_sandgrass','sw_sandgrass4','sw_rockgrassb2','des_dirt2 trackl','des_dirtgrassmixb','des_dirtgrassmixc','desertstones256grass','desmuddesgrsblend','hiwayinsideblend3_256','desgrassbrn_lod','des_scrub1_lod','desgreengrasslod','grasstype7','sandgrndlod','concretedust2_lod','bow_church_grass_lod','des_dirt1_lod','vgsecoast02_lod','vgsecoast05_lod','vgs_rockbot1a_lod','vgn_ground8_lod','vgn_ground10_lod','vgn_ground3_lod','grassdry_lod','5af8d285','brickred'} addEvent('pp',true) addEventHandler('pp', root, function() if setting == 1 then terrain = terrainTexture.low elseif setting == 2 then terrain = terrainTexture.medium elseif setting == 3 then terrain = terrainTexture.high end if terrain then if not shader then shader = dxCreateShader("shader/fx/shader.fx") end dxSetShaderValue(shader, 'Tex0', terrain) for i=1, #grass do engineApplyShaderToWorldTexture(shader, grass[i]) end end end) Not sure why, but it doesn't load the grass texture when i call the directory outside of the function, everything else works just fine. im lost lol No errors either. dxSetShaderValue(shader, 'Tex0', terrain) this is where it should be applied but its not for some reason Edited March 3, 2021 by greentumbleweed Link to comment
Moderators IIYAMA Posted March 4, 2021 Moderators Share Posted March 4, 2021 6 hours ago, IIYAMA said: addEventHandler("onClientResourceStart", root, function () Change root to resourceRoot. (My bad) And add some debug lines to check if everything is executed. 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