1

GamePlay3d のサンプルから取得したシェーダー 'textured.vert' を変更しようとしていますが、次のエラーが発生します。

エラー: 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
}
4

1 に答える 1