Я пытаюсь модифицировать шейдер 'textured.vert', взятый из образцов GamePlay3d, но получаю следующую ошибку:
ОШИБКА: 0:108: '' : синтаксическая ошибка, неверная директива препроцессора
ОШИБКА: 0:108: '' : синтаксическая ошибка, непредвиденные токены, следующие за директивой препроцессора - ожидается новая строка
ОШИБКА: 0:112: '' : синтаксическая ошибка, неверная директива препроцессора
ОШИБКА: 0:112: '' : синтаксическая ошибка, непредвиденные токены, следующие за директивой препроцессора - ожидается новая строка
ОШИБКА: 0:120: '' : синтаксическая ошибка, неверная директива препроцессора
ОШИБКА : 0:120: '' : синтаксическая ошибка, непредвиденные токены после директивы препроцессора - ожидается новая строка
РЕДАКТИРОВАТЬ: если вернуть первые 12 строк, это работает!:
#ifndef DIRECTIONAL_LIGHT_COUNT
#define DIRECTIONAL_LIGHT_COUNT 0
#endif
#ifndef SPOT_LIGHT_COUNT
#define SPOT_LIGHT_COUNT 0
#endif
#ifndef POINT_LIGHT_COUNT
#define POINT_LIGHT_COUNT 0
#endif
#if (DIRECTIONAL_LIGHT_COUNT > 0) || (POINT_LIGHT_COUNT > 0) || (SPOT_LIGHT_COUNT > 0)
#define LIGHTING
#endif
Код шейдера, который модифицировал:
#ifndef DIRECTIONAL_LIGHT_COUNT
#define DIRECTIONAL_LIGHT_COUNT 0
#endif
#if (DIRECTIONAL_LIGHT_COUNT > 0)
#define LIGHTING
#endif
///////////////////////////////////////////////////////////
// Atributes
attribute vec3 a_position;
#if defined(LIGHTING)
#if defined(BUMPED)
attribute vec3 a_tangent;
attribute vec3 a_binormal;
#endif
#endif
///////////////////////////////////////////////////////////
// Uniforms
uniform mat4 u_worldViewProjectionMatrix;
#if defined(LIGHTING)
uniform mat4 u_inverseTransposeWorldViewMatrix;
#if defined(SPECULAR)
uniform mat4 u_worldViewMatrix;
#endif
#if defined(BUMPED) && (DIRECTIONAL_LIGHT_COUNT > 0)
uniform vec3 u_directionalLightDirection[DIRECTIONAL_LIGHT_COUNT];
#endif
#if defined(SPECULAR)
uniform vec3 u_cameraPosition;
#endif
#endif
#if defined(TEXTURE_OFFSET)
uniform vec2 u_textureOffset;
#endif
///////////////////////////////////////////////////////////
// Varyings
varying vec3 v_texCoord;
#if defined(LIGHTING)
#if !defined(BUMPED)
varying vec3 v_normalVector;
#endif
#if defined(BUMPED) && (DIRECTIONAL_LIGHT_COUNT > 0)
varying vec3 v_directionalLightDirection[DIRECTIONAL_LIGHT_COUNT];
#endif
#if defined(SPECULAR)
varying vec3 v_cameraDirection;
#endif
#include "lighting.vert"
#endif
void main()
{
vec4 position = vec4(a_position, 1.0);
gl_Position = u_worldViewProjectionMatrix * position;
#if defined(LIGHTING)
vec3 normal = a_position;
// Transform the normal, tangent and binormals to view space.
mat3 inverseTransposeWorldViewMatrix = mat3(u_inverseTransposeWorldViewMatrix[0].xyz, u_inverseTransposeWorldViewMatrix[1].xyz, u_inverseTransposeWorldViewMatrix[2].xyz);
vec3 normalVector = normalize(inverseTransposeWorldViewMatrix * normal);
#if defined(BUMPED)
vec3 tangent = a_tangent;
vec3 binormal = a_binormal;
vec3 tangentVector = normalize(inverseTransposeWorldViewMatrix * tangent);
vec3 binormalVector = normalize(inverseTransposeWorldViewMatrix * binormal);
mat3 tangentSpaceTransformMatrix = mat3(tangentVector.x, binormalVector.x, normalVector.x, tangentVector.y, binormalVector.y, normalVector.y, tangentVector.z, binormalVector.z, normalVector.z);
applyLight(position, tangentSpaceTransformMatrix);
#else
v_normalVector = normalVector;
applyLight(position);
#endif
#endif
v_texCoord = position;
#if defined(TEXTURE_OFFSET)
v_texCoord += u_textureOffset;
#endif
}
#include "lighting.vert"
, так что там? И как вы обрабатываете включение шейдера (и загрузку всего шейдера)? - person derhass   schedule 19.10.2014