PDA

View Full Version : OGLES2 Add Full Shader Today



feelthat
11-28-2014, 10:26 PM
Add full shader on ogles2, test in iphone 4, IOS 7.1 Good

https://github.com/fatalfeel/proton_sdk_source

feelthat
11-29-2014, 12:57 PM
//pointLight of COGLES2Solid.vsh and COGLES2Solid2.vsh

if (NdotL > 0.0)
{
diffuse += uLightDiffuse[index] * NdotL * Attenuation;

vec3 HalfVector = normalize(L + vec3(0.0, 0.0, 1.0));
float NdotH = max(0.0, dot(normal, HalfVector));

float SpecularFactor = pow(NdotH, uMaterialShininess);
specular += uLightSpecular[index] * SpecularFactor * Attenuation;
}
//to

if (NdotL > 0.0)
{
diffuse += uLightDiffuse[index] * NdotL * Attenuation;
}

vec3 HalfVector = normalize(L + vec3(0.0, 0.0, 1.0));
float NdotH = dot(normal, HalfVector);

if (NdotH > 0.0)
{
specular += pow(NdotH, uMaterialShininess) * uLightSpecular[index] * Attenuation;
}



ref.
http://glslstudio.com/primer/
http://antonholmquist.com/blog/opengl-es-2-0-shader-lighting-examples/
https://github.com/kizzx2/irrlicht-ogl-es/blob/master/media/Shaders/COGLES2FixedPipeline.vsh
http://ogldev.atspace.co.uk/www/tutorial19/tutorial19.html
http://www.ntu.edu.sg/home/ehchua/programming/opengl/cg_basicstheory.html


Add full shader on ogles2, test in iphone 4, IOS 7.1 Good

https://github.com/fatalfeel/proton_sdk_source

North44
12-01-2014, 02:08 AM
Add full shader on ogles2, test in iphone 4, IOS 7.1 Good

https://github.com/fatalfeel/proton_sdk_source

Hmm...I wonder what's this about?

feelthat
12-04-2014, 04:13 PM
fixed bug for new ndk
add faster multiply matrix for ios and android

#if defined TARGET_OS_IPHONE
vDSP_mmul( m2, 1, m1, 1, M, 1, 4, 4, 4 );

#elif defined ANDROID_NDK
float32x4_t x0,x1,x2,x3;
float32x4_t y0,y1,y2,y3;

x0 = vld1q_f32(&m1[0]);
x1 = vld1q_f32(&m1[4]);
x2 = vld1q_f32(&m1[8]);
x3 = vld1q_f32(&m1[12]);

y0 = vld1q_f32(&m2[0]);
y1 = vld1q_f32(&m2[4]);
y2 = vld1q_f32(&m2[8]);
y3 = vld1q_f32(&m2[12]);

const float32x4_t A0 = vmulq_f32(x0, vdupq_n_f32(vgetq_lane_f32(y0,0)));
const float32x4_t B0 = vmulq_f32(x1, vdupq_n_f32(vgetq_lane_f32(y0,1)));
const float32x4_t C0 = vmulq_f32(x2, vdupq_n_f32(vgetq_lane_f32(y0,2)));
const float32x4_t D0 = vmulq_f32(x3, vdupq_n_f32(vgetq_lane_f32(y0,3)));
const float32x4_t _R0 = vaddq_f32( vaddq_f32(A0 , B0), vaddq_f32(C0, D0) );

const float32x4_t A1 = vmulq_f32(x0, vdupq_n_f32(vgetq_lane_f32(y1,0)));
const float32x4_t B1 = vmulq_f32(x1, vdupq_n_f32(vgetq_lane_f32(y1,1)));
const float32x4_t C1 = vmulq_f32(x2, vdupq_n_f32(vgetq_lane_f32(y1,2)));
const float32x4_t D1 = vmulq_f32(x3, vdupq_n_f32(vgetq_lane_f32(y1,3)));
const float32x4_t _R1 = vaddq_f32( vaddq_f32(A1 , B1), vaddq_f32(C1 , D1) );

const float32x4_t A2 = vmulq_f32(x0, vdupq_n_f32(vgetq_lane_f32(y2,0)));
const float32x4_t B2 = vmulq_f32(x1, vdupq_n_f32(vgetq_lane_f32(y2,1)));
const float32x4_t C2 = vmulq_f32(x2, vdupq_n_f32(vgetq_lane_f32(y2,2)));
const float32x4_t D2 = vmulq_f32(x3, vdupq_n_f32(vgetq_lane_f32(y2,3)));
const float32x4_t _R2 = vaddq_f32( vaddq_f32(A2 , B2), vaddq_f32(C2 , D2) );

