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

 

 

본 웹사이트는 광고를 포함하고 있습니다.
광고 클릭에서 발생하는 수익금은 모두 웹사이트 서버의 유지 및 관리, 그리고 기술 콘텐츠 향상을 위해 쓰여집니다.
번호 제목 글쓴이 날짜 조회 수
46 Check if a key exists inside a json object : JSON 키값이 있는지 조사 졸리운_곰 2018.09.03 465
45 Grouping JSON by values : JSON 값으로 그룹핑 분류 졸리운_곰 2018.09.01 480
44 Javascript 자식창에서 부모창으로 데이터 전달하기 졸리운_곰 2018.08.23 961
43 [자바스크립트] 정규표현식을 사용하여 태그만 제거하기 졸리운_곰 2018.08.01 675
42 [JS] HTML 태그들을 제거하자! #자바스크립트HTML태그제거 #HTML태그삭제 #HTML태그없애기 file 졸리운_곰 2018.08.01 383
41 자바스크립트 Base64 인코딩, 디코딩 졸리운_곰 2018.06.18 588
40 Get Query String Parameters with JavaScript 졸리운_곰 2018.06.08 477
39 Get request parameters using Javascript 졸리운_곰 2018.06.08 455
38 json 배열 합치기(merge) 및 소팅하기 졸리운_곰 2018.06.08 683
37 Object.assign 두 개의 Object 를 하나로 병합하기 How to merge different object in javascript 졸리운_곰 2018.06.08 552
36 jQuery.extend(), 두개 이상의 객체를 합치기(Merge) file 졸리운_곰 2018.06.08 512
35 jQuery 원하는 요소에 벨류(value) 값 넣기 졸리운_곰 2018.05.30 371
34 [jQuery] 요소(Element) 존재 여부 확인 졸리운_곰 2018.05.29 664
33 [제이쿼리/jQuery] 요소 갯수 구하기 .length file 졸리운_곰 2018.05.25 409
32 [삽잡이::javascript] JSON Array를 만들어보자 file 졸리운_곰 2018.05.25 194
31 Javascript 함수 생성 2가지 방법의 차이점 file 졸리운_곰 2018.05.24 498
30 React 시작하기 [javascript] 졸리운_곰 2018.05.20 508
29 javascript 에서 큐, 스택, 트리 졸리운_곰 2018.02.27 513
28 CKEditor. Plugin 직접 만들기. 예: Cy-GistInsert file 졸리운_곰 2018.02.21 459
27 템플릿 엔진을 벗어나고 싶은 이유, React 와 Angular 2 사이의 갈등 중간 정리 졸리운_곰 2017.09.26 1354
대표 김성준 주소 : 경기 용인 분당수지 U타워 등록번호 : 142-07-27414
통신판매업 신고 : 제2012-용인수지-0185호 출판업 신고 : 수지구청 제 123호 개인정보보호최고책임자 : 김성준 sjkim70@stechstar.com
대표전화 : 010-4589-2193 [fax] 02-6280-1294 COPYRIGHT(C) stechstar.com ALL RIGHTS RESERVED