≡
Products
▼
Support
▼
Company
▼
Forum
Ambiera Forum
Discussions, Help and Support.
Create a new account
,
Search
, or Login:
Create reply in
Shader using additional blending conflicts with alphaed geometry (webGL)
Posted by:
(you are not logged in)
Enter the missing letter in: "I?ternational"
(you are not logged in)
Text:
[quote][b][/b] wrote: Dieter, you are too kind because I'm afraid I couldn't help you. About applying custom-made shaders inside CCB I have thrown in the towel. It is too complicated for my little brain. However a few weeks ago I was able to create some interesting shaders for the animated soldier. They are based on some original ones found on GLSL tutorials published on the web. In this topic https://www.ambiera.com/forum.php?t=8705 I posted a comment with a link to my shared CCB tests uploaded on my OneDrive. In the subfolder SPACE key UP DOWN Demo, I included this shader : [code] var vertexShader = "varying vec3 normal;\n" + "varying vec3 vpos;\n" + "void main()\n" + "{\n" + " // vertex normal\n" + " normal = normalize(gl_NormalMatrix * gl_Normal);\n" + " // vertex position\n" + " vpos = vec3(gl_ModelViewMatrix * gl_Vertex);\n" + " // vertex position\n" + " gl_Position = ftransform();\n" + " gl_TexCoord[0] = gl_TextureMatrix[0,1] * gl_MultiTexCoord0;\n" + " gl_TexCoord[1] = gl_TextureMatrix[0,1] * gl_MultiTexCoord0;\n" + "}"; var fragmentShader = "uniform sampler2D tex01;\n" + "varying vec3 normal;\n" + "varying vec3 vpos;\n" + "uniform float shininess;\n" + "void main()\n" + "{\n" + "float shininess = 10;\n" + " vec4 color01 = texture2D(tex01, vec2(gl_TexCoord[0])); \n" + " vec4 color02 = texture2D(tex01, vec2(gl_TexCoord[1])); \n" + " vec3 n = normalize(normal);\n" + " vec4 diffuse = vec4(0.0);\n" + " vec4 specular = vec4(0.0);\n" + " // the material properties are embedded in the shader (for now)\n" + " vec4 mat_ambient = vec4(0.5, 0.5, 0.5, 0.5);\n" + " vec4 mat_diffuse = vec4(0.5, 0.5, 0.5, 0.5);\n" + " vec4 mat_specular = vec4(1.0, 1.0, 1.0, 0.5);\n" + " // ambient term\n" + " vec4 ambient = mat_ambient * gl_LightSource[0].ambient;\n" + " // diffuse color\n" + " vec4 kd = mat_diffuse * gl_LightSource[0].diffuse;\n" + " // specular color\n" + " vec4 ks = mat_specular * gl_LightSource[0].specular;\n" + " // diffuse term\n" + " vec3 lightDir = normalize(gl_LightSource[0].position.xyz - vpos);\n" + " float NdotL = dot(n, lightDir);\n" + " if (NdotL > 0.0)\n" + " diffuse = kd * NdotL;\n" + " // specular term\n" + " vec3 rVector = normalize(2.0 * n * dot(n, lightDir) - lightDir);\n" + " vec3 viewVector = normalize(-vpos);\n" + " float RdotV = dot(rVector, viewVector);\n" + " if (RdotV > 0.0)\n" + " specular = ks * pow(RdotV, shininess);\n" + " gl_FragColor = color01*(ambient + diffuse + specular);\n" + "}"; var newMaterial = ccbCreateMaterial(vertexShader, fragmentShader, 0, null); var soldier = ccbGetSceneNodeFromName('soldier'); ccbSetSceneNodeMaterialProperty(soldier, 0, 'Type', newMaterial); ccbSetSceneNodeMaterialProperty(soldier, 1, 'Type', newMaterial); ccbSetSceneNodeMaterialProperty(soldier, 2, 'Type', newMaterial); ccbSetSceneNodeMaterialProperty(soldier, 4, 'Type', newMaterial); [/code] While testing the GLSL shaders, I noticed that some of them activate the possibility to apply a normal map to the animated meshes (example : the soldier) while the CCB doc mentions that it is not possible (reference : normal map -> limitations). You made a nice job with your behavior to apply custom-made shader. Thank you for teaching your skills with this community. It is quite helpful. About the shaders, for the purpose of real-time testing, I prefer having the possibility to edit them inside an 'action -> Execute Java Script'. :-)[/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