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

发布于 2024-10-22 02:01:32 字数 1125 浏览 4 评论 0原文

    //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 将循环使用我拥有的不同模式。我该如何实施呢?

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

    //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);  

The above code uses different calculations to display lighting, in the pixel shader file I have. I need to control this from the keyboard, which needs to be declared in main and, for example, VK_A will cycle through the different modes I have. How do I go about implementing this?

How do you guys normally add keyboard controll to change this? Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

暖心男生 2024-10-29 02:01:33

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

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

您遇到了一些更具体的问题吗?

Compile a separate version of the shader for each mode, either hand authoring them or using string manipulation to generate each set of source code.

In your application, keep track of the current mode and set the appropriate shader on the device, each frame, before rendering the affected geometry.

Is there some more specific issue you are encountering?

李白 2024-10-29 02:01:33

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

An alternative to having multiple shaders would be to use a uniform in the shader to select between different code paths and to cycle the value of that uniform based on keyboard input.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文