mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-18 11:54:59 -04:00
fog
This commit is contained in:
parent
427c3283cb
commit
fba9c24c8b
@ -52,7 +52,7 @@ In the root folder of your jar file (the mod) must be a file called `mod.json`.
|
|||||||
- `version_name`, `authors` and `name` is the classic implementation of metadata. Can be anything, will be displayed in the mod list. **Required**
|
- `version_name`, `authors` and `name` is the classic implementation of metadata. Can be anything, will be displayed in the mod list. **Required**
|
||||||
- `modding_api_version` Modding API version of minosoft. Currently `1` **Required**
|
- `modding_api_version` Modding API version of minosoft. Currently `1` **Required**
|
||||||
- `resource_namespace` is the prefix of items (for Minecraft it is `minecraft`). Aka the thing before the `:`. **Required**
|
- `resource_namespace` is the prefix of items (for Minecraft it is `minecraft`). Aka the thing before the `:`. **Required**
|
||||||
- `main_class` the Main class of your mod (self explaining). The main class needs to extent the abstract class `MinosoftMod`. **Required**
|
- `main_class` the Main class of your mod (self explaining). The main class needs to extend the abstract class `MinosoftMod`. **Required**
|
||||||
- `loading` Loading attributes. **Optional**
|
- `loading` Loading attributes. **Optional**
|
||||||
- `priority` should the mod be loaded at the beginning or at the end. Possible values are `LOWEST`, `LOW`, `NORMAL`, `HIGH`, `HIGHEST` **Optional**
|
- `priority` should the mod be loaded at the beginning or at the end. Possible values are `LOWEST`, `LOW`, `NORMAL`, `HIGH`, `HIGHEST` **Optional**
|
||||||
- `dependencies` Used if you need another mod to work **Optional**
|
- `dependencies` Used if you need another mod to work **Optional**
|
||||||
|
@ -34,7 +34,7 @@ enum class KeyAction {
|
|||||||
// custom ones
|
// custom ones
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Key must be hold in addition to a other action
|
* Key must be hold in addition to another action
|
||||||
*/
|
*/
|
||||||
MODIFIER,
|
MODIFIER,
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ class MatrixHandler(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun calculateProjectionMatrix(screenDimensions: Vec2 = renderWindow.window.sizef) {
|
private fun calculateProjectionMatrix(screenDimensions: Vec2 = renderWindow.window.sizef) {
|
||||||
projectionMatrix = glm.perspective(fov.rad.toFloat(), screenDimensions.x / screenDimensions.y, 0.01f, 10000.0f)
|
projectionMatrix = glm.perspective(fov.rad.toFloat(), screenDimensions.x / screenDimensions.y, 0.01f, 1000.0f)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun init() {
|
fun init() {
|
||||||
|
@ -13,9 +13,12 @@ class OpenGLFramebufferDepthTexture(
|
|||||||
id = glGenTextures()
|
id = glGenTextures()
|
||||||
glBindTexture(GL_TEXTURE_2D, id)
|
glBindTexture(GL_TEXTURE_2D, id)
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, size.x, size.y, 0, GL_DEPTH_COMPONENT, GL_FLOAT, null as ByteBuffer?)
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, size.x, size.y, 0, GL_DEPTH_COMPONENT, GL_FLOAT, null as ByteBuffer?)
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL)
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_NONE)
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_NONE)
|
||||||
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)
|
||||||
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
|
||||||
}
|
}
|
||||||
|
@ -20,16 +20,34 @@ out vec4 foutColor;
|
|||||||
uniform sampler2D uColor;
|
uniform sampler2D uColor;
|
||||||
uniform sampler2D uDepth;
|
uniform sampler2D uDepth;
|
||||||
|
|
||||||
|
uniform float uFogStart = 60.0f;
|
||||||
|
uniform float uFogEnd = 75.0f;
|
||||||
|
|
||||||
|
#define NEAR_PLANE 0.01f
|
||||||
|
#define FAR_PLANE 1000.0f
|
||||||
|
|
||||||
|
float linearize_depth(float depth) {
|
||||||
|
return (2.0f * NEAR_PLANE * FAR_PLANE) / (FAR_PLANE + NEAR_PLANE - (depth * 2.0f - 1.0f) * (FAR_PLANE - NEAR_PLANE));
|
||||||
|
}
|
||||||
|
|
||||||
|
float calulate_fog_alpha(float depth) {
|
||||||
|
if (depth < uFogStart){
|
||||||
|
return 1.0f;
|
||||||
|
}
|
||||||
|
if (depth > uFogEnd){
|
||||||
|
discard;
|
||||||
|
}
|
||||||
|
|
||||||
|
return pow(1.0f - (depth - uFogStart) / (uFogEnd - uFogStart), 2);
|
||||||
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
vec4 color = texture(uColor, finUV);
|
vec4 color = texture(uColor, finUV);
|
||||||
if (color.a == 0.0f) {
|
if (color.a == 0.0f) {
|
||||||
discard;
|
discard;
|
||||||
}
|
}
|
||||||
float depth = texture(uDepth, finUV).r;
|
float depth = linearize_depth(texture(uDepth, finUV).x);
|
||||||
foutColor = vec4(color.xyz, depth);
|
float alpha = calulate_fog_alpha(depth);
|
||||||
|
|
||||||
if (foutColor.a == 0.0f) {
|
foutColor = vec4(color.xyz, alpha);
|
||||||
discard;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
uniform sampler2DArray uTextures[7];
|
uniform sampler2DArray uTextures[7];
|
||||||
|
|
||||||
vec4 getTexture(uint textureId, vec3 uv) { // ToDo: This method is just stupid and workarounds a opengl crash with mesa drivers
|
vec4 getTexture(uint textureId, vec3 uv) { // ToDo: This method is just stupid and workarounds an opengl crash with mesa drivers
|
||||||
#if defined __NVIDIA || defined __AMD
|
#if defined __NVIDIA || defined __AMD
|
||||||
return texture(uTextures[textureId], uv);
|
return texture(uTextures[textureId], uv);
|
||||||
#else
|
#else
|
||||||
@ -30,7 +30,7 @@ vec4 getTexture(uint textureId, vec3 uv) { // ToDo: This method is just stupid a
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
vec4 getTexture(uint textureId, vec3 uv, float mipmapLevel) { // ToDo: This method is just stupid and workarounds a opengl crash with mesa drivers
|
vec4 getTexture(uint textureId, vec3 uv, float mipmapLevel) { // ToDo: This method is just stupid and workarounds an opengl crash with mesa drivers
|
||||||
#if defined __NVIDIA || defined __AMD
|
#if defined __NVIDIA || defined __AMD
|
||||||
return textureLod(uTextures[textureId], uv, mipmapLevel);
|
return textureLod(uTextures[textureId], uv, mipmapLevel);
|
||||||
#else
|
#else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user