小编Geo*_*hef的帖子

GLSL纹理大小

我的片段着色器有问题。我想获取纹理的大小(从图像加载)。

我知道可以使用textureSize(sampler)获取包含纹理大小的ivec2。但是我不知道为什么这不起作用(它不能编译):

#version 120

uniform sampler2D tex;

float textureSize;
float texelSize;


void main()
{
    textureSize = textureSize(tex).x;//first line
    //textureSize = 512.0;//if i set the above line as comment and use this one the shader compiles.
    texelSize = 1.0 / textureSize;

    vec4 color = texture2D(tex,gl_TexCoord[0].st);
    gl_FragColor = color * gl_Color;
}
Run Code Online (Sandbox Code Playgroud)

opengl textures glsl

5
推荐指数
1
解决办法
1万
查看次数

按顺序将float转换为int而不进行强制转换

我正在尝试校验一系列浮点数.因此我想按顺序将它们转换为整数.有没有快速的方法来自己不操纵字节?

java

1
推荐指数
1
解决办法
496
查看次数

标签 统计

glsl ×1

java ×1

opengl ×1

textures ×1