• Content count

  • Joined

  • Last visited

  • Days Won


Pryme8 last won the day on January 7

Pryme8 had the most liked content!

1 Follower

About Pryme8

  • Rank
    Advanced Member
  • Birthday 04/29/1986

Profile Information

  • Gender
  • Location
    Nor. Cal
  • Interests
    Crushing it

Recent Profile Visitors

1,797 profile views
  1. You sir are a gentleman and a scholar. Ohh man I was sooo close.... thanks @Deltakosh I was getting pretty frustrated with this! "vec4 worldPosition = world * vec4(position, 1.0);" "fFogDistance = (view * worldPosition).z;" this is what fixed it for me thank you!
  2. I have beat this document and others into the ground trying to get fog to work on a custom shader... Does anyone have a working GLSL example not in typescript but like a actual BABYLON.Effect.ShadersStore version. I have been hitting my head against a wall trying to get this to work and the more I dig the more confused I am getting because it seems like everyone variables and uniforms are called different things and do not follow any sort of convention from example to example...
  3. whats stupming me up is when I try to figure out what the glsl really looks like for the standard material, I end up with this just going through the vertex shader "gl_Position = viewProjection * finalWorld * vec4(position, 1.0);" and I have never seen finalWorld anywhere, and am not sure wtf it is... I had it running I thought on an example, but any time I try to do it my object ends up disappearing). I know this is for your Terrain Editor, but If we can figure this out, Im sure it will help you as well. This is as close as I can get without really having consistent references... and it compiles... but does not work. Any ideas? this.header.scene.ambientColor = new BABYLON.Color3(0.6, 0.6, 1.0); this.header.scene.fogMode = BABYLON.Scene.FOGMODE_EXP; this.header.scene.distance = 0.01; this.header.scene.fogColor = new BABYLON.Color3(0.9, 0.9, 0.85); /*--- BUILD SHADERS ---*/ BABYLON.Effect.ShadersStore["oceanVertexShader"]= `precision highp float; // Attributes attribute vec3 position; attribute vec3 normal; attribute vec2 uv; // Uniforms uniform mat4 worldView,worldViewProjection; uniform mat3 view; uniform mat3 worldPosition; uniform float time; uniform vec3 cameraPosition; // Varying varying vec3 vPosition; varying vec3 vNormal; varying vec2 vUV; varying float vFogDistance; // Simplex 2D noise vec3 permute(vec3 x) { return mod(((x*34.0)+1.0)*x, 289.0); } float snoise(vec2 v){ const vec4 C = vec4(0.211324865405187, 0.366025403784439,-0.577350269189626, 0.024390243902439); vec2 i = floor(v + dot(v, C.yy)); vec2 x0 = v - i + dot(i, C.xx); vec2 i1; i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0); vec4 x12 = x0.xyxy + C.xxzz; x12.xy -= i1; i = mod(i, 289.0); vec3 p = permute( permute( i.y + vec3(0.0, i1.y, 1.0 ))+ i.x + vec3(0.0, i1.x, 1.0 )); vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy),dot(,, 0.0); m = m*m ; m = m*m ; vec3 x = 2.0 * fract(p * C.www) - 1.0; vec3 h = abs(x) - 0.5; vec3 ox = floor(x + 0.5); vec3 a0 = x - ox; m *= 1.79284291400159 - 0.85373472095314 * ( a0*a0 + h*h ); vec3 g; g.x = a0.x * x0.x + h.x * x0.y; g.yz = a0.yz * x12.xz + h.yz * x12.yw; return 130.0 * dot(m, g); } float wave(vec3 pos){ vec2 xy = vec2(pos.x, pos.z + (time / 1.))/vec2(1.0, 1.5); float h = snoise(xy); return h; } void main(void) { vec3 v = position; v.y = wave(v)*2.0; gl_Position = worldViewProjection * vec4(v, 1.0); vPosition = v; vNormal = normal; vUV = uv; vFogDistance = (view * position).z; }`; BABYLON.Effect.ShadersStore["oceanFragmentShader"]= `precision highp float; // Varying varying vec3 vPosition; varying vec3 vNormal; varying vec2 vUV; // Uniforms uniform mat4 world; uniform mat3 view; // Refs uniform vec3 cameraPosition; uniform sampler2D textureSampler; #define FOGMODE_NONE 0. #define FOGMODE_EXP 1. #define FOGMODE_EXP2 2. #define FOGMODE_LINEAR 3. #define E 2.71828 uniform vec4 vFogInfos; uniform vec3 vFogColor; varying float vFogDistance; float CalcFogFactor() { float fogCoeff = 1.0; float fogStart = vFogInfos.y; float fogEnd = vFogInfos.z; float fogDensity = vFogInfos.w; if (FOGMODE_LINEAR == vFogInfos.x) { fogCoeff = (fogEnd - vFogDistance) / (fogEnd - fogStart); } else if (FOGMODE_EXP == vFogInfos.x) { fogCoeff = 1.0 / pow(E, vFogDistance * fogDensity); } else if (FOGMODE_EXP2 == vFogInfos.x) { fogCoeff = 1.0 / pow(E, vFogDistance * vFogDistance * fogDensity * fogDensity); } return clamp(fogCoeff, 0.0, 1.0); } void main(void) { vec4 color = vec4(0.5, 0.5, 0.8, 1.0); float fog = CalcFogFactor(); color.rgb = fog * color.rgb + (1.0 - fog) * vFogColor; gl_FragColor = color; } ` // Compile var oceanMaterial = new BABYLON.ShaderMaterial("oceanShader", this.header.scene, { vertex: "ocean", fragment: "ocean", }, { attributes: ["position", "normal", "uv"], uniforms: ["world", "worldPosition", "worldView", "worldViewProjection", "view", "projection", "cameraPosition"] }); = 0; oceanMaterial.setFloat("time", 0); oceanMaterial.setVector3("cameraPosition", camera.position); oceanMaterial.backFaceCulling = false; //oceanMaterial.setMatrix("view", this.header.scene.getViewMatrix()); oceanMaterial.setVector3("vFogColor", this.header.scene.fogColor); /*--- BUILD SCENE SECTION ---*/ var water_top = BABYLON.MeshBuilder.CreateGround("water_top", {width: 200, height: 100, subdivsions: 10}, this.header.scene); water_top.material = oceanMaterial; /*--- BEFORE RENDER ---*/ this.header.scene.registerBeforeRender(function(){ += (self.header.scene.getAnimationRatio()/100.0); oceanMaterial.setFloat("time",; }); and I do get this error though Error: WebGL: uniformMatrix4fv: Function used differs from uniform size: 9 Sorry not trying to hyjack your thread, just noticed we are both fighting the same problem!
  4. I followed the dirrections on but I can not get it to work... o_O.
  5. @Dad72 how did you merge the StandardMaterial? I am clueless on how to build my on glsl file out of the standard shader for some reason. I tried doing it from scratch but it was a no go...
  6. Did you implement your custom shader that has the fog mode transferred from the basic shader in this version? I was looking to reference that. @Dad72
  7. Dude, thank you for this! I dont know why none one else has hopped on this, you have soem good textures on there!
  8. aww dang, I am passing through San Fran on those dates, but have prior arrangements... that would of been fun!
  9. o_O, I should have kept my mouth shut maybe...
  10. I was not asking about webgl. i was asking about webCL @letsbrostudio
  11. I am just now getting over a major injury and will be resuming my work on this and my legends game as soon as I catch up with paid work.
  12. Anyone know if webCL is working on any browsers yet?
  13. i might be mistaken but I think he goes over how to make shadows in this article it may be irrelevant though to what your doing... I'd try to help but I can't look at screens for very long right now cause of medication in taking right now makes me get screen sick.
  14. Im west coast US... but I dont know about moderating... and don't know if I want that responsibility... but if you have no better contenders on the west coast. @rich I just reread what you looking for, if that's the front of the work load being a mod, then yeah I got you buddy. I will not be doing any disciplinary stuff though not into being a warden...