Uniforms types

Mr.doob edited this page on 23 Aug 2014 · 12 revisions

These mappings are also available since r68:

switch ( type ) {

	case '1i':
		_gl.uniform1i( location, value );
		break;

	case '1f':
		_gl.uniform1f( location, value );
		break;

	case '2f':
		_gl.uniform2f( location, value[ 0 ], value[ 1 ] );
		break;

	case '3f':
		_gl.uniform3f( location, value[ 0 ], value[ 1 ], value[ 2 ] );
		break;

	case '4f':
		_gl.uniform4f( location, value[ 0 ], value[ 1 ], value[ 2 ], value[ 3 ] );
		break;

	case '1iv':
		_gl.uniform1iv( location, value );
		break;

	case '3iv':
		_gl.uniform3iv( location, value );
		break;

	case '1fv':
		_gl.uniform1fv( location, value );
		break;

	case '2fv':
		_gl.uniform2fv( location, value );
		break;

	case '3fv':
		_gl.uniform3fv( location, value );
		break;

	case '4fv':
		_gl.uniform4fv( location, value );
		break;

	case 'Matrix3fv':
		_gl.uniformMatrix3fv( location, false, value );
		break;

	case 'Matrix4fv':
		_gl.uniformMatrix4fv( location, false, value );
		break;

}

These still work:

var uniformsExample = {

"uInt" :  { type: "i", value: 1 },     // single integer
"uFloat" : { type: "f", value: 3.14 }, // single float

"uVec2" : { type: "v2", value: new THREE.Vector2( 0, 1 ) },       // single Vector2
"uVec3" : { type: "v3", value: new THREE.Vector3( 0, 1, 2 ) },    // single Vector3
"uVec4" : { type: "v4", value: new THREE.Vector4( 0, 1, 2, 3 ) }, // single Vector4

"uCol" : { type: "c", value: new THREE.Color( 0xffaa00 ) }, // single Color

"uMat4" : { type: "m4", value: new THREE.Matrix4() }, // single Matrix4

/*
// till r50
"uTex" :     { type: "t", value: 0, texture: THREE.ImageUtils.loadTexture( "texture.jpg" ) }, // regular texture
"uTexCube" : { type: "t", value: 1, texture: THREE.ImageUtils.loadTextureCube( [ "px.jpg", "nx.jpg", // cube texture
                                                                                 "py.jpg", "ny.jpg", 
                                                                                 "pz.jpg", "nz.jpg" ] ) },
*/

// since r51
"uTex" :     { type: "t", value: THREE.ImageUtils.loadTexture( "texture.jpg" ) }, // regular texture
"uTexCube" : { type: "t", value: THREE.ImageUtils.loadTextureCube( [ "px.jpg", "nx.jpg", // cube texture
                                                                     "py.jpg", "ny.jpg", 
                                                                     "pz.jpg", "nz.jpg" ] ) },

"uIntArray"  : { type: "iv1", value: [ 1, 2, 3, 4, 5 ] },    // integer array (plain)
"uIntArray3" : { type: "iv", value: [ 1, 2, 3, 4, 5, 6 ] },   // integer array (ivec3)

"uFloatArray"  : { type: "fv1", value: [ 0.1, 0.2, 0.3, 0.4, 0.5 ] },    // float array (plain)
"uFloatArray3" : { type: "fv",  value: [ 0.1, 0.2, 0.3, 0.4, 0.5, 0.6 ] }, // float array (vec3)

"uVec2Array" : { type: "v2v", value: [ new THREE.Vector2( 0.1, 0.2 ), 
                                       new THREE.Vector2( 0.4, 0.5 ) ] }, // Vector2 array

"uVec3Array" : { type: "v3v", value: [ new THREE.Vector3( 0.1, 0.2, 0.3 ), 
                                       new THREE.Vector3( 0.4, 0.5, 0.6 ) ] }, // Vector3 array

"uVec4Array" : { type: "v4v", value: [ new THREE.Vector4( 0.1, 0.2, 0.3, 0.4 ), 
                                       new THREE.Vector4( 0.4, 0.5, 0.6, 0.7 ) ] }, // Vector4 array

"uMat4Array" : { type: "m4v", value: [ new THREE.Matrix4(), new THREE.Matrix4() ] }, // Matrix4 array

"uTexArray" : { type: "tv", value: [ new THREE.Texture(), new THREE.Texture() ] } // texture array (regular)
                                                                                              // texture units start from value

};

