vanilladocs
vanillapunch.com
API / core/fullscreenpass

core/fullscreenpass

풀스크린 패스. (화면 전체를 덮는 삼각형 1개 + 프래그먼트 셰이더)

Fullscreen pass. (one triangle covering the whole screen + fragment shader)

FullscreenPassextends Object

짝Counterpart: vanilla-engine FullscreenPass

풀스크린 패스. (화면 전체를 덮는 삼각형 1개 + 프래그먼트 셰이더)

  • 배경 / 포스트 프로세싱 등 화면 단위 효과의 기본 단위.

Fullscreen pass. (one triangle covering the whole screen + fragment shader)

  • The basic unit of screen level effects such as backgrounds / post processing.
예제Example프래그먼트 셰이더 하나로 화면 채우기Fill the screen with a single fragment shader
import { FullscreenPass } from "./build/vanilla.js";

const width = 320;
const height = 180;
const canvas = document.createElement("canvas");
canvas.width = width;
canvas.height = height;
document.body.appendChild(canvas);
const webGL2RenderingContext = canvas.getContext("webgl2");
const fragmentShaderSource = `#version 300 es
precision highp float;
in vec2 fragmentTextureCoordinate;
uniform vec3 tintColor;
out vec4 outputColor;
void main() {
	outputColor = vec4(fragmentTextureCoordinate * tintColor.rg, tintColor.b, 1.0);
}
`;
const fullscreenPass = new FullscreenPass(webGL2RenderingContext, fragmentShaderSource);
webGL2RenderingContext.viewport(0, 0, width, height);
fullscreenPass.useProgram();
const tintColorLocation = fullscreenPass.getUniformLocation("tintColor");
webGL2RenderingContext.uniform3f(tintColorLocation, 1.0, 0.6, 0.3);
fullscreenPass.draw();
const errorCode = webGL2RenderingContext.getError();
console.log(errorCode === webGL2RenderingContext.NO_ERROR);
생성자constructorconstructor(webGL2RenderingContext, fragmentShaderSource)#0.3.0 부터since 0.3.0소스source

생성.

Constructor.

webGL2RenderingContextWebGL2RenderingContext
WebGL2 렌더링 컨텍스트.WebGL2 rendering context.
fragmentShaderSourcestring
프래그먼트 셰이더 GLSL ES 3.00 소스. (앞뒤 공백은 잘라 쓴다, in 으로 fragmentCoordinate(-1 ~ 1) 와 fragmentTextureCoordinate(0 ~ 1) 를 받는다)Fragment shader GLSL ES 3.00 source. (leading and trailing whitespace is trimmed, receives fragmentCoordinate (-1 ~ 1) and fragmentTextureCoordinate (0 ~ 1) as in)

짝Counterpart: vanilla-engine FullscreenPass.new

메서드methoduseProgram()#0.4.0 부터since 0.4.0소스source

패스 사용 시작. (프로그램 + 빈 버텍스 어레이 바인드, 러스트 판 use_program 과 같다)

Starts using the pass. (Binds the program and an empty vertex array, same as Rust use_program)

짝Counterpart: vanilla-engine FullscreenPass.use_program

메서드methoddraw()#0.3.0 부터since 0.3.0소스source

출력. (use() 와 유니폼 설정 이후 호출)

Render. (Call after use() and setting uniforms)

짝Counterpart: vanilla-engine FullscreenPass.draw

메서드methodgetUniformLocation(uniformName)#0.3.0 부터since 0.3.0소스source

유니폼 로케이션 반환. (캐시)

Returns the uniform location. (cached)

uniformNamestring
유니폼 이름.Uniform name.

반환ReturnsWebGLUniformLocation 유니폼 위치. (셰이더에 없으면 null)Uniform location. (null when not in the shader)

짝Counterpart: vanilla-engine FullscreenPass.get_uniform_location

메서드methodgetWebGL2RenderingContext()#0.3.0 부터since 0.3.0소스source

렌더링 컨텍스트 반환.

Returns the rendering context.

반환ReturnsWebGL2RenderingContext 렌더링 컨텍스트.Rendering context.

메서드methodgetShaderProgram()#0.3.0 부터since 0.3.0소스source

셰이더 프로그램 반환.

Returns the shader program.

반환ReturnsShaderProgram 풀스크린 버텍스 셰이더와 받은 프래그먼트 셰이더를 링크한 프로그램.Program linking the fullscreen vertex shader with the given fragment shader.

짝Counterpart: vanilla-engine FullscreenPass.get_shader_program

메서드methodgetVertexArray()#0.3.0 부터since 0.3.0소스source

버텍스 어레이 반환.

Returns the vertex array.

반환ReturnsWebGLVertexArrayObject 버퍼 없는 빈 버텍스 어레이. (정점은 gl_VertexID 로 셰이더가 만든다)Empty vertex array without buffers. (the shader builds vertices from gl_VertexID)

짝Counterpart: vanilla-engine FullscreenPass.get_vertex_array

메서드methoddestroy()#0.4.0 부터since 0.4.0소스source

파괴. (셰이더 프로그램과 버텍스 어레이를 지운다)

Destroy. (Deletes the shader program and vertex array)

짝Counterpart: vanilla-engine FullscreenPass.destroy