1

I am porting my project from pure LWJGL to libGDX, and I'd like to know if there is a way to create a program only with the Fragment Shader?

What I'd like to do is to change the color of my texture where it is gray to a color I receive as a parameter. The shader worked perfectly before, but now, it seems that I need to add a Vertex Shader - what does not make any sense to me. So I wrote this:

void main() {
    gl_Position = ftransform();
}

That, according to the internet, is the simplest possible VS: it does nothing, and it really shouldn't. But it doesn't work: nothing is displayed, and no compilation errors or warnings are thrown. I tried to replace my Fragment Shader with a simpler one, but the results were even stranger:

void main() {
    gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}

This should only paint everything in red. But when I run, the program crashes, no error is thrown, no Exception, very odd behavior. I know that libGDX adds tilting, but I don't think it would work either, because I need to replace only the gray-scale colors, and depending on the intensity, I need to correctly modulate the correct color (that is varying). Another shader I am using (Fragment only, again) is to set the entire scene to gray-scale (when on the pause menu). It won't work either.

4

1 回答 1

2

当谈到现代 OpenGL 中的着色器时,您总是必须至少提供一个顶点和一个片段着色器。OpenGL-2 给了您一些回旋余地,但缺点是您仍然必须与神秘的固定功能状态机作斗争。

根据互联网,这是最简单的VS:它什么都不做,它真的不应该。

是什么让你认为它“什么都不做”。当然它会做一些事情:它将传入的原始数字转换为合理的东西,即剪辑空间中的顶点。

于 2013-09-08T11:34:59.967 回答