diff --git a/BBMOD_GML/BBMOD.resource_order b/BBMOD_GML/BBMOD.resource_order index e87a84c9..79907d19 100644 --- a/BBMOD_GML/BBMOD.resource_order +++ b/BBMOD_GML/BBMOD.resource_order @@ -96,6 +96,7 @@ {"name":"BBMOD_ImageBasedLight","order":3,"path":"scripts/BBMOD_ImageBasedLight/BBMOD_ImageBasedLight.yy",}, {"name":"DrawTextShadow","order":2,"path":"scripts/DrawTextShadow/DrawTextShadow.yy",}, {"name":"__bbmod_light_ambient","order":5,"path":"scripts/__bbmod_light_ambient/__bbmod_light_ambient.yy",}, + {"name":"BBMOD_TerrainMaterial","order":7,"path":"scripts/BBMOD_TerrainMaterial/BBMOD_TerrainMaterial.yy",}, {"name":"BBMOD_SetQuaternionModule","order":2,"path":"scripts/BBMOD_SetQuaternionModule/BBMOD_SetQuaternionModule.yy",}, {"name":"BBMOD_ShDefaultUnlitColor","order":13,"path":"shaders/BBMOD_ShDefaultUnlitColor/BBMOD_ShDefaultUnlitColor.yy",}, {"name":"SndShell2","order":2,"path":"sounds/SndShell2/SndShell2.yy",}, @@ -116,7 +117,6 @@ {"name":"BBMOD_ShInstanceIDAnimated","order":1,"path":"shaders/BBMOD_ShInstanceIDAnimated/BBMOD_ShInstanceIDAnimated.yy",}, {"name":"BBMOD_VertexFormat","order":4,"path":"scripts/BBMOD_VertexFormat/BBMOD_VertexFormat.yy",}, {"name":"BBMOD_LightmapShader","order":1,"path":"scripts/BBMOD_LightmapShader/BBMOD_LightmapShader.yy",}, - {"name":"SprSand","order":1,"path":"sprites/SprSand/SprSand.yy",}, {"name":"BBMOD_IRenderable","order":1,"path":"scripts/BBMOD_IRenderable/BBMOD_IRenderable.yy",}, {"name":"BBMOD_MixQuaternionFromSpeedModule","order":1,"path":"scripts/BBMOD_MixQuaternionFromSpeedModule/BBMOD_MixQuaternionFromSpeedModule.yy",}, {"name":"BBMOD_MixVec2OverTimeModule","order":3,"path":"scripts/BBMOD_MixVec2OverTimeModule/BBMOD_MixVec2OverTimeModule.yy",}, @@ -148,7 +148,7 @@ {"name":"OItem","order":1,"path":"objects/OItem/OItem.yy",}, {"name":"SndWhoosh","order":5,"path":"sounds/SndWhoosh/SndWhoosh.yy",}, {"name":"BBMOD_AddVec2OverTimeModule","order":3,"path":"scripts/BBMOD_AddVec2OverTimeModule/BBMOD_AddVec2OverTimeModule.yy",}, - {"name":"SprSplatmap","order":5,"path":"sprites/SprSplatmap/SprSplatmap.yy",}, + {"name":"SprSplatmap","order":3,"path":"sprites/SprSplatmap/SprSplatmap.yy",}, {"name":"__bbmod_d3d11","order":9,"path":"scripts/__bbmod_d3d11/__bbmod_d3d11.yy",}, {"name":"BBMOD_MixVec2FromHealthModule","order":2,"path":"scripts/BBMOD_MixVec2FromHealthModule/BBMOD_MixVec2FromHealthModule.yy",}, {"name":"__BBMOD_ShCheckMRT","order":11,"path":"shaders/__BBMOD_ShCheckMRT/__BBMOD_ShCheckMRT.yy",}, @@ -185,6 +185,7 @@ {"name":"BBMOD_ShTerrain","order":3,"path":"shaders/BBMOD_ShTerrain/BBMOD_ShTerrain.yy",}, {"name":"BBMOD_ShDefaultColorAnimated","order":18,"path":"shaders/BBMOD_ShDefaultColorAnimated/BBMOD_ShDefaultColorAnimated.yy",}, {"name":"ShZombieDepth","order":1,"path":"shaders/ShZombieDepth/ShZombieDepth.yy",}, + {"name":"BBMOD_TerrainLayer","order":5,"path":"scripts/BBMOD_TerrainLayer/BBMOD_TerrainLayer.yy",}, {"name":"__BBMOD_ShPrefilterSpecular","order":16,"path":"shaders/__BBMOD_ShPrefilterSpecular/__BBMOD_ShPrefilterSpecular.yy",}, {"name":"BBMOD_SpotLight","order":4,"path":"scripts/BBMOD_SpotLight/BBMOD_SpotLight.yy",}, {"name":"BBMOD_DefaultLightmapMaterial","order":6,"path":"scripts/BBMOD_DefaultLightmapMaterial/BBMOD_DefaultLightmapMaterial.yy",}, @@ -204,6 +205,7 @@ {"name":"BBMOD_SprColorGradingLUT","order":1,"path":"sprites/BBMOD_SprColorGradingLUT/BBMOD_SprColorGradingLUT.yy",}, {"name":"__bbmod_string","order":6,"path":"scripts/__bbmod_string/__bbmod_string.yy",}, {"name":"BBMOD_Node","order":2,"path":"scripts/BBMOD_Node/BBMOD_Node.yy",}, + {"name":"BBMOD_TerrainShader","order":6,"path":"scripts/BBMOD_TerrainShader/BBMOD_TerrainShader.yy",}, {"name":"BBMOD_MixSpeedModule","order":1,"path":"scripts/BBMOD_MixSpeedModule/BBMOD_MixSpeedModule.yy",}, {"name":"BBMOD_Matrix","order":6,"path":"scripts/BBMOD_Matrix/BBMOD_Matrix.yy",}, {"name":"BBMOD_SprBlack","order":14,"path":"sprites/BBMOD_SprBlack/BBMOD_SprBlack.yy",}, @@ -212,7 +214,7 @@ {"name":"BBMOD_AddVec4OverTimeModule","order":1,"path":"scripts/BBMOD_AddVec4OverTimeModule/BBMOD_AddVec4OverTimeModule.yy",}, {"name":"BBMOD_Vec4","order":4,"path":"scripts/BBMOD_Vec4/BBMOD_Vec4.yy",}, {"name":"SndFootstep1","order":1,"path":"sounds/SndFootstep1/SndFootstep1.yy",}, - {"name":"SprHeightmap","order":4,"path":"sprites/SprHeightmap/SprHeightmap.yy",}, + {"name":"SprHeightmap","order":2,"path":"sprites/SprHeightmap/SprHeightmap.yy",}, {"name":"BBMOD_ShGizmoSelect","order":5,"path":"shaders/BBMOD_ShGizmoSelect/BBMOD_ShGizmoSelect.yy",}, {"name":"BBMOD_MixVec3FromHealthModule","order":3,"path":"scripts/BBMOD_MixVec3FromHealthModule/BBMOD_MixVec3FromHealthModule.yy",}, {"name":"BBMOD_ShDefaultDepth","order":7,"path":"shaders/BBMOD_ShDefaultDepth/BBMOD_ShDefaultDepth.yy",}, @@ -265,7 +267,7 @@ {"name":"bbmod_cmp","order":1,"path":"scripts/bbmod_cmp/bbmod_cmp.yy",}, {"name":"Fnt48","order":2,"path":"fonts/Fnt48/Fnt48.yy",}, {"name":"BBMOD_ShTerrainUnlit","order":4,"path":"shaders/BBMOD_ShTerrainUnlit/BBMOD_ShTerrainUnlit.yy",}, - {"name":"SprDirt","order":2,"path":"sprites/SprDirt/SprDirt.yy",}, + {"name":"SprDirt","order":1,"path":"sprites/SprDirt/SprDirt.yy",}, {"name":"BBMOD_ShDefaultUnlitColorBatched","order":14,"path":"shaders/BBMOD_ShDefaultUnlitColorBatched/BBMOD_ShDefaultUnlitColorBatched.yy",}, {"name":"BBMOD_ResourceManager","order":18,"path":"scripts/BBMOD_ResourceManager/BBMOD_ResourceManager.yy",}, {"name":"SndPunch","order":4,"path":"sounds/SndPunch/SndPunch.yy",}, diff --git a/BBMOD_GML/BBMOD.yyp b/BBMOD_GML/BBMOD.yyp index ab298fe2..377b6ded 100644 --- a/BBMOD_GML/BBMOD.yyp +++ b/BBMOD_GML/BBMOD.yyp @@ -182,6 +182,7 @@ {"id":{"name":"__bbmod_ssao","path":"scripts/__bbmod_ssao/__bbmod_ssao.yy",},}, {"id":{"name":"DrawTextShadow","path":"scripts/DrawTextShadow/DrawTextShadow.yy",},}, {"id":{"name":"__bbmod_light_ambient","path":"scripts/__bbmod_light_ambient/__bbmod_light_ambient.yy",},}, + {"id":{"name":"BBMOD_TerrainMaterial","path":"scripts/BBMOD_TerrainMaterial/BBMOD_TerrainMaterial.yy",},}, {"id":{"name":"BBMOD_SetQuaternionModule","path":"scripts/BBMOD_SetQuaternionModule/BBMOD_SetQuaternionModule.yy",},}, {"id":{"name":"BBMOD_ShDefaultUnlitColor","path":"shaders/BBMOD_ShDefaultUnlitColor/BBMOD_ShDefaultUnlitColor.yy",},}, {"id":{"name":"SndShell2","path":"sounds/SndShell2/SndShell2.yy",},}, @@ -287,6 +288,7 @@ {"id":{"name":"BBMOD_ShPostProcess","path":"shaders/BBMOD_ShPostProcess/BBMOD_ShPostProcess.yy",},}, {"id":{"name":"BBMOD_ShDefaultColorAnimated","path":"shaders/BBMOD_ShDefaultColorAnimated/BBMOD_ShDefaultColorAnimated.yy",},}, {"id":{"name":"ShZombieDepth","path":"shaders/ShZombieDepth/ShZombieDepth.yy",},}, + {"id":{"name":"BBMOD_TerrainLayer","path":"scripts/BBMOD_TerrainLayer/BBMOD_TerrainLayer.yy",},}, {"id":{"name":"BBMOD_DualQuaternion","path":"scripts/BBMOD_DualQuaternion/BBMOD_DualQuaternion.yy",},}, {"id":{"name":"__BBMOD_ShPrefilterSpecular","path":"shaders/__BBMOD_ShPrefilterSpecular/__BBMOD_ShPrefilterSpecular.yy",},}, {"id":{"name":"BBMOD_SpotLight","path":"scripts/BBMOD_SpotLight/BBMOD_SpotLight.yy",},}, @@ -309,6 +311,7 @@ {"id":{"name":"BBMOD_SprColorGradingLUT","path":"sprites/BBMOD_SprColorGradingLUT/BBMOD_SprColorGradingLUT.yy",},}, {"id":{"name":"__bbmod_string","path":"scripts/__bbmod_string/__bbmod_string.yy",},}, {"id":{"name":"BBMOD_Node","path":"scripts/BBMOD_Node/BBMOD_Node.yy",},}, + {"id":{"name":"BBMOD_TerrainShader","path":"scripts/BBMOD_TerrainShader/BBMOD_TerrainShader.yy",},}, {"id":{"name":"BBMOD_MixSpeedModule","path":"scripts/BBMOD_MixSpeedModule/BBMOD_MixSpeedModule.yy",},}, {"id":{"name":"BBMOD_Matrix","path":"scripts/BBMOD_Matrix/BBMOD_Matrix.yy",},}, {"id":{"name":"BBMOD_SprBlack","path":"sprites/BBMOD_SprBlack/BBMOD_SprBlack.yy",},}, diff --git a/BBMOD_GML/Xshaders/Exposure.xsh b/BBMOD_GML/Xshaders/Exposure.xsh index c73a0801..68d2c842 100644 --- a/BBMOD_GML/Xshaders/Exposure.xsh +++ b/BBMOD_GML/Xshaders/Exposure.xsh @@ -1,4 +1,4 @@ void Exposure() { - gl_FragColor.rgb = vec3(1.0) - exp(-gl_FragColor.rgb * bbmod_Exposure); + gl_FragColor.rgb *= bbmod_Exposure * bbmod_Exposure; } diff --git a/BBMOD_GML/Xshaders/Material.xsh b/BBMOD_GML/Xshaders/Material.xsh index beede54b..9a6c1449 100644 --- a/BBMOD_GML/Xshaders/Material.xsh +++ b/BBMOD_GML/Xshaders/Material.xsh @@ -14,12 +14,12 @@ struct Material vec3 Lightmap; }; -Material CreateMaterial(mat3 TBN) +Material CreateMaterial() { Material m; m.Base = vec3(1.0); m.Opacity = 1.0; - m.Normal = normalize(TBN * vec3(0.0, 0.0, 1.0)); + m.Normal = vec3(0.0, 0.0, 1.0); m.Metallic = 0.0; m.Roughness = 1.0; m.Specular = vec3(0.0); diff --git a/BBMOD_GML/Xshaders/MetallicMaterial.xsh b/BBMOD_GML/Xshaders/MetallicMaterial.xsh index 5cf9b842..62b4fc63 100644 --- a/BBMOD_GML/Xshaders/MetallicMaterial.xsh +++ b/BBMOD_GML/Xshaders/MetallicMaterial.xsh @@ -19,9 +19,9 @@ Material UnpackMaterial( sampler2D texBaseOpacity, float isRoughness, sampler2D texNormalW, +#if !defined(X_TERRAIN) float isMetallic, sampler2D texMaterial, -#if !defined(X_TERRAIN) #if !defined(X_LIGHTMAP) sampler2D texSubsurface, #endif @@ -34,7 +34,7 @@ Material UnpackMaterial( mat3 TBN, vec2 uv) { - Material m = CreateMaterial(TBN); + Material m = CreateMaterial(); // Base color and opacity vec4 baseOpacity = texture2D(texBaseOpacity, @@ -69,6 +69,11 @@ Material UnpackMaterial( } // Material properties +#if defined(X_TERRAIN) + m.Metallic = 0.0; + m.AO = 1.0; + m.Specular = F0_DEFAULT; +#else vec4 materialProps = texture2D(texMaterial, #if defined(X_2D) mix(bbmod_MaterialUV.xy, bbmod_MaterialUV.zw, uv) @@ -90,7 +95,6 @@ Material UnpackMaterial( m.SpecularPower = exp2(1.0 + (m.Smoothness * 10.0)); } -#if !defined(X_TERRAIN) #if !defined(X_LIGHTMAP) // Subsurface (color and intensity) vec4 subsurface = texture2D(texSubsurface, uv); diff --git a/BBMOD_GML/Xshaders/PBRShader.xsh b/BBMOD_GML/Xshaders/PBRShader.xsh index 55246434..dea4b325 100644 --- a/BBMOD_GML/Xshaders/PBRShader.xsh +++ b/BBMOD_GML/Xshaders/PBRShader.xsh @@ -3,6 +3,7 @@ #pragma include("DoPointLightPS.xsh") #pragma include("DoSpotLightPS.xsh") #pragma include("Exposure.xsh") +#pragma include("TonemapReinhard.xsh") #pragma include("Fog.xsh") #pragma include("GammaCorrect.xsh") #pragma include("IBL.xsh") @@ -130,5 +131,6 @@ void PBRShader(Material material, float depth) Fog(depth); Exposure(); + TonemapReinhard(); GammaCorrect(); } diff --git a/BBMOD_GML/Xshaders/TonemapReinhard.xsh b/BBMOD_GML/Xshaders/TonemapReinhard.xsh new file mode 100644 index 00000000..1d074718 --- /dev/null +++ b/BBMOD_GML/Xshaders/TonemapReinhard.xsh @@ -0,0 +1,4 @@ +void TonemapReinhard() +{ + gl_FragColor.rgb = gl_FragColor.rgb / (vec3(1.0) + gl_FragColor.rgb); +} diff --git a/BBMOD_GML/Xshaders/Uber_PS.xsh b/BBMOD_GML/Xshaders/Uber_PS.xsh index 8ac80c62..43ba0526 100644 --- a/BBMOD_GML/Xshaders/Uber_PS.xsh +++ b/BBMOD_GML/Xshaders/Uber_PS.xsh @@ -81,12 +81,14 @@ uniform vec4 bbmod_BaseOpacityMultiplier; // If 1.0 then the material uses roughness uniform float bbmod_IsRoughness; -// If 1.0 then the material uses metallic workflow -uniform float bbmod_IsMetallic; // RGB: Tangent-space normal, A: Smoothness or roughness uniform sampler2D bbmod_NormalW; +#if !defined(X_TERRAIN) +// If 1.0 then the material uses metallic workflow +uniform float bbmod_IsMetallic; // RGB: specular color / R: Metallic, G: ambient occlusion uniform sampler2D bbmod_Material; +#endif #if !defined(X_TERRAIN) #if !defined(X_LIGHTMAP) @@ -205,6 +207,8 @@ uniform vec3 bbmod_LightPunctualDataB[2 * BBMOD_MAX_PUNCTUAL_LIGHTS]; uniform sampler2D bbmod_Splatmap; // Splatmap channel to read. Use -1 for none. uniform int bbmod_SplatmapIndex; +// Colormap texture +uniform sampler2D bbmod_Colormap; #endif // X_TERRAIN #if defined(X_PBR) @@ -280,9 +284,9 @@ void main() bbmod_BaseOpacity, bbmod_IsRoughness, bbmod_NormalW, +#if !defined(X_TERRAIN) bbmod_IsMetallic, bbmod_Material, -#if !defined(X_TERRAIN) #if !defined(X_LIGHTMAP) bbmod_Subsurface, #endif @@ -311,6 +315,9 @@ void main() : ((bbmod_SplatmapIndex == 2) ? splatmap.b : splatmap.a))); } + + // Colormap + material.Base *= xGammaToLinear(texture2D(bbmod_Colormap, v_vSplatmapCoord).xyz); #endif material.Base *= xGammaToLinear(bbmod_BaseOpacityMultiplier.rgb); diff --git a/BBMOD_GML/Xshaders/UnlitShader.xsh b/BBMOD_GML/Xshaders/UnlitShader.xsh index 0765f606..c837a922 100644 --- a/BBMOD_GML/Xshaders/UnlitShader.xsh +++ b/BBMOD_GML/Xshaders/UnlitShader.xsh @@ -1,5 +1,6 @@ #pragma include("Fog.xsh") #pragma include("Exposure.xsh") +#pragma include("TonemapReinhard.xsh") #pragma include("GammaCorrect.xsh") #if defined(X_PARTICLES) #pragma include("Projecting.xsh") @@ -23,5 +24,6 @@ void UnlitShader(Material material, float depth) #endif Fog(depth); Exposure(); + TonemapReinhard(); GammaCorrect(); } diff --git a/BBMOD_GML/extensions/BBMOD_CameraHTML5/BBMOD_CameraHTML5.yy b/BBMOD_GML/extensions/BBMOD_CameraHTML5/BBMOD_CameraHTML5.yy index e462ca01..8e48895b 100644 --- a/BBMOD_GML/extensions/BBMOD_CameraHTML5/BBMOD_CameraHTML5.yy +++ b/BBMOD_GML/extensions/BBMOD_CameraHTML5/BBMOD_CameraHTML5.yy @@ -16,7 +16,7 @@ "date": "2022-01-09T15:30:47.4419817+01:00", "description": "", "exportToGame": true, - "extensionVersion": "3.18.1", + "extensionVersion": "3.19.0", "files": [ {"resourceType":"GMExtensionFile","resourceVersion":"1.0","name":"","constants":[],"copyToTargets":32,"filename":"BBMOD_CameraHTML5.js","final":"","functions":[ {"resourceType":"GMExtensionFunction","resourceVersion":"1.0","name":"bbmod_html5_pointer_lock","argCount":0,"args":[],"documentation":"","externalName":"bbmod_html5_pointer_lock","help":"bbmod_html5_pointer_lock()","hidden":false,"kind":5,"returnType":2,}, diff --git a/BBMOD_GML/objects/OMain/Create_0.gml b/BBMOD_GML/objects/OMain/Create_0.gml index 903f268f..c2d97b89 100644 --- a/BBMOD_GML/objects/OMain/Create_0.gml +++ b/BBMOD_GML/objects/OMain/Create_0.gml @@ -99,8 +99,10 @@ if (os_browser == browser_not_a_browser) } // Any object/struct that has a render method can be added to the renderer: -renderer.add(batchShell) - .add(global.terrain); +renderer + .add(batchShell) + .add(global.terrain) + ; // Add a refleciton probe var _terrainWidth = global.terrain.Size.X * global.terrain.Scale.X; diff --git a/BBMOD_GML/objects/OMain/Draw_64.gml b/BBMOD_GML/objects/OMain/Draw_64.gml index 0e9658f9..f97d5c0b 100644 --- a/BBMOD_GML/objects/OMain/Draw_64.gml +++ b/BBMOD_GML/objects/OMain/Draw_64.gml @@ -2,7 +2,7 @@ if (!renderer.UseAppSurface) { renderer.present(); } - + var _windowWidth = window_get_width(); var _windowHeight = window_get_height(); var _font = draw_get_font(); diff --git a/BBMOD_GML/options/amazonfire/options_amazonfire.yy b/BBMOD_GML/options/amazonfire/options_amazonfire.yy index f7fd1c9c..f22eece0 100644 --- a/BBMOD_GML/options/amazonfire/options_amazonfire.yy +++ b/BBMOD_GML/options/amazonfire/options_amazonfire.yy @@ -44,5 +44,5 @@ "option_amazonfire_texture_page": "2048x2048", "option_amazonfire_tools_from_version": false, "option_amazonfire_tv_banner": "${base_options_dir}/amazonfire/tv_banner.png", - "option_amazonfire_version": "3.18.1", + "option_amazonfire_version": "3.19.0", } \ No newline at end of file diff --git a/BBMOD_GML/options/android/options_android.yy b/BBMOD_GML/options/android/options_android.yy index 0a79b06e..74669ac0 100644 --- a/BBMOD_GML/options/android/options_android.yy +++ b/BBMOD_GML/options/android/options_android.yy @@ -73,5 +73,5 @@ "option_android_tv_banner": "${base_options_dir}/android/tv_banner.png", "option_android_tv_isgame": true, "option_android_use_facebook": false, - "option_android_version": "3.18.1", + "option_android_version": "3.19.0", } \ No newline at end of file diff --git a/BBMOD_GML/options/html5/options_html5.yy b/BBMOD_GML/options/html5/options_html5.yy index 1f98e147..39880164 100644 --- a/BBMOD_GML/options/html5/options_html5.yy +++ b/BBMOD_GML/options/html5/options_html5.yy @@ -28,6 +28,6 @@ "option_html5_usebuiltinfont": true, "option_html5_usebuiltinparticles": true, "option_html5_usesplash": false, - "option_html5_version": "3.18.1.0", + "option_html5_version": "3.19.0.0", "option_html5_webgl": 1, } \ No newline at end of file diff --git a/BBMOD_GML/options/ios/options_ios.yy b/BBMOD_GML/options/ios/options_ios.yy index ae30c135..69ce7290 100644 --- a/BBMOD_GML/options/ios/options_ios.yy +++ b/BBMOD_GML/options/ios/options_ios.yy @@ -42,5 +42,5 @@ "option_ios_splashscreen_background_colour": 255, "option_ios_team_id": "", "option_ios_texture_page": "2048x2048", - "option_ios_version": "3.18.1", + "option_ios_version": "3.19.0", } \ No newline at end of file diff --git a/BBMOD_GML/options/linux/options_linux.yy b/BBMOD_GML/options/linux/options_linux.yy index 35880dc1..a7d863b7 100644 --- a/BBMOD_GML/options/linux/options_linux.yy +++ b/BBMOD_GML/options/linux/options_linux.yy @@ -20,5 +20,5 @@ "option_linux_start_fullscreen": false, "option_linux_sync": false, "option_linux_texture_page": "2048x2048", - "option_linux_version": "3.18.1", + "option_linux_version": "3.19.0", } \ No newline at end of file diff --git a/BBMOD_GML/options/mac/options_mac.yy b/BBMOD_GML/options/mac/options_mac.yy index 870cb080..2de55bae 100644 --- a/BBMOD_GML/options/mac/options_mac.yy +++ b/BBMOD_GML/options/mac/options_mac.yy @@ -29,7 +29,7 @@ "option_mac_start_fullscreen": false, "option_mac_team_id": "", "option_mac_texture_page": "2048x2048", - "option_mac_version": "3.18.1", + "option_mac_version": "3.19.0", "option_mac_vsync": false, "option_mac_x86_64": true, } \ No newline at end of file diff --git a/BBMOD_GML/options/operagx/options_operagx.yy b/BBMOD_GML/options/operagx/options_operagx.yy index d3654fb8..a7e025ab 100644 --- a/BBMOD_GML/options/operagx/options_operagx.yy +++ b/BBMOD_GML/options/operagx/options_operagx.yy @@ -23,5 +23,5 @@ "option_operagx_team_id": "", "option_operagx_team_name": "", "option_operagx_texture_page": "2048x2048", - "option_operagx_version": "3.18.1.0", + "option_operagx_version": "3.19.0.0", } \ No newline at end of file diff --git a/BBMOD_GML/options/tvos/options_tvos.yy b/BBMOD_GML/options/tvos/options_tvos.yy index b204a462..62e19f1f 100644 --- a/BBMOD_GML/options/tvos/options_tvos.yy +++ b/BBMOD_GML/options/tvos/options_tvos.yy @@ -24,5 +24,5 @@ "option_tvos_topshelf_2x": "${base_options_dir}/tvos/topshelf/topshelf_2x.png", "option_tvos_topshelf_wide": "${base_options_dir}/tvos/topshelf/topshelf_wide.png", "option_tvos_topshelf_wide_2x": "${base_options_dir}/tvos/topshelf/topshelf_wide_2x.png", - "option_tvos_version": "3.18.1", + "option_tvos_version": "3.19.0", } \ No newline at end of file diff --git a/BBMOD_GML/options/windows/options_windows.yy b/BBMOD_GML/options/windows/options_windows.yy index 915842cb..2a3c464b 100644 --- a/BBMOD_GML/options/windows/options_windows.yy +++ b/BBMOD_GML/options/windows/options_windows.yy @@ -29,6 +29,6 @@ "option_windows_steam_use_alternative_launcher": false, "option_windows_texture_page": "2048x2048", "option_windows_use_splash": false, - "option_windows_version": "3.18.1.0", + "option_windows_version": "3.19.0.0", "option_windows_vsync": false, } \ No newline at end of file diff --git a/BBMOD_GML/options/windowsuap/options_windowsuap.yy b/BBMOD_GML/options/windowsuap/options_windowsuap.yy index a6e62025..981914f6 100644 --- a/BBMOD_GML/options/windowsuap/options_windowsuap.yy +++ b/BBMOD_GML/options/windowsuap/options_windowsuap.yy @@ -4,7 +4,7 @@ "option_windowsuap_publisher_display_name": "YourPublisherName", "option_windowsuap_package_display_name": "YourPackageDisplayName", "option_windowsuap_description": "Your Description", - "option_windowsuap_version": "3.18.1.0", + "option_windowsuap_version": "3.19.0.0", "option_windowsuap_orient_portrait": true, "option_windowsuap_orient_portrait_flipped": true, "option_windowsuap_orient_landscape": true, diff --git a/BBMOD_GML/scripts/BBMOD_BaseCamera/BBMOD_BaseCamera.gml b/BBMOD_GML/scripts/BBMOD_BaseCamera/BBMOD_BaseCamera.gml index f2ba6d03..61d4e01c 100644 --- a/BBMOD_GML/scripts/BBMOD_BaseCamera/BBMOD_BaseCamera.gml +++ b/BBMOD_GML/scripts/BBMOD_BaseCamera/BBMOD_BaseCamera.gml @@ -332,7 +332,7 @@ function BBMOD_BaseCamera() constructor } var _ray = _forward.Add(_up.Scale(_scaleUp).Add( _right.Scale((_screenX / _screenWidth) * 2.0 - 1.0))); - return _ray.Normalize(); + return _ray; }; /// @func apply() diff --git a/BBMOD_GML/scripts/BBMOD_BaseRenderer/BBMOD_BaseRenderer.gml b/BBMOD_GML/scripts/BBMOD_BaseRenderer/BBMOD_BaseRenderer.gml index ba82038c..fcecf4b9 100644 --- a/BBMOD_GML/scripts/BBMOD_BaseRenderer/BBMOD_BaseRenderer.gml +++ b/BBMOD_GML/scripts/BBMOD_BaseRenderer/BBMOD_BaseRenderer.gml @@ -368,7 +368,7 @@ function BBMOD_BaseRenderer() constructor if (Gizmo && EditMode) { - Gizmo.update(delta_time); + Gizmo.update(_deltaTime); } return self; @@ -385,8 +385,6 @@ function BBMOD_BaseRenderer() constructor /// @private static __render_reflection_probes = function () { - gml_pragma("forceinline"); - var _view = matrix_get(matrix_view); var _projection = matrix_get(matrix_projection); @@ -536,8 +534,6 @@ function BBMOD_BaseRenderer() constructor /// @private static __render_shadowmap = function () { - gml_pragma("forceinline"); - static _renderQueues = bbmod_render_queues_get(); var _shadowCaster = undefined; @@ -598,7 +594,7 @@ function BBMOD_BaseRenderer() constructor bbmod_render_pass_set(BBMOD_ERenderPass.Shadows); __surShadowmap = bbmod_surface_check( - __surShadowmap, _light.ShadowmapResolution, _light.ShadowmapResolution); + __surShadowmap, _light.ShadowmapResolution, _light.ShadowmapResolution, surface_rgba8unorm, true); surface_set_target(__surShadowmap); draw_clear(c_red); @@ -734,7 +730,7 @@ function BBMOD_BaseRenderer() constructor //////////////////////////////////////////////////////////////////// // Instance highlight __surInstanceHighlight = bbmod_surface_check( - __surInstanceHighlight, _renderWidth, _renderHeight); + __surInstanceHighlight, _renderWidth, _renderHeight, surface_rgba8unorm, true); surface_set_target(__surInstanceHighlight); draw_clear_alpha(0, 0.0); @@ -857,7 +853,7 @@ function BBMOD_BaseRenderer() constructor bbmod_render_pass_set(BBMOD_ERenderPass.Forward); // Unset in case it gets destroyed when the room changes etc. - bbmod_shader_unset_global(BBMOD_SHADOWMAP); + bbmod_shader_unset_global(BBMOD_U_SHADOWMAP); bbmod_material_reset(); diff --git a/BBMOD_GML/scripts/BBMOD_BaseShader/BBMOD_BaseShader.gml b/BBMOD_GML/scripts/BBMOD_BaseShader/BBMOD_BaseShader.gml index 8d3fa8a4..47926e7e 100644 --- a/BBMOD_GML/scripts/BBMOD_BaseShader/BBMOD_BaseShader.gml +++ b/BBMOD_GML/scripts/BBMOD_BaseShader/BBMOD_BaseShader.gml @@ -12,8 +12,6 @@ /// @param {Asset.GMShader} _shader The shader resource. /// @param {Struct.BBMOD_VertexFormat} _vertexFormat The vertex format required /// by the shader. -/// -/// @see BBMOD_VertexFormat function BBMOD_BaseShader(_shader, _vertexFormat) : BBMOD_Shader(_shader, _vertexFormat) constructor { diff --git a/BBMOD_GML/scripts/BBMOD_Terrain/BBMOD_Terrain.gml b/BBMOD_GML/scripts/BBMOD_Terrain/BBMOD_Terrain.gml index 94cf18c9..0192c34e 100644 --- a/BBMOD_GML/scripts/BBMOD_Terrain/BBMOD_Terrain.gml +++ b/BBMOD_GML/scripts/BBMOD_Terrain/BBMOD_Terrain.gml @@ -1,6 +1,10 @@ /// @module Terrain -/// @func BBMOD_Terrain([_heightmap[, _subimage]]) +/// @macro {Real} +/// @private +#macro __BBMOD_SAVE_TERRAIN_VERSION 0 + +/// @func BBMOD_Terrain([_heightmap[, _subimage[, _chunkSize]]]) /// /// @implements {BBMOD_IDestructible} /// @@ -12,14 +16,20 @@ /// later using the terrain's methods. /// @param {Real} [_subimage] The sprite subimage to use for the heightmap. /// Defaults to 0. -function BBMOD_Terrain(_heightmap=undefined, _subimage=0) constructor +/// @param {Real} [_chunkSize] The width and height of a single terrain chunk. +/// Defaults to 128. +function BBMOD_Terrain(_heightmap=undefined, _subimage=0, _chunkSize=128) constructor { /// @var {Struct.BBMOD_RenderQueue} Render queue for terrain layers. /// @readonly static RenderQueue = new BBMOD_RenderQueue("Terrain", -$FFFFFFFE); - /// @var {Array} Array of five material layers. Use - /// `undefined` instead of a material to disable certain layer. + /// @var {Struct.BBMOD_TerrainMaterial} The material used when rendering + /// the terrain. Default is {@link BBMOD_MATERIAL_TERRAIN}. + Material = BBMOD_MATERIAL_TERRAIN; + + /// @var {Array} Array of five terrain layers. + /// Use `undefined` to disable certain layer. Layer = array_create(5, undefined); /// @var {Pointer.Texture} A texture that controls visibility of individual @@ -28,6 +38,9 @@ function BBMOD_Terrain(_heightmap=undefined, _subimage=0) constructor /// second layer, the green channel controls the third layer etc. Splatmap = pointer_null; + /// @var {Pointer.Texture} A texture to multiply the terrain colors with. + Colormap = pointer_null; + /// @var {Id.DsGrid} /// @private __splatmapGrid = ds_grid_create(1, 1); @@ -90,9 +103,24 @@ function BBMOD_Terrain(_heightmap=undefined, _subimage=0) constructor /// @var {Id.VertexBuffer} The vertex buffer or `undefined` if the terrain /// was not built yet. /// @readonly - /// @see BBMOD_Terrain.build_mesh + /// @obsolete This property was replaced with {@link BBMOD_Terrain.Chunks}. VertexBuffer = undefined; + /// @var {Real} The width and height of a single terrain chunk. + ChunkSize = _chunkSize; + + /// @var {Id.DsGrid} Grid of vertex buffers, each representing + /// an individual terrain chunk. + Chunks = ds_grid_create(1, 1); + + ds_grid_clear(Chunks, undefined); + + /// @var {Real} The radius (in chunk size) within which terrain chunks are visible + /// around the camera. Zero means only the chunk that the camera is on is visible. + /// Use `infinity` to make all chunks visible. Default value is `infinity`. + /// @see bbmod_camera_set_position + ChunkRadius = infinity; + /// @func in_bounds(_x, _y) /// /// @desc Checks whether the coordinate is within the terrain's bounds. @@ -191,6 +219,24 @@ function BBMOD_Terrain(_heightmap=undefined, _subimage=0) constructor buffer_delete(_buffer); + for (var i = ds_grid_width(Chunks) - 1; i >= 0; --i) + { + for (var j = ds_grid_height(Chunks) - 1; j >= 0; --j) + { + var _chunk = Chunks[# i, j]; + if (_chunk != undefined) + { + vertex_delete_buffer(_chunk); + } + } + } + + var _chunksX = max(ceil(_spriteWidth / ChunkSize), 1); + var _chunksY = max(ceil(_spriteHeight / ChunkSize), 1); + + ds_grid_resize(Chunks, _chunksX, _chunksY); + ds_grid_clear(Chunks, undefined); + return self; }; @@ -227,8 +273,6 @@ function BBMOD_Terrain(_heightmap=undefined, _subimage=0) constructor /// @param {Real} _j The Y coordinate in the terrain's height grid. /// /// @return {Real} The terrain's height at given index. - /// - /// @see BBMOD_Terrain.__height static get_height_index = function (_i, _j) { gml_pragma("forceinline"); @@ -306,12 +350,12 @@ function BBMOD_Terrain(_heightmap=undefined, _subimage=0) constructor if (frac(_xScaled) <= frac(_yScaled)) { return (new BBMOD_Vec3(0.0, -Scale.Y, (_h1 - _h4) * Scale.Z)) - .Cross(new BBMOD_Vec3(Scale.X, 0.0, (_h3 - _h4) * Scale.Z)) - .Normalize(); + .CrossSelf(new BBMOD_Vec3(Scale.X, 0.0, (_h3 - _h4) * Scale.Z)) + .NormalizeSelf(); } return (new BBMOD_Vec3(0.0, Scale.Y, (_h3 - _h2) * Scale.Z)) - .Cross(new BBMOD_Vec3(-Scale.X, 0.0, (_h1 - _h2) * Scale.Z)) - .Normalize(); + .CrossSelf(new BBMOD_Vec3(-Scale.X, 0.0, (_h1 - _h2) * Scale.Z)) + .NormalizeSelf(); }; /// @func get_layer(_x, _y[, _threshold]) @@ -491,27 +535,37 @@ function BBMOD_Terrain(_heightmap=undefined, _subimage=0) constructor return self; }; - /// @func build_mesh() + /// @func build_chunk(_chunkI, _chunkJ) + /// + /// @desc Force-rebuilds a chunk mesh even if it's not dirty and clears + /// its dirty state. /// - /// @desc Rebuilds the terrain's mesh. + /// @param {Real} _chunkI The X index of the chunk. + /// @param {Real} _chunkJ The Y index of the chunk. /// /// @return {Struct.BBMOD_Terrain} Returns `self`. - static build_mesh = function () + static build_chunk = function (_chunkI, _chunkJ) { - if (VertexBuffer != undefined) + var _chunk = Chunks[# _chunkI, _chunkJ]; + if (_chunk != undefined) { - vertex_delete_buffer(VertexBuffer); + vertex_delete_buffer(_chunk); } + var _height = __height; - var _rows = ds_grid_width(_height); - var _cols = ds_grid_height(_height); + var _terrainWidth = ds_grid_width(_height); + var _terrainHeight = ds_grid_height(_height); + var _rows = min(_terrainWidth - 1 - _chunkI * ChunkSize, ChunkSize); + var _cols = min(_terrainHeight - 1 - _chunkJ * ChunkSize, ChunkSize); + var _vbuffer = vertex_create_buffer(); vertex_begin(_vbuffer, VertexFormat.Raw); - var _i = 0; - repeat (_rows - 1) + + var _i = _chunkI * ChunkSize; + repeat (_rows) { - var _j = 0; - repeat (_cols - 1) + var _j = _chunkJ * ChunkSize; + repeat (_cols) { var _z1 = _height[# _i, _j]; var _z2 = _height[# _i + 1, _j]; @@ -527,14 +581,14 @@ function BBMOD_Terrain(_heightmap=undefined, _subimage=0) constructor var _x4 = _i; var _y4 = _j + 1; - var _u1 = _i / _rows; - var _v1 = _j / _cols; - var _u2 = (_i + 1) / _rows; - var _v2 = _j / _cols; - var _u3 = (_i + 1) / _rows; - var _v3 = (_j + 1) / _cols; - var _u4 = _i / _rows; - var _v4 = (_j + 1) / _cols; + var _u1 = _i / _terrainWidth; + var _v1 = _j / _terrainHeight; + var _u2 = (_i + 1) / _terrainWidth; + var _v2 = _j / _terrainHeight; + var _u3 = (_i + 1) / _terrainWidth; + var _v3 = (_j + 1) / _terrainHeight; + var _u4 = _i / _terrainWidth; + var _v4 = (_j + 1) / _terrainHeight; var _n1X = __normalSmoothX[# _i, _j]; var _n1Y = __normalSmoothY[# _i, _j]; @@ -600,9 +654,36 @@ function BBMOD_Terrain(_heightmap=undefined, _subimage=0) constructor } ++_i; } + vertex_end(_vbuffer); vertex_freeze(_vbuffer); - VertexBuffer = _vbuffer; + Chunks[# _chunkI, _chunkJ] = _vbuffer; + + return self; + }; + + /// @func build_mesh() + /// + /// @desc Rebuilds all dirty chunks of the terrain mesh. + /// + /// @return {Struct.BBMOD_Terrain} Returns `self`. + static build_mesh = function () + { + var _chunksX = ds_grid_width(Chunks); + var _chunksY = ds_grid_height(Chunks); + + var i = 0; + repeat (_chunksX) + { + var j = 0; + repeat (_chunksY) + { + build_chunk(i, j); + ++j; + } + ++i; + } + return self; }; @@ -613,28 +694,110 @@ function BBMOD_Terrain(_heightmap=undefined, _subimage=0) constructor /// @return {Struct.BBMOD_Terrain} Returns `self`. static submit = function () { + if (!Material.apply(VertexFormat)) + { + return self; + } + var _matrix = matrix_build(Position.X, Position.Y, Position.Z, 0, 0, 0, Scale.X, Scale.Y, Scale.Z); var _normalMatrix = bbmod_matrix_build_normalmatrix(_matrix); matrix_set(matrix_world, _matrix); - var i = 0; + + var _chunksX = ds_grid_width(Chunks); + var _chunksY = ds_grid_height(Chunks); + + var _chunkFromX, _chunkFromY, _chunkToX, _chunkToY; + + if (ChunkRadius == infinity) + { + _chunkFromX = 0; + _chunkFromY = 0; + _chunkToX = _chunksX; + _chunkToY = _chunksY; + } + else + { + var _camPos = bbmod_camera_get_position(); + var _camI = clamp(((_camPos.X - Position.X) / Scale.X) / ChunkSize, 0, _chunksX); + var _camJ = clamp(((_camPos.Y - Position.Y) / Scale.Y) / ChunkSize, 0, _chunksY); + _chunkFromX = clamp(floor(_camI - ChunkRadius), 0, _chunksX); + _chunkFromY = clamp(floor(_camJ - ChunkRadius), 0, _chunksY); + _chunkToX = clamp(ceil(_camI + ChunkRadius), 0, _chunksX); + _chunkToY = clamp(ceil(_camJ + ChunkRadius), 0, _chunksY); + } + + var _shaderCurrent = shader_current(); + var _uSplatmap = shader_get_sampler_index(_shaderCurrent, BBMOD_U_SPLATMAP); + var _uSplatmapIndex = shader_get_uniform(_shaderCurrent, BBMOD_U_SPLATMAP_INDEX); + var _uColormap = shader_get_sampler_index(_shaderCurrent, BBMOD_U_COLORMAP); + var _uTextureScale = shader_get_uniform(_shaderCurrent, BBMOD_U_TEXTURE_SCALE); + var _uNormalMatrix = shader_get_uniform(_shaderCurrent, BBMOD_U_NORMAL_MATRIX); + var _uNormalW = shader_get_sampler_index(_shaderCurrent, BBMOD_U_NORMAL_W); + var _uIsRoughness = shader_get_uniform(_shaderCurrent, BBMOD_U_IS_ROUGHNESS); + + texture_set_stage(_uSplatmap, Splatmap); + texture_set_stage(_uColormap, Colormap); + shader_set_uniform_f(_uTextureScale, TextureRepeat.X, TextureRepeat.Y); + shader_set_uniform_matrix_array(_uNormalMatrix, _normalMatrix); + + gpu_push_state(); + + var _isFirstLayer = true; + var _isSecondLayer = true; + var _renderPass = bbmod_render_pass_get(); + + var _l = 0; repeat (5) { - var _mat = Layer[i]; - if (_mat != undefined && _mat.apply(VertexFormat)) + var _layer = Layer[_l]; + if (_layer != undefined) { - var _shaderCurrent = shader_current(); - var _uSplatmap = shader_get_sampler_index(_shaderCurrent, BBMOD_U_SPLATMAP); - var _uSplatmapIndex = shader_get_uniform(_shaderCurrent, BBMOD_U_SPLATMAP_INDEX); - var _uTextureScale = shader_get_uniform(_shaderCurrent, BBMOD_U_TEXTURE_SCALE); - var _uNormalMatrix = shader_get_uniform(_shaderCurrent, BBMOD_U_NORMAL_MATRIX); - texture_set_stage(_uSplatmap, Splatmap); - shader_set_uniform_i(_uSplatmapIndex, i - 1); - shader_set_uniform_f(_uTextureScale, TextureRepeat.X, TextureRepeat.Y); - shader_set_uniform_matrix_array(_uNormalMatrix, _normalMatrix); - vertex_submit(VertexBuffer, pr_trianglelist, _mat.BaseOpacity); + var _layerNormalRoughness = _layer[$ "NormalRoughness"]; + + if (_isFirstLayer) + { + gpu_set_blendenable(false); + gpu_set_colorwriteenable(true, true, true, true); + _isFirstLayer = false; + } + else if (_isSecondLayer) + { + gpu_set_blendenable(true); + gpu_set_colorwriteenable(true, true, true, false); + _isSecondLayer = false; + } + + shader_set_uniform_i(_uSplatmapIndex, _l - 1); + texture_set_stage(_uNormalW, _layerNormalRoughness ?? (_layer[$ "NormalSmoothness"] ?? sprite_get_texture(BBMOD_SprDefaultNormalW, 0))); + shader_set_uniform_f(_uIsRoughness, (_layerNormalRoughness != undefined) ? 1.0 : 0.0); + + var _i = _chunkFromX; + repeat (_chunkToX - _chunkFromX) + { + var _j = _chunkFromY; + repeat (_chunkToY - _chunkFromY) + { + var _chunk = Chunks[# _i, _j]; + if (_chunk != undefined) + { + vertex_submit(_chunk, pr_trianglelist, _layer.BaseOpacity); + } + ++_j; + } + ++_i; + } + + if (_renderPass != BBMOD_ERenderPass.Forward + && _renderPass != BBMOD_ERenderPass.ReflectionCapture) + { + break; + } } - ++i; + ++_l; } + + gpu_pop_state(); + return self; }; @@ -647,39 +810,101 @@ function BBMOD_Terrain(_heightmap=undefined, _subimage=0) constructor { var _matrix = matrix_build(Position.X, Position.Y, Position.Z, 0, 0, 0, Scale.X, Scale.Y, Scale.Z); var _normalMatrix = bbmod_matrix_build_normalmatrix(_matrix); - var i = 0; + var _chunksX = ds_grid_width(Chunks); + var _chunksY = ds_grid_height(Chunks); + + var _chunkFromX, _chunkFromY, _chunkToX, _chunkToY; + + if (ChunkRadius == infinity) + { + _chunkFromX = 0; + _chunkFromY = 0; + _chunkToX = _chunksX; + _chunkToY = _chunksY; + } + else + { + var _camPos = bbmod_camera_get_position(); + var _camI = clamp(((_camPos.X - Position.X) / Scale.X) / ChunkSize, 0, _chunksX); + var _camJ = clamp(((_camPos.Y - Position.Y) / Scale.Y) / ChunkSize, 0, _chunksY); + _chunkFromX = clamp(floor(_camI - ChunkRadius), 0, _chunksX); + _chunkFromY = clamp(floor(_camJ - ChunkRadius), 0, _chunksY); + _chunkToX = clamp(ceil(_camI + ChunkRadius), 0, _chunksX); + _chunkToY = clamp(ceil(_camJ + ChunkRadius), 0, _chunksY); + } + + RenderQueue + .ApplyMaterial(Material, VertexFormat) + .BeginConditionalBlock() + .SetSampler(BBMOD_U_SPLATMAP, Splatmap) + .SetSampler(BBMOD_U_COLORMAP, Colormap) + .SetUniformFloat2(BBMOD_U_TEXTURE_SCALE, TextureRepeat.X, TextureRepeat.Y) + .SetUniformMatrixArray(BBMOD_U_NORMAL_MATRIX, _normalMatrix) + .SetWorldMatrix(_matrix); + + var _isFirstLayer = true; + var _isSecondLayer = true; + + var _l = 0; repeat (5) { - var _mat = Layer[i]; - if (_mat != undefined) + var _layer = Layer[_l]; + if (_layer != undefined) { - RenderQueue - .ApplyMaterial(_mat, VertexFormat, (i == 0) ? ~0 : ((1 << BBMOD_ERenderPass.Forward) | (1 << BBMOD_ERenderPass.ReflectionCapture))) - .BeginConditionalBlock(); + var _layerNormalRoughness = _layer[$ "NormalRoughness"]; - if (i == 0) + if (_isFirstLayer) { - RenderQueue.SetGpuBlendEnable(false); + RenderQueue + .SetGpuBlendEnable(false) + .SetGpuColorWriteEnable(true, true, true, true); + _isFirstLayer = false; } - else + else if (_isSecondLayer) { - RenderQueue.SetGpuColorWriteEnable(true, true, true, false); + RenderQueue + .CheckRenderPass((1 << BBMOD_ERenderPass.Forward) | (1 << BBMOD_ERenderPass.ReflectionCapture)) + .BeginConditionalBlock() + .SetGpuBlendEnable(true) + .SetGpuColorWriteEnable(true, true, true, false); + _isSecondLayer = false; } RenderQueue - .SetGpuZWriteEnable(i == 0) - .SetGpuZFunc((i == 0) ? cmpfunc_lessequal : cmpfunc_equal) - .SetSampler(BBMOD_U_SPLATMAP, Splatmap) - .SetUniformInt(BBMOD_U_SPLATMAP_INDEX, i - 1) - .SetUniformFloat2(BBMOD_U_TEXTURE_SCALE, TextureRepeat.X, TextureRepeat.Y) - .SetUniformMatrixArray(BBMOD_U_NORMAL_MATRIX, _normalMatrix) - .SetWorldMatrix(_matrix) - .SubmitVertexBuffer(VertexBuffer, pr_trianglelist, _mat.BaseOpacity) - .ResetMaterial() - .EndConditionalBlock(); + .SetGpuZWriteEnable(_l == 0) + .SetGpuZFunc((_l == 0) ? cmpfunc_lessequal : cmpfunc_equal) + .SetUniformInt(BBMOD_U_SPLATMAP_INDEX, _l - 1) + .SetSampler(BBMOD_U_NORMAL_W, _layerNormalRoughness ?? (_layer[$ "NormalSmoothness"] ?? sprite_get_texture(BBMOD_SprDefaultNormalW, 0))) + .SetUniformFloat(BBMOD_U_IS_ROUGHNESS, (_layerNormalRoughness != undefined) ? 1.0 : 0.0); + + var _i = _chunkFromX; + repeat (_chunkToX - _chunkFromX) + { + var _j = _chunkFromY; + repeat (_chunkToY - _chunkFromY) + { + var _chunk = Chunks[# _i, _j]; + if (_chunk != undefined) + { + RenderQueue.SubmitVertexBuffer(_chunk, pr_trianglelist, _layer.BaseOpacity); + } + ++_j; + } + ++_i; + } + + if (!_isSecondLayer) + { + RenderQueue.EndConditionalBlock(); + } } - ++i; + ++_l; } + + RenderQueue + .ResetMaterial() + .EndConditionalBlock(); + return self; }; @@ -693,10 +918,21 @@ function BBMOD_Terrain(_heightmap=undefined, _subimage=0) constructor ds_grid_destroy(__normalSmoothX); ds_grid_destroy(__normalSmoothY); ds_grid_destroy(__normalSmoothZ); - if (VertexBuffer != undefined) + + for (var i = ds_grid_width(Chunks) - 1; i >= 0; --i) { - vertex_delete_buffer(VertexBuffer); + for (var j = ds_grid_height(Chunks) - 1; j >= 0; --j) + { + var _chunk = Chunks[# i, j]; + if (_chunk != undefined) + { + vertex_delete_buffer(_chunk); + } + } } + + ds_grid_destroy(Chunks); + return undefined; }; diff --git a/BBMOD_GML/scripts/BBMOD_TerrainLayer/BBMOD_TerrainLayer.gml b/BBMOD_GML/scripts/BBMOD_TerrainLayer/BBMOD_TerrainLayer.gml new file mode 100644 index 00000000..4d7a25c2 --- /dev/null +++ b/BBMOD_GML/scripts/BBMOD_TerrainLayer/BBMOD_TerrainLayer.gml @@ -0,0 +1,21 @@ +/// @module Terrain + +/// @func BBMOD_TerrainLayer() +/// +/// @desc Describes a material of a single terrain layer. +/// +/// @see BBMOD_Terrain.Layer +function BBMOD_TerrainLayer() constructor +{ + /// @var {Pointer.Texture} A texture with a base color in the RGB channels + /// and opacity in the alpha channel. + BaseOpacity = pointer_null; + + /// @var {Pointer.Texture} A texture with tangent-space normals in the RGB + /// channels and smoothness in the alpha channel or `undefined`. + NormalSmoothness = sprite_get_texture(BBMOD_SprDefaultNormalW, 0); + + /// @var {Pointer.Texture} A texture with tangent-space normals in the RGB + /// channels and roughness in the alpha channel or `undefined`. + NormalRoughness = undefined; +} diff --git a/BBMOD_GML/scripts/BBMOD_TerrainLayer/BBMOD_TerrainLayer.yy b/BBMOD_GML/scripts/BBMOD_TerrainLayer/BBMOD_TerrainLayer.yy new file mode 100644 index 00000000..2ef9a202 --- /dev/null +++ b/BBMOD_GML/scripts/BBMOD_TerrainLayer/BBMOD_TerrainLayer.yy @@ -0,0 +1,11 @@ +{ + "resourceType": "GMScript", + "resourceVersion": "1.0", + "name": "BBMOD_TerrainLayer", + "isCompatibility": false, + "isDnD": false, + "parent": { + "name": "Terrain", + "path": "folders/BBMOD/Terrain.yy", + }, +} \ No newline at end of file diff --git a/BBMOD_GML/scripts/BBMOD_TerrainMaterial/BBMOD_TerrainMaterial.gml b/BBMOD_GML/scripts/BBMOD_TerrainMaterial/BBMOD_TerrainMaterial.gml new file mode 100644 index 00000000..d571194f --- /dev/null +++ b/BBMOD_GML/scripts/BBMOD_TerrainMaterial/BBMOD_TerrainMaterial.gml @@ -0,0 +1,18 @@ +/// @module Terrain + +/// @func BBMOD_TerrainMaterial([_shader]) +/// +/// @extends BBMOD_BaseMaterial +/// +/// @desc A material that can be used when rendering terrain. +/// +/// @param {Struct.BBMOD_Shader} [_shader] A shader that the material uses in +/// the {@link BBMOD_ERenderPass.Forward} pass. Leave `undefined` if you would +/// like to use {@link BBMOD_Material.set_shader} to specify shaders used in +/// specific render passes. +/// +/// @see BBMOD_Shader +function BBMOD_TerrainMaterial(_shader=undefined) + : BBMOD_BaseMaterial(_shader) constructor +{ +} diff --git a/BBMOD_GML/scripts/BBMOD_TerrainMaterial/BBMOD_TerrainMaterial.yy b/BBMOD_GML/scripts/BBMOD_TerrainMaterial/BBMOD_TerrainMaterial.yy new file mode 100644 index 00000000..8335eb8f --- /dev/null +++ b/BBMOD_GML/scripts/BBMOD_TerrainMaterial/BBMOD_TerrainMaterial.yy @@ -0,0 +1,11 @@ +{ + "resourceType": "GMScript", + "resourceVersion": "1.0", + "name": "BBMOD_TerrainMaterial", + "isCompatibility": false, + "isDnD": false, + "parent": { + "name": "Terrain", + "path": "folders/BBMOD/Terrain.yy", + }, +} \ No newline at end of file diff --git a/BBMOD_GML/scripts/BBMOD_TerrainShader/BBMOD_TerrainShader.gml b/BBMOD_GML/scripts/BBMOD_TerrainShader/BBMOD_TerrainShader.gml new file mode 100644 index 00000000..e3589204 --- /dev/null +++ b/BBMOD_GML/scripts/BBMOD_TerrainShader/BBMOD_TerrainShader.gml @@ -0,0 +1,15 @@ +/// @module Terrain + +/// @func BBMOD_TerrainShader() +/// +/// @extends BBMOD_BaseShader +/// +/// @desc Base class for BBMOD terrain shaders. +/// +/// @param {Asset.GMShader} _shader The shader resource. +/// @param {Struct.BBMOD_VertexFormat} _vertexFormat The vertex format required +/// by the shader. +function BBMOD_TerrainShader(_shader, _vertexFormat) + : BBMOD_BaseShader(_shader, _vertexFormat) constructor +{ +} diff --git a/BBMOD_GML/scripts/BBMOD_TerrainShader/BBMOD_TerrainShader.yy b/BBMOD_GML/scripts/BBMOD_TerrainShader/BBMOD_TerrainShader.yy new file mode 100644 index 00000000..79876671 --- /dev/null +++ b/BBMOD_GML/scripts/BBMOD_TerrainShader/BBMOD_TerrainShader.yy @@ -0,0 +1,11 @@ +{ + "resourceType": "GMScript", + "resourceVersion": "1.0", + "name": "BBMOD_TerrainShader", + "isCompatibility": false, + "isDnD": false, + "parent": { + "name": "Terrain", + "path": "folders/BBMOD/Terrain.yy", + }, +} \ No newline at end of file diff --git a/BBMOD_GML/scripts/__bbmod_defines/__bbmod_defines.gml b/BBMOD_GML/scripts/__bbmod_defines/__bbmod_defines.gml index 779e2b58..774a2c1e 100644 --- a/BBMOD_GML/scripts/__bbmod_defines/__bbmod_defines.gml +++ b/BBMOD_GML/scripts/__bbmod_defines/__bbmod_defines.gml @@ -9,10 +9,10 @@ #macro BBMOD_RELEASE_MAJOR 3 /// @macro {Real} The minor version number of this BBMOD release. -#macro BBMOD_RELEASE_MINOR 18 +#macro BBMOD_RELEASE_MINOR 19 /// @macro {Real} The patch version number of this BBMOD release. -#macro BBMOD_RELEASE_PATCH 1 +#macro BBMOD_RELEASE_PATCH 0 /// @macro {String} The version of this BBMOD release as a string ("major.minor.patch" format). #macro BBMOD_RELEASE_STRING $"{BBMOD_RELEASE_MAJOR}.{BBMOD_RELEASE_MINOR}.{BBMOD_RELEASE_PATCH}" @@ -313,6 +313,10 @@ /// holds the shadowmap texture. #macro BBMOD_U_SHADOWMAP "bbmod_Shadowmap" +/// @macro {String} Name of a fragment shader uniform of type `sampler2D` that +/// holds the colormap texture. +#macro BBMOD_U_COLORMAP "bbmod_Colormap" + /// @macro {String} Name of a fragment shader uniform of type `vec2` that holds /// the texel size of a shadowmap texture. #macro BBMOD_U_SHADOWMAP_TEXEL "bbmod_ShadowmapTexel" diff --git a/BBMOD_GML/scripts/__bbmod_terrain/__bbmod_terrain.gml b/BBMOD_GML/scripts/__bbmod_terrain/__bbmod_terrain.gml index afbb83a6..5e9715de 100644 --- a/BBMOD_GML/scripts/__bbmod_terrain/__bbmod_terrain.gml +++ b/BBMOD_GML/scripts/__bbmod_terrain/__bbmod_terrain.gml @@ -1,27 +1,27 @@ /// @module Terrain -/// @macro {Struct.BBMOD_DefaultShader} Shader for terrain materials. +/// @macro {Struct.BBMOD_TerrainShader} Shader for terrain materials. #macro BBMOD_SHADER_TERRAIN __bbmod_shader_terrain() -/// @macro {Struct.BBMOD_DefaultMaterial} Base terrain material. +/// @macro {Struct.BBMOD_TerrainMaterial} Base terrain material. #macro BBMOD_MATERIAL_TERRAIN __bbmod_material_terrain() -/// @macro {Struct.BBMOD_DefaultShader} Shader for unlit terrain materials. +/// @macro {Struct.BBMOD_TerrainShader} Shader for unlit terrain materials. #macro BBMOD_SHADER_TERRAIN_UNLIT __bbmod_shader_terrain_unlit() -/// @macro {Struct.BBMOD_DefaultMaterial} Unlit terrain material. +/// @macro {Struct.BBMOD_BaseMaterial} Unlit terrain material. #macro BBMOD_MATERIAL_TERRAIN_UNLIT __bbmod_material_terrain_unlit() function __bbmod_shader_terrain() { - static _shader = new BBMOD_DefaultShader( + static _shader = new BBMOD_TerrainShader( BBMOD_ShTerrain, BBMOD_VFORMAT_DEFAULT); return _shader; } function __bbmod_shader_terrain_unlit() { - static _shader = new BBMOD_DefaultShader( + static _shader = new BBMOD_TerrainShader( BBMOD_ShTerrainUnlit, BBMOD_VFORMAT_DEFAULT); return _shader; } @@ -31,7 +31,7 @@ function __bbmod_material_terrain() static _material = undefined; if (_material == undefined) { - _material = new BBMOD_DefaultMaterial(BBMOD_SHADER_TERRAIN); + _material = new BBMOD_TerrainMaterial(BBMOD_SHADER_TERRAIN); _material.set_shader(BBMOD_ERenderPass.ReflectionCapture, BBMOD_SHADER_TERRAIN); _material.set_shader(BBMOD_ERenderPass.Shadows, BBMOD_SHADER_DEFAULT_DEPTH); _material.Repeat = true; diff --git a/BBMOD_GML/scripts/bbmod_mixvec2fromhealthmodule/bbmod_mixvec2fromhealthmodule.gml b/BBMOD_GML/scripts/bbmod_mixvec2fromhealthmodule/bbmod_mixvec2fromhealthmodule.gml index 8d00f9c3..86ea399e 100644 --- a/BBMOD_GML/scripts/bbmod_mixvec2fromhealthmodule/bbmod_mixvec2fromhealthmodule.gml +++ b/BBMOD_GML/scripts/bbmod_mixvec2fromhealthmodule/bbmod_mixvec2fromhealthmodule.gml @@ -10,7 +10,7 @@ /// @param {Real} [_property] The first of the two consecutive properties. Use /// values from {@link BBMOD_EParticle}. Defaults to `undefined`. /// @param {Struct.BBMOD_Vec2} [_from] The value when the particle has full health. -/// Defaults to `(0.0, 0.0)`. +/// Defaults to `(0, 0)`. /// @param {Struct.BBMOD_Vec2} [_to] The value when the particle has no health left. /// Defaults to `_from`. /// @@ -26,7 +26,7 @@ function BBMOD_MixVec2FromHealthModule( Property = _property; /// @var {Struct.BBMOD_Vec2} The value when the particle has full health. - /// Default value is `(0.0, 0.0)`. + /// Default value is `(0, 0)`. From = _from; /// @var {Struct.BBMOD_Vec2} The value when the particle has no health left. diff --git a/BBMOD_GML/scripts/bbmod_mixvec2fromspeedmodule/bbmod_mixvec2fromspeedmodule.gml b/BBMOD_GML/scripts/bbmod_mixvec2fromspeedmodule/bbmod_mixvec2fromspeedmodule.gml index ef716e9a..296f52a5 100644 --- a/BBMOD_GML/scripts/bbmod_mixvec2fromspeedmodule/bbmod_mixvec2fromspeedmodule.gml +++ b/BBMOD_GML/scripts/bbmod_mixvec2fromspeedmodule/bbmod_mixvec2fromspeedmodule.gml @@ -11,7 +11,7 @@ /// @param {Real} [_property] The first of the two consecutive properties. Use /// values from {@link BBMOD_EParticle}. Defaults to `undefined`. /// @param {Struct.BBMOD_Vec2} [_from] The value when the particle has full health. -/// Defaults to `(0.0, 0.0)`. +/// Defaults to `(0, 0)`. /// @param {Struct.BBMOD_Vec2} [_to] The value when the particle has no health left. /// Defaults to `_from`. /// @param {Real} [_min] If the particles' speed is less than this, then the @@ -33,7 +33,7 @@ function BBMOD_MixVec2FromSpeedModule( Property = _property; /// @var {Struct.BBMOD_Vec2} The value when the particle has full health. - /// Default value is `(0.0, 0.0)`. + /// Default value is `(0, 0)`. From = _from; /// @var {Struct.BBMOD_Vec2} The value when the particle has no health left. diff --git a/BBMOD_GML/scripts/bbmod_mixvec2module/bbmod_mixvec2module.gml b/BBMOD_GML/scripts/bbmod_mixvec2module/bbmod_mixvec2module.gml index dcdb405f..3fdf3be0 100644 --- a/BBMOD_GML/scripts/bbmod_mixvec2module/bbmod_mixvec2module.gml +++ b/BBMOD_GML/scripts/bbmod_mixvec2module/bbmod_mixvec2module.gml @@ -11,7 +11,7 @@ /// @param {Real} [_property] The first of the two consecutive properties. Use /// values from {@link BBMOD_EParticle}. Defaults to `undefined`. /// @param {Struct.BBMOD_Vec2} [_from] The value to mix from. Defaults to -/// `(0.0, 0.0)`. +/// `(0, 0)`. /// @param {Struct.BBMOD_Vec2} [_to] The value to mix to. Defaults to `_from`. /// @param {Bool} [_separate] If `true`, then each component is mixed independently /// on other components, otherwise all components are mixed using the same factor. @@ -30,7 +30,7 @@ function BBMOD_MixVec2Module( Property = _property; /// @var {Struct.BBMOD_Vec2} The initial value to mix from. Default value is - /// `(0.0, 0.0)`. + /// `(0, 0)`. From = _from; /// @var {Struct.BBMOD_Vec2} The initial value to mix to. Default value is the diff --git a/BBMOD_GML/scripts/bbmod_mixvec2overtimemodule/bbmod_mixvec2overtimemodule.gml b/BBMOD_GML/scripts/bbmod_mixvec2overtimemodule/bbmod_mixvec2overtimemodule.gml index 2e3c2d46..6383f796 100644 --- a/BBMOD_GML/scripts/bbmod_mixvec2overtimemodule/bbmod_mixvec2overtimemodule.gml +++ b/BBMOD_GML/scripts/bbmod_mixvec2overtimemodule/bbmod_mixvec2overtimemodule.gml @@ -10,7 +10,7 @@ /// @param {Real} [_property] The first of the two consecutive properties. Use /// values from {@link BBMOD_EParticle}. Defaults to `undefined`. /// @param {Struct.BBMOD_Vec2} [_from] The value when the particle has full health. -/// Defaults to `(0.0, 0.0)`. +/// Defaults to `(0, 0)`. /// @param {Struct.BBMOD_Vec2} [_to] The value when the particle has no health left. /// Defaults to `_from`. /// @param {Real} [_duration] How long in seconds it takes to mix between the @@ -29,7 +29,7 @@ function BBMOD_MixVec2OverTimeModule( Property = _property; /// @var {Struct.BBMOD_Vec2} The value when the particle has full health. - /// Default value is `(0.0, 0.0)`. + /// Default value is `(0, 0)`. From = _from; /// @var {Struct.BBMOD_Vec2} The value when the particle has no health left. diff --git a/BBMOD_GML/scripts/bbmod_mixvec3fromhealthmodule/bbmod_mixvec3fromhealthmodule.gml b/BBMOD_GML/scripts/bbmod_mixvec3fromhealthmodule/bbmod_mixvec3fromhealthmodule.gml index 5d113b93..0cbda5ac 100644 --- a/BBMOD_GML/scripts/bbmod_mixvec3fromhealthmodule/bbmod_mixvec3fromhealthmodule.gml +++ b/BBMOD_GML/scripts/bbmod_mixvec3fromhealthmodule/bbmod_mixvec3fromhealthmodule.gml @@ -10,7 +10,7 @@ /// @param {Real} [_property] The first of the three consecutive properties. Use /// values from {@link BBMOD_EParticle}. Defaults to `undefined`. /// @param {Struct.BBMOD_Vec3} [_from] The value when the particle has full health. -/// Defaults to `(0.0, 0.0, 0.0)`. +/// Defaults to `(0, 0, 0)`. /// @param {Struct.BBMOD_Vec3} [_to] The value when the particle has no health left. /// Defaults to `_from`. /// @@ -26,7 +26,7 @@ function BBMOD_MixVec3FromHealthModule( Property = _property; /// @var {Struct.BBMOD_Vec3} The value when the particle has full health. Default - /// value is `(0.0, 0.0, 0.0)`. + /// value is `(0, 0, 0)`. From = _from; /// @var {Struct.BBMOD_Vec3} The value when the particle has no health left. Default diff --git a/BBMOD_GML/scripts/bbmod_mixvec3fromspeedmodule/bbmod_mixvec3fromspeedmodule.gml b/BBMOD_GML/scripts/bbmod_mixvec3fromspeedmodule/bbmod_mixvec3fromspeedmodule.gml index 5c6524a8..df032e91 100644 --- a/BBMOD_GML/scripts/bbmod_mixvec3fromspeedmodule/bbmod_mixvec3fromspeedmodule.gml +++ b/BBMOD_GML/scripts/bbmod_mixvec3fromspeedmodule/bbmod_mixvec3fromspeedmodule.gml @@ -11,7 +11,7 @@ /// @param {Real} [_property] The first of the three consecutive properties. Use /// values from {@link BBMOD_EParticle}. Defaults to `undefined`. /// @param {Struct.BBMOD_Vec3} [_from] The value when the particle has full health. -/// Defaults to `(0.0, 0.0, 0.0)`. +/// Defaults to `(0, 0, 0)`. /// @param {Struct.BBMOD_Vec3} [_to] The value when the particle has no health left. /// Defaults to `_from`. /// @param {Real} [_min] If the particles' speed is less than this, then the @@ -33,7 +33,7 @@ function BBMOD_MixVec3FromSpeedModule( Property = _property; /// @var {Struct.BBMOD_Vec3} The value when the particle has full health. Default - /// value is `(0.0, 0.0, 0.0)`. + /// value is `(0, 0, 0)`. From = _from; /// @var {Struct.BBMOD_Vec3} The value when the particle has no health left. Default diff --git a/BBMOD_GML/scripts/bbmod_mixvec3module/bbmod_mixvec3module.gml b/BBMOD_GML/scripts/bbmod_mixvec3module/bbmod_mixvec3module.gml index ae70dc4b..9b696ee2 100644 --- a/BBMOD_GML/scripts/bbmod_mixvec3module/bbmod_mixvec3module.gml +++ b/BBMOD_GML/scripts/bbmod_mixvec3module/bbmod_mixvec3module.gml @@ -11,7 +11,7 @@ /// @param {Real} [_property] The first of the three consecutive properties. Use /// values from {@link BBMOD_EParticle}. Defaults to `undefined`. /// @param {Struct.BBMOD_Vec3} [_from] The value to mix from. Defaults to -/// `(0.0, 0.0, 0.0)`. +/// `(0, 0, 0)`. /// @param {Struct.BBMOD_Vec3} [_to] The value to mix to. Defaults to `_from`. /// @param {Bool} [_separate] If `true`, then each component is mixed /// independently on other components, otherwise all components are mixed using @@ -30,7 +30,7 @@ function BBMOD_MixVec3Module( Property = _property; /// @var {Struct.BBMOD_Vec3} The initial value to mix from. Default value is - /// `(0.0, 0.0, 0.0)`. + /// `(0, 0, 0)`. From = _from; /// @var {Struct.BBMOD_Vec3} The initial value to mix to. Default value is diff --git a/BBMOD_GML/scripts/bbmod_mixvec3overtimemodule/bbmod_mixvec3overtimemodule.gml b/BBMOD_GML/scripts/bbmod_mixvec3overtimemodule/bbmod_mixvec3overtimemodule.gml index e6df8ab3..66304710 100644 --- a/BBMOD_GML/scripts/bbmod_mixvec3overtimemodule/bbmod_mixvec3overtimemodule.gml +++ b/BBMOD_GML/scripts/bbmod_mixvec3overtimemodule/bbmod_mixvec3overtimemodule.gml @@ -10,7 +10,7 @@ /// @param {Real} [_property] The first of the three consecutive properties. Use /// values from {@link BBMOD_EParticle}. Defaults to `undefined`. /// @param {Struct.BBMOD_Vec3} [_from] The value when the particle has full health. -/// Defaults to `(0.0, 0.0, 0.0)`. +/// Defaults to `(0, 0, 0)`. /// @param {Struct.BBMOD_Vec3} [_to] The value when the particle has no health left. /// Defaults to `_from`. /// @param {Real} [_duration] How long in seconds it takes to mix between the @@ -29,7 +29,7 @@ function BBMOD_MixVec3OverTimeModule( Property = _property; /// @var {Struct.BBMOD_Vec3} The value when the particle has full health. Default - /// value is `(0.0, 0.0, 0.0)`. + /// value is `(0, 0, 0)`. From = _from; /// @var {Struct.BBMOD_Vec3} The value when the particle has no health left. Default diff --git a/BBMOD_GML/scripts/bbmod_mixvec4fromhealthmodule/bbmod_mixvec4fromhealthmodule.gml b/BBMOD_GML/scripts/bbmod_mixvec4fromhealthmodule/bbmod_mixvec4fromhealthmodule.gml index e6f1be2f..2a029a15 100644 --- a/BBMOD_GML/scripts/bbmod_mixvec4fromhealthmodule/bbmod_mixvec4fromhealthmodule.gml +++ b/BBMOD_GML/scripts/bbmod_mixvec4fromhealthmodule/bbmod_mixvec4fromhealthmodule.gml @@ -10,7 +10,7 @@ /// @param {Real} [_property] The first of the four consecutive properties. Use /// values from {@link BBMOD_EParticle}. Defaults to `undefined`. /// @param {Struct.BBMOD_Vec4} [_from] The value when the particle has full health. -/// Defaults to `(0.0, 0.0, 0.0, 0.0)`. +/// Defaults to `(0, 0, 0, 0)`. /// @param {Struct.BBMOD_Vec4} [_to] The value when the particle has no health left. /// Defaults to `_from`. /// @@ -26,7 +26,7 @@ function BBMOD_MixVec4FromHealthModule( Property = _property; /// @var {Struct.BBMOD_Vec4} The value when the particle has full health. - /// Default value is `(0.0, 0.0, 0.0, 0.0)`. + /// Default value is `(0, 0, 0, 0)`. From = _from; /// @var {Struct.BBMOD_Vec4} The value when the particle has no health left. diff --git a/BBMOD_GML/scripts/bbmod_mixvec4fromspeedmodule/bbmod_mixvec4fromspeedmodule.gml b/BBMOD_GML/scripts/bbmod_mixvec4fromspeedmodule/bbmod_mixvec4fromspeedmodule.gml index d9441b65..1abeb4c8 100644 --- a/BBMOD_GML/scripts/bbmod_mixvec4fromspeedmodule/bbmod_mixvec4fromspeedmodule.gml +++ b/BBMOD_GML/scripts/bbmod_mixvec4fromspeedmodule/bbmod_mixvec4fromspeedmodule.gml @@ -11,7 +11,7 @@ /// @param {Real} [_property] The first of the four consecutive properties. Use /// values from {@link BBMOD_EParticle}. Defaults to `undefined`. /// @param {Struct.BBMOD_Vec4} [_from] The value when the particle has full health. -/// Defaults to `(0.0, 0.0, 0.0, 0.0)`. +/// Defaults to `(0, 0, 0, 0)`. /// @param {Struct.BBMOD_Vec4} [_to] The value when the particle has no health left. /// Defaults to `_from`. /// @param {Real} [_min] If the particles' speed is less than this, then the @@ -33,7 +33,7 @@ function BBMOD_MixVec4FromSpeedModule( Property = _property; /// @var {Struct.BBMOD_Vec4} The value when the particle has full health. - /// Default value is `(0.0, 0.0, 0.0, 0.0)`. + /// Default value is `(0, 0, 0, 0)`. From = _from; /// @var {Struct.BBMOD_Vec4} The value when the particle has no health left. diff --git a/BBMOD_GML/scripts/bbmod_mixvec4module/bbmod_mixvec4module.gml b/BBMOD_GML/scripts/bbmod_mixvec4module/bbmod_mixvec4module.gml index 75b70991..52981d2e 100644 --- a/BBMOD_GML/scripts/bbmod_mixvec4module/bbmod_mixvec4module.gml +++ b/BBMOD_GML/scripts/bbmod_mixvec4module/bbmod_mixvec4module.gml @@ -11,7 +11,7 @@ /// @param {Real} [_property] The first of the four consecutive properties. Use /// values from {@link BBMOD_EParticle}. Defaults to `undefined`. /// @param {Struct.BBMOD_Vec4} [_from] The value to mix from. Defaults to -/// `(0.0, 0.0, 0.0, 0.0)`. +/// `(0, 0, 0, 0)`. /// @param {Struct.BBMOD_Vec4} [_to] The value to mix to. Defaults to `_from`. /// @param {Bool} [_separate] If `true`, then each component is mixed independently /// on other components, otherwise all components are mixed using the same factor. @@ -30,7 +30,7 @@ function BBMOD_MixVec4Module( Property = _property; /// @var {Struct.BBMOD_Vec4} The initial value to mix from. Default value is - /// `(0.0, 0.0, 0.0, 0.0)`. + /// `(0, 0, 0, 0)`. From = _from; /// @var {Struct.BBMOD_Vec4} The initial value to mix to. Default value is the diff --git a/BBMOD_GML/scripts/bbmod_mixvec4overtimemodule/bbmod_mixvec4overtimemodule.gml b/BBMOD_GML/scripts/bbmod_mixvec4overtimemodule/bbmod_mixvec4overtimemodule.gml index aecca38b..c89429bd 100644 --- a/BBMOD_GML/scripts/bbmod_mixvec4overtimemodule/bbmod_mixvec4overtimemodule.gml +++ b/BBMOD_GML/scripts/bbmod_mixvec4overtimemodule/bbmod_mixvec4overtimemodule.gml @@ -10,7 +10,7 @@ /// @param {Real} [_property] The first of the four consecutive properties. Use /// values from {@link BBMOD_EParticle}. Defaults to `undefined`. /// @param {Struct.BBMOD_Vec4} [_from] The value when the particle has full health. -/// Defaults to `(0.0, 0.0, 0.0, 0.0)`. +/// Defaults to `(0, 0, 0, 0)`. /// @param {Struct.BBMOD_Vec4} [_to] The value when the particle has no health left. /// Defaults to `_from`. /// @param {Real} [_duration] How long in seconds it takes to mix between the @@ -29,7 +29,7 @@ function BBMOD_MixVec4OverTimeModule( Property = _property; /// @var {Struct.BBMOD_Vec4} The value when the particle has full health. - /// Default value is `(0.0, 0.0, 0.0, 0.0)`. + /// Default value is `(0, 0, 0, 0)`. From = _from; /// @var {Struct.BBMOD_Vec4} The value when the particle has no health left. diff --git a/BBMOD_GML/scripts/bbmod_mrt_is_supported/bbmod_mrt_is_supported.gml b/BBMOD_GML/scripts/bbmod_mrt_is_supported/bbmod_mrt_is_supported.gml index 8e698411..6ac48870 100644 --- a/BBMOD_GML/scripts/bbmod_mrt_is_supported/bbmod_mrt_is_supported.gml +++ b/BBMOD_GML/scripts/bbmod_mrt_is_supported/bbmod_mrt_is_supported.gml @@ -43,4 +43,4 @@ function bbmod_mrt_is_supported() return _isSupported; } -__bbmod_info("Multiple render targets " + (bbmod_mrt_is_supported() ? "ARE" : "NOT") + " supported!"); +__bbmod_info("MRT " + (!bbmod_mrt_is_supported() ? "not " : "") + "supported!"); diff --git a/BBMOD_GML/scripts/bbmod_setvec2module/bbmod_setvec2module.gml b/BBMOD_GML/scripts/bbmod_setvec2module/bbmod_setvec2module.gml index f1cd78e7..0064cefa 100644 --- a/BBMOD_GML/scripts/bbmod_setvec2module/bbmod_setvec2module.gml +++ b/BBMOD_GML/scripts/bbmod_setvec2module/bbmod_setvec2module.gml @@ -10,7 +10,7 @@ /// @param {Real} [_property] The first property. Use values from /// {@link BBMOD_EParticle}. Defaults to `undefined`. /// @param {Struct.BBMOD_Vec2} [_value] The initial value of the properties. -/// Defaults to `(0.0, 0.0)`. +/// Defaults to `(0, 0)`. /// /// @see BBMOD_EParticle function BBMOD_SetVec2Module(_property=undefined, _value=new BBMOD_Vec2()) @@ -21,7 +21,7 @@ function BBMOD_SetVec2Module(_property=undefined, _value=new BBMOD_Vec2()) Property = _property; /// @var {Struct.BBMOD_Vec2} The initial value of the properties. Default - /// value is `(0.0, 0.0)`. + /// value is `(0, 0)`. Value = _value; static on_particle_start = function (_emitter, _particleIndex) diff --git a/BBMOD_GML/scripts/bbmod_setvec3module/bbmod_setvec3module.gml b/BBMOD_GML/scripts/bbmod_setvec3module/bbmod_setvec3module.gml index 83f791f0..e332872c 100644 --- a/BBMOD_GML/scripts/bbmod_setvec3module/bbmod_setvec3module.gml +++ b/BBMOD_GML/scripts/bbmod_setvec3module/bbmod_setvec3module.gml @@ -10,7 +10,7 @@ /// @param {Real} [_property] The first property. Use values from /// {@link BBMOD_EParticle}. Defaults to `undefined`. /// @param {Struct.BBMOD_Vec3} [_value] The initial value of the properties. -/// Defaults to `(0.0, 0.0, 0.0)`. +/// Defaults to `(0, 0, 0)`. /// /// @see BBMOD_EParticle function BBMOD_SetVec3Module(_property=undefined, _value=new BBMOD_Vec3()) @@ -21,7 +21,7 @@ function BBMOD_SetVec3Module(_property=undefined, _value=new BBMOD_Vec3()) Property = _property; /// @var {Struct.BBMOD_Vec3} The initial value of the properties. Default - /// value is `(0.0, 0.0, 0.0)`. + /// value is `(0, 0, 0)`. Value = _value; static on_particle_start = function (_emitter, _particleIndex) diff --git a/BBMOD_GML/scripts/bbmod_setvec4module/bbmod_setvec4module.gml b/BBMOD_GML/scripts/bbmod_setvec4module/bbmod_setvec4module.gml index ceb97533..7c02d5b0 100644 --- a/BBMOD_GML/scripts/bbmod_setvec4module/bbmod_setvec4module.gml +++ b/BBMOD_GML/scripts/bbmod_setvec4module/bbmod_setvec4module.gml @@ -10,7 +10,7 @@ /// @param {Real} [_property] The first property. Use values from /// {@link BBMOD_EParticle}. Defaults to `undefined`. /// @param {Struct.BBMOD_Vec4} [_value] The initial value of the properties. -/// Defaults to `(0.0, 0.0, 0.0, 0.0)`. +/// Defaults to `(0, 0, 0, 0)`. /// /// @see BBMOD_EParticle function BBMOD_SetVec4Module(_property=undefined, _value=new BBMOD_Vec4()) @@ -21,7 +21,7 @@ function BBMOD_SetVec4Module(_property=undefined, _value=new BBMOD_Vec4()) Property = _property; /// @var {Struct.BBMOD_Vec4} The initial value of the properties. Default - /// value is `(0.0, 0.0, 0.0, 0.0)`. + /// value is `(0, 0, 0, 0)`. Value = _value; static on_particle_start = function (_emitter, _particleIndex) diff --git a/BBMOD_GML/scripts/bbmod_vtf_is_supported/bbmod_vtf_is_supported.gml b/BBMOD_GML/scripts/bbmod_vtf_is_supported/bbmod_vtf_is_supported.gml index 33fb04ee..40f5387d 100644 --- a/BBMOD_GML/scripts/bbmod_vtf_is_supported/bbmod_vtf_is_supported.gml +++ b/BBMOD_GML/scripts/bbmod_vtf_is_supported/bbmod_vtf_is_supported.gml @@ -42,4 +42,4 @@ function bbmod_vtf_is_supported() return _isSupported; } -__bbmod_info("Vertex texture fetching " + (bbmod_vtf_is_supported() ? "IS" : "NOT") + " supported!"); +__bbmod_info("VTF " + (!bbmod_vtf_is_supported() ? "not " : "") + "supported!"); diff --git a/BBMOD_GML/shaders/BBMOD_ShDefault/BBMOD_ShDefault.fsh b/BBMOD_GML/shaders/BBMOD_ShDefault/BBMOD_ShDefault.fsh index a50c9008..752f4a2b 100644 --- a/BBMOD_GML/shaders/BBMOD_ShDefault/BBMOD_ShDefault.fsh +++ b/BBMOD_GML/shaders/BBMOD_ShDefault/BBMOD_ShDefault.fsh @@ -45,10 +45,10 @@ uniform vec4 bbmod_BaseOpacityMultiplier; // If 1.0 then the material uses roughness uniform float bbmod_IsRoughness; -// If 1.0 then the material uses metallic workflow -uniform float bbmod_IsMetallic; // RGB: Tangent-space normal, A: Smoothness or roughness uniform sampler2D bbmod_NormalW; +// If 1.0 then the material uses metallic workflow +uniform float bbmod_IsMetallic; // RGB: specular color / R: Metallic, G: ambient occlusion uniform sampler2D bbmod_Material; @@ -179,12 +179,12 @@ struct Material vec3 Lightmap; }; -Material CreateMaterial(mat3 TBN) +Material CreateMaterial() { Material m; m.Base = vec3(1.0); m.Opacity = 1.0; - m.Normal = normalize(TBN * vec3(0.0, 0.0, 1.0)); + m.Normal = vec3(0.0, 0.0, 1.0); m.Metallic = 0.0; m.Roughness = 1.0; m.Specular = vec3(0.0); @@ -385,7 +385,11 @@ void DoSpotLightPS( } void Exposure() { - gl_FragColor.rgb = vec3(1.0) - exp(-gl_FragColor.rgb * bbmod_Exposure); + gl_FragColor.rgb *= bbmod_Exposure * bbmod_Exposure; +} +void TonemapReinhard() +{ + gl_FragColor.rgb = gl_FragColor.rgb / (vec3(1.0) + gl_FragColor.rgb); } void Fog(float depth) @@ -538,7 +542,7 @@ Material UnpackMaterial( mat3 TBN, vec2 uv) { - Material m = CreateMaterial(TBN); + Material m = CreateMaterial(); // Base color and opacity vec4 baseOpacity = texture2D(texBaseOpacity, @@ -780,6 +784,7 @@ void PBRShader(Material material, float depth) Fog(depth); Exposure(); + TonemapReinhard(); GammaCorrect(); } diff --git a/BBMOD_GML/shaders/BBMOD_ShDefaultAnimated/BBMOD_ShDefaultAnimated.fsh b/BBMOD_GML/shaders/BBMOD_ShDefaultAnimated/BBMOD_ShDefaultAnimated.fsh index a50c9008..752f4a2b 100644 --- a/BBMOD_GML/shaders/BBMOD_ShDefaultAnimated/BBMOD_ShDefaultAnimated.fsh +++ b/BBMOD_GML/shaders/BBMOD_ShDefaultAnimated/BBMOD_ShDefaultAnimated.fsh @@ -45,10 +45,10 @@ uniform vec4 bbmod_BaseOpacityMultiplier; // If 1.0 then the material uses roughness uniform float bbmod_IsRoughness; -// If 1.0 then the material uses metallic workflow -uniform float bbmod_IsMetallic; // RGB: Tangent-space normal, A: Smoothness or roughness uniform sampler2D bbmod_NormalW; +// If 1.0 then the material uses metallic workflow +uniform float bbmod_IsMetallic; // RGB: specular color / R: Metallic, G: ambient occlusion uniform sampler2D bbmod_Material; @@ -179,12 +179,12 @@ struct Material vec3 Lightmap; }; -Material CreateMaterial(mat3 TBN) +Material CreateMaterial() { Material m; m.Base = vec3(1.0); m.Opacity = 1.0; - m.Normal = normalize(TBN * vec3(0.0, 0.0, 1.0)); + m.Normal = vec3(0.0, 0.0, 1.0); m.Metallic = 0.0; m.Roughness = 1.0; m.Specular = vec3(0.0); @@ -385,7 +385,11 @@ void DoSpotLightPS( } void Exposure() { - gl_FragColor.rgb = vec3(1.0) - exp(-gl_FragColor.rgb * bbmod_Exposure); + gl_FragColor.rgb *= bbmod_Exposure * bbmod_Exposure; +} +void TonemapReinhard() +{ + gl_FragColor.rgb = gl_FragColor.rgb / (vec3(1.0) + gl_FragColor.rgb); } void Fog(float depth) @@ -538,7 +542,7 @@ Material UnpackMaterial( mat3 TBN, vec2 uv) { - Material m = CreateMaterial(TBN); + Material m = CreateMaterial(); // Base color and opacity vec4 baseOpacity = texture2D(texBaseOpacity, @@ -780,6 +784,7 @@ void PBRShader(Material material, float depth) Fog(depth); Exposure(); + TonemapReinhard(); GammaCorrect(); } diff --git a/BBMOD_GML/shaders/BBMOD_ShDefaultBatched/BBMOD_ShDefaultBatched.fsh b/BBMOD_GML/shaders/BBMOD_ShDefaultBatched/BBMOD_ShDefaultBatched.fsh index a50c9008..752f4a2b 100644 --- a/BBMOD_GML/shaders/BBMOD_ShDefaultBatched/BBMOD_ShDefaultBatched.fsh +++ b/BBMOD_GML/shaders/BBMOD_ShDefaultBatched/BBMOD_ShDefaultBatched.fsh @@ -45,10 +45,10 @@ uniform vec4 bbmod_BaseOpacityMultiplier; // If 1.0 then the material uses roughness uniform float bbmod_IsRoughness; -// If 1.0 then the material uses metallic workflow -uniform float bbmod_IsMetallic; // RGB: Tangent-space normal, A: Smoothness or roughness uniform sampler2D bbmod_NormalW; +// If 1.0 then the material uses metallic workflow +uniform float bbmod_IsMetallic; // RGB: specular color / R: Metallic, G: ambient occlusion uniform sampler2D bbmod_Material; @@ -179,12 +179,12 @@ struct Material vec3 Lightmap; }; -Material CreateMaterial(mat3 TBN) +Material CreateMaterial() { Material m; m.Base = vec3(1.0); m.Opacity = 1.0; - m.Normal = normalize(TBN * vec3(0.0, 0.0, 1.0)); + m.Normal = vec3(0.0, 0.0, 1.0); m.Metallic = 0.0; m.Roughness = 1.0; m.Specular = vec3(0.0); @@ -385,7 +385,11 @@ void DoSpotLightPS( } void Exposure() { - gl_FragColor.rgb = vec3(1.0) - exp(-gl_FragColor.rgb * bbmod_Exposure); + gl_FragColor.rgb *= bbmod_Exposure * bbmod_Exposure; +} +void TonemapReinhard() +{ + gl_FragColor.rgb = gl_FragColor.rgb / (vec3(1.0) + gl_FragColor.rgb); } void Fog(float depth) @@ -538,7 +542,7 @@ Material UnpackMaterial( mat3 TBN, vec2 uv) { - Material m = CreateMaterial(TBN); + Material m = CreateMaterial(); // Base color and opacity vec4 baseOpacity = texture2D(texBaseOpacity, @@ -780,6 +784,7 @@ void PBRShader(Material material, float depth) Fog(depth); Exposure(); + TonemapReinhard(); GammaCorrect(); } diff --git a/BBMOD_GML/shaders/BBMOD_ShDefaultColor/BBMOD_ShDefaultColor.fsh b/BBMOD_GML/shaders/BBMOD_ShDefaultColor/BBMOD_ShDefaultColor.fsh index 6227f726..bb8c59d4 100644 --- a/BBMOD_GML/shaders/BBMOD_ShDefaultColor/BBMOD_ShDefaultColor.fsh +++ b/BBMOD_GML/shaders/BBMOD_ShDefaultColor/BBMOD_ShDefaultColor.fsh @@ -47,10 +47,10 @@ uniform vec4 bbmod_BaseOpacityMultiplier; // If 1.0 then the material uses roughness uniform float bbmod_IsRoughness; -// If 1.0 then the material uses metallic workflow -uniform float bbmod_IsMetallic; // RGB: Tangent-space normal, A: Smoothness or roughness uniform sampler2D bbmod_NormalW; +// If 1.0 then the material uses metallic workflow +uniform float bbmod_IsMetallic; // RGB: specular color / R: Metallic, G: ambient occlusion uniform sampler2D bbmod_Material; @@ -181,12 +181,12 @@ struct Material vec3 Lightmap; }; -Material CreateMaterial(mat3 TBN) +Material CreateMaterial() { Material m; m.Base = vec3(1.0); m.Opacity = 1.0; - m.Normal = normalize(TBN * vec3(0.0, 0.0, 1.0)); + m.Normal = vec3(0.0, 0.0, 1.0); m.Metallic = 0.0; m.Roughness = 1.0; m.Specular = vec3(0.0); @@ -387,7 +387,11 @@ void DoSpotLightPS( } void Exposure() { - gl_FragColor.rgb = vec3(1.0) - exp(-gl_FragColor.rgb * bbmod_Exposure); + gl_FragColor.rgb *= bbmod_Exposure * bbmod_Exposure; +} +void TonemapReinhard() +{ + gl_FragColor.rgb = gl_FragColor.rgb / (vec3(1.0) + gl_FragColor.rgb); } void Fog(float depth) @@ -540,7 +544,7 @@ Material UnpackMaterial( mat3 TBN, vec2 uv) { - Material m = CreateMaterial(TBN); + Material m = CreateMaterial(); // Base color and opacity vec4 baseOpacity = texture2D(texBaseOpacity, @@ -782,6 +786,7 @@ void PBRShader(Material material, float depth) Fog(depth); Exposure(); + TonemapReinhard(); GammaCorrect(); } diff --git a/BBMOD_GML/shaders/BBMOD_ShDefaultColorAnimated/BBMOD_ShDefaultColorAnimated.fsh b/BBMOD_GML/shaders/BBMOD_ShDefaultColorAnimated/BBMOD_ShDefaultColorAnimated.fsh index 6227f726..bb8c59d4 100644 --- a/BBMOD_GML/shaders/BBMOD_ShDefaultColorAnimated/BBMOD_ShDefaultColorAnimated.fsh +++ b/BBMOD_GML/shaders/BBMOD_ShDefaultColorAnimated/BBMOD_ShDefaultColorAnimated.fsh @@ -47,10 +47,10 @@ uniform vec4 bbmod_BaseOpacityMultiplier; // If 1.0 then the material uses roughness uniform float bbmod_IsRoughness; -// If 1.0 then the material uses metallic workflow -uniform float bbmod_IsMetallic; // RGB: Tangent-space normal, A: Smoothness or roughness uniform sampler2D bbmod_NormalW; +// If 1.0 then the material uses metallic workflow +uniform float bbmod_IsMetallic; // RGB: specular color / R: Metallic, G: ambient occlusion uniform sampler2D bbmod_Material; @@ -181,12 +181,12 @@ struct Material vec3 Lightmap; }; -Material CreateMaterial(mat3 TBN) +Material CreateMaterial() { Material m; m.Base = vec3(1.0); m.Opacity = 1.0; - m.Normal = normalize(TBN * vec3(0.0, 0.0, 1.0)); + m.Normal = vec3(0.0, 0.0, 1.0); m.Metallic = 0.0; m.Roughness = 1.0; m.Specular = vec3(0.0); @@ -387,7 +387,11 @@ void DoSpotLightPS( } void Exposure() { - gl_FragColor.rgb = vec3(1.0) - exp(-gl_FragColor.rgb * bbmod_Exposure); + gl_FragColor.rgb *= bbmod_Exposure * bbmod_Exposure; +} +void TonemapReinhard() +{ + gl_FragColor.rgb = gl_FragColor.rgb / (vec3(1.0) + gl_FragColor.rgb); } void Fog(float depth) @@ -540,7 +544,7 @@ Material UnpackMaterial( mat3 TBN, vec2 uv) { - Material m = CreateMaterial(TBN); + Material m = CreateMaterial(); // Base color and opacity vec4 baseOpacity = texture2D(texBaseOpacity, @@ -782,6 +786,7 @@ void PBRShader(Material material, float depth) Fog(depth); Exposure(); + TonemapReinhard(); GammaCorrect(); } diff --git a/BBMOD_GML/shaders/BBMOD_ShDefaultColorBatched/BBMOD_ShDefaultColorBatched.fsh b/BBMOD_GML/shaders/BBMOD_ShDefaultColorBatched/BBMOD_ShDefaultColorBatched.fsh index 6227f726..bb8c59d4 100644 --- a/BBMOD_GML/shaders/BBMOD_ShDefaultColorBatched/BBMOD_ShDefaultColorBatched.fsh +++ b/BBMOD_GML/shaders/BBMOD_ShDefaultColorBatched/BBMOD_ShDefaultColorBatched.fsh @@ -47,10 +47,10 @@ uniform vec4 bbmod_BaseOpacityMultiplier; // If 1.0 then the material uses roughness uniform float bbmod_IsRoughness; -// If 1.0 then the material uses metallic workflow -uniform float bbmod_IsMetallic; // RGB: Tangent-space normal, A: Smoothness or roughness uniform sampler2D bbmod_NormalW; +// If 1.0 then the material uses metallic workflow +uniform float bbmod_IsMetallic; // RGB: specular color / R: Metallic, G: ambient occlusion uniform sampler2D bbmod_Material; @@ -181,12 +181,12 @@ struct Material vec3 Lightmap; }; -Material CreateMaterial(mat3 TBN) +Material CreateMaterial() { Material m; m.Base = vec3(1.0); m.Opacity = 1.0; - m.Normal = normalize(TBN * vec3(0.0, 0.0, 1.0)); + m.Normal = vec3(0.0, 0.0, 1.0); m.Metallic = 0.0; m.Roughness = 1.0; m.Specular = vec3(0.0); @@ -387,7 +387,11 @@ void DoSpotLightPS( } void Exposure() { - gl_FragColor.rgb = vec3(1.0) - exp(-gl_FragColor.rgb * bbmod_Exposure); + gl_FragColor.rgb *= bbmod_Exposure * bbmod_Exposure; +} +void TonemapReinhard() +{ + gl_FragColor.rgb = gl_FragColor.rgb / (vec3(1.0) + gl_FragColor.rgb); } void Fog(float depth) @@ -540,7 +544,7 @@ Material UnpackMaterial( mat3 TBN, vec2 uv) { - Material m = CreateMaterial(TBN); + Material m = CreateMaterial(); // Base color and opacity vec4 baseOpacity = texture2D(texBaseOpacity, @@ -782,6 +786,7 @@ void PBRShader(Material material, float depth) Fog(depth); Exposure(); + TonemapReinhard(); GammaCorrect(); } diff --git a/BBMOD_GML/shaders/BBMOD_ShDefaultLightmap/BBMOD_ShDefaultLightmap.fsh b/BBMOD_GML/shaders/BBMOD_ShDefaultLightmap/BBMOD_ShDefaultLightmap.fsh index 65d5ac1c..e3a86269 100644 --- a/BBMOD_GML/shaders/BBMOD_ShDefaultLightmap/BBMOD_ShDefaultLightmap.fsh +++ b/BBMOD_GML/shaders/BBMOD_ShDefaultLightmap/BBMOD_ShDefaultLightmap.fsh @@ -46,10 +46,10 @@ uniform vec4 bbmod_BaseOpacityMultiplier; // If 1.0 then the material uses roughness uniform float bbmod_IsRoughness; -// If 1.0 then the material uses metallic workflow -uniform float bbmod_IsMetallic; // RGB: Tangent-space normal, A: Smoothness or roughness uniform sampler2D bbmod_NormalW; +// If 1.0 then the material uses metallic workflow +uniform float bbmod_IsMetallic; // RGB: specular color / R: Metallic, G: ambient occlusion uniform sampler2D bbmod_Material; @@ -181,12 +181,12 @@ struct Material vec3 Lightmap; }; -Material CreateMaterial(mat3 TBN) +Material CreateMaterial() { Material m; m.Base = vec3(1.0); m.Opacity = 1.0; - m.Normal = normalize(TBN * vec3(0.0, 0.0, 1.0)); + m.Normal = vec3(0.0, 0.0, 1.0); m.Metallic = 0.0; m.Roughness = 1.0; m.Specular = vec3(0.0); @@ -384,7 +384,11 @@ void DoSpotLightPS( } void Exposure() { - gl_FragColor.rgb = vec3(1.0) - exp(-gl_FragColor.rgb * bbmod_Exposure); + gl_FragColor.rgb *= bbmod_Exposure * bbmod_Exposure; +} +void TonemapReinhard() +{ + gl_FragColor.rgb = gl_FragColor.rgb / (vec3(1.0) + gl_FragColor.rgb); } void Fog(float depth) @@ -538,7 +542,7 @@ Material UnpackMaterial( mat3 TBN, vec2 uv) { - Material m = CreateMaterial(TBN); + Material m = CreateMaterial(); // Base color and opacity vec4 baseOpacity = texture2D(texBaseOpacity, @@ -780,6 +784,7 @@ void PBRShader(Material material, float depth) Fog(depth); Exposure(); + TonemapReinhard(); GammaCorrect(); } diff --git a/BBMOD_GML/shaders/BBMOD_ShDefaultSprite/BBMOD_ShDefaultSprite.fsh b/BBMOD_GML/shaders/BBMOD_ShDefaultSprite/BBMOD_ShDefaultSprite.fsh index 39e11589..babfba9f 100644 --- a/BBMOD_GML/shaders/BBMOD_ShDefaultSprite/BBMOD_ShDefaultSprite.fsh +++ b/BBMOD_GML/shaders/BBMOD_ShDefaultSprite/BBMOD_ShDefaultSprite.fsh @@ -45,10 +45,10 @@ uniform vec4 bbmod_BaseOpacityMultiplier; // If 1.0 then the material uses roughness uniform float bbmod_IsRoughness; -// If 1.0 then the material uses metallic workflow -uniform float bbmod_IsMetallic; // RGB: Tangent-space normal, A: Smoothness or roughness uniform sampler2D bbmod_NormalW; +// If 1.0 then the material uses metallic workflow +uniform float bbmod_IsMetallic; // RGB: specular color / R: Metallic, G: ambient occlusion uniform sampler2D bbmod_Material; @@ -184,12 +184,12 @@ struct Material vec3 Lightmap; }; -Material CreateMaterial(mat3 TBN) +Material CreateMaterial() { Material m; m.Base = vec3(1.0); m.Opacity = 1.0; - m.Normal = normalize(TBN * vec3(0.0, 0.0, 1.0)); + m.Normal = vec3(0.0, 0.0, 1.0); m.Metallic = 0.0; m.Roughness = 1.0; m.Specular = vec3(0.0); @@ -390,7 +390,11 @@ void DoSpotLightPS( } void Exposure() { - gl_FragColor.rgb = vec3(1.0) - exp(-gl_FragColor.rgb * bbmod_Exposure); + gl_FragColor.rgb *= bbmod_Exposure * bbmod_Exposure; +} +void TonemapReinhard() +{ + gl_FragColor.rgb = gl_FragColor.rgb / (vec3(1.0) + gl_FragColor.rgb); } void Fog(float depth) @@ -543,7 +547,7 @@ Material UnpackMaterial( mat3 TBN, vec2 uv) { - Material m = CreateMaterial(TBN); + Material m = CreateMaterial(); // Base color and opacity vec4 baseOpacity = texture2D(texBaseOpacity, @@ -769,6 +773,7 @@ void PBRShader(Material material, float depth) Fog(depth); Exposure(); + TonemapReinhard(); GammaCorrect(); } diff --git a/BBMOD_GML/shaders/BBMOD_ShDefaultUnlit/BBMOD_ShDefaultUnlit.fsh b/BBMOD_GML/shaders/BBMOD_ShDefaultUnlit/BBMOD_ShDefaultUnlit.fsh index 469a7c00..0d16cf85 100644 --- a/BBMOD_GML/shaders/BBMOD_ShDefaultUnlit/BBMOD_ShDefaultUnlit.fsh +++ b/BBMOD_GML/shaders/BBMOD_ShDefaultUnlit/BBMOD_ShDefaultUnlit.fsh @@ -43,10 +43,10 @@ uniform vec4 bbmod_BaseOpacityMultiplier; // If 1.0 then the material uses roughness uniform float bbmod_IsRoughness; -// If 1.0 then the material uses metallic workflow -uniform float bbmod_IsMetallic; // RGB: Tangent-space normal, A: Smoothness or roughness uniform sampler2D bbmod_NormalW; +// If 1.0 then the material uses metallic workflow +uniform float bbmod_IsMetallic; // RGB: specular color / R: Metallic, G: ambient occlusion uniform sampler2D bbmod_Material; @@ -133,7 +133,11 @@ void Fog(float depth) } void Exposure() { - gl_FragColor.rgb = vec3(1.0) - exp(-gl_FragColor.rgb * bbmod_Exposure); + gl_FragColor.rgb *= bbmod_Exposure * bbmod_Exposure; +} +void TonemapReinhard() +{ + gl_FragColor.rgb = gl_FragColor.rgb / (vec3(1.0) + gl_FragColor.rgb); } void GammaCorrect() @@ -156,12 +160,12 @@ struct Material vec3 Lightmap; }; -Material CreateMaterial(mat3 TBN) +Material CreateMaterial() { Material m; m.Base = vec3(1.0); m.Opacity = 1.0; - m.Normal = normalize(TBN * vec3(0.0, 0.0, 1.0)); + m.Normal = vec3(0.0, 0.0, 1.0); m.Metallic = 0.0; m.Roughness = 1.0; m.Specular = vec3(0.0); @@ -215,7 +219,7 @@ Material UnpackMaterial( mat3 TBN, vec2 uv) { - Material m = CreateMaterial(TBN); + Material m = CreateMaterial(); // Base color and opacity vec4 baseOpacity = texture2D(texBaseOpacity, @@ -277,6 +281,7 @@ void UnlitShader(Material material, float depth) // Soft particles Fog(depth); Exposure(); + TonemapReinhard(); GammaCorrect(); } diff --git a/BBMOD_GML/shaders/BBMOD_ShDefaultUnlitAnimated/BBMOD_ShDefaultUnlitAnimated.fsh b/BBMOD_GML/shaders/BBMOD_ShDefaultUnlitAnimated/BBMOD_ShDefaultUnlitAnimated.fsh index 469a7c00..0d16cf85 100644 --- a/BBMOD_GML/shaders/BBMOD_ShDefaultUnlitAnimated/BBMOD_ShDefaultUnlitAnimated.fsh +++ b/BBMOD_GML/shaders/BBMOD_ShDefaultUnlitAnimated/BBMOD_ShDefaultUnlitAnimated.fsh @@ -43,10 +43,10 @@ uniform vec4 bbmod_BaseOpacityMultiplier; // If 1.0 then the material uses roughness uniform float bbmod_IsRoughness; -// If 1.0 then the material uses metallic workflow -uniform float bbmod_IsMetallic; // RGB: Tangent-space normal, A: Smoothness or roughness uniform sampler2D bbmod_NormalW; +// If 1.0 then the material uses metallic workflow +uniform float bbmod_IsMetallic; // RGB: specular color / R: Metallic, G: ambient occlusion uniform sampler2D bbmod_Material; @@ -133,7 +133,11 @@ void Fog(float depth) } void Exposure() { - gl_FragColor.rgb = vec3(1.0) - exp(-gl_FragColor.rgb * bbmod_Exposure); + gl_FragColor.rgb *= bbmod_Exposure * bbmod_Exposure; +} +void TonemapReinhard() +{ + gl_FragColor.rgb = gl_FragColor.rgb / (vec3(1.0) + gl_FragColor.rgb); } void GammaCorrect() @@ -156,12 +160,12 @@ struct Material vec3 Lightmap; }; -Material CreateMaterial(mat3 TBN) +Material CreateMaterial() { Material m; m.Base = vec3(1.0); m.Opacity = 1.0; - m.Normal = normalize(TBN * vec3(0.0, 0.0, 1.0)); + m.Normal = vec3(0.0, 0.0, 1.0); m.Metallic = 0.0; m.Roughness = 1.0; m.Specular = vec3(0.0); @@ -215,7 +219,7 @@ Material UnpackMaterial( mat3 TBN, vec2 uv) { - Material m = CreateMaterial(TBN); + Material m = CreateMaterial(); // Base color and opacity vec4 baseOpacity = texture2D(texBaseOpacity, @@ -277,6 +281,7 @@ void UnlitShader(Material material, float depth) // Soft particles Fog(depth); Exposure(); + TonemapReinhard(); GammaCorrect(); } diff --git a/BBMOD_GML/shaders/BBMOD_ShDefaultUnlitBatched/BBMOD_ShDefaultUnlitBatched.fsh b/BBMOD_GML/shaders/BBMOD_ShDefaultUnlitBatched/BBMOD_ShDefaultUnlitBatched.fsh index 469a7c00..0d16cf85 100644 --- a/BBMOD_GML/shaders/BBMOD_ShDefaultUnlitBatched/BBMOD_ShDefaultUnlitBatched.fsh +++ b/BBMOD_GML/shaders/BBMOD_ShDefaultUnlitBatched/BBMOD_ShDefaultUnlitBatched.fsh @@ -43,10 +43,10 @@ uniform vec4 bbmod_BaseOpacityMultiplier; // If 1.0 then the material uses roughness uniform float bbmod_IsRoughness; -// If 1.0 then the material uses metallic workflow -uniform float bbmod_IsMetallic; // RGB: Tangent-space normal, A: Smoothness or roughness uniform sampler2D bbmod_NormalW; +// If 1.0 then the material uses metallic workflow +uniform float bbmod_IsMetallic; // RGB: specular color / R: Metallic, G: ambient occlusion uniform sampler2D bbmod_Material; @@ -133,7 +133,11 @@ void Fog(float depth) } void Exposure() { - gl_FragColor.rgb = vec3(1.0) - exp(-gl_FragColor.rgb * bbmod_Exposure); + gl_FragColor.rgb *= bbmod_Exposure * bbmod_Exposure; +} +void TonemapReinhard() +{ + gl_FragColor.rgb = gl_FragColor.rgb / (vec3(1.0) + gl_FragColor.rgb); } void GammaCorrect() @@ -156,12 +160,12 @@ struct Material vec3 Lightmap; }; -Material CreateMaterial(mat3 TBN) +Material CreateMaterial() { Material m; m.Base = vec3(1.0); m.Opacity = 1.0; - m.Normal = normalize(TBN * vec3(0.0, 0.0, 1.0)); + m.Normal = vec3(0.0, 0.0, 1.0); m.Metallic = 0.0; m.Roughness = 1.0; m.Specular = vec3(0.0); @@ -215,7 +219,7 @@ Material UnpackMaterial( mat3 TBN, vec2 uv) { - Material m = CreateMaterial(TBN); + Material m = CreateMaterial(); // Base color and opacity vec4 baseOpacity = texture2D(texBaseOpacity, @@ -277,6 +281,7 @@ void UnlitShader(Material material, float depth) // Soft particles Fog(depth); Exposure(); + TonemapReinhard(); GammaCorrect(); } diff --git a/BBMOD_GML/shaders/BBMOD_ShDefaultUnlitColor/BBMOD_ShDefaultUnlitColor.fsh b/BBMOD_GML/shaders/BBMOD_ShDefaultUnlitColor/BBMOD_ShDefaultUnlitColor.fsh index 28e7a351..05efc1ed 100644 --- a/BBMOD_GML/shaders/BBMOD_ShDefaultUnlitColor/BBMOD_ShDefaultUnlitColor.fsh +++ b/BBMOD_GML/shaders/BBMOD_ShDefaultUnlitColor/BBMOD_ShDefaultUnlitColor.fsh @@ -45,10 +45,10 @@ uniform vec4 bbmod_BaseOpacityMultiplier; // If 1.0 then the material uses roughness uniform float bbmod_IsRoughness; -// If 1.0 then the material uses metallic workflow -uniform float bbmod_IsMetallic; // RGB: Tangent-space normal, A: Smoothness or roughness uniform sampler2D bbmod_NormalW; +// If 1.0 then the material uses metallic workflow +uniform float bbmod_IsMetallic; // RGB: specular color / R: Metallic, G: ambient occlusion uniform sampler2D bbmod_Material; @@ -135,7 +135,11 @@ void Fog(float depth) } void Exposure() { - gl_FragColor.rgb = vec3(1.0) - exp(-gl_FragColor.rgb * bbmod_Exposure); + gl_FragColor.rgb *= bbmod_Exposure * bbmod_Exposure; +} +void TonemapReinhard() +{ + gl_FragColor.rgb = gl_FragColor.rgb / (vec3(1.0) + gl_FragColor.rgb); } void GammaCorrect() @@ -158,12 +162,12 @@ struct Material vec3 Lightmap; }; -Material CreateMaterial(mat3 TBN) +Material CreateMaterial() { Material m; m.Base = vec3(1.0); m.Opacity = 1.0; - m.Normal = normalize(TBN * vec3(0.0, 0.0, 1.0)); + m.Normal = vec3(0.0, 0.0, 1.0); m.Metallic = 0.0; m.Roughness = 1.0; m.Specular = vec3(0.0); @@ -217,7 +221,7 @@ Material UnpackMaterial( mat3 TBN, vec2 uv) { - Material m = CreateMaterial(TBN); + Material m = CreateMaterial(); // Base color and opacity vec4 baseOpacity = texture2D(texBaseOpacity, @@ -279,6 +283,7 @@ void UnlitShader(Material material, float depth) // Soft particles Fog(depth); Exposure(); + TonemapReinhard(); GammaCorrect(); } diff --git a/BBMOD_GML/shaders/BBMOD_ShDefaultUnlitColorAnimated/BBMOD_ShDefaultUnlitColorAnimated.fsh b/BBMOD_GML/shaders/BBMOD_ShDefaultUnlitColorAnimated/BBMOD_ShDefaultUnlitColorAnimated.fsh index 28e7a351..05efc1ed 100644 --- a/BBMOD_GML/shaders/BBMOD_ShDefaultUnlitColorAnimated/BBMOD_ShDefaultUnlitColorAnimated.fsh +++ b/BBMOD_GML/shaders/BBMOD_ShDefaultUnlitColorAnimated/BBMOD_ShDefaultUnlitColorAnimated.fsh @@ -45,10 +45,10 @@ uniform vec4 bbmod_BaseOpacityMultiplier; // If 1.0 then the material uses roughness uniform float bbmod_IsRoughness; -// If 1.0 then the material uses metallic workflow -uniform float bbmod_IsMetallic; // RGB: Tangent-space normal, A: Smoothness or roughness uniform sampler2D bbmod_NormalW; +// If 1.0 then the material uses metallic workflow +uniform float bbmod_IsMetallic; // RGB: specular color / R: Metallic, G: ambient occlusion uniform sampler2D bbmod_Material; @@ -135,7 +135,11 @@ void Fog(float depth) } void Exposure() { - gl_FragColor.rgb = vec3(1.0) - exp(-gl_FragColor.rgb * bbmod_Exposure); + gl_FragColor.rgb *= bbmod_Exposure * bbmod_Exposure; +} +void TonemapReinhard() +{ + gl_FragColor.rgb = gl_FragColor.rgb / (vec3(1.0) + gl_FragColor.rgb); } void GammaCorrect() @@ -158,12 +162,12 @@ struct Material vec3 Lightmap; }; -Material CreateMaterial(mat3 TBN) +Material CreateMaterial() { Material m; m.Base = vec3(1.0); m.Opacity = 1.0; - m.Normal = normalize(TBN * vec3(0.0, 0.0, 1.0)); + m.Normal = vec3(0.0, 0.0, 1.0); m.Metallic = 0.0; m.Roughness = 1.0; m.Specular = vec3(0.0); @@ -217,7 +221,7 @@ Material UnpackMaterial( mat3 TBN, vec2 uv) { - Material m = CreateMaterial(TBN); + Material m = CreateMaterial(); // Base color and opacity vec4 baseOpacity = texture2D(texBaseOpacity, @@ -279,6 +283,7 @@ void UnlitShader(Material material, float depth) // Soft particles Fog(depth); Exposure(); + TonemapReinhard(); GammaCorrect(); } diff --git a/BBMOD_GML/shaders/BBMOD_ShDefaultUnlitColorBatched/BBMOD_ShDefaultUnlitColorBatched.fsh b/BBMOD_GML/shaders/BBMOD_ShDefaultUnlitColorBatched/BBMOD_ShDefaultUnlitColorBatched.fsh index 28e7a351..05efc1ed 100644 --- a/BBMOD_GML/shaders/BBMOD_ShDefaultUnlitColorBatched/BBMOD_ShDefaultUnlitColorBatched.fsh +++ b/BBMOD_GML/shaders/BBMOD_ShDefaultUnlitColorBatched/BBMOD_ShDefaultUnlitColorBatched.fsh @@ -45,10 +45,10 @@ uniform vec4 bbmod_BaseOpacityMultiplier; // If 1.0 then the material uses roughness uniform float bbmod_IsRoughness; -// If 1.0 then the material uses metallic workflow -uniform float bbmod_IsMetallic; // RGB: Tangent-space normal, A: Smoothness or roughness uniform sampler2D bbmod_NormalW; +// If 1.0 then the material uses metallic workflow +uniform float bbmod_IsMetallic; // RGB: specular color / R: Metallic, G: ambient occlusion uniform sampler2D bbmod_Material; @@ -135,7 +135,11 @@ void Fog(float depth) } void Exposure() { - gl_FragColor.rgb = vec3(1.0) - exp(-gl_FragColor.rgb * bbmod_Exposure); + gl_FragColor.rgb *= bbmod_Exposure * bbmod_Exposure; +} +void TonemapReinhard() +{ + gl_FragColor.rgb = gl_FragColor.rgb / (vec3(1.0) + gl_FragColor.rgb); } void GammaCorrect() @@ -158,12 +162,12 @@ struct Material vec3 Lightmap; }; -Material CreateMaterial(mat3 TBN) +Material CreateMaterial() { Material m; m.Base = vec3(1.0); m.Opacity = 1.0; - m.Normal = normalize(TBN * vec3(0.0, 0.0, 1.0)); + m.Normal = vec3(0.0, 0.0, 1.0); m.Metallic = 0.0; m.Roughness = 1.0; m.Specular = vec3(0.0); @@ -217,7 +221,7 @@ Material UnpackMaterial( mat3 TBN, vec2 uv) { - Material m = CreateMaterial(TBN); + Material m = CreateMaterial(); // Base color and opacity vec4 baseOpacity = texture2D(texBaseOpacity, @@ -279,6 +283,7 @@ void UnlitShader(Material material, float depth) // Soft particles Fog(depth); Exposure(); + TonemapReinhard(); GammaCorrect(); } diff --git a/BBMOD_GML/shaders/BBMOD_ShParticleLit/BBMOD_ShParticleLit.fsh b/BBMOD_GML/shaders/BBMOD_ShParticleLit/BBMOD_ShParticleLit.fsh index a58a5ba0..8b3618ef 100644 --- a/BBMOD_GML/shaders/BBMOD_ShParticleLit/BBMOD_ShParticleLit.fsh +++ b/BBMOD_GML/shaders/BBMOD_ShParticleLit/BBMOD_ShParticleLit.fsh @@ -47,10 +47,10 @@ uniform vec4 bbmod_BaseOpacityMultiplier; // If 1.0 then the material uses roughness uniform float bbmod_IsRoughness; -// If 1.0 then the material uses metallic workflow -uniform float bbmod_IsMetallic; // RGB: Tangent-space normal, A: Smoothness or roughness uniform sampler2D bbmod_NormalW; +// If 1.0 then the material uses metallic workflow +uniform float bbmod_IsMetallic; // RGB: specular color / R: Metallic, G: ambient occlusion uniform sampler2D bbmod_Material; @@ -191,12 +191,12 @@ struct Material vec3 Lightmap; }; -Material CreateMaterial(mat3 TBN) +Material CreateMaterial() { Material m; m.Base = vec3(1.0); m.Opacity = 1.0; - m.Normal = normalize(TBN * vec3(0.0, 0.0, 1.0)); + m.Normal = vec3(0.0, 0.0, 1.0); m.Metallic = 0.0; m.Roughness = 1.0; m.Specular = vec3(0.0); @@ -397,7 +397,11 @@ void DoSpotLightPS( } void Exposure() { - gl_FragColor.rgb = vec3(1.0) - exp(-gl_FragColor.rgb * bbmod_Exposure); + gl_FragColor.rgb *= bbmod_Exposure * bbmod_Exposure; +} +void TonemapReinhard() +{ + gl_FragColor.rgb = gl_FragColor.rgb / (vec3(1.0) + gl_FragColor.rgb); } void Fog(float depth) @@ -550,7 +554,7 @@ Material UnpackMaterial( mat3 TBN, vec2 uv) { - Material m = CreateMaterial(TBN); + Material m = CreateMaterial(); // Base color and opacity vec4 baseOpacity = texture2D(texBaseOpacity, @@ -793,6 +797,7 @@ void PBRShader(Material material, float depth) Fog(depth); Exposure(); + TonemapReinhard(); GammaCorrect(); } diff --git a/BBMOD_GML/shaders/BBMOD_ShParticleUnlit/BBMOD_ShParticleUnlit.fsh b/BBMOD_GML/shaders/BBMOD_ShParticleUnlit/BBMOD_ShParticleUnlit.fsh index ecd166d8..fb4e26b8 100644 --- a/BBMOD_GML/shaders/BBMOD_ShParticleUnlit/BBMOD_ShParticleUnlit.fsh +++ b/BBMOD_GML/shaders/BBMOD_ShParticleUnlit/BBMOD_ShParticleUnlit.fsh @@ -45,10 +45,10 @@ uniform vec4 bbmod_BaseOpacityMultiplier; // If 1.0 then the material uses roughness uniform float bbmod_IsRoughness; -// If 1.0 then the material uses metallic workflow -uniform float bbmod_IsMetallic; // RGB: Tangent-space normal, A: Smoothness or roughness uniform sampler2D bbmod_NormalW; +// If 1.0 then the material uses metallic workflow +uniform float bbmod_IsMetallic; // RGB: specular color / R: Metallic, G: ambient occlusion uniform sampler2D bbmod_Material; @@ -145,7 +145,11 @@ void Fog(float depth) } void Exposure() { - gl_FragColor.rgb = vec3(1.0) - exp(-gl_FragColor.rgb * bbmod_Exposure); + gl_FragColor.rgb *= bbmod_Exposure * bbmod_Exposure; +} +void TonemapReinhard() +{ + gl_FragColor.rgb = gl_FragColor.rgb / (vec3(1.0) + gl_FragColor.rgb); } void GammaCorrect() @@ -216,12 +220,12 @@ struct Material vec3 Lightmap; }; -Material CreateMaterial(mat3 TBN) +Material CreateMaterial() { Material m; m.Base = vec3(1.0); m.Opacity = 1.0; - m.Normal = normalize(TBN * vec3(0.0, 0.0, 1.0)); + m.Normal = vec3(0.0, 0.0, 1.0); m.Metallic = 0.0; m.Roughness = 1.0; m.Specular = vec3(0.0); @@ -275,7 +279,7 @@ Material UnpackMaterial( mat3 TBN, vec2 uv) { - Material m = CreateMaterial(TBN); + Material m = CreateMaterial(); // Base color and opacity vec4 baseOpacity = texture2D(texBaseOpacity, @@ -343,6 +347,7 @@ void UnlitShader(Material material, float depth) } Fog(depth); Exposure(); + TonemapReinhard(); GammaCorrect(); } diff --git a/BBMOD_GML/shaders/BBMOD_ShTerrain/BBMOD_ShTerrain.fsh b/BBMOD_GML/shaders/BBMOD_ShTerrain/BBMOD_ShTerrain.fsh index 00ed8d80..ddc282c6 100644 --- a/BBMOD_GML/shaders/BBMOD_ShTerrain/BBMOD_ShTerrain.fsh +++ b/BBMOD_GML/shaders/BBMOD_ShTerrain/BBMOD_ShTerrain.fsh @@ -47,12 +47,8 @@ uniform vec4 bbmod_BaseOpacityMultiplier; // If 1.0 then the material uses roughness uniform float bbmod_IsRoughness; -// If 1.0 then the material uses metallic workflow -uniform float bbmod_IsMetallic; // RGB: Tangent-space normal, A: Smoothness or roughness uniform sampler2D bbmod_NormalW; -// RGB: specular color / R: Metallic, G: ambient occlusion -uniform sampler2D bbmod_Material; // Pixels with alpha less than this value will be discarded uniform float bbmod_AlphaTest; @@ -128,6 +124,8 @@ uniform vec3 bbmod_LightPunctualDataB[2 * BBMOD_MAX_PUNCTUAL_LIGHTS]; uniform sampler2D bbmod_Splatmap; // Splatmap channel to read. Use -1 for none. uniform int bbmod_SplatmapIndex; +// Colormap texture +uniform sampler2D bbmod_Colormap; //////////////////////////////////////////////////////////////////////////////// // Shadow mapping @@ -184,12 +182,12 @@ struct Material vec3 Lightmap; }; -Material CreateMaterial(mat3 TBN) +Material CreateMaterial() { Material m; m.Base = vec3(1.0); m.Opacity = 1.0; - m.Normal = normalize(TBN * vec3(0.0, 0.0, 1.0)); + m.Normal = vec3(0.0, 0.0, 1.0); m.Metallic = 0.0; m.Roughness = 1.0; m.Specular = vec3(0.0); @@ -376,7 +374,11 @@ void DoSpotLightPS( } void Exposure() { - gl_FragColor.rgb = vec3(1.0) - exp(-gl_FragColor.rgb * bbmod_Exposure); + gl_FragColor.rgb *= bbmod_Exposure * bbmod_Exposure; +} +void TonemapReinhard() +{ + gl_FragColor.rgb = gl_FragColor.rgb / (vec3(1.0) + gl_FragColor.rgb); } void Fog(float depth) @@ -522,12 +524,10 @@ Material UnpackMaterial( sampler2D texBaseOpacity, float isRoughness, sampler2D texNormalW, - float isMetallic, - sampler2D texMaterial, mat3 TBN, vec2 uv) { - Material m = CreateMaterial(TBN); + Material m = CreateMaterial(); // Base color and opacity vec4 baseOpacity = texture2D(texBaseOpacity, @@ -554,22 +554,9 @@ Material UnpackMaterial( } // Material properties - vec4 materialProps = texture2D(texMaterial, - uv - ); - - if (isMetallic == 1.0) - { - m.Metallic = materialProps.r; - m.AO = materialProps.g; - m.Specular = mix(F0_DEFAULT, m.Base, m.Metallic); - m.Base *= (1.0 - m.Metallic); - } - else - { - m.Specular = materialProps.rgb; - m.SpecularPower = exp2(1.0 + (m.Smoothness * 10.0)); - } + m.Metallic = 0.0; + m.AO = 1.0; + m.Specular = F0_DEFAULT; return m; } @@ -762,6 +749,7 @@ void PBRShader(Material material, float depth) Fog(depth); Exposure(); + TonemapReinhard(); GammaCorrect(); } @@ -775,8 +763,6 @@ void main() bbmod_BaseOpacity, bbmod_IsRoughness, bbmod_NormalW, - bbmod_IsMetallic, - bbmod_Material, v_mTBN, v_vTexCoord); @@ -791,6 +777,9 @@ void main() : splatmap.a))); } + // Colormap + material.Base *= xGammaToLinear(texture2D(bbmod_Colormap, v_vSplatmapCoord).xyz); + material.Base *= xGammaToLinear(bbmod_BaseOpacityMultiplier.rgb); material.Opacity *= bbmod_BaseOpacityMultiplier.a; diff --git a/BBMOD_GML/shaders/BBMOD_ShTerrainUnlit/BBMOD_ShTerrainUnlit.fsh b/BBMOD_GML/shaders/BBMOD_ShTerrainUnlit/BBMOD_ShTerrainUnlit.fsh index 52dc6639..71ba3d3b 100644 --- a/BBMOD_GML/shaders/BBMOD_ShTerrainUnlit/BBMOD_ShTerrainUnlit.fsh +++ b/BBMOD_GML/shaders/BBMOD_ShTerrainUnlit/BBMOD_ShTerrainUnlit.fsh @@ -45,12 +45,8 @@ uniform vec4 bbmod_BaseOpacityMultiplier; // If 1.0 then the material uses roughness uniform float bbmod_IsRoughness; -// If 1.0 then the material uses metallic workflow -uniform float bbmod_IsMetallic; // RGB: Tangent-space normal, A: Smoothness or roughness uniform sampler2D bbmod_NormalW; -// RGB: specular color / R: Metallic, G: ambient occlusion -uniform sampler2D bbmod_Material; // Pixels with alpha less than this value will be discarded uniform float bbmod_AlphaTest; @@ -102,6 +98,8 @@ uniform vec4 bbmod_LightDirectionalColor; uniform sampler2D bbmod_Splatmap; // Splatmap channel to read. Use -1 for none. uniform int bbmod_SplatmapIndex; +// Colormap texture +uniform sampler2D bbmod_Colormap; //////////////////////////////////////////////////////////////////////////////// // @@ -138,7 +136,11 @@ void Fog(float depth) } void Exposure() { - gl_FragColor.rgb = vec3(1.0) - exp(-gl_FragColor.rgb * bbmod_Exposure); + gl_FragColor.rgb *= bbmod_Exposure * bbmod_Exposure; +} +void TonemapReinhard() +{ + gl_FragColor.rgb = gl_FragColor.rgb / (vec3(1.0) + gl_FragColor.rgb); } void GammaCorrect() @@ -161,12 +163,12 @@ struct Material vec3 Lightmap; }; -Material CreateMaterial(mat3 TBN) +Material CreateMaterial() { Material m; m.Base = vec3(1.0); m.Opacity = 1.0; - m.Normal = normalize(TBN * vec3(0.0, 0.0, 1.0)); + m.Normal = vec3(0.0, 0.0, 1.0); m.Metallic = 0.0; m.Roughness = 1.0; m.Specular = vec3(0.0); @@ -213,12 +215,10 @@ Material UnpackMaterial( sampler2D texBaseOpacity, float isRoughness, sampler2D texNormalW, - float isMetallic, - sampler2D texMaterial, mat3 TBN, vec2 uv) { - Material m = CreateMaterial(TBN); + Material m = CreateMaterial(); // Base color and opacity vec4 baseOpacity = texture2D(texBaseOpacity, @@ -245,22 +245,9 @@ Material UnpackMaterial( } // Material properties - vec4 materialProps = texture2D(texMaterial, - uv - ); - - if (isMetallic == 1.0) - { - m.Metallic = materialProps.r; - m.AO = materialProps.g; - m.Specular = mix(F0_DEFAULT, m.Base, m.Metallic); - m.Base *= (1.0 - m.Metallic); - } - else - { - m.Specular = materialProps.rgb; - m.SpecularPower = exp2(1.0 + (m.Smoothness * 10.0)); - } + m.Metallic = 0.0; + m.AO = 1.0; + m.Specular = F0_DEFAULT; return m; } @@ -273,6 +260,7 @@ void UnlitShader(Material material, float depth) // Soft particles Fog(depth); Exposure(); + TonemapReinhard(); GammaCorrect(); } @@ -286,8 +274,6 @@ void main() bbmod_BaseOpacity, bbmod_IsRoughness, bbmod_NormalW, - bbmod_IsMetallic, - bbmod_Material, v_mTBN, v_vTexCoord); @@ -302,6 +288,9 @@ void main() : splatmap.a))); } + // Colormap + material.Base *= xGammaToLinear(texture2D(bbmod_Colormap, v_vSplatmapCoord).xyz); + material.Base *= xGammaToLinear(bbmod_BaseOpacityMultiplier.rgb); material.Opacity *= bbmod_BaseOpacityMultiplier.a; diff --git a/BBMOD_GML/shaders/ShZombie/ShZombie.fsh b/BBMOD_GML/shaders/ShZombie/ShZombie.fsh index 4d679534..39b89e2b 100644 --- a/BBMOD_GML/shaders/ShZombie/ShZombie.fsh +++ b/BBMOD_GML/shaders/ShZombie/ShZombie.fsh @@ -76,10 +76,10 @@ uniform vec4 bbmod_BaseOpacityMultiplier; // If 1.0 then the material uses roughness uniform float bbmod_IsRoughness; -// If 1.0 then the material uses metallic workflow -uniform float bbmod_IsMetallic; // RGB: Tangent-space normal, A: Smoothness or roughness uniform sampler2D bbmod_NormalW; +// If 1.0 then the material uses metallic workflow +uniform float bbmod_IsMetallic; // RGB: specular color / R: Metallic, G: ambient occlusion uniform sampler2D bbmod_Material; @@ -210,12 +210,12 @@ struct Material vec3 Lightmap; }; -Material CreateMaterial(mat3 TBN) +Material CreateMaterial() { Material m; m.Base = vec3(1.0); m.Opacity = 1.0; - m.Normal = normalize(TBN * vec3(0.0, 0.0, 1.0)); + m.Normal = vec3(0.0, 0.0, 1.0); m.Metallic = 0.0; m.Roughness = 1.0; m.Specular = vec3(0.0); @@ -416,7 +416,11 @@ void DoSpotLightPS( } void Exposure() { - gl_FragColor.rgb = vec3(1.0) - exp(-gl_FragColor.rgb * bbmod_Exposure); + gl_FragColor.rgb *= bbmod_Exposure * bbmod_Exposure; +} +void TonemapReinhard() +{ + gl_FragColor.rgb = gl_FragColor.rgb / (vec3(1.0) + gl_FragColor.rgb); } void Fog(float depth) @@ -569,7 +573,7 @@ Material UnpackMaterial( mat3 TBN, vec2 uv) { - Material m = CreateMaterial(TBN); + Material m = CreateMaterial(); // Base color and opacity vec4 baseOpacity = texture2D(texBaseOpacity, @@ -811,6 +815,7 @@ void PBRShader(Material material, float depth) Fog(depth); Exposure(); + TonemapReinhard(); GammaCorrect(); } diff --git a/docs_src/Changelog/Changelog3.19.0.md b/docs_src/Changelog/Changelog3.19.0.md new file mode 100644 index 00000000..7991fecd --- /dev/null +++ b/docs_src/Changelog/Changelog3.19.0.md @@ -0,0 +1,19 @@ +# Changelog 3.19.0 +In this release terrain mesh is split into chunks of configurable size and you can control how many chunks to render from the camera's position. Using this you can create larger terrains and draw just a portion of them to save on triangle count. The terrain now also supports a color map, which multiplies the base texture. Terrain material layers were reworked as a preparation for a deferred rendering pipeline. Please read the following changelog thoroughly before upgrading to this version. + +* Added new property `Colormap` to `BBMOD_Terrain`, which is a texture to multiply the terrain colors with. +* Added new macro `BBMOD_U_COLORMAP`, which is the name of a fragment shader uniform of type `sampler2D` that holds the color map texture. +* Added new property `ChunkSize` to `BBMOD_Terrain`, which is the width and height of a single terrain chunk. Terrain mesh is now split into chunks which consist of `Chunksize`x`Chunksize` quads. +* Added new optional argument `_chunkSize` to the constructor of `BBMOD_Terrain`. This is the width and height of a single terrain chunk. Defaults to 128. +* Added new property `Chunks` to `BBMOD_Terrain`, which is a grid of vertex buffers, each representing an individual terrain chunk. +* Added new property `ChunkRadius`, which is the radius (in chunk size) within which terrain chunks are visible around the camera. Zero means only the chunk that the camera is on is visible. Use `infinity` to make all chunks visible. Default value is `infinity`. +* Property `VertexBuffer` of `BBMOD_Terrain` is now **obsolete**! It was replaced with the new `Chunks` property. +* Added new property `Material` to `BBMOD_Terrain`, which is the shader used when rendering the terrain. Default is `BBMOD_MATERIAL_TERRAIN`. +* Added new struct `BBMOD_TerrainLayer`, which describes a material of a single terrain layer. +* Entries in `BBMOD_Terrain.Layer` should now be of `Struct.BBMOD_TerrainLayer` type **instead of** `Struct.BBMOD_DefaultMaterial`! +* Added new struct `BBMOD_TerrainShader`, which is the base class for BBMOD terrain shaders. +* Shaders `BBMOD_SHADER_TERRAIN` and `BBMOD_SHADER_TERRAIN_UNLIT` are now constructed from `BBMOD_TerrainShader`. +* Added new struct `BBMOD_TerrainMaterial`, which is a material that can be used when rendering terrain. +* Materials `BBMOD_MATERIAL_TERRAIN` and `BBMOD_MATERIAL_TERRAIN_UNLIT` are now constructed from `BBMOD_TerrainMaterial`. +* Fixed method `screen_point_to_vec3` of `BBMOD_BaseCamera` normalizing the resulting vector when it should not be normalized. +* Fixed crash after `BBMOD_Camera.set_mouselook(true)` in YYC. diff --git a/docs_src/Changelog/Changelog_.md b/docs_src/Changelog/Changelog_.md index 7dffe4ef..145e60ee 100644 --- a/docs_src/Changelog/Changelog_.md +++ b/docs_src/Changelog/Changelog_.md @@ -2,6 +2,7 @@ In this section you can find changelogs for all releases of BBMOD since 3.0.0. ## Contents +* [3.19.0](./Changelog3.19.0.html) * [3.18.1](./Changelog3.18.1.html) * [3.18.0](./Changelog3.18.0.html) * [3.17.2](./Changelog3.17.2.html) diff --git a/docs_src/index.md b/docs_src/index.md index 675e21c1..a02a94fa 100644 --- a/docs_src/index.md +++ b/docs_src/index.md @@ -1,5 +1,5 @@ # BBMOD -Welcome to the official documentation of BBMOD 3.18.1! +Welcome to the official documentation of BBMOD 3.19.0! BBMOD is an advanced 3D rendering solution for GameMaker. It consists of a custom model, animation and material formats, a model converter (BBMOD CLI), diff --git a/gmdoc.json b/gmdoc.json index 6da5ee9d..cdb0cc78 100644 --- a/gmdoc.json +++ b/gmdoc.json @@ -5,7 +5,7 @@ "title": "BBMOD Docs", "author": "BlueBurn", "prefix": ["bbmod", "__bbmod"], - "version": "3.18.1", + "version": "3.19.0", "analytics": "", "api": { "rating": "/bbmod/page_rating.php" @@ -15,6 +15,7 @@ "Changelog": { "file": "Changelog/Changelog_.md", "pages": { + "3.19.0": "Changelog/Changelog3.19.0.md", "3.18.1": "Changelog/Changelog3.18.1.md", "3.18.0": "Changelog/Changelog3.18.0.md", "3.17.2": "Changelog/Changelog3.17.2.md",