Procedurally varying fog

begla

Project Founder and Lead Developer
Contributor
Architecture
Logistics
I've just pushed a small rendering update including some optimizations, fixes and even some new stuff. I've added procedurally varying fog based on the time of the day and a noise function. The fog is limited during the night and increases during sunrise and dawn but is limited at night.

You can take a closer look at how the fog changes using the develop command for speeding up the world time. Here's a screenshot on a very, very foggy day. Maybe it can get even foggier than that. :pinkiecrazy:

Screen Shot 2012-06-19 at 01.46.18.png
 

begla

Project Founder and Lead Developer
Contributor
Architecture
Logistics
Screen Shot 2012-06-19 at 02.15.45.png
That one looks even nicer! Just wanted to make sure the applet is up-to-date and I've appeared in this beautiful seed there! :alien:
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
Nice! Good potential there :)

It can be very powerful in the current build, and for some reason triggers around high noon for me, or maybe a little past it, hard to tell at times since it gets so foggy :D

It also appears inside caves, hehe. I figure with some proper weather triggers the strong fog could be very nifty at times, and it could be useful for hiding the world edge

Game looks better overall, torches are working better again on nice and epic, still break due to a shader error on my box in ugly, alas :)
 

overdhose

Active Member
Contributor
Design
World
GUI
might be a problem on windhoze / my machine but this is what I get when I launch the applet, I tried different settings but they all had the same result :
fog1.pngfog2.png

*update : quickly fetched last commits and merged dev, same deal, I don't get fog :(
maybe a problem with nvidia / directx / amd ?
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
Fog only shows on Nice or Epic :)

I didn't see the quirky smeared blocks (Win7, Radeon), but I haven't tried the applet this time around
 

overdhose

Active Member
Contributor
Design
World
GUI
Like I said : I tried all settings :p

which is strange, because the second screenie is on ugly, so it shouldn't show fog all together then
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
Oh, sorry. Yeah, I figure those smeared blocks are independent of the fog. Any shader errors or anything in the logs?

Anyway, off to bed for tonight, will check again tomorrow!
 

overdhose

Active Member
Contributor
Design
World
GUI
did find some errors :
Code:
INFO: Loaded shader:engine:genericmesh
jun 19, 2012 7:09:59 AM org.terasology.rendering.assets.Shader verifyCompile
INFO: 0(76) : error C1008: undefined variable "smoothTriangleWave"
0(89) : error C1008: undefined variable "smoothTriangleWave"
0(90) : error C1008: undefined variable "smoothTriangleWave"
0(96) : error C1008: undefined variable "smoothTriangleWave"
0(96) : error C1008: undefined variable "smoothTriangleWave"
0(98) : error C1008: undefined variable "smoothTriangleWave"
 
jun 19, 2012 7:09:59 AM org.terasology.logic.manager.AssetManager loadAsset
INFO: Loaded shader:engine:chunk
jun 19, 2012 7:09:59 AM org.terasology.logic.manager.AssetManager loadAsset
INFO: Loaded shader:engine:sky
jun 19, 2012 7:09:59 AM org.terasology.logic.manager.AssetManager loadAsset
INFO: Loaded shader:engine:blur
jun 19, 2012 7:09:59 AM org.terasology.logic.manager.AssetManager loadAsset
INFO: Loaded shader:engine:defaulttextured
jun 19, 2012 7:09:59 AM org.terasology.logic.manager.AssetManager loadAsset
INFO: Loaded shader:engine:down
jun 19, 2012 7:09:59 AM org.terasology.logic.manager.AssetManager loadAsset
INFO: Loaded shader:engine:post
jun 19, 2012 7:09:59 AM org.terasology.logic.manager.AssetManager loadAsset
INFO: Loaded shader:engine:gelatinouscube
jun 19, 2012 7:09:59 AM org.terasology.rendering.assets.Shader verifyCompile
INFO: 0(82) : error C7011: implicit cast from "float" to "vec4"
0(82) : error C1103: too few parameters in function call
might also be due to my turtle model, although I think the smoothtriangle error is fog related
 

begla

Project Founder and Lead Developer
Contributor
Architecture
Logistics
Will look into this errors this evening (hopefully). The smoothTriangleWave errors are related to the waving grass. Those errors sometimes happen when the outsourced shader function files are not included at the right time.

Hiding fog in caves might become tricky, since this fog does not have an actual volume. The simplest solution would be to test the player's position. But this would disable fog when the player stands below a tree or a mountain edge. How does Minecraft solve this problem?
 

Immortius

Lead Software Architect
Contributor
Architecture
GUI
I get fog, but non-grass blocks are messed up in a variety of ways. Billboards are tinted green (including flowers), and dirt + water are noisy as shown above.
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
I don't think MC has true fog? Just the ever-present "hide the edge of the world" fog. And that does appear inside caves as well, tho sometimes you can't make it out really well unless you can look far enough to see the "sky" beyond the chunk limit or so to make it light up a bit.
 

overdhose

Active Member
Contributor
Design
World
GUI
strange, ignore my comment about not getting fog, must have been a problem with my machine this morning, I reloaded the world I created and had fog from the moment it loaded but yeah the glitches remain.
 

begla

Project Founder and Lead Developer
Contributor
Architecture
Logistics
Screen Shot 2012-06-19 at 21.07.58.png
I've reduced the overall fog intensity. Will look into fixing the other things this evening.

EDIT: But before that... Here's another nice shot.
 

begla

Project Founder and Lead Developer
Contributor
Architecture
Logistics
Uhm. Why are the shaders currently stored in two places? There is this new asset based shader variant and my own implementation. The new asset variant fails to compile because the shader include files are not appended or loaded correctly. But that seems to be no problem because my code still relies on my own shader programs. Uah!

Immortius - What's going on here? :)
 

metouto

Active Member
Contributor
Art
Screen Shot 2012-06-19 at 21.07.58.png


I think I have found and circled our problem :whistle: .... it is an Apache AHD64D Helicopter dropping supplies and men into begla's computer :sneaky: to mess up development of Terasology :omg: because other like games are jealous of how well we are doing this game :ninja: And to think they waited till fog was showing up :cry:
 

Immortius

Lead Software Architect
Contributor
Architecture
GUI
Uhm. Why are the shaders currently stored in two places? There is this new asset based shader variant and my own implementation. The new asset variant fails to compile because the shader include files are not appended or loaded correctly. But that seems to be no problem because my code still relies on my own shader programs. Uah!

Immortius - What's going on here? :)
It is only the global functions that are stored in two places, isn't it?

I'll explain it better tonight, but I added a material system that combines a shader + settings from user defined files to allow people to specify materials to apply to creatures (shader + texture). Didn't quite get around moving the older shaderparam stuff. If it even should be.
 

Immortius

Lead Software Architect
Contributor
Architecture
GUI
And now it is "tonight".

Uhm. Why are the shaders currently stored in two places? There is this new asset based shader variant and my own implementation. The new asset variant fails to compile because the shader include files are not appended or loaded correctly. But that seems to be no problem because my code still relies on my own shader programs. Uah!

Immortius - What's going on here? :)
At least some of the problem you are encountering is because the original shader system is reading the global includes from the shaders directory, while the new shader/material system reads it from the global includes in "org/terasology/include/" - this is simply because I forgot to go back and change the original shader system. :oops: I was moving the includes to a separate location because they are not shader assets.

Anyhow, a while back I did some work on the Asset system (extending off of t3hk0d3's work). The goal was to have support for the assets needed for allowing the addition of custom mesh, with minimal code required. These assets were Mesh, Shader, Texture and Material.

Textures were fairly simple, although I added the ability to have a json file with the same name as the image to provide additional settings - currently just the filter mode (Linear, Bilinear and Nearest) and wrap mode (repeat and clamp). However I wanted to go a little further than just having entities with a mesh component specifying a texture and it being hardcoded in the background to use a single shader, changing its texture params for each mesh.

So a Material asset describes a combination of a shader, and the settings for the shader's parameters including texture parameters. To feed into this I added a shader asset, which loads up the shader programs, as well as a json file describing what parameters the shader has (this could probably be improved). So this is the new Shader class. The individual shader programs are compiled, but aren't linked at this stage - instead the shader asset acts as a factory, producing the final shader program for any materials using it.

A Material asset brings it all together. A simple json format is used to specify the material:
Code:
{
    "shader" : "engine:genericMesh",
    "params" : {
        "diffuse" : "engine:mhead",
        "colorOffset" : [1.0, 1.0, 1.0],
        "textured" : true
    }
}
Then when the material is loaded, the shader is loaded, linked, and its parameters set. Because each material has a separate shader program, the parameters don't need to be changed unless the material's parameters are changed at runtime - which can be done through the Material's methods. The material is shared between all references to it, so any change to its parameters affects all of them - I've been tossing up whether there should be a mechanism for an entity to end up with an individual material instance, which would be useful if it can change independently of other users of the material.

Upshot of all this is that new mesh, textures, shaders and materials can be added, and applied to prefabs (and hence entities) without writing any code. Downside is I forgot to clean up properly afterwards.
 

Immortius

Lead Software Architect
Contributor
Architecture
GUI
Investigating the smeared blocks, isolated it to this block of code:

Code:
/* APPLY OVERALL BIOME COLOR OFFSET */
    if (!(texCoord.x >= grassCoordinate.x && texCoord.x < grassCoordinate.x + TEXTURE_OFFSET && texCoord.y >= grassCoordinate.y && texCoord.y < grassCoordinate.y + TEXTURE_OFFSET)) {
        if (gl_Color.rgb != vec3(1.0)) {
            color.rgb = color.r * gl_Color.rgb;
            color.a *= gl_Color.a;
        }
        else {
            color.rgb *= gl_Color.rgb;
            color.a *= gl_Color.a;
        }
Specifically:
Code:
if (gl_Color.rgb != vec3(1.0))
I guess there's a little noise in gl_Color under some systems? Using
Code:
if (gl_Color.r < 0.99 || gl_Color.g < 0.99 || gl_Color.b < 0.99 )
fixes it for me.

(Incidentally glIntercept is a great tool, lets you edit and compile shaders at runtime).
 
Top