≡
Products
▼
Support
▼
Company
▼
Forum
Ambiera Forum
Discussions, Help and Support.
Create a new account
,
Search
, or Login:
Create reply in
shader for web target
Posted by:
(you are not logged in)
Enter the missing letter in: "I?ternational"
(you are not logged in)
Text:
[quote][b]csp-games[/b] wrote: just a little update... I tried hard, but wasn't able so far to use any blending mode other than solid (1), lightmap (2, but results in solid at least when used as texture1) and add.blend (12), which results in the beforementioned disappearing of anything using alpha textures: the grass, the leaves, the water. I however still got to test a simple alpha texture with a real alpha channel, like the grass. Cause I just had an idea for a shader based LOD manager for trees. Imagine a nice tree, fairly detailed. You render it eg. 36 times from all angles in steps of 10 degrees and save those renders with alpha channel, all combined on a 6*6 spritesheet. Now in the engine, when the tree is near the camera you show the tree and hide a decal at the same position. But if the tree is far away, you hide the tree mesh and show the decal. The decal is textured with the spritesheet and the shader will compute which of the 6*6 sprites is used, based on the angle to the camera, handed over using ccbSetShaderConstant. This way you can have thoudsands of seemingly high polygon trees in the scene without significant impact on the framerate. Except for the trees close to the cam, each tree will have only 2 triangles, plus they use the same material. The question however is, whether alpha is supported by the shader options in CC. Also interesting: I was able to copy the cc canvas to a javascript array, so you can read pixels: [code] dd__canvas = document.getElementById('3darea'); myarr=new Uint8Array (dd__canvas.width * dd__canvas.height * 4); dd__gl = dd__canvas.getContext('webgl2', {preserveDrawingBuffer: true}); dd__gl.readPixels(0, 0, dd__canvas.width, dd__canvas.height, dd__gl.RGBA, dd__gl.UNSIGNED_BYTE, myarr); [/code] However, a shader cannot access this array :( ... also, GLSL es2 shaders can a priori not access the "backbuffer" - they can only create a "framebuffer", render to it, then access it. The shader options of cc , as far as I see, allow only input-access to the textures 1+2 of the material of the mesh when the shader program is initialized, so even if you alter the texture of the mesh after starting the shader, the shader will use the old texture. I also tried to dynamically load the cc canvas as a texture: [code] var node2= ccbGetSceneNodeFromName("cubeMesh6"); ccbSetSceneNodeMaterialProperty(node2, 0, 'Texture1', dd__canvas.toDataURL("image/png"));// doesn't work ccbSetSceneNodeMaterialProperty(node2, 0, 'Texture1', "copperlichtdata/back.jpg");// works [/code] that would have allowed to build all kinds of fx, but the "data:" url isn't supported by CC, which is a bit strange. I also checked whether it is the non-power-of-2 size of the canvas, but CC loads those ok, at least the editor does so. However, you can draw this data: image to a 2D canvas. I wish Niko would give use some more intel about the shader support. I see some variables are reserved/preset, like texture1, texture2 etc. Would be useful to have a list of those built in variables, so a CC user doesn't have to become a GLSL expert to do any little thing.[/quote]
Possible Codes
Feature
Code
Link
[url] www.example.com [/url]
Bold
[b]bold text[/b]
Image
[img]http://www.example.com/image.jpg[/img]
Quote
[quote]quoted text[/quote]
Code
[code]source code[/code]
Emoticons
Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact