我遇到了一些困難來實現棋盤格的程序紋理。以下是我需要得到:程序紋理棋盤格OpenGL
這裏是我得到:
這是接近,但我的紋理就什麼,我需要得到一種旋轉。
這是我的着色器的代碼:
#version 330
in vec2 uv;
out vec3 color;
uniform sampler1D colormap;
void main() {
float sx = sin(10*3.14*uv.x)/2 + 0.5;
float sy = sin(10*3.14*uv.y)/2 + 0.5;
float s = (sx + sy)/2;
if(true){
color = texture(colormap,s).rgb;
}
顏色表是從0到1的映射,其中0對應於紅色,1爲綠色。
我認爲問題來自我使用的公式,(sx + sy)/ 2。我需要讓廣場不旋轉,但與大廣場的邊界對齊。 如果有人有想法得到好的公式。
謝謝。