GL_PRIMITIVECOUNTEXT: Необладающий идентификаторC++

Программы на C++. Форум разработчиков
Ответить
Anonymous
 GL_PRIMITIVECOUNTEXT: Необладающий идентификатор

Сообщение Anonymous »

Я планирую внедрить сетчатые шейдеры на моем игровом двигателе, но теперь у меня возникают проблемы, собирающие мой шейдер задач на Вулкане. Я получил эту ошибку: < /p>
error: 'gl_PrimitiveCountEXT' : undeclared identifier
< /code>
afaik, который должен быть частью спецификации Vulkan, поэтому мне было интересно, почему это не обнаруженный идентификатор. < /p>
На всякий случай я прикрепляю свой сетчатые и фрагские шейдеры тоже, чтобы я мог попробовать получить некоторую помощь в рендеринге любой сетки на экране < /p>
Задача Shader < /p>
#version 460
#extension GL_EXT_mesh_shader : require

layout(local_size_x = 1) in; // Defines the workgroup size

void main() {
gl_PrimitiveCountEXT = 1; // Dispatch one primitive to the mesh shader
}
< /code>
сетчатый шейдер < /p>
#version 460
#extension GL_EXT_mesh_shader : require

layout(local_size_x = 1) in;
layout(triangles, max_primitives = 1) out;

layout(set = 0, binding = 0) uniform GlobalUBO {
mat4 view;
mat4 proj;
} ubo;

layout(push_constant) uniform PushConstants {
mat4 model;
} push;

// Output vertex & primitive data
layout(triangles, max_vertices = 3, max_primitives = 1) out;

// Assign explicit locations for per-vertex outputs
layout(location = 0) out vec3 fragPos[];
layout(location = 1) out vec3 fragNormal[];
layout(location = 2) out vec2 fragTexCoord[];
layout(location = 3) out vec3 fragColor[];

void main() {
// Define a triangle
vec4 pos[3] = {
push.model * vec4(-0.5, -0.5, 0.0, 1.0),
push.model * vec4( 0.5, -0.5, 0.0, 1.0),
push.model * vec4( 0.0, 0.5, 0.0, 1.0)
};

// Constant normal
vec3 normal = vec3(0.0, 0.0, 1.0);
vec2 tex[3] = { vec2(0.0, 0.0), vec2(1.0, 0.0), vec2(0.5, 1.0) };
vec3 color = vec3(1.0, 1.0, 1.0);

// Output vertex data
for (int i = 0; i < 3; i++) {
gl_MeshVerticesEXT.gl_Position = ubo.proj * ubo.view * pos;

fragPos = pos.xyz;
fragNormal = normal;
fragTexCoord = tex;
fragColor = color;
}

// Define the triangle primitive
gl_PrimitiveTriangleIndicesEXT[0] = uvec3(0, 1, 2);
}
< /code>
frag shader < /p>
#version 460
#extension GL_EXT_mesh_shader : require

// Inputs from the mesh shader (must match `pervertexEXT` struct)
layout(location = 0) in vec3 fragPos;
layout(location = 1) in vec3 fragNormal;
layout(location = 2) in vec2 fragTexCoord;
layout(location = 3) in vec3 fragColor;

// Output to the framebuffer
layout(location = 0) out vec4 outColor;

// Texture sampler bound to set 1, binding 0
layout(set = 1, binding = 0) uniform sampler2D textureSampler;

// Basic lighting parameters
vec3 lightPos = vec3(0.0, 10.0, 0.0);
vec3 lightColor = vec3(1.0, 1.0, 1.0);
vec3 viewPos = vec3(2.0, 2.0, 2.0);

void main() {
// Normalize the normal
vec3 norm = normalize(fragNormal);

// Basic light direction
vec3 lightDir = normalize(vec3(0.0f, 1.0f, 1.0f));

// Diffuse lighting calculation
float diff = max(dot(norm, lightDir), 0.0);
vec3 diffuse = diff * lightColor;

// Sample texture
vec3 texColor = texture(textureSampler, fragTexCoord).rgb;

// Combine color, lighting, and texture
outColor = vec4(texColor * fragColor * diffuse, 1.0);
}


Подробнее здесь: https://stackoverflow.com/questions/794 ... identifier
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C++»