Search the Community

Showing results for tags 'custommaterial'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Coding and Game Design
  • Frameworks
    • Phaser 3
    • Phaser 2
    • Pixi.js
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start



Website URL





Found 5 results

  1. I'm picking up an older project again, and moving it to the current version of BJS. This is a pain, though, because I'd been extending the StandardMaterial shader within a copy of the BJS framework itself. The project made extensive use of noise and shape functions to simulate textures within the GPU by altering the diffuse, specular and normal values of the StandardMaterial, based on a flag hacked into the framework. The advantage of this method vs. ShaderMaterial was getting unlimited resolution textures at no bandwidth cost without having to reimplement all the goodies in the StandardMaterial--SSAO2, fog, shadows, etc. The disadvantage: Lack of portability, and having to find a way to re-minify everything myself before deployment. (My kingdom for uglify.js to support the `` multiline literal...) Before I start migrating my hacks, I wanted to ask this of the smart people around the water cooler: Can anyone suggest a more elegent way to do this, without modifying BJS itself?
  2. NasimiAsl

    Samples for CustomMaterial

    hi i start write some documentation here for custom material ( its realy easy for me to make it here but i can move it in documentation after that complete ) definition : Custom Material inherited from stable version of Standard material (a carbon Copy of BABYLON.StandarMaterial) when we need CustomMaterial ? : any time you wanna make any custom option but you can't manage that in standard material . vertex shader definitions : position(readonly) or positionUpdated(vec3) : local position per vertex normal(readonly) or NormalUpdated(vec3) : local normal fragment shader definitions : vPositionW( readonly) : world position per pixel vNormalW(read only) vDiffuseUV(vec2) : (readonly) : defined uv attribute append when you have DiffuseTexture diffuseColor(vec3) you can manage that with Fragment_Custom_Diffuse : for control Diffuse color **** that mixed with diffuseTexture if you add any texture alpha(float) you can manage that from Fragment_Custom_alpha : for control transparency color(vec4) last result after attached all effect (light fog shadow ... ) you can manage that in Fragment_before_FragColor methods : Start .material = new BABYLON.CustomMaterial("name",scene); Demo : You can define customMaterial exactly like StandardMaterial and you have all property and methods in custom material too AddUniform material.AddUniform('test1','vec3'); simple (float,vec2, vec3,vec4,...) demo sampler without UV with Define UV array array3 , float Fragment_Begin material.Fragment_Begin( string) #include<__decl__defaultFragment> [Fragment_Begin] #extension GL_OES_standard_derivatives : enable for define any new extension or include any shader (not find any requirement for make sample) Fragment_Definitions material.Fragment_Definitions( string) #[Fragment_Definitions] void main(void) { this define before main you can define any varying or global function before main demo : make varying for simple noise used vertex data to add normal demo : change vertex use definition function Fragment_MainBegin void main(void) { vNormalW = vNormalW_helper; #[Fragment_MainBegin] demo : correct normal for back face Fragment_Custom_Diffuse you most find your result red and green and blue (witch any way you like ) and set it in diffuseColor or result *** result (vec3) in this method replaced (one time) by diffuseColor set texture setTexture use diffuseColor Fragment_Custom_Alpha you most find your alpha and set it to alpha variable or in result *** result (vec3) in this method replaced (one time) byalpha demo manage transparency Fragment_Before_FragColor before the last result you have chance to manage your result your final color available in color variable and you most be set it color after your changes *** result (vec4) in this method replaced (one time) by color demo result with and without light effect Vertex_Begin for define any new extension or include any shader (not find any requirement for make sample) Vertex_Definitions this define before main you can define any varying or global function before main Vertex_MainBegin same as Fragment_Main Vertex_Before_PositionUpdated localPosition = positionUpdated; #[Vertex_Before_PositionUpdated] gl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0); you most change positionUpdated in here for change last vertex result Vertex_Before_NormalUpdated #ifdef NORMAL #[Vertex_Before_NormalUpdated] localNormal = normalUpdated; vNormalW_helper=normalize(vec3(finalWorld*vec4(normalUpdated,0.0))); you most change normalUpdated in here for change last vertex normal result related samples Update Uniform demo
  3. When you turn ti the right you see a reflection on the floor. How can I set the specularColor in a customMaterial to reduce the amount of specularity?
  4. Hi, Playground: In the playground, if I use a uniform vec3, toggling scene.shadowsEnabled causes the ground to turn black. Not using uniform works. Is it a bug? Thank you very much!
  5. NasimiAsl

    CustomMaterial for BJS ver 3.0

    you can make your shader inside the StandardMaterial with CustomShader 1. make your Custom diffuse : 2. manage color in last step // cel - toon shade - vertex update [in progress]