ambiera logo

Ambiera Forum

Discussions, Help and Support.

folder icon Ambiera Forum > CopperCube > Programming and Scripting
forum topic indicator shader not working
person icon
guest_coa
Guest
Quote
2025-09-19 15:15:35

i tryed the test code in coppercube documation
and had the cubeMesh1 on scene but it does not brighten any idea why? i used the opengl version

trying to learn more about shaders

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);


person icon
wing
Guest
Quote
2025-09-19 17:52:22

Well, that’s not surprising - you’re not actually doing anything to change the color in the shader…
For example, if you want to adjust the brightness, you could do something like change this line:
gl_FragColor = col; to gl_FragColor = col * 2; which will make it brighter, or gl_FragColor = col / 2; which will make it darker.

person icon
guest_coa
Guest
Quote
2025-09-20 07:53:32

thanks wings for your help but i get this error

shader failed to compile
error could not implicity convert operand to arithmetic operator

person icon
guest_coa
Guest
Quote
2025-09-20 09:10:23

no worries i got it to work

person icon
guest_Alireza
Guest
Quote
2025-09-20 16:46:35

I suggest you get help from Chat GPT to create a CopperCube shader. I managed to create several good shaders.

person icon
Sike
Guest
Quote
2025-09-20 20:55:57

That's cool alireza, which shaders could you create?

person icon
guest_Alireza
Guest
Quote
2025-09-21 00:18:57

Sike wrote:
That's cool alireza, which shaders could you create?

I have been able to create a number of shaders for WebGL, such as animated shadows (without using the engine's default shadows), torchlight, metal glow, etc.

person icon
Sikes
Guest
Quote
2025-09-21 01:06:02

Mmmm, thats brilliant
Do you mind sharing with community or displaying it in work visually, I would love to see it?

person icon
guest_Alireza
Guest
Quote
2025-09-21 09:32:56

Sikes wrote:
Mmmm, thats brilliant
Do you mind sharing with community or displaying it in work visually, I would love to see it?

I will send ccb file source to you. Are you in discord?

person icon
guest_coa
Guest
Quote
2025-09-21 09:42:46

thanks for the suggestion Alireza

person icon
guest_Alireza
Guest
Quote
2025-09-21 10:53:09

guest_coa wrote:
thanks for the suggestion Alireza

Your welcome. To request GPT Chat to write a shader, because CopperCube is not a well-known engine, it may give you wrong codes at first. It is better to send it one of the shader examples from the Ambeira site so that it can understand what the CopperCube shader framework is like by examining it and then request the shader and features you want from it.

person icon
Sikes
Guest
Quote
2025-09-21 12:03:21

Yes, alireza I'm on discord, I've texted you right now

person icon
guest_Alireza
Guest
Quote
2025-09-21 16:16:16

Sikes wrote:
Yes, alireza I'm on discord, I've texted you right now

I didn't receive a message. Are you sure you sent it correctly? My username there is aki.


Create reply:










 

  

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


icon_holyicon_cryicon_devilicon_lookicon_grinicon_kissicon_monkeyicon_hmpf
icon_sadicon_happyicon_smileicon_uhicon_blink   






Copyright© Ambiera e.U. all rights reserved.
Contact | Imprint | Products | Privacy Policy | Terms and Conditions |