const float32x4_t A3 = vmulq_f32(x0, vdupq_n_f32(vgetq_lane_f32(y3,0)));
const float32x4_t B3 = vmulq_f32(x1, vdupq_n_f32(vgetq_lane_f32(y3,1)));
const float32x4_t C3 = vmulq_f32(x2, vdupq_n_f32(vgetq_lane_f32(y3,2)));
const float32x4_t D3 = vmulq_f32(x3, vdupq_n_f32(vgetq_lane_f32(y3,3)));
const float32x4_t _R3 = vaddq_f32( vaddq_f32(A3 , B3), vaddq_f32(C3, D3) );

vst1q_f32(&M[0], _R0);
vst1q_f32(&M[4], _R1);
vst1q_f32(&M[8], _R2);
vst1q_f32(&M[12], _R3);

#else
M[0] = m1[0]*m2[0] + m1[4]*m2[1] + m1[8]*m2[2] + m1[12]*m2[3];
M[1] = m1[1]*m2[0] + m1[5]*m2[1] + m1[9]*m2[2] + m1[13]*m2[3];
M[2] = m1[2]*m2[0] + m1[6]*m2[1] + m1[10]*m2[2] + m1[14]*m2[3];
M[3] = m1[3]*m2[0] + m1[7]*m2[1] + m1[11]*m2[2] + m1[15]*m2[3];

M[4] = m1[0]*m2[4] + m1[4]*m2[5] + m1[8]*m2[6] + m1[12]*m2[7];
M[5] = m1[1]*m2[4] + m1[5]*m2[5] + m1[9]*m2[6] + m1[13]*m2[7];
M[6] = m1[2]*m2[4] + m1[6]*m2[5] + m1[10]*m2[6] + m1[14]*m2[7];
M[7] = m1[3]*m2[4] + m1[7]*m2[5] + m1[11]*m2[6] + m1[15]*m2[7];

M[8] = m1[0]*m2[8] + m1[4]*m2[9] + m1[8]*m2[10] + m1[12]*m2[11];
M[9] = m1[1]*m2[8] + m1[5]*m2[9] + m1[9]*m2[10] + m1[13]*m2[11];
M[10] = m1[2]*m2[8] + m1[6]*m2[9] + m1[10]*m2[10] + m1[14]*m2[11];
M[11] = m1[3]*m2[8] + m1[7]*m2[9] + m1[11]*m2[10] + m1[15]*m2[11];

M[12] = m1[0]*m2[12] + m1[4]*m2[13] + m1[8]*m2[14] + m1[12]*m2[15];
M[13] = m1[1]*m2[12] + m1[5]*m2[13] + m1[9]*m2[14] + m1[13]*m2[15];
M[14] = m1[2]*m2[12] + m1[6]*m2[13] + m1[10]*m2[14] + m1[14]*m2[15];
M[15] = m1[3]*m2[12] + m1[7]*m2[13] + m1[11]*m2[14] + m1[15]*m2[15];
#endif


//pointLight of COGLES2Solid.vsh and COGLES2Solid2.vsh

if (NdotL > 0.0)
{
diffuse += uLightDiffuse[index] * NdotL * Attenuation;

vec3 HalfVector = normalize(L + vec3(0.0, 0.0, 1.0));
float NdotH = max(0.0, dot(normal, HalfVector));

float SpecularFactor = pow(NdotH, uMaterialShininess);
specular += uLightSpecular[index] * SpecularFactor * Attenuation;
}
//to

if (NdotL > 0.0)
{
diffuse += uLightDiffuse[index] * NdotL * Attenuation;
}

vec3 HalfVector = normalize(L + vec3(0.0, 0.0, 1.0));
float NdotH = dot(normal, HalfVector);

if (NdotH > 0.0)
{
specular += pow(NdotH, uMaterialShininess) * uLightSpecular[index] * Attenuation;
}



ref.
http://glslstudio.com/primer/
http://antonholmquist.com/blog/opengl-es-2-0-shader-lighting-examples/
https://github.com/kizzx2/irrlicht-ogl-es/blob/master/media/Shaders/COGLES2FixedPipeline.vsh
http://ogldev.atspace.co.uk/www/tutorial19/tutorial19.html

albzterninja
12-11-2014, 05:50 PM
(WARNING, NOTHING POST RELATED!)

Lel, i have absolutely no idea what you guys are talking about, but I'm downloading Microsoft visuals c++ express and Direct x SDK, and I'm gonna try to someday understand this :]