≡
Products
▼
Support
▼
Company
▼
Forum
Ambiera Forum
Discussions, Help and Support.
Create a new account
,
Search
, or Login:
Create reply in
How Access TextureSlot2 with GLSL Scripting?
Posted by:
(you are not logged in)
Enter the missing letter in: "Internatio?al"
(you are not logged in)
Text:
[quote][b]hadoken[/b] wrote: Hi everyone, I wonder how to get a scene node's second assigned texture into CopperCube GLSL shader scripting? In my shader test behavior from the docs I tried changing 0 to 1 at those commands: in vertex shader part: [b]gl_TexCoord[1] = gl_MultiTexCoord1;[/b] in fragment shader part: [b] vec4 col = texture2D(myTexture, vec2(gl_TexCoord[1]));[/b] Unfortunately that doesn't do the trick. Also tried various 0/1 combinations. Nothing ... So what would I have to do to get my second texture's color information into the shader instead of the first texture's color? Please help anyone. THX [img]https://i.imgur.com/0ZwbGc7.png[/img] [code]/* <behavior jsname="behavior_TestShaderGLSL" description="behavior_TestShaderGLSL"> </behavior> */ behavior_TestShaderGLSL = function() { } behavior_TestShaderGLSL.prototype.onAnimate = function(currentNode) { var vertexShader = "uniform mat4 mWorldViewProj; \n" + "uniform mat4 mInvWorld; \n" + "uniform mat4 mTransWorld; \n" + " \n" + "void main(void) \n" + "{ \n" + " gl_Position = mWorldViewProj * gl_Vertex; \n" + " \n" + " // normal would be this: \n" + " vec4 normal = vec4(gl_Normal, 0.0); \n" + " normal = mInvWorld * normal; \n" + " normal = normalize(normal); \n" + " \n" + " // world position would be this: \n" + " vec4 worldpos = gl_Vertex * mTransWorld; \n" + " \n" + " gl_FrontColor = gl_BackColor = vec4(1.0, 1.0, 1.0, 0.0); \n" + " \n" + " gl_TexCoord[0] = gl_MultiTexCoord0; \n" + "}"; var fragmentShader = "uniform sampler2D myTexture; \n" + " \n" + "void main (void) \n" + "{ \n" + " vec4 col = texture2D(myTexture, vec2(gl_TexCoord[0])); \n" + " col *= gl_Color; \n" + " gl_FragColor = col; \n" + "}"; var newMaterial = ccbCreateMaterial(vertexShader, fragmentShader, 0, null); var cube = ccbGetSceneNodeFromName('cubeMesh1'); ccbSetSceneNodeMaterialProperty(cube, 0, 'Type', newMaterial); } [/code][/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