首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用于控制像素着色器的键盘输入

用于控制像素着色器的键盘输入
EN

Stack Overflow用户
提问于 2011-03-12 01:44:48
回答 2查看 391关注 0票数 0
代码语言:javascript
复制
    //pixelcolour with ambient
    //pixelcolour = vec4( textureshade*shadescale + ambient* textureshade+ textureshade*diffuseshadescale, 1.0 );   

    //ambient           
    pixelcolour += vec4(ambient*textureshade,1.0);

    //diffuse
    //pixelcolour += vec4(textureshade*diffuseshadescale, 1.0);

    //ambient && diffuse
    //pixelcolour += vec4( ambient* textureshade+ textureshade*diffuseshadescale, 1.0 );

    //ambient && specular
    //shadescale= pow(dot(h,nn),shinyness);
    //pixelcolour += vec4 ( textureshade*shadescale + ambient* textureshade, 1.0 );

    //specular && diffuse
    //shadescale= pow(dot(h,nn),shinyness);
    //pixelcolour += vec4 ( textureshade*shadescale + textureshade*diffuseshadescale , 1.0 );

    //ambient && specular && diffuse
    //shadescale= pow(dot(h,nn),shinyness);
    //pixelcolour += vec4 ( textureshade*shadescale + textureshade*diffuseshadescale + ambient*textureshade, 1.0);  

上面的代码使用不同的计算来显示照明,在我有的像素着色器文件中。我需要从键盘控制它,它需要在main中声明,例如,VK_A将在我拥有的不同模式之间循环。我该如何去实现它呢?

你们通常如何添加键盘控制来改变这一点?谢谢

EN

回答 2

Stack Overflow用户

发布于 2011-03-12 01:55:34

为每种模式编译单独版本的着色器,可以手动编写着色器,也可以使用字符串操作来生成每组源代码。

在应用程序中,在渲染受影响的几何体之前,跟踪当前模式并在设备上设置适当的着色器。

你有没有遇到一些更具体的问题?

票数 1
EN

Stack Overflow用户

发布于 2011-03-12 06:03:23

使用多个着色器的另一种方法是使用着色器中的均匀着色器在不同代码路径之间进行选择,并根据键盘输入循环该均匀着色器的值。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5276444

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档