create rough guide on how to create custom uniforms to be used in the scene controller

This commit is contained in:
Xonk
2025-04-09 23:56:43 -04:00
parent 214dab3478
commit 656e33a51f
3 changed files with 251 additions and 88 deletions

View File

@ -23,8 +23,6 @@ flat varying float rodExposure;
flat varying float avgL2;
flat varying float centerDepth;
#include "/lib/scene_controller.glsl"
uniform int hideGUI;
uniform sampler2D colortex4;
@ -38,17 +36,15 @@ uniform vec3 sunPosition;
uniform vec2 texelSize;
uniform float sunElevation;
uniform float eyeAltitude;
uniform float rainStrength;
uniform float nightVision;
uniform float near;
// uniform float far;
uniform float frameTime;
uniform int frameCounter;
uniform float rainStrength;
// uniform int worldTime;
vec3 sunVec = normalize(mat3(gbufferModelViewInverse) * sunPosition);
// vec3 sunVec = normalize(LightDir);
#include "/lib/sky_gradient.glsl"
#include "/lib/util.glsl"
#include "/lib/ROBOBO_sky.glsl"
@ -74,28 +70,6 @@ float tanh(float x){
float ld(float depth) {
return (2.0 * near) / (far + near - depth * (far - near)); // (-depth * (far - near)) = (2.0 * near)/ld - far - near
}
uniform float nightVision;
uniform int worldDay;
void getWeatherParams(
inout vec4 weatherParams0,
inout vec4 weatherParams1,
float layer0_coverage,
float layer1_coverage,
float layer2_coverage,
float uniformFog_density,
float layer0_density,
float layer1_density,
float layer2_density,
float cloudyFog_density
){
weatherParams0 = vec4(layer0_coverage, layer1_coverage, layer2_coverage, uniformFog_density);
weatherParams1 = vec4(layer0_density, layer1_density, layer2_density, cloudyFog_density);
}
float hash11(float p)
{
p = fract(p * .1031);
@ -104,6 +78,9 @@ float hash11(float p)
return fract(p);
}
#define USE_SCENE_CONTROLLER_SETTINGS
#include "/lib/scene_controller.glsl"
void main() {
gl_Position = ftransform()*0.5+0.5;
@ -188,69 +165,72 @@ void main() {
/// --- SCENE CONTROLLER PARAMETERS --- ///
///////////////////////////////////////////
parameters.smallCumulus = vec2(CloudLayer0_coverage, CloudLayer0_density);
parameters.largeCumulus = vec2(CloudLayer1_coverage, CloudLayer1_density);
parameters.altostratus = vec2(CloudLayer2_coverage, CloudLayer2_density);
parameters.fog = vec2(1.0, 1.0);
#ifdef Daily_Weather
#ifdef CHOOSE_RANDOM_WEATHER_PROFILE
int dayCounter = int(clamp(hash11(float(mod(worldDay, 1000))) * 10.0, 0,10));
#else
int dayCounter = int(mod(worldDay, 10));
#endif
//----------- cloud coverage
vec3 weatherProfile_cloudCoverage[10] = vec3[](
vec3(DAY0_l0_coverage, DAY0_l1_coverage, DAY0_l2_coverage),
vec3(DAY1_l0_coverage, DAY1_l1_coverage, DAY1_l2_coverage),
vec3(DAY2_l0_coverage, DAY2_l1_coverage, DAY2_l2_coverage),
vec3(DAY3_l0_coverage, DAY3_l1_coverage, DAY3_l2_coverage),
vec3(DAY4_l0_coverage, DAY4_l1_coverage, DAY4_l2_coverage),
vec3(DAY5_l0_coverage, DAY5_l1_coverage, DAY5_l2_coverage),
vec3(DAY6_l0_coverage, DAY6_l1_coverage, DAY6_l2_coverage),
vec3(DAY7_l0_coverage, DAY7_l1_coverage, DAY7_l2_coverage),
vec3(DAY8_l0_coverage, DAY8_l1_coverage, DAY8_l2_coverage),
vec3(DAY9_l0_coverage, DAY9_l1_coverage, DAY9_l2_coverage)
// components are split for readability/user friendliness within this function
applySceneControllerParameters(
parameters.smallCumulus.x, parameters.smallCumulus.y,
parameters.largeCumulus.x, parameters.largeCumulus.y,
parameters.altostratus.x, parameters.altostratus.y,
parameters.fog.x, parameters.fog.y
);
//----------- cloud density
vec3 weatherProfile_cloudDensity[10] = vec3[](
vec3(DAY0_l0_density, DAY0_l1_density, DAY0_l2_density),
vec3(DAY1_l0_density, DAY1_l1_density, DAY1_l2_density),
vec3(DAY2_l0_density, DAY2_l1_density, DAY2_l2_density),
vec3(DAY3_l0_density, DAY3_l1_density, DAY3_l2_density),
vec3(DAY4_l0_density, DAY4_l1_density, DAY4_l2_density),
vec3(DAY5_l0_density, DAY5_l1_density, DAY5_l2_density),
vec3(DAY6_l0_density, DAY6_l1_density, DAY6_l2_density),
vec3(DAY7_l0_density, DAY7_l1_density, DAY7_l2_density),
vec3(DAY8_l0_density, DAY8_l1_density, DAY8_l2_density),
vec3(DAY9_l0_density, DAY9_l1_density, DAY9_l2_density)
);
vec3 getWeatherProfile_coverage = weatherProfile_cloudCoverage[dayCounter];
vec3 getWeatherProfile_density = weatherProfile_cloudDensity[dayCounter];
// #ifdef Daily_Weather
// #ifdef CHOOSE_RANDOM_WEATHER_PROFILE
// int dayCounter = int(clamp(hash11(float(mod(worldDay, 1000))) * 10.0, 0,10));
// #else
// int dayCounter = int(mod(worldDay, 10));
// #endif
parameters.smallCumulus = vec2(getWeatherProfile_coverage.x, getWeatherProfile_density.x);
parameters.largeCumulus = vec2(getWeatherProfile_coverage.y, getWeatherProfile_density.y);
parameters.altostratus = vec2(getWeatherProfile_coverage.z, getWeatherProfile_density.z);
// //----------- cloud coverage
// vec3 weatherProfile_cloudCoverage[10] = vec3[](
// vec3(DAY0_l0_coverage, DAY0_l1_coverage, DAY0_l2_coverage),
// vec3(DAY1_l0_coverage, DAY1_l1_coverage, DAY1_l2_coverage),
// vec3(DAY2_l0_coverage, DAY2_l1_coverage, DAY2_l2_coverage),
// vec3(DAY3_l0_coverage, DAY3_l1_coverage, DAY3_l2_coverage),
// vec3(DAY4_l0_coverage, DAY4_l1_coverage, DAY4_l2_coverage),
// vec3(DAY5_l0_coverage, DAY5_l1_coverage, DAY5_l2_coverage),
// vec3(DAY6_l0_coverage, DAY6_l1_coverage, DAY6_l2_coverage),
// vec3(DAY7_l0_coverage, DAY7_l1_coverage, DAY7_l2_coverage),
// vec3(DAY8_l0_coverage, DAY8_l1_coverage, DAY8_l2_coverage),
// vec3(DAY9_l0_coverage, DAY9_l1_coverage, DAY9_l2_coverage)
// );
//----------- fog density
vec2 weatherProfile_fogDensity[10] = vec2[](
vec2(DAY0_ufog_density, DAY0_cfog_density),
vec2(DAY1_ufog_density, DAY1_cfog_density),
vec2(DAY2_ufog_density, DAY2_cfog_density),
vec2(DAY3_ufog_density, DAY3_cfog_density),
vec2(DAY4_ufog_density, DAY4_cfog_density),
vec2(DAY5_ufog_density, DAY5_cfog_density),
vec2(DAY6_ufog_density, DAY6_cfog_density),
vec2(DAY7_ufog_density, DAY7_cfog_density),
vec2(DAY8_ufog_density, DAY8_cfog_density),
vec2(DAY9_ufog_density, DAY9_cfog_density)
);
// //----------- cloud density
// vec3 weatherProfile_cloudDensity[10] = vec3[](
// vec3(DAY0_l0_density, DAY0_l1_density, DAY0_l2_density),
// vec3(DAY1_l0_density, DAY1_l1_density, DAY1_l2_density),
// vec3(DAY2_l0_density, DAY2_l1_density, DAY2_l2_density),
// vec3(DAY3_l0_density, DAY3_l1_density, DAY3_l2_density),
// vec3(DAY4_l0_density, DAY4_l1_density, DAY4_l2_density),
// vec3(DAY5_l0_density, DAY5_l1_density, DAY5_l2_density),
// vec3(DAY6_l0_density, DAY6_l1_density, DAY6_l2_density),
// vec3(DAY7_l0_density, DAY7_l1_density, DAY7_l2_density),
// vec3(DAY8_l0_density, DAY8_l1_density, DAY8_l2_density),
// vec3(DAY9_l0_density, DAY9_l1_density, DAY9_l2_density)
// );
parameters.fog = weatherProfile_fogDensity[dayCounter];
#endif
// vec3 getWeatherProfile_coverage = weatherProfile_cloudCoverage[dayCounter];
// vec3 getWeatherProfile_density = weatherProfile_cloudDensity[dayCounter];
// parameters.smallCumulus = vec2(getWeatherProfile_coverage.x, getWeatherProfile_density.x);
// parameters.largeCumulus = vec2(getWeatherProfile_coverage.y, getWeatherProfile_density.y);
// parameters.altostratus = vec2(getWeatherProfile_coverage.z, getWeatherProfile_density.z);
// //----------- fog density
// vec2 weatherProfile_fogDensity[10] = vec2[](
// vec2(DAY0_ufog_density, DAY0_cfog_density),
// vec2(DAY1_ufog_density, DAY1_cfog_density),
// vec2(DAY2_ufog_density, DAY2_cfog_density),
// vec2(DAY3_ufog_density, DAY3_cfog_density),
// vec2(DAY4_ufog_density, DAY4_cfog_density),
// vec2(DAY5_ufog_density, DAY5_cfog_density),
// vec2(DAY6_ufog_density, DAY6_cfog_density),
// vec2(DAY7_ufog_density, DAY7_cfog_density),
// vec2(DAY8_ufog_density, DAY8_cfog_density),
// vec2(DAY9_ufog_density, DAY9_cfog_density)
// );
// parameters.fog = weatherProfile_fogDensity[dayCounter];
// #endif
//////////////////////////////
/// --- EXPOSURE STUFF --- ///

View File

@ -1,3 +1,179 @@
#if defined USE_SCENE_CONTROLLER_SETTINGS
/*===============================================================================================================================================================
=============== HOW TO MAKE FUNCTIONAL CUSTOM SCENE CONTROLLER PARAMETERS ===============
THERE ARE 2 FILES YOU NEED TO OPEN INSIDE OF THE SHADERPACK FOLDER AS TO OPERATE WITHIN
- the "shaders.properties" file located in shaderpacks/bliss/shaders/shaders.properties
- the "scene_controller.glsl" file located in shaderpacks/bliss/shaders/lib/scene_controller.glsl (you are already in it reading its contents)
you can create a custom configuration of parameters that appear in specific circumstances within minecraft.
to do this, you first need to know when you are in a specific circumstance.
you need to create "triggers", which have 2 states, a true and a false state. these are known as "boolean" variables
here is a step by step process of how to create and use your own custom uniform "trigger", and use it to activate your own parameters in the scene controller.
------------- STEP 1 -------------
create a "custom uniform". it should be a boolean value that returns as true or false.
these are created and named in the "shaders.properties" file
take note of writing style and syntax or errors will happen
examples:
blank slates for syntax clarity
uniform.bool.blankBool = if(VALUE <is greater/less than, or equal to> ANOTHER_VALUE)
uniform.bool.blankBool = if(VALUE > ANOTHE_RVALUE)
uniform.bool.blankBool = if(VALUE < ANOTHER_VALUE)
uniform.bool.blankBool = if(VALUE == ANOTHER_VALUE)
uniform.bool.blankBool = if(in(biome, BIOEM_A, BIOME_B, BIOME_C))
uniform.bool.blankBool = if(in(biome, BIOME_A))
uniform.bool.nameWhateverYouWant_isExampleBool1 = if(in(biome, BIOME_DARK_FOREST, BIOME_DESERT, BIOME_PLAINS))
uniform.bool.nameWhateverYouWant_isExampleBool2 = if(nightvision > 0.0)
uniform.bool.nameWhateverYouWant_isExampleBool3 = if(cameraPosition.x < 40.0 && cameraPosition.y > -100.0)
uniform.bool.nameWhateverYouWant_isExampleBool4 = if(rainStrength > 0.0)
uniform.bool.nameWhateverYouWant_isExampleBool5 = if(eyeBrightness.x/240.0 > 0.0)
there are many things you can detect (this is by no means a complete list, links to the iris documentation of what you can detect are linked below)
-if it is raining/thunderstorming (snowing and raining are one in the same here sadly)
-what biome the player is standing in
-the torch/sky light level the player is standing in
-the position in world coordinates the player is standing in
-if the player is above or under water/lava/powderedsnow
-if the player has above or below specific health/armor/hunger values
-if the player has nightvision/darkness/blindness/invisibility (theres only a few potion status effects you can detect)
-if the player is on fire or not
documentation for creating custom uniforms in shaders.properties https://shaders.properties/current/reference/shadersproperties/custom_uniforms/
documentation for player status related uniforms https://shaders.properties/current/reference/uniforms/status/
documentation for player position/camera related uniforms https://shaders.properties/current/reference/uniforms/camera/
------------- STEP 2 -------------
declare/call the variable in the "scene_controller.glsl" file
this is required to make use of the custom uniform you made in the shader.properties file
take note of writing style and syntax or errors will happen
example:
uniform bool nameWhateverYouWant_isExampleBool1;
uniform bool nameWhateverYouWant_isExampleBool2;
uniform bool nameWhateverYouWant_isExampleBool3;
------------- STEP 3 -------------
use the custom uniform
in the scene_controller.glsl file, within the applySceneControllerParameters() function, there is a designated area.
in that area, you will check if the custom uniforms you have made are true or false or "triggered", and if any are true, make the parameters equal whatever values you want.
take note of writing style and syntax or errors will happen
example:
blank slate for syntax clarity
if( <arguements go here> ){
<what runs does when the arguement is true>;
}
if( nameWhateverYouWant_isExampleBool1 ){
smallCumulusCoverage = 1.0;
smallCumulusDensity = 0.5;
fogColor = vec3(1.0, 0.0, 0.0);
}
if( nameWhateverYouWant_isExampleBool2 ){
smallCumulusCoverage = 0.0;
smallCumulusDensity = 0.2;
fogColor = vec3(1.0, 1.0, 1.0);
}
if( nameWhateverYouWant_isExampleBool3 ){
smallCumulusCoverage = 0.0;
smallCumulusDensity = 0.2;
fogColor = vec3(1.0, 1.0, 1.0);
}
for color picking, the shader is mixing RGB values together. the values are in the 0.0 to 1.0 range instead of 0.0 to 255.0
example:
vec3 exampleColor1 = vec3(RedValue, GreenValue, BlueValue);
vec3 exampleColor2 = vec3(1.0, 0.724, 0.1114);
this is a handy tool for colorpicking in the correct number range: https://rgbcolorpicker.com/0-1
------------- STEP 4 -------------
save both files, and reload the shaderpack (you can click R or just enable/disable it).
that is the end of the guide.
=============== DEBUGGING ===============
for debugging shaders.properties, you will need to
1. look at the game's latest.log, it will spit errors out, while nothing apparent will be wrong in-game when reloading the shader
for debugging scene_controller.glsl,you will need to
1. open the shaderpacks selection menu
2. click the key combination CTRL + D and enable debug mode
3. if errors happen it will tell you whats wrong, kind of.
if you follow syntax it should not error, if it does, check for incorrect:
-spelling (capitalization, incorrect variable names)
-use of semicolons ; (they should be a stopper at the end-point of EVERY line of code but only in scene_controller.glsl. DO NOT use them like that in shaders.propertes, or it will error)
-use of brackets ()
-use of other brackets {}
=============== IMPORTANT NOTES ===============
different custom uniforms SHOULD NOT be allowed to return true at the same times, otherwise they will overwrite eachother in order of what is done last, reading from the top of the file to the bottom.
example:
if you make a custom uniform that returns true if the player is in the swamp, and a second different custom uniform that returns true when a player is above the Y coord of 40
if( isInSwampBiome ){
smallCumulusCoverage = 1.0;
smallCumulusDensity = 0.5;
}
if( isAboveYCoord ){
smallCumulusCoverage = 0.2;
smallCumulusDensity = 0.1;
}
THIS WILL CONFLICT if you are at the same time in a swamp, and above Y coord 40.
in this case, isAboveYCoord's settings wins and will overwrite isInSwampBiome's settings.
this will not cause an error or warning, its just how the math works and how the shader compiler reads the code.
YOU CANNOT ADD NEW PARAMETERS TO CONTROL, YOU ARE ONLY ABLE TO CONTROL PRE-EXISTING ONES
BECAUSE ADDING NEW ONES IS ALOT MORE COMPLEX AND REQUIRES KNOWING HOW TO CODE IN GLSL AND KNOWLEDGE OF HOW THE SHADER IS DESIGNED
===============================================================================================================================================================*/
//=============== DECLARE UNIFORMS BELOW HERE ===============
uniform int worldDay;
//=============== DECLARE UNIFORMS ABOVE HERE ===============
void applySceneControllerParameters(
out float smallCumulusCoverage, out float smallCumulusDensity,
out float largeCumulusCoverage, out float largeCumulusDensity,
out float altostratusCoverage, out float altostratusDensity,
out float fogA, out float fogB
){
// these are the default parameters if no "trigger" or custom uniform is being used.
// do not remove them
smallCumulusCoverage = CloudLayer0_coverage;
smallCumulusDensity = CloudLayer0_density;
largeCumulusCoverage = CloudLayer1_coverage;
largeCumulusDensity = CloudLayer1_density;
altostratusCoverage = CloudLayer2_coverage;
altostratusDensity = CloudLayer2_density;
fogA = 1.0;
fogB = 1.0;
//=============== CONFIGURE CUSTOM SCENE PARAMETERS BELOW HERE ===============
//=============== CONFIGURE CUSTOM SCENE PARAMETERS ABOVE HERE ===============
}
#endif
//====================================================================================================================================================================
//=============== EVERYTHING BELOW HERE IS NOT FOR CUSTOM SCENE CONTROLLER STUFF AND SHOULD NOT BE MODIFIED UNLESS YOU KNOW EXACTLY WHAT YOU ARE DOING ===============
//====================================================================================================================================================================
// write various parameters within singular pixels of a texture, which is a non-clearing buffer reprojecting the previous frame of itself, onto itself.
// this allows smooth interpolation over time from any old parameter value, to any new parameter value.
@ -73,4 +249,4 @@ void readSceneControllerParameters(
largeCumulus = vec2(data1.z,data2.x);
altostratus = vec2(data2.y,data2.z);
fog = vec2(0.0);
}
}

View File

@ -1,7 +1,14 @@
#=============== DECLARE CUSTOM UNIFORMS FOR THE SCENE CONTROLLER BELOW HERE ===============
#====================================================================================================================================================================
#=============== EVERYTHING BELOW HERE IS NOT FOR CUSTOM SCENE CONTROLLER STUFF AND SHOULD NOT BE MODIFIED UNLESS YOU KNOW EXACTLY WHAT YOU ARE DOING ===============
#====================================================================================================================================================================
clouds=off
stars=false
vignette=false
underwaterOverlay=false
dynamicHandLight=true
oldLighting=false