Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
Hey! I made a game that I almost finished, and here I just added some effects so that the game is a little bit nicer, and I would like to add some chromatic aberration to it but I don't know how to do that. Can someone help me? |
||||
|
Use shaders or screen shaders extension by JIC you need to modify it though. |
||||
|
Do you want to achieve something like that? I've only made it for OpenGL, since I'm not that familiar with hlsl. But the approach will be the same. 1. You need to setup a full screen "filter node" on top of your camera. Just refer to JIC's video here: https://youtu.be/mpHAUPlb71w?t=1... Since I'm using OpenGl I also had to flip mesh normal (right click on the mesh -> modify selection -> flip direction of all faces) and set Z scale to -2.91. And change publish setting renderer to OpenGL. 2. Write an action that uses render to texture to render your camera view to the "filter node", and shader which adds CA effect to it. 2.1 Use RTT function to render to texture: ccbRegisterOnFrameEvent(function () { Notice that this could be optimized by storing screen height, width, filter node as variables or using JS closure to generate this function. Also notice that RTT function only works inside onFrameEvent, it could not be added to behavior onAnimate. 2.2 Shader. I simply copied glsl vertex shader from here: https://www.ambiera.com/coppercu.... Fragment shader shifts red and blue uv texture coordinate to -0.005 and 0.005 on x axis correspondingly. I came up with the following: version 130 Which is also might be not the most efficient way to do that. Now you combine everything in one action, and add it to "before first draw" behavior of your root node. |
||||
|
// The following embedded xml is for the editor and describes how the action can be edited: You do it pretty much the same way for DX, but write shader using hlsl of course. Demo project here:https://drive.google.com/file/d/... |
||||
|
I revisited this today, damn it looks ugly:) It looked much better on a bigger screen. But the approach is still correct I believe, you just need to rewrite the shader properly. |
||||
|
Will this oke oke ever be released for exe. And also thanks to the community that you work for the common good thanks from everyone who is grateful (google translate). |
|