Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > CopperCube Open discussion
anyone interested in SHADERS

count2rfeit
Registered User
Quote
2020-12-23 18:35:06

here are a couple tools to check out:

https://shadered.org/
a really cool tool for shader editing (free and open source- download)


https://www.shadertoy.com/
a website where people share the shaders they have created


https://www.youtube.com/watch?v=...
a video about the SHADERed linked above


Zoo
Guest
Quote
2020-12-23 19:05:30

How do you make it work with CC6?


count2rfeit
Registered User
Quote
2020-12-24 16:59:45

well, shaders are a VERY complicated subject... you really need to research what shaders are and what they can do.

basically, they are programs (codes) that tell the GPU (your graphics card) what to draw on the computer screen (vertex shaders) and how adjust it (pixel shaders).... plus there are other types of shaders.

so they are written in a program language that is directed at your GPU. to create shaders - you need to learn how to write in these programs (the 2 most common are HLSL and GLSL) and how to apply them in your game.

like I said... complicated!

but in the CC Documentation, there is a section about shaders and how to use them in CC6... niko even provides and couple of examples.

the bottom line is if you want to work with shaders (they can create some really cool effects) you will need to do some research about them and learn some new skills.

the links I provided above are intended as just a starting point to look at and learn more about how they are written...

even if you decide not to create - they are a good source to try to better understand what these (pixel) shaders are and how they work...

cheers and good luck


csp-games
Guest
Quote
2021-02-06 03:10:04

Also, get Niko's example running may be the first step. I did it by adding a behaviour to a mesh that contains a section that is executed only once. This section contains the whole example from the docs. You only have to replace the cubemesh reference by "node" - you can use the 2D jumpnrun extension as a basis. here is what I've done:


// Supported types are: int, float, string, bool, color, vect3d, scenenode, texture, action
/*
<behavior jsname="behavior_MyTest" description="dd tests">
<property name="Something" type="float" default="1.0" />
</behavior>
*/


behavior_MyTest = function()
{
this.old_ms = 0;
};



// called every frame:
behavior_MyTest.prototype.onAnimate = function(node, timeMs)
{
// run only once:
if (this.old_ms == 0)
{
this.old_ms=1;
// shader test-------------------------------------------------------------------------------------------------------------------------
var vertexShader =
"uniform mat4 worldviewproj; \n" +
" \n" +
"attribute vec4 vPosition; \n" +
"attribute vec4 vNormal; \n" +
"attribute vec4 vColor; \n" +
"attribute vec2 vTexCoord1; \n" +
"attribute vec2 vTexCoord2; \n" +
" \n" +
"varying vec4 v_color; \n" +
"varying vec2 v_texCoord1; \n" +
"varying vec2 v_texCoord2; \n" +
" \n" +
"void main() \n" +
"{ \n" +
" v_color = vColor; \n" +
" gl_Position = worldviewproj * vPosition; \n" +
" v_texCoord1 = vTexCoord1.st; \n" +
" v_texCoord2 = vTexCoord2.st; \n" +
"} ";

var fragmentShader =
"uniform sampler2D texture1; \n" +
"uniform sampler2D texture2; \n" +
"uniform vec4 pulse; \n" +
" \n" +
"varying vec2 v_texCoord1; \n" +
"varying vec2 v_texCoord2; \n" +
" \n" +
"void main() \n" +
"{ \n" +
" vec2 texCoord = vec2(v_texCoord1.s, v_texCoord1.t); \n" +
" gl_FragColor = texture2D(texture1, texCoord) * pulse; \n" +
"} \n";

myShaderCallBack = function()
{
var time = new Date().getTime();
var pulse = (time % 500) / 500.0;
ccbSetShaderConstant(2, 'pulse', pulse, pulse, 0, pulse);
}

var newMaterial = ccbCreateMaterial(vertexShader, fragmentShader, 0, myShaderCallBack);

// note, "node" is automaticly the mesh you applied this bahaviour to. not working with terrain or scene node
var cube = node; //ccbGetSceneNodeFromName('cubeMesh1');
ccbSetSceneNodeMaterialProperty(cube, 0, 'Type', newMaterial);
//--------------------------------------------------------------------------------------------- shader test end

return false;
}

return true;
}

must be saved as behavior_MyTest.js in documents/coppercube/extensions/




csp-games
Guest
Quote
2021-02-06 03:55:17

that said, the page shadertoy just froze my browser and half-froze the system, had to end a couple of programs to get the gui responsive again. Shaders are assembler programs, and seemingly, despite running on the GPU, they can crash a system almost as easy as assembler on the CPU. It was the second ocean shader on that page. But it's amazing what some people achieve, shaders are soo limited in commands - some cracks write entire raytracers as shaders, running near realtime usability.


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Internationa?" (you are not logged in)


Text:

 

  

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