Jump to content

[Request] Add Black hole shader


Gotbread

Recommended Posts

Hello fellow Kerbonauts! :)

 

I have been playing with Kerbal Galaxy 2, but one thing really bugged me. Yeah, this thing

 

MH9mGz6.png

 

This should be a black hole but...

 

So i wrote something better :)

 

Taking the Black hole Gargantua from the movie Interstellar as an example:

 

This comes from a realtime relativistic raytracer. The path of the light is derived from the schwarzschild metric so this is as accurate as it can get.

Here is the Source code and Executable for anyone interested. Be aware that this shader needs quite a powerfull graphics card to run in realtime.

If your card struggles with this, just hold down CTRL while starting the executable. It will run in a smaller windowed mode which does not use as

much resources as the fullscreen version. Controls are WASDE to move around, QE for up and down, RF to rotate the camera,

Hold down SHIFT to increase moving speed. Hold down CTRL to increase moving speed more. Hold down SHIFT and CTRL to increase

moving speed even more.

 

And for the extra curious, press SPACE to shoot a colored ray from the cameras position. This ray will not be affected and shows the path though

space (which is unphysical but helps to visualize). Full source code is attached, you need a C++ compiler and a DirectX sdk which includes DirectX11.

 

The renderer uses a (procedural) spherical object which has a custom shader. This shader does the raytracing. The image is rendered into a offscreen

buffer and used with a fullscreen effect shader to apply the bloom effect in a second pass.

 

Now for the request part:

 

I dont know enough about unity and C# to implement this myself. I saw Tuareg has written a Custom Shader Loader so this should in principle be possible.

Ideally you would replace the black hole object in kerbal galaxy with a spherical dummy object and apply the provided shader to it. The second bloom-pass

would be very nice, as it helps to underline the effect, but is not top priority.

The whole thing is intended as an addon for kerbal galaxy, to get the improved effect while keeping the rest the same.

 

I would also be thankful for any resources helping me to implement this, like how to create and use a shader in unity.

 

License

Edited by Gotbread
Link to comment
Share on other sites

  • 3 weeks later...
This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...