简体   繁体   中英

GLSL vertex shader for texture display not compiling

I've got a vertex shader that doesn't want to compile, but I see absolutely no reason for the error it is giving. It's failing with the following error:

ERROR: D:\local\Temp\f46179fe-8934-4135-820a-bed1e54b98bf.tmp:22: 'texture2D' : no matching overloaded function found 
ERROR: D:\local\Temp\f46179fe-8934-4135-820a-bed1e54b98bf.tmp:22: 'assign' :  cannot convert from ' const float' to ' smooth out 4-component vector of float'
ERROR: D:\local\Temp\f46179fe-8934-4135-820a-bed1e54b98bf.tmp:22: '' : compilation terminated 
ERROR: 3 compilation errors.  No code generated.


SPIR-V is not generated for failed compile or link

Here is the code:

#version 460
//Passes variables from uniforms to frag_hud shader

layout(location = 0) in vec3 pos;
layout(location = 1) in vec2 vert_tex_coord;

uniform float vert_col_dist;
uniform sampler2D vert_hud01;
uniform sampler2D vert_hud02;
uniform sampler2D vert_hud03;

out vec2 tex_coord;
out float col_dist;
out vec4 hud01;
out vec4 hud02;
out vec4 hud03;

void main() {
    gl_Position = vec4(pos, 1.0);
    tex_coord = vec2(vert_tex_coord.x, vert_tex_coord.y);
    col_dist = vert_col_dist;
    hud01 = texture2D(vert_hud01, vert_tex_coord);
    hud02 = texture2D(vert_hud02, vert_tex_coord);
    hud03 = texture2D(vert_hud03, vert_tex_coord);
}

Figured it out. Needed to use texture() instead of texture2D().

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM