April 12, 2011

realistic skin shader

for about 2 weeks now I`ve been working on a human skin shader. As this is a paid job for medical simulation, it has to look as close as possible to real life. Though as this is a paid job it means that there will not be free code sample here yet. Shader consists of simple math so it runs really fast.


- Widely customizable (could be used for any material)
- Tangent-space normal mapping
- Supports up to 8 lights (OpenGL has 8 light limit)
- Spherical Harmonics lighting
- Advanced specular reflections with fresnel ramp


standart phong shading for comparison:

April 6, 2011

webcam head tracking using FaceAPI

FaceAPI is a real-time head-tracking engine which uses webcam input to acquire 3D position and orientation coordinates per frame of video. And it works!

I implemented it in Blender Game Engine for cockpit view of BGE Air Race game.

and here is how I got it working in BGE

1. Downloaded FaceAPI here: LINK
2. Downloaded FaceApiStreamer here: LINK
(exports 6 degrees of freedom head tracking to a UDP socket connection)
3. Acquire the values from FaceApiStramer in BGE with Python code like this (not sure if it is quite right, but it kinda works):

from socket import *
controller = GameLogic.getCurrentController()
own = controller.owner

if own["once"] == True:
# Set the socket parameters
host = ""
port = 29129
addr = (host,port)
# Create socket and bind to address
GameLogic.UDPSock = socket(AF_INET,SOCK_DGRAM)
own["once"] = False


data,svrip = GameLogic.UDPSock.recvfrom(1024)
str = data.split(' ')
own['xPos'] = float(str[0])
own['zPos'] = float(str[1])
own['yPos'] = float(str[2])
own['pitch'] = float(str[3])
own['yaw'] = float(str[4])
own['roll'] = float(str[5])

Here is a blend file: LINK
you will need FaceAPI instaled and FaceApiStreamer running in background.