add a textured sphere8.obj test with obj loader
fix shaders, so that shadowed and non-shadowed are matching fix registerGraphicsUnitSphereShape API (level of detail), support textured sphere too add support for textured cube add start for a Tutorial.cpp
This commit is contained in:
@@ -26,7 +26,7 @@ void main(void)
|
||||
vec3 ct,cf;
|
||||
float intensity,at,af;
|
||||
intensity = max(dot(lightDir,normalize(normal)),0);
|
||||
cf = intensity*vec3(1.0,1.0,1.0)+ambient;
|
||||
cf = intensity*(vec3(1.0,1.0,1.0)-ambient)+ambient;
|
||||
af = 1.0;
|
||||
|
||||
ct = texel.rgb;
|
||||
|
||||
@@ -23,7 +23,7 @@ static const char* instancingFragmentShader= \
|
||||
" vec3 ct,cf;\n"
|
||||
" float intensity,at,af;\n"
|
||||
" intensity = max(dot(lightDir,normalize(normal)),0);\n"
|
||||
" cf = intensity*vec3(1.0,1.0,1.0)+ambient;\n"
|
||||
" cf = intensity*(vec3(1.0,1.0,1.0)-ambient)+ambient;\n"
|
||||
" af = 1.0;\n"
|
||||
" \n"
|
||||
" ct = texel.rgb;\n"
|
||||
|
||||
@@ -13,6 +13,7 @@ layout (location = 6) in vec3 instance_scale;
|
||||
|
||||
uniform mat4 ModelViewMatrix;
|
||||
uniform mat4 ProjectionMatrix;
|
||||
uniform vec3 lightDirIn;
|
||||
|
||||
out Fragment
|
||||
{
|
||||
@@ -60,17 +61,13 @@ out vec3 lightDir,normal,ambient;
|
||||
void main(void)
|
||||
{
|
||||
vec4 q = instance_quaternion;
|
||||
ambient = vec3(0.3,.3,0.3);
|
||||
|
||||
|
||||
vec4 local_normal = (quatRotate3( vertexnormal,q));
|
||||
vec3 light_pos = vec3(-0.3,0.1,0.1);
|
||||
normal = local_normal.xyz;//normalize(ModelViewMatrix * local_normal).xyz;
|
||||
|
||||
lightDir = normalize(light_pos);//gl_LightSource[0].position.xyz));
|
||||
// lightDir = normalize(vec3(gl_LightSource[0].position));
|
||||
|
||||
vec4 axis = vec4(1,1,1,0);
|
||||
ambient = vec3(0.6,.6,0.6);
|
||||
|
||||
vec4 worldNormal = (quatRotate3( vertexnormal,q));
|
||||
normal = normalize(worldNormal).xyz;
|
||||
|
||||
lightDir = lightDirIn;
|
||||
|
||||
vec4 localcoord = quatRotate3( position.xyz*instance_scale,q);
|
||||
vec4 vertexPos = ProjectionMatrix * ModelViewMatrix *(instance_position+localcoord);
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ static const char* instancingVertexShader= \
|
||||
"layout (location = 6) in vec3 instance_scale;\n"
|
||||
"uniform mat4 ModelViewMatrix;\n"
|
||||
"uniform mat4 ProjectionMatrix;\n"
|
||||
"uniform vec3 lightDirIn;\n"
|
||||
"out Fragment\n"
|
||||
"{\n"
|
||||
" vec4 color;\n"
|
||||
@@ -51,16 +52,13 @@ static const char* instancingVertexShader= \
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
" vec4 q = instance_quaternion;\n"
|
||||
" ambient = vec3(0.3,.3,0.3);\n"
|
||||
" \n"
|
||||
" \n"
|
||||
" vec4 local_normal = (quatRotate3( vertexnormal,q));\n"
|
||||
" vec3 light_pos = vec3(-0.3,0.1,0.1);\n"
|
||||
" normal = local_normal.xyz;//normalize(ModelViewMatrix * local_normal).xyz;\n"
|
||||
" lightDir = normalize(light_pos);//gl_LightSource[0].position.xyz));\n"
|
||||
"// lightDir = normalize(vec3(gl_LightSource[0].position));\n"
|
||||
" \n"
|
||||
" vec4 axis = vec4(1,1,1,0);\n"
|
||||
" ambient = vec3(0.6,.6,0.6);\n"
|
||||
" \n"
|
||||
" vec4 worldNormal = (quatRotate3( vertexnormal,q));\n"
|
||||
" normal = normalize(worldNormal).xyz;\n"
|
||||
" \n"
|
||||
" lightDir = lightDirIn;\n"
|
||||
" \n"
|
||||
" vec4 localcoord = quatRotate3( position.xyz*instance_scale,q);\n"
|
||||
" vec4 vertexPos = ProjectionMatrix * ModelViewMatrix *(instance_position+localcoord);\n"
|
||||
" gl_Position = vertexPos;\n"
|
||||
|
||||
@@ -23,13 +23,13 @@ out vec4 color;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec4 texel = fragment.color*texture(Diffuse,vert.texcoord);//fragment.color;
|
||||
vec4 texel = fragment.color*texture(Diffuse,vert.texcoord);
|
||||
vec3 ct,cf;
|
||||
float intensity,at,af;
|
||||
|
||||
intensity = clamp( dot( normalize(normal),lightDir ), 0,1 );
|
||||
|
||||
cf = ambient;
|
||||
|
||||
af = 1.0;
|
||||
|
||||
ct = texel.rgb;
|
||||
@@ -43,14 +43,9 @@ void main(void)
|
||||
|
||||
float visibility = texture(shadowMap, vec3(ShadowCoord.xy,(ShadowCoord.z-bias)/ShadowCoord.w));
|
||||
|
||||
intensity*=2;
|
||||
if (intensity>1)
|
||||
intensity=1.f;
|
||||
intensity = 0.7*intensity + 0.3*intensity*visibility;
|
||||
|
||||
visibility *= intensity;
|
||||
|
||||
if (visibility<0.6)
|
||||
visibility=0.6f;
|
||||
cf = intensity*(vec3(1.0,1.0,1.0)-ambient)+ambient;
|
||||
|
||||
color = vec4(ct * visibility, fragment.color.w);
|
||||
color = vec4(ct * cf, fragment.color.w);
|
||||
}
|
||||
|
||||
@@ -17,13 +17,13 @@ static const char* useShadowMapInstancingFragmentShader= \
|
||||
"out vec4 color;\n"
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
" vec4 texel = fragment.color*texture(Diffuse,vert.texcoord);//fragment.color;\n"
|
||||
" vec4 texel = fragment.color*texture(Diffuse,vert.texcoord);\n"
|
||||
" vec3 ct,cf;\n"
|
||||
" float intensity,at,af;\n"
|
||||
" \n"
|
||||
" intensity = clamp( dot( normalize(normal),lightDir ), 0,1 );\n"
|
||||
" \n"
|
||||
" cf = ambient;\n"
|
||||
" \n"
|
||||
" af = 1.0;\n"
|
||||
" \n"
|
||||
" ct = texel.rgb;\n"
|
||||
@@ -35,15 +35,10 @@ static const char* useShadowMapInstancingFragmentShader= \
|
||||
" bias = clamp(bias, 0,0.01);\n"
|
||||
" float visibility = texture(shadowMap, vec3(ShadowCoord.xy,(ShadowCoord.z-bias)/ShadowCoord.w));\n"
|
||||
" \n"
|
||||
" intensity*=2;\n"
|
||||
" if (intensity>1)\n"
|
||||
" intensity=1.f;\n"
|
||||
" intensity = 0.7*intensity + 0.3*intensity*visibility;\n"
|
||||
" \n"
|
||||
" visibility *= intensity;\n"
|
||||
" \n"
|
||||
" if (visibility<0.6)\n"
|
||||
" visibility=0.6f;\n"
|
||||
" cf = intensity*(vec3(1.0,1.0,1.0)-ambient)+ambient;\n"
|
||||
" \n"
|
||||
" color = vec4(ct * visibility, fragment.color.w);\n"
|
||||
" color = vec4(ct * cf, fragment.color.w);\n"
|
||||
"}\n"
|
||||
;
|
||||
|
||||
@@ -65,7 +65,7 @@ out vec3 lightDir,normal,ambient;
|
||||
void main(void)
|
||||
{
|
||||
vec4 q = instance_quaternion;
|
||||
ambient = vec3(0.3,.3,0.3);
|
||||
ambient = vec3(0.6,.6,0.6);
|
||||
|
||||
vec4 worldNormal = (quatRotate3( vertexnormal,q));
|
||||
|
||||
@@ -73,7 +73,7 @@ void main(void)
|
||||
|
||||
lightDir = lightDirIn;
|
||||
|
||||
vec4 axis = vec4(1,1,1,0);
|
||||
|
||||
vec4 localcoord = quatRotate3( position.xyz*instance_scale,q);
|
||||
vec4 vertexPos = MVP* vec4((instance_position+localcoord).xyz,1);
|
||||
|
||||
|
||||
@@ -55,14 +55,14 @@ static const char* useShadowMapInstancingVertexShader= \
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
" vec4 q = instance_quaternion;\n"
|
||||
" ambient = vec3(0.3,.3,0.3);\n"
|
||||
" ambient = vec3(0.6,.6,0.6);\n"
|
||||
" \n"
|
||||
" vec4 worldNormal = (quatRotate3( vertexnormal,q));\n"
|
||||
" \n"
|
||||
" normal = normalize(worldNormal).xyz;\n"
|
||||
" lightDir = lightDirIn;\n"
|
||||
" \n"
|
||||
" vec4 axis = vec4(1,1,1,0);\n"
|
||||
" \n"
|
||||
" vec4 localcoord = quatRotate3( position.xyz*instance_scale,q);\n"
|
||||
" vec4 vertexPos = MVP* vec4((instance_position+localcoord).xyz,1);\n"
|
||||
" gl_Position = vertexPos;\n"
|
||||
|
||||
Reference in New Issue
Block a user