내 게임 엔진에서 기본 스텐실 그림자가 작동합니다. 로,OpenGL : 광원의 스텐실 그림자를 변형합니다.
/*
* @brief Applies translation, rotation and scale for the shadow of the specified
* entity. In order to reuse the vertex arrays from the primary rendering
* pass, the shadow origin must transformed into model-view space.
*/
static void R_RotateForMeshShadow_default(const r_entity_t *e) {
vec3_t origin, delta;
if (!e) {
glPopMatrix();
return;
}
R_TransformForEntity(e, e->lighting->shadow_origin, origin);
VectorSubtract(e->lighting->shadow_origin, e->origin, delta);
const vec_t scale = 1.0 + VectorLength(delta)/LIGHTING_MAX_SHADOW_DISTANCE;
/*const vec_t dot = DotProduct(e->lighting->shadow_normal, e->lighting->dir);
const vec_t sy = sin(Radians(e->angles[YAW]));
const vec_t cy = cos(Radians(e->angles[YAW]));*/
glPushMatrix();
glTranslatef(origin[0], origin[1], origin[2] + 1.0);
glRotatef(-e->angles[PITCH], 0.0, 1.0, 0.0);
glScalef(scale, scale, 0.0);
} 내가 접지면 (shadow_normal) 및 조명 방향의 내적을 주석 한
: 나는 내가 가지고있는 조명 방향에 따라 그림자를 변형하기 위해 노력하고있어 모델의 요의 죄와 코사인이라고 생각합니다. 그림자의 크기를 늘릴 필요가 있다고 확신 할 수 있기 때문에 올바른 공식이 원근감있는 올바른 변형을 산출하는지 알지 못하기 때문에 . 투영을 더 잘 이해하는 사람에게는 이것이 아마 어린 아이의 놀이 일 것입니다. 나를 위해, 나는 어둠 속에서 찌름입니다.