Implemented specular reflective lighting for OpenGL 3.x, everything looks shiny (will add APIs to make it less shiny ;-)
Remove roof from kitchens/1.sdf, otherwise shadows and shinyness won't work (light is outside the room, bouncing against roof-top) Make kuka_iiwa/model.urdf more smooth, use .obj for per-vertex normals (using Blender, import STL, export OBJ, enable triangles, normals and Z-UP, Y forward)
This commit is contained in:
@@ -13,7 +13,12 @@ static const char* useShadowMapInstancingVertexShader= \
|
||||
"uniform mat4 ProjectionMatrix;\n"
|
||||
"uniform mat4 DepthBiasModelViewProjectionMatrix;\n"
|
||||
"uniform mat4 MVP;\n"
|
||||
"uniform vec3 lightDirIn;\n"
|
||||
"uniform vec3 lightPosIn;\n"
|
||||
"uniform vec3 cameraPositionIn;\n"
|
||||
"uniform mat4 ViewMatrixInverse;\n"
|
||||
"uniform float materialShininessIn;\n"
|
||||
"uniform vec3 lightSpecularIntensityIn;\n"
|
||||
"uniform vec3 materialSpecularColorIn;\n"
|
||||
"out vec4 ShadowCoord;\n"
|
||||
"out Fragment\n"
|
||||
"{\n"
|
||||
@@ -51,7 +56,12 @@ static const char* useShadowMapInstancingVertexShader= \
|
||||
" vec4 temp = quatMul ( q, p );\n"
|
||||
" return quatMul ( temp, vec4 ( -q.x, -q.y, -q.z, q.w ) );\n"
|
||||
"}\n"
|
||||
"out vec3 lightDir,normal,ambient;\n"
|
||||
"out vec3 lightPos,normal,ambient;\n"
|
||||
"out vec4 vertexPos;\n"
|
||||
"out vec3 cameraPosition;\n"
|
||||
"out float materialShininess;\n"
|
||||
"out vec3 lightSpecularIntensity;\n"
|
||||
"out vec3 materialSpecularColor;\n"
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
" vec4 q = instance_quaternion;\n"
|
||||
@@ -59,13 +69,18 @@ static const char* useShadowMapInstancingVertexShader= \
|
||||
" \n"
|
||||
" vec4 worldNormal = (quatRotate3( vertexnormal,q));\n"
|
||||
" \n"
|
||||
" normal = normalize(worldNormal).xyz;\n"
|
||||
" lightDir = lightDirIn;\n"
|
||||
" \n"
|
||||
" normal = worldNormal.xyz;\n"
|
||||
" lightPos = lightPosIn;\n"
|
||||
" cameraPosition = cameraPositionIn;\n"
|
||||
" materialShininess = materialShininessIn;\n"
|
||||
" lightSpecularIntensity = lightSpecularIntensityIn;\n"
|
||||
" materialSpecularColor = materialSpecularColorIn;\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"
|
||||
" vertexPos = vec4((instance_position+localcoord).xyz,1);\n"
|
||||
" \n"
|
||||
" vec4 vertexLoc = MVP* vec4((instance_position+localcoord).xyz,1);\n"
|
||||
" gl_Position = vertexLoc;\n"
|
||||
" ShadowCoord = DepthBiasModelViewProjectionMatrix * vec4((instance_position+localcoord).xyz,1);\n"
|
||||
" fragment.color = instance_color;\n"
|
||||
" vert.texcoord = uvcoords;\n"
|
||||
|
||||
Reference in New Issue
Block a user