Shader (GLSL)

경축! 아무것도 안하여 에스천사게임즈가 새로운 모습으로 재오픈 하였습니다.
어린이용이며, 설치가 필요없는 브라우저 게임입니다.
https://s1004games.com

uniform int uInt;
uniform float uFloat;

uniform vec2 uVec2;
uniform vec3 uVec3;
uniform vec4 uVec4;

uniform vec3 uCol;

uniform mat4 uMat4;

uniform sampler2D uTex;
uniform samplerCube uTexCube;

uniform int uIntArray[ 5 ];
uniform ivec3 uIntArray3[ 2 ];

uniform float uFloatArray[ 5 ];
uniform vec3 uFloatArray3[ 2 ];

uniform vec2 uVec2Array[ 2 ];
uniform vec3 uVec3Array[ 2 ];
uniform vec4 uVec4Array[ 2 ];

uniform mat4 uMat4Array[ 2 ];

uniform sampler2D uTexArray[ 2 ];

 

[출처] https://github.com/mrdoob/three.js/wiki/Uniforms-types

 

 

본 웹사이트는 광고를 포함하고 있습니다.
광고 클릭에서 발생하는 수익금은 모두 웹사이트 서버의 유지 및 관리, 그리고 기술 콘텐츠 향상을 위해 쓰여집니다.
번호 제목 글쓴이 날짜 조회 수
13 [웹 어셈블리, WSAM] Persisting data with Emscripten : Emscripten으로 데이터 유지하기 졸리운_곰 2024.04.20 381
12 [웹 어셈블리, WSAM] Porting a Linux Program to Run in Browser using Emscripten : mscripten을 사용하여 브라우저에서 실행되도록 Linux 프로그램 포팅 졸리운_곰 2024.04.20 392
11 [웹 어셈블리, WSAM] An example of emscripten with WebSocket. file 졸리운_곰 2023.12.12 462
10 [웹 어셈블리, WSAM] サーバサイドはWebAssemblyの夢を見るか? – Node.jsでwasmってみた : 서버 측은 WebAssembly의 꿈을 꾸는가? – Node.js에서 wasm 해 보았습니다. file 졸리운_곰 2023.08.27 365
9 [웹 어셈블리 WSAM, webassembly] WebAssembly on the server-side : 서버측 웹어셈블리 file 졸리운_곰 2023.08.27 504
8 [Blazor][WASM] Awesome Blazor file 졸리운_곰 2021.08.15 20070
7 [Blazor][C# .net] Blazor와 C#으로 풀스택 웹 개발하기 file 졸리운_곰 2021.08.15 444
6 [WASM][web assembly] 웹 어셈블리를 보다 쉽게 웹 어플리케이션에 적용하는 방법 file 졸리운_곰 2021.07.19 426
5 Using Blazor, Tensorflow and ML.NET to Identify Images file 졸리운_곰 2021.07.03 529
4 [WASM][WebAssembly] The Top 81 Emscripten Open Source Projects 졸리운_곰 2021.04.19 518
3 [WebAssembly][WSAM] Blazor와 WebAssembly 소개 file 졸리운_곰 2021.03.28 516
2 Webassembly Tutorial using Emscripten file 졸리운_곰 2020.10.24 646
1 [웹어셈블리] Visual Studio 2019와 Emscripten (emcc) 개발 file 졸리운_곰 2020.10.18 2094
대표 김성준 주소 : 경기 용인 분당수지 U타워 등록번호 : 142-07-27414
통신판매업 신고 : 제2012-용인수지-0185호 출판업 신고 : 수지구청 제 123호 개인정보보호최고책임자 : 김성준 sjkim70@stechstar.com
대표전화 : 010-4589-2193 [fax] 02-6280-1294 COPYRIGHT(C) stechstar.com ALL RIGHTS RESERVED