This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Final for now... | |
// iPhone 3Gs: 5.9ms | |
#ifdef VERTEX | |
attribute vec4 a_position; | |
attribute vec2 a_uv; | |
attribute vec3 a_normal; | |
attribute vec4 a_tangent; | |
uniform mat4 u_mvp; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// lr,lg,lb - light color | |
// spec = specular power | |
int idx = 0; | |
for (int y = 0; y < height; ++y) | |
{ | |
for (int x = 0; x < width; ++x, idx+=4) | |
{ | |
float vx = float(x) / width; | |
float vy = float(y) / height; | |
float nl = vx; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifdef VERTEX | |
attribute vec4 a_position; | |
attribute vec2 a_uv; | |
attribute vec3 a_normal; | |
attribute vec4 a_tangent; | |
uniform mat4 u_mvp; | |
uniform mat4 u_world2object; | |
uniform vec4 u_worldlightdir; | |
uniform vec4 u_worldcampos; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.wp_syntax, .wp_syntax .line_numbers, .wp_syntax .code, .wp_syntax pre { | |
background-color: #f8f8f8; | |
color: #111; | |
font-family: Consolas, Lucida Console, Monaco, monospace; | |
} | |
.wp_syntax { | |
border-radius: 5px; | |
margin: 0 0 1.5em 0; | |
border: 1px solid #ddd; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Both vertex & fragment shaders (define VERTEX or FRAGMENT before loading each). | |
Looks like crash caused by indexing into uniform array. Crash goes away if: | |
1) replacing array indices [i] with actual constants (0 & 1) and removing index math, OR | |
2) removing unrelated ALU ops (' - viewpos'), OR | |
3) rewriting shader to not be unrolled; using for (int i = 0; i < 2; ++i) loop. | |
Shader by itself does not make any practical sense, I just simplified a more complex shader to smallest that still crashes. | |
Crashes inside PVR driver on iPad 2, iOS 4.3: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Crashes iPad 2, iOS 4.3. Thread 0 Crashed: | |
0 IMGSGX543GLDriver 0x30c28b92 UpdateShaderParams + 14 | |
1 IMGSGX543GLDriver 0x30c29266 glrUpdateCtxSysFragmentProgram + 1406 | |
2 IMGSGX543GLDriver 0x30c21970 glrUpdateFragmentProgramInline + 292 | |
3 IMGSGX543GLDriver 0x30c21e58 glrLoadCurrentPipelinePrograms + 576 | |
4 IMGSGX543GLDriver 0x30c2a54c gldUpdateDispatch + 856 | |
5 GLEngine 0x35ca1bac gleDoDrawDispatchCore + 252 | |
6 GLEngine 0x35c285cc glDrawArrays_IMM_Exec + 208 | |
7 OpenGLES 0x30bd2edc glDrawArrays + 28 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// world, view, projection matrices | |
var world = obj.transform.localToWorldMatrix; | |
var view = cam.worldToCameraMatrix; | |
var proj = cam.projectionMatrix; | |
// the actual projection matrix used in shaders | |
// is actually massaged a bit to work across all platforms | |
// (different Z value ranges etc.) | |
var gpuProj = GL.GetGPUProjectionMatrix (proj, false); | |
var gpuMV = view * world; // UNITY_MATRIX_MV |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// i = uniform location of vec4 array | |
// this is fine | |
glUniform4fv (i, 4, GL_FALSE, ptr); // load 4 elements of an array | |
// this is NOT fine! | |
glUniform4fv (i+0, 1, GL_FALSE, ptr); // this will set one element of an array | |
glUniform4fv (i+1, 1, GL_FALSE, ptr+4); // this and following may or might not work! | |
glUniform4fv (i+2, 1, GL_FALSE, ptr+8); | |
glUniform4fv (i+3, 1, GL_FALSE, ptr+12); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// in our case, | |
const float kRGBMMaxRange = 8.0f; | |
const float kOneOverRGBMMaxRange = 1.0f / kRGBMMaxRange; | |
// encode to RGBM, c = ARGB colors in 0..1 floats | |
float r = c[1] * kOneOverRGBMMaxRange; | |
float g = c[2] * kOneOverRGBMMaxRange; | |
float b = c[3] * kOneOverRGBMMaxRange; |
OlderNewer