Jump to content
  • Advertisement
  • entries
  • comments
  • views

Cascaded Light Propagation Volumes, VS RC 2015, Retarded Calculators + More stuff

Sign in to follow this  


Well, let's begin shall we! happy.png ( This article isn't very focused, it's just small notes and such )


For a while I've been thinking about working on cascaded light propagation volumes, so I finally did. For now I just have a 64 (detailed) + a 32 ( less detailed ) grid that are filled using the voxel caches. Although I have not worked on the energy ratio yet ( My solution is hacky ), I like the result.

(Images scaled to fit, originally rendered at resolution 1920x1080. The whitish color is because I've got some simple volumetric lighting going on, although it doesn't respond to the LPV yet) (PS. Still lots of work, so there are issues + light bleeding ) ( And there's no textures on the trees, for... reasons and stuff rolleyes.gif )

I've also worked on my BRDF shading model which is based on Disneys solution, and integrated my BRDF shading model into the LPV system ( Although it's a simplified version, as we don't need all the detail and some computations are meaningless in this context ). And I really think it made the indirect colors feel more part of the scene.

A poor quality gif showing how the light propagates through the scene:



On the complete other side, as I'm rewriting the engine I felt like upgrading to the RC Version of VS 2015 ( And dear god I recommend it to anyone ). And so I needed to recompile lots of libraries, such as SFML ( + most dependecies ), AntTweakBar, +small stuff. Now the AntTweakBar case was special, as it really only supports SFML 1.6. It contains a minified version of the SFML 1.6 events that it then uses, although when the memory layout changes in SFML 2.3 it all fucks up (Sorry). So I had to change some of the minified internal version of SFML to make it work, for anyone here is the modified part of the minified sfml (It's hackyish, mostly c&p from the sfml sources, so there's most likely errors and such, but for now it does the job ):namespace sf { namespace Key { enum Code { Unknown = -1, ///< Unhandled key A = 0, ///< The A key B, ///< The B key C, ///< The C key D, ///< The D key E, ///< The E key F, ///< The F key G, ///< The G key H, ///< The H key I, ///< The I key J, ///< The J key K, ///< The K key L, ///< The L key M, ///< The M key N, ///< The N key O, ///< The O key P, ///< The P key Q, ///< The Q key R, ///< The R key S, ///< The S key T, ///< The T key U, ///< The U key V, ///< The V key W, ///< The W key X, ///< The X key Y, ///< The Y key Z, ///< The Z key Num0, ///< The 0 key Num1, ///< The 1 key Num2, ///< The 2 key Num3, ///< The 3 key Num4, ///< The 4 key Num5, ///< The 5 key Num6, ///< The 6 key Num7, ///< The 7 key Num8, ///< The 8 key Num9, ///< The 9 key Escape, ///< The Escape key LControl, ///< The left Control key LShift, ///< The left Shift key LAlt, ///< The left Alt key LSystem, ///< The left OS specific key: window (Windows and Linux), apple (MacOS X), ... RControl, ///< The right Control key RShift, ///< The right Shift key RAlt, ///< The right Alt key RSystem, ///< The right OS specific key: window (Windows and Linux), apple (MacOS X), ... Menu, ///< The Menu key LBracket, ///< The [ key RBracket, ///< The ] key SemiColon, ///< The ; key Comma, ///< The , key Period, ///< The . key Quote, ///< The ' key Slash, ///< The / key BackSlash, ///< The \ key Tilde, ///< The ~ key Equal, ///< The = key Dash, ///< The - key Space, ///< The Space key Return, ///< The Return key BackSpace, ///< The Backspace key Tab, ///< The Tabulation key PageUp, ///< The Page up key PageDown, ///< The Page down key End, ///< The End key Home, ///< The Home key Insert, ///< The Insert key Delete, ///< The Delete key Add, ///< The + key Subtract, ///< The - key Multiply, ///< The * key Divide, ///< The / key Left, ///< Left arrow Right, ///< Right arrow Up, ///< Up arrow Down, ///< Down arrow Numpad0, ///< The numpad 0 key Numpad1, ///< The numpad 1 key Numpad2, ///< The numpad 2 key Numpad3, ///< The numpad 3 key Numpad4, ///< The numpad 4 key Numpad5, ///< The numpad 5 key Numpad6, ///< The numpad 6 key Numpad7, ///< The numpad 7 key Numpad8, ///< The numpad 8 key Numpad9, ///< The numpad 9 key F1, ///< The F1 key F2, ///< The F2 key F3, ///< The F3 key F4, ///< The F4 key F5, ///< The F5 key F6, ///< The F6 key F7, ///< The F7 key F8, ///< The F8 key F9, ///< The F9 key F10, ///< The F10 key F11, ///< The F11 key F12, ///< The F12 key F13, ///< The F13 key F14, ///< The F14 key F15, ///< The F15 key Pause, ///< The Pause key KeyCount ///< Keep last -- the total number of keyboard keys }; } namespace Mouse { enum Button { Left, ///< The left mouse button Right, ///< The right mouse button Middle, ///< The middle (wheel) mouse button XButton1, ///< The first extra mouse button XButton2, ///< The second extra mouse button ButtonCount ///< Keep last -- the total number of mouse buttons }; enum Wheel { VerticalWheel, ///< The vertical mouse wheel HorizontalWheel ///< The horizontal mouse wheel }; } namespace Sensor { enum Type { Accelerometer, ///< Measures the raw acceleration (m/s^2) Gyroscope, ///< Measures the raw rotation rates (degrees/s) Magnetometer, ///< Measures the ambient magnetic field (micro-teslas) Gravity, ///< Measures the direction and intensity of gravity, independent of device acceleration (m/s^2) UserAcceleration, ///< Measures the direction and intensity of device acceleration, independent of the gravity (m/s^2) Orientation, ///< Measures the absolute 3D orientation (degrees) Count ///< Keep last -- the total number of sensor types }; }; namespace Joy { enum Axis { X, ///< The X axis Y, ///< The Y axis Z, ///< The Z axis R, ///< The R axis U, ///< The U axis V, ///< The V axis PovX, ///< The X axis of the point-of-view hat PovY ///< The Y axis of the point-of-view hat }; enum { Count = 4, ButtonCount = 32 }; } typedef unsigned char Uint8; typedef unsigned int Uint32; class Event { public: struct SizeEvent { unsigned int Width, Height; }; struct KeyEvent { Key::Code Code; bool Alt, Control, Shift, System; }; struct TextEvent { Uint32 Unicode; }; struct MouseMoveEvent { int X, Y; }; struct MouseButtonEvent { Mouse::Button Button; int X, Y; }; struct MouseWheelEvent { int Delta, x, y; }; struct MouseWheelScrollEvent { Mouse::Wheel wheel; float Delta; int x, y; }; struct JoystickConnectEvent{ unsigned int joystickId; }; struct JoystickMoveEvent { unsigned int JoystickId; Joy::Axis Axis; float Position; }; struct JoystickButtonEvent { unsigned int JoystickId, Button; }; struct TouchEvent { unsigned int finger; ///< Index of the finger in case of multi-touch events int x; ///< X position of the touch, relative to the left of the owner window int y; ///< Y position of the touch, relative to the top of the owner window }; struct SensorEvent { Sensor::Type type; ///< Type of the sensor float x; ///< Current value of the sensor on X axis float y; ///< Current value of the sensor on Y axis float z; ///< Current value of the sensor on Z axis }; enum EventType { Closed, ///< The window requested to be closed (no data) Resized, ///< The window was resized (data in event.size) LostFocus, ///< The window lost the focus (no data) GainedFocus, ///< The window gained the focus (no data) TextEntered, ///< A character was entered (data in event.text) KeyPressed, ///< A key was pressed (data in event.key) KeyReleased, ///< A key was released (data in event.key) MouseWheelMoved, ///< The mouse wheel was scrolled (data in event.mouseWheel) (deprecated) MouseWheelScrolled, ///< The mouse wheel was scrolled (data in event.mouseWheelScroll) MouseButtonPressed, ///< A mouse button was pressed (data in event.mouseButton) MouseButtonReleased, ///< A mouse button was released (data in event.mouseButton) MouseMoved, ///< The mouse cursor moved (data in event.mouseMove) MouseEntered, ///< The mouse cursor entered the area of the window (no data) MouseLeft, ///< The mouse cursor left the area of the window (no data) JoystickButtonPressed, ///< A joystick button was pressed (data in event.joystickButton) JoystickButtonReleased, ///< A joystick button was released (data in event.joystickButton) JoystickMoved, ///< The joystick moved along an axis (data in event.joystickMove) JoystickConnected, ///< A joystick was connected (data in event.joystickConnect) JoystickDisconnected, ///< A joystick was disconnected (data in event.joystickConnect) TouchBegan, ///< A touch event began (data in event.touch) TouchMoved, ///< A touch moved (data in event.touch) TouchEnded, ///< A touch event ended (data in event.touch) SensorChanged, ///< A sensor value changed (data in event.sensor) Count ///< Keep last -- the total number of event types }; EventType Type; union { SizeEvent size; ///< Size event parameters (Event::Resized) KeyEvent key; ///< Key event parameters (Event::KeyPressed, Event::KeyReleased) TextEvent text; ///< Text event parameters (Event::TextEntered) MouseMoveEvent mouseMove; ///< Mouse move event parameters (Event::MouseMoved) MouseButtonEvent mouseButton; ///< Mouse button event parameters (Event::MouseButtonPressed, Event::MouseButtonReleased) MouseWheelEvent mouseWheel; ///< Mouse wheel event parameters (Event::MouseWheelMoved) (deprecated) MouseWheelScrollEvent mouseWheelScroll; ///< Mouse wheel event parameters (Event::MouseWheelScrolled) JoystickMoveEvent joystickMove; ///< Joystick move event parameters (Event::JoystickMoved) JoystickButtonEvent joystickButton; ///< Joystick button event parameters (Event::JoystickButtonPressed, Event::JoystickButtonReleased) JoystickConnectEvent joystickConnect; ///< Joystick (dis)connect event parameters (Event::JoystickConnected, Event::JoystickDisconnected) TouchEvent touch; ///< Touch events parameters (Event::TouchBegan, Event::TouchMoved, Event::TouchEnded) SensorEvent sensor; ///< Sensor event parameters (Event::SensorChanged) }; };} // namespace sf
On top of that the performance of my engine in VS 2015 strangely increased by a few milliseconds which really surprised me. I'm not completely sure what it is. And in VS 2013 I had a strangely huge overhead when starting my application inside VS which made the file io incredibly slow, in VS 2015 this issue is gone and this huge waiting time is gone ( 20 seconds to a minute... ) smile.png .

I finally got to redesign my gbuffer, and while there's lots of work to be done, it all fits nicely, general structure:2Channel: x = Depth, y = Packed(metallicness, anisotropicness),4Channel: xy = Normal, z = Packed(subsurface, thickness), w = Packed(specular, roughness)4Channel: xyz = Diffuse, z = Packed(clear_coat, emmision)
The tangent is then reconstructed later, and it's pretty cheap and works fine for my needs. Now all the user has to do is call GBuffer_Retrieve(...) from their shaders and then all the data is decompressed which they then can use, the final data container looks somewhat like the following:struct GBufferData{ float3 Diffuse; float3 PositionVS; float3 TangentVS; float3 NormalVS; float3 Position; float3 Normal; float3 Tangent; float SpecPower; float Roughness; float Metallic; float Emmision; float ClearCoat; float Anisotropic; float SubSurface; float Thickness;};
Now, you might say "But what if I don't want to use it all, huge overhead", which is true, but, compilers! The cute little compiler will optimize out any computations that aren't needed, so if you don't need a certain element decompressed, it wont be (Yay)! So all of that fits together nicely.

But at the same time I think I've got an issue with the performance concerning filling the gbuffer stage, as it's huge compared to everything else. Perhaps it's the compression of the gbuffer, not sure yet.

But, it's acceptable for now, although I think I can squeeze some cute little milliseconds out of it happy.png .

On a side note I've also been trying to work on some basic voxel cone tracing but it's far from done. And I seriously underestimated the performance issues, but it's pretty fun.


Now due to family related issues I had to take my brother to our beach house ( Nothing fancy ), and there I allocated some time to work on my retarded calculator! It's a small application based on a very basic neural network, I didn't have time to work on my bias nodes or even my activation function, for now the output of the neuron is simply weight * data, although it actually produces acceptable results. The network is composed of 4 layers:

  • 10 Neurons
  • 7 Neurons
  • 5 Neurons
  • 1 Neuron

    Again, this was just for fun, I didn't even adapt the learning rate during the back propagation, it was just to fill out a bit of time. The output from the application:Starting trianing of neural network Train iteration complete, error 0.327538 Train iteration complete, error 0.294999 Train iteration complete, error 0.266 Train iteration complete, error 0.240112 Train iteration complete, error 0.216965 Train iteration complete, error 0.196237 Train iteration complete, error 0.177651 Train iteration complete, error 0.160962 Train iteration complete, error 0.145959 Train iteration complete, error 0.132454 Train iteration complete, error 0.120285 ......... a few milliseconds later Training completed, error falls within treshold of 1e-06!=============================== Final testing stage Feeding forward the neural network Final averaged testing error: 0.0178298===============================Please enter a command...>> f var(a0) Input: #0 -> 2 #1 -> 4 #2 -> 3 #3 -> 1 #4 -> 4 #5 -> 5 #6 -> 2 #7 -> 3 #8 -> 4 #9 -> 1 Feeding forward the neural network Layer Dump: #0 = 29.346>> e var(a0) algo({sum(I)}) Evaluating error: (a0) Error: 0.345961


    So, overall, I'm pretty happy with it all. But I haven't been able to allocate enough time ( You know, life and stuff, school or whatever everybody suddenly expects of you ). But if anybody is reading this, can you comment on the colors of the images, meaning do you find it natural or cartoony, I find them a bit cartoony. Well, thanks for even reaching the bottom! laugh.png

Sign in to follow this  


Recommended Comments

The PPP (pretty-picture-poster) is back :D


About your G-Buffer: Why do you have explicite depth ? Can't you use the depth buffer ?

Share this comment

Link to comment

The PPP (pretty-picture-poster) is back biggrin.png


About your G-Buffer: Why do you have explicite depth ? Can't you use the depth buffer ?


:P. I didn't even think of that, I'll give it a go!

Share this comment

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!