In: Computer Science
Describe how you would adapt the RGB color model in WebGL to allow you to work with a subtractive color model.
Basically colours with 0 to 1 range are processed in WebGL and storing the colours depends upon the user. Similar to CSS, where you mention the colour in format such as #123456, for red: rgb(18,52,86). However, the hindrance in WebGL commence when the user built textures as well as buffers. In-order to adapt the RGB colours in WebGL, the binary structure of the buffer should be determined and then apply the data in that particular buffer. The WebGL will transform binary into values and user can use it in WebGL. For instance, building a texture employing gl.UNSIGNED_BYTE in format of storage and the texture ranges from 0 to 255 and WebGL the values will get transformed into 0 to 1. The gl.float employ 0 to 1 but it needs 4x for storage. The vertex colour data can be stored as gl.UNISIGNED BYTE and when reading the data , the values will be back to 0 to 1. The drawing of the pixel depends on the user (programmer) for instance, if user mention [10, 20, 30, 40] , it does not mean that red is the first value, WebGL is often considered as rasterization engine which enables drawing of values into 2D arrays. Let us see how to apply colours :