≡
Products
▼
Support
▼
Company
▼
Forum
Ambiera Forum
Discussions, Help and Support.
Create a new account
,
Search
, or Login:
Create reply in
Introduction to HLSL Shaders.
Posted by:
(you are not logged in)
Enter the missing letter in: "Internatio?al"
(you are not logged in)
Text:
[quote][b][/b] wrote: By the way, today I spent a few hours (yes, I know, it took me too much time, because everything is difficult for a newbie) to write this "action script" dedicated to the shaders. I wouldn't ever be able to imagine and to fully write that script by myself without having discovered this very nice "action_shader" created by the member 'pmax' in this forum. Please see this thread : [url]https://www.ambiera.com/forum.php?t=3634[/url] And here is the source code of the "action_ShaderPlus.js" : [code]// 'action_ShaderPlus' is inspired by the original 'action_Shader' created by 'Pmax'. // Please visit this thread in Ambiera/Coppercube/Forum : 'https://www.ambiera.com/forum.php?t=3634' // It is assumed that both Vertex and Fragment Shaders are assigned to the material. /* <action jsname="action_ShaderPlus" description="Assign Vertex and Fragment Shaders"> <property name="sceneNode" type="scenenode" /> <property name="materialIndex" type="int" default="0" /> <property name="vertexFile" type="string" default="v_01.glsl" /> <property name="fragmentFile" type="string" default="f_01.glsl" /> <property name="materialType" type="int" default="0" /> <property name="shaderCallBackChoice" type="int" default="1" /> </action> */ action_ShaderPlus = function() { }; action_ShaderPlus.prototype.execute = function(currentNode) { var vertexShader = ccbReadFileContent(this.vertexFile); // Read the file containing the Vertex Shader var fragmentShader = ccbReadFileContent(this.fragmentFile); // Read the file containing the Fragment Shader var baseMaterialType = this.materialType; // 0 for solid, 2 for lightmap, 12 for additive transparency, ... myShaderCallBack_1 = function() { // example provided in CopperCube's Documentation var time = new Date().getTime(); var pulse = (time % 500) / 500.0; ccbSetShaderConstant(2, 'callBackUniformVector', pulse, pulse, 0, pulse); //don't forget to add this definition of the read-only variable in the fragment shader (see next line) //uniform vec4 callBackUniformVector; } myShaderCallBack_2 = function() { // another example : no incidence on the fragment shader with those default values var param_1 = 1.0; // the first parameter transmitted to the uniform vec4 callBackUniformVector var param_2 = 1.0; // the second parameter var param_3 = 1.0; // the third parameter var param_4 = 1.0; // the fourth parameter (the default values of 1.0 are shown as example) ccbSetShaderConstant(2, 'callBackUniformVector', param_1,param_2,param_3,param_4); //don't forget to add this definition of the read-only variable in the fragment shader (see next line) //uniform vec4 callBackUniformVector; } if (this.shaderCallBackChoice == 1){ var newMaterial = ccbCreateMaterial(vertexShader, fragmentShader, this.materialType, myShaderCallBack_1); } else if (this.shaderCallBackChoice == 2) { var newMaterial = ccbCreateMaterial(vertexShader, fragmentShader, this.materialType, myShaderCallBack_2); } else { // other available options ... var newMaterial = ccbCreateMaterial(vertexShader, fragmentShader, this.materialType, myShaderCallBack_1); } ccbSetSceneNodeMaterialProperty(this.sceneNode, this.materialIndex, '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