Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Writing a postprocess effect

Mikulas Florek edited this pageApr 12, 2020 ·1 revision
  1. duplicate filepipelines/fxaa.lua, let's call itpipelines/test.lua
  2. open the lua file and change the postprocess function to following:
functionpostprocess(env,transparent_phase,ldr_buffer,gbuffer0,gbuffer1,gbuffer_depth,shadowmap)ifnotenabledthenreturnldr_bufferendiftransparent_phase~="post_tonemap"thenreturnldr_bufferendlocalres=env.createRenderbuffer(1,1,true,"rgba8","test")env.beginBlock("test")iftest_shader==nilthentest_shader=env.preloadShader("pipelines/test.shd")endenv.setRenderTargets(res)env.drawArray(0,4,test_shader, {ldr_buffer },{},{},{depth_test=false,blending=""})env.endBlock()returnresend

As you can see, everyfxaa string was replaced withtest string.3. create filepipelines/test.shd with following content

vertex_shader[[out vec2 v_uv;void main(){v_uv = vec2(gl_VertexID & 1, (gl_VertexID & 2) * 0.5);gl_Position = vec4((gl_VertexID & 1) * 2 - 1, (gl_VertexID & 2) - 1, 0, 1);}]]fragment_shader[[in vec2 v_uv;out vec4 o_color;void main(){o_color.xyz = vec3(0, 0, 0);o_color.w = 1 - length(v_uv - vec2(0.5));}]]
  1. add a new lua script component to your scene and usepipelines/test.lua as its source

If everything goes ok, you should see your postprocess effect - black in the center of scene view and white on edges.

Clone this wiki locally

[8]ページ先頭

©2009-2025 Movatter.jp