ShaderToy的FragCoord.xy值及更多 [英] ShaderToy's FragCoord.xy value and more

查看:65
本文介绍了ShaderToy的FragCoord.xy值及更多的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为计算机图形任务,我们被分配将一些ShaderToy过滤器转换为老师的个人语言,但是我找不到任何文档或教程可以帮助我解决我不断遇到的许多新问题,通过研究自己达到了一个很好的地步,但现在我被困住了!

As a computer graphics task we were assigned to translate some ShaderToy filters into our teacher's personal language, but I can't find any documentation or tutorial that can help me with many of the new stuff that I keep encountering, I managed to get to a good point by myself with some research but now I'm stuck!

我的问题是:

FragCoord.xy 返回的确切值是什么?(如果我猜对的话,使用 vec2 FragCoord = {i,j} ).

FragCoord.xy what exact value returns? (With vec2 FragCoord = {i, j} if I guessed correctly).

如果我将 FragCoord.xy 除以720,会返回什么 vec2 值?

If I divided FragCoord.xy by 720, what vec2 value would be returned?

谢谢

推荐答案

.xy 被称为

您可以分别使用x,y,z或w分别指代第一,第二,第三和第四部分.

You can use x, y, z, or w, referring to the first, second, third, and fourth components, respectively.

这意味着 FragCoord.xy 接受 FragCoord x y 组件并创建一个类型为矢量的向量 vec2 .甚至可以多次使用组件(例如 FragCoord.yy FragCoord.yy )或更改其顺序(例如 FragCoord.yx ).

That means FragCoord.xy takes the x and y component of FragCoord and creates a vector of type vec2. It is even possible to use components multiple times (e.g. FragCoord.xx, FragCoord.yy) or to change it's order (e.g. FragCoord.yx).

GLSL二进制运算符以组件方式工作.因此, FragCoord.xy/720 可以替换为 vec2(FragCoord.x/720,FragCoord.y/720).

GLSL binary Operators work component-wise. Therefore FragCoord.xy / 720 can be replaced by vec2(FragCoord.x / 720, FragCoord.y / 720).

这篇关于ShaderToy的FragCoord.xy值及更多的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