문제

Can someone provide an example on how to use X.shaders in XTK ?

I need to use custom shaders to apply texture and color with alpha component for vertices.

도움이 되었습니까?

해결책

After reading the code : for the moment you cannot. Initialy the shader class was not done to be public, but I submited an issue to Haehn to export it as public so you can instantiate one shader. In addition it needs 2 setters for the fragment and vertex sources and to remove the test for all attributes/uniforms to be used in the shader sources.

Notice that with the current code you cannot add parameters to your shaders (btw there should be enough for any use, you can see them here in the "attributes" and "uniforms").

To use it, after that, I'd say :

 var r = new X.renderer3D(); //create a renderer
 r.init(); //initiate it
 var sh = new X.shaders(); // create a new par of shaders
 /* here use the futur setters to set sources from a string or a file */
 r.addShaders(sh); // this set the shaders for the renderer and try to compile them
 // DO NOT call init anymore or it would erase the current shaders and replace them by default ones
 /*
 Any code to fill the scene, etc...
 */
 r.render();

But it needs to wait the 3 changes I said at the beginning of this post. I'm waiting for Haehn's news.

다른 팁

@Ricola3D is right.

The discussion regarding this is here:

https://github.com/xtk/X/issues/69

But if you want an alpha channel for vertices, you can use X.object.opacity.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top