≡
Products
▼
Support
▼
Company
▼
Forum
Ambiera Forum
Discussions, Help and Support.
Create a new account
,
Search
, or Login:
Create reply in
Examples shaders
Posted by:
(you are not logged in)
Enter the missing letter in: "Internati?nal"
(you are not logged in)
Text:
[quote][b]Specularmap[/b] wrote: This is called Normalmap but where it can be used in a scene is hard to say) When the light around the model strange looks from the positive to the negative black and white*look* [code] var vertexShader = "varying vec3 ViewDirection;\n" + "varying vec3 LightDirection;\n" + "varying vec4 baseColor;\n" + "void main(void)\n" + "{\n" + " gl_Position = ftransform();\n" + " gl_TexCoord[0] = gl_MultiTexCoord0;\n" + " ViewDirection = -vec3(gl_ModelViewMatrix * gl_Vertex);\n" + " LightDirection = gl_LightSource[0].position.xyz;\n" + " baseColor = gl_Color;\n" + "}"; var fragmentShader = "uniform sampler2D bump;\n" + "uniform float Ka;\n" + "uniform float Kd;\n" + "uniform float Ks;\n" + "uniform float Ke;\n" + "varying vec4 baseColor;\n" + "varying vec3 ViewDirection;\n" + "varying vec3 LightDirection;\n" + "void main(void)\n" + "{\n" + " float Ke = 1.84;\n" + " float Ks = 0.7;\n" + " float Kd = 0.9;\n" + " vec3 bumpPert = normalize( -(0.5,0.5,0.5) + texture2D(bump, gl_TexCoord[0].st).rgb );\n" + " vec3 LightDir = normalize(LightDirection);\n" + " vec3 ViewDir = normalize(ViewDirection);\n" + " vec3 nNormal = normalize(gl_NormalMatrix * bumpPert);\n" + " float diffuse = clamp(dot(LightDir, nNormal), 0.0, 1.0);\n" + " float specular = pow(clamp(dot(reflect(ViewDir, nNormal),-LightDir),0.0, 1.0), Ke);\n" + " gl_FragColor = (Kd * diffuse * baseColor) + (Ks * specular)*baseColor;\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] [img]http://i.imgur.com/26yIFPh.jpg[/img][/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