Jump to content

[Question] How to apply post processing to KSP Flight scene camera


Recommended Posts

I have created a button which displays on the Main GUI during the flight scene. When this button is pressed, I would like to apply a post processing shader to the entire final rendered scene, including ships, scenery.. everything.

Right now I have created a Material object and passed in the string contents of the CG shader.

I then call Graphic.Blit like this:

void OnRenderImage(RenderTexture source, RenderTexture dest)

{

if (currentMaterial != null)

{

Graphics.Blit(source, dest, currentMaterial);

}

}

currentMaterial is set to the shader material upon the press of the button.

For some reason however, pressing the button, while showing that the correct code segment has been reached via some debugging in the log, no post processing effects occur on the main camera.

Anyone have insight into this?

Link to comment
Share on other sites

Maybe that is the problem. I didn't actually try to grab any camera. I attempted to apply it simply using Graphics.Blit()

I did do one attempt using a slightly different method where I used transform.camera.SetReplacementShader, but I was unable to figure out how to implement the shader itself using this method. I can define a shader in C# by passing the shader contents in as a string to a new Material object, but the SetReplacementShader method does not accept string contents like the Material object does. I'm hoping someone has experience with something like this and can give some clues as to how they implemented it.

Link to comment
Share on other sites

Take a look at this: http://docs.unity3d.com/Documentation/ScriptReference/GameObject.AddComponent.html

It's the Unity Script Reference page for adding components through script, so all you have to do is find the correct camera and add an image effect component (KSP should have them imported...) via this method to add the post processing. You may have to tinker around with implementing the image effect components into the plugin if KSP doesn't have them.

There's most certainly other ways to do it, and since plugin developers have to publicize their source code you can take a look at the Lazor System code to see how Romfarer applies the black/white effect to the docking camera.

Link to comment
Share on other sites

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...