# CYOS's WebGPU Phong shader may be incorrect

**URL:** <https://forum.babylonjs.com/t/cyoss-webgpu-phong-shader-may-be-incorrect/45914>\
**Category:** Bugs\
**Tags:** wgsl, cyos\
**Created:** [November 24, 2023, 9:18pm UTC](https://forum.babylonjs.com/t/cyoss-webgpu-phong-shader-may-be-incorrect/45914 "2023-11-24T21:18:40Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![cx20](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cx20/32/46_2.png) [@cx20](https://forum.babylonjs.com/u/cx20)\
**Post date:** [November 24, 2023, 9:18pm UTC](https://forum.babylonjs.com/t/cyoss-webgpu-phong-shader-may-be-incorrect/45914/1 "2023-11-24T21:18:40Z")

</div>

I tried the CYOS WebGPU shader.  
[https://cyos.babylonjs.com/](https://cyos.babylonjs.com/)  
However, the execution result of WebGPU’s Phong shader seems to be too bright compared to WebGL2.

When I checked the code, it seems that `specComp2` is being calculated, but it is not being used. I think that’s probably the cause.

```auto
// Specular
let angleW = normalize(viewDirectionW + lightVectorW);
let specComp = max(0., dot(vNormalW, angleW));
let specComp2 = pow(specComp, max(1., 64.)) * 2.;

//fragmentOutputs.color = vec4(color * ndl + vec3(specComp), 1.);
fragmentOutputs.color = vec4(color * ndl + vec3(specComp2), 1.);

```

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/8/8/8865fd9fbadfbf4c084334b334948406eb349b99.jpeg)

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/9/6/969073a7738a9282397f900d510e43b174f02a7e.jpeg)

The settings I tried are below.  
TEMPLATES: Phong  
MESHES: Sphere  
3D API: WebGPU

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [November 24, 2023, 9:41pm UTC](https://forum.babylonjs.com/t/cyoss-webgpu-phong-shader-may-be-incorrect/45914/2 "2023-11-24T21:41:26Z")

</div>

Yup it is a bug I ll push a PR ASAP for @RaananW to deploy 🙂

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [November 24, 2023, 9:47pm UTC](https://forum.babylonjs.com/t/cyoss-webgpu-phong-shader-may-be-incorrect/45914/3 "2023-11-24T21:47:33Z")

</div>

Fix is here [fix webgpu phong shader · BabylonJS/CYOS@22b7d78 · GitHub](https://github.com/BabylonJS/CYOS/commit/22b7d78c1b8bec75442c530be8d45b479c7c1173)

---

<div class="post-metadata">

**Author:** ![cx20](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cx20/32/46_2.png) [@cx20](https://forum.babylonjs.com/u/cx20)\
**Post date:** [November 24, 2023, 9:51pm UTC](https://forum.babylonjs.com/t/cyoss-webgpu-phong-shader-may-be-incorrect/45914/4 "2023-11-24T21:51:15Z")

</div>

Thank you for the quick correction.  
I checked the others, and it seems that there is a similar problem with “Wave”.

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [November 24, 2023, 10:05pm UTC](https://forum.babylonjs.com/t/cyoss-webgpu-phong-shader-may-be-incorrect/45914/5 "2023-11-24T22:05:45Z")

</div>

The same PR will fix it as the fragment is shared but thanks for your feedback @cx20 !!!

---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [November 27, 2023, 1:04pm UTC](https://forum.babylonjs.com/t/cyoss-webgpu-phong-shader-may-be-incorrect/45914/6 "2023-11-27T13:04:23Z")

</div>

just to update - deployed and working correctly

---

<div class="post-metadata">

**Author:** ![cx20](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cx20/32/46_2.png) [@cx20](https://forum.babylonjs.com/u/cx20)\
**Post date:** [November 27, 2023, 3:22pm UTC](https://forum.babylonjs.com/t/cyoss-webgpu-phong-shader-may-be-incorrect/45914/7 "2023-11-27T15:22:52Z")

</div>

I have confirmed that the shader is fixed.

BTW, I noticed another problem with CYOS.  
I would appreciate it if you could check this as well.

> [@CYOS zip download stores shaders in ShadersStoreWGSL, even with WebGL](https://forum.babylonjs.com/t/cyos-zip-download-stores-shaders-in-shadersstorewgsl-even-with-webgl/45962):
>
> I tried zip download using CYOS. [https://cyos.babylonjs.com/](https://cyos.babylonjs.com/) Strangely enough, even if WebGL1/2 is selected as the 3D API, shaders seem to be stored in ShadersStoreWGSL. I suggest revising the logic to ensure that the shaders are stored in the appropriate location based on the selected API in the dropdown menu, rather than relying on whether the WebGPU API is supported or not.
