[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4280: ob_start(): output handler 'ob_gzhandler' conflicts with 'zlib output compression'
Oolite Bulletins • Shaders’ Outpost - Page 29
Page 29 of 29

Re: Shaders’ Outpost

Posted: Mon Sep 10, 2018 8:09 pm
by gsagostinho
@another_commander thank you so much!

Re: Shaders’ Outpost

Posted: Wed Sep 12, 2018 3:06 pm
by smcameron
gsagostinho wrote:
Tue Jul 18, 2017 12:26 pm
As some of you know, I have been working on an update for the System Features Rings OXP and there were some discussion about it in the Screenshots thread starting with this post. Because the discussion was out of topic over there (sorry again!), I thought of continuing it here. I currently have three issues that I would like to solve/improve and I would greatly appreciate some advice:

- drawing distance seems to be set at 2.7 OU, at which points the rings pop out of existance. Apparently this would have to be modified in the core code of the game.

- applying opacity < 1.0 to rings: no matter what value I use as the last argument of gl_FragColor. Some people told me that I can't have transparency in Oolite. Others told me to look at the atmosphere fragment shader, but I can't understand why the transparency works there and not with the rings shader. I have also read online that one must enable blending in order to work with opacity, but I am an utter complete GLSL noob and I don't know what that means nor how to accomplish it.

- a minor thing, but would someone here perhaps know how to improve the Moire patterns that the rings display?
Hi, I'm new here, and I am reviving a topic that's more than a year old, but perhaps it will be interesting anyway. I have spent some time working on rings in my own open source space game, and I can describe what I did for that. Perhaps some of it will be useful in Oolite as well. I was largely inspired by this amazing video: https://www.youtube.com/watch?v=UgxWkOXcdZU which is supposedly made from photographs of Saturn taken by the Cassini probe, which is to say, it's not CGI.

There are a couple interesting things I noticed about this video.

1) The rings tend to be either fully opaque, or have fully transparent gaps (opacity tends to be either 1.0 or 0.0, with little in the way of translucent sections.)

2) The two sides of the rings are not the same. One side is in shadow, and is darker (but not fully dark) and one side is in sun, and is brighter.

As for the opacity, I was a little reluctant to discard translucency entirely, since while it may be the case that Saturn has little in the way of translucent rings, other imaginary planets might be different. Nevertheless, I did make the rings tend a bit towards opacity. What I really did was link the opacity to the brightness, more or less, of the underlying texture, so that lighter areas of the rings were more opaque, and darker areas more transparent (this alpha manipulation is baked into the texture).

As for the two sides, in my ring shader (I have a shader specifically for rings), I determine the plane of the ring, and determine which side of this plane the camera is on, and which side of this plane the light source resides. If the camera and the light source are on the same side, then we are looking at the bright side of the ring. If the camera and the light source are on opposite sides of the plane, then we are looking at the dark side, and the brightness is attenuated.

As for the moire effect, what I did is use essentially a 1 dimensional texture, which defines a cross section of the ring. Actually, I used a 2 dimensional texture, but each ring uses only a single texel wide slice of this texture. That way I can cram 512 different ring textures into a single 512x512 image, and it's high enough resolution that I don't seem to have too much problems with moire, or rather, the way the texture is sampled, the moire doesn't seem to happen. In the fragment shader, I compute the distance from the center of the ring, and use this to index into one axis of the texture (the other axis is held constant -- but a different constant for each planet's ring.) And also in the ring fragment shader, I shoot a ray back towards the light source to see if it intersects the planet, and thus get the planet's shadow onto the ring. And in the planet fragment shader, I find the intersection of a ray from the planet surface to the light source with the ring, and sample the ring texture to allow casting the shadow of the ring onto the planet in a way that matches the rings. I also put a little bit of specular reflection on the ring.

Results look like the links below. The first two show the same planet from different angles, showing the light and dark side of the ring, the 3rd shows some specular reflection.




Ring shader: https://github.com/smcameron/space-nerd ... xel.shader
Planet shader: https://github.com/smcameron/space-nerd ... xel.shader

Perhaps some of these ideas will find their way into Oolite in some form or another.

Re: Shaders’ Outpost

Posted: Wed Sep 12, 2018 3:15 pm
by gsagostinho
Hi smcameron, thank you so much for your post! Your works looks really good. The problem I ran when I was working on that shader was that it was not possible to use transparencies, only full 1.0 or 0.0. The result I manage to get looks like this: http://aegidian.org/bb/viewtopic.php?f= ... 75#p258675 I am super busy with RL at the moment but please feel free to try to improve what I created in the rings OXP. Cheers!

Re: Shaders’ Outpost

Posted: Wed Sep 12, 2018 7:50 pm
by another_commander
Those rings look very cool. Thanks for the pointers to the shaders. I will definitely have a closer look at what they do as soon as I get a chance.

Re: Shaders’ Outpost

Posted: Sun Oct 28, 2018 6:26 pm
by another_commander
In today's nightly we have a small experiment: filmic tonemapping. This is something really neat and it mostly works with HDR assets. However, it seems that it does really well with Oolite, so here it goes. If you want to know more about filmic tonemapping, there is a really good presentation by one of Naughty Dog's developers here; jump to around minute 26 for the relevant parts.

Essentially, instead of simply applying normal gamma correction at the end of our shader, we apply this totally magical formula:

Code: Select all

vec4 x = max(vec4(0.0), totalColor - 0.004);
totalColor = (x * (6.2 * x + 0.5)) / (x * (6.2 * x + 1.7) + 0.06);
This has the gamma correction already baked in and generates very vivid colors and great dark tones. Have a go with the latest nightly and let us know what you think. Here are screenies comparing our current system (above) against filmic tonemapping (below).


Re: Shaders’ Outpost

Posted: Wed Dec 19, 2018 4:12 pm
by Griff
that looks really nice, it really helps brings out the colour in that lovely planet texture. fab metallic sheen on the cobra3 as well - Oolite is looking really awesome - stunning work A_C :)