Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

58 Excellent

About havenphillip

  • Rank
    Advanced Member

Profile Information

  • Gender

Recent Profile Visitors

991 profile views
  1. Hey Josh I know you're busy and I keep bugging you with this but could you explain real quick how I get the seams so I can disable displacement on them. I've been looking everywhere and can't seem to find the answer. This is my displacement code: //Vertex displacement //----------------------------------------------------------------- vec4 height = texture(texture3,ex_texcoords0); float offset = (height.r + height.g + height.b)*0.025; vec4 newPos = vec4(modelvertexposition.xyz + vNormal* offset,1.0); if (height.r > 0.5) { gl_Position = projectioncameramatrix * newPos; } //-------------------------------------------------------------------
  2. Dude, how do I get the seams? and then use vertex alpha to control the displacement? What is it? Like length(texcoords) or something? Do you have a code example or even a shader you'd be wiliing to impart? Or a webpage or tutorial somewhere that shows an example? That would be awesome. I learned how to displace but after reading your article I just assumed you needed "per-vertex" which I thought meant you have to subdivide. I've been scouring the internet for geometry shader examples for subdivision and tesselation shaders. I imagine the new engine will be much faster, and therefore better for this kind of thing, but I'm still trying to wrap my head around LE4.
  3. I wish I knew shaders well enough to make something like that. I messed with the tesselation shader and found some geometry shaders but I can't see how to take care of those cracks in the seams. If you integrated this into Leadwerks 4 and sold it as an add-on I'd buy it. 20 bucks. These texture editors make your heightmaps look cool but then you bring it to Leadwerks and you lose a little bit in translation. Then again, it might serve better strictly as a selling point for LE5. Sounds like you got some ground-breaking stuff going on over there. Either way Turbo look great. Two thumbs up.
  4. Would it be difficult to do this for regular Leadwerks as well? It just looks really cool. It
  5. I'm pretty sure there's a way to use the groundrocks shader on your material to create a billboard so that you can paint the rocks on terrain. Seems like I did that before.
  6. What might be cool is if you had a view of the whole planet that you could bring up, and then clicking different points on the planet would load different maps, giving the impression somewhat that you're going all over the place.
  7. That looks great. Can we do vertex displacement in LE4? I found this little code segment on the internet. I get it in the editor but not in-game on the brush. vec4 dv = textureLod(texture3,ex_texcoords0.xy,0.0); float df = 0.015*dv.x + 0.024*dv.y + 0.021*dv.z; vec4 newVertexPos = vec4(vec3(dv.xyz* ex_normal*0.01) * df * 100.0, 0.0) + ex_vertexposition; gl_Position = (projectioncameramatrix * newVertexPos);
  8. Cool, man. I had fun trying to solve that one.
  9. This appears to be doing it. It's limiting the zoom but the wheel is cumulative I don't know how to fix that. Once you reach the limit, if you keep rolling the wheel it keeps counting it... Script.minZoom = 0 Script.maxZoom = 30 Script.curZoom = 0 function Script:Zoom() local oldWheelPos = 0.0 if self.currentMousePos ~= nil then oldWheelPos = self.currentMousePos.z end self.currentMousePos = window:GetMousePosition() self.currentMousePos.x = Math:Round(self.currentMousePos.x) self.currentMousePos.y = Math:Round(self.currentMousePos.y) local newWheelPos = (self.currentMousePos.z - oldWheelPos) if oldWheelPos < 0.0 then self.entity:Move(0,0,self.curZoom) self.curZoom = 0 - newWheelPos System:Print("Zoom in") if self.currentMousePos.z < self.minZoom then --limits max in zoom self.curZoom = 0 end elseif oldWheelPos > 0.0 then self.entity:Move(0,0,-self.curZoom) self.curZoom = 0 + newWheelPos System:Print("Zoom out") if self.currentMousePos.z > self.maxZoom then -- limits max out zoom self.curZoom = 0 end end end
  10. You know what I just assumed there was something like a "mouse.back." I made it up as a dummy command because I thought you already had something there. I sort of got it working from this post. I've never bothered with the mouse wheel: This sort of works: function Script:UpdateWorld() self.maxZoom = 10 self.minZoom = 0 local oldWheelPos = 0.0 if self.currentMousePos ~= nil then oldWheelPos = self.currentMousePos.z end self.currentMousePos = window:GetMousePosition() self.currentMousePos.x = Math:Round(self.currentMousePos.x) self.currentMousePos.y = Math:Round(self.currentMousePos.y) local newWheelPos = (self.currentMousePos.z - oldWheelPos) * 0.1 if newWheelPos > 0.0 or newWheelPos < 0.0 then self.curZoom = oldWheelPos + newWheelPos self.camera:Move(0,0,self.curZoom) self.curZoom = Math:Clamp(self.curZoom, self.minZoom, self.maxZoom) -- limits the zoom to stay between min and max zoom end
  11. Something like: function Script:UpdateWorld() if MouseWheel(Mouse.Back) then cameraposition.z = cameraposition.z - 1 end if MouseWheel(Mouse.Forward) then cameraposition.z = cameraposition.z + 1 end Math:Clamp(cameraposition.z,0, 10) end
  12. You could try Math:Clamp(number to clamp, minimum zoom, maximum zoom) https://www.leadwerks.com/learn?page=API-Reference_Object_Math_Clamp
  13. Is there a way to get rid of this doubling up of the gun and hands in the refraction shader? I'm wracking my brain here. Here's my fragment shader: #version 400 #define BFN_ENABLED 1 //Uniforms uniform sampler2D texture0;//diffuse map uniform sampler2D texture1;//light map uniform sampler2D texture2;//specular map uniform samplerCube texture5;//cube map uniform sampler2DMS texture9; uniform sampler2D texture10;//screen color uniform samplerCube texture15;//BFN map uniform vec4 materialcolorspecular; //uniform vec4 lighting_ambient; //uniform vec4 ambientlight; uniform int decalmode; uniform float materialroughness; uniform vec2 buffersize; uniform bool isbackbuffer; //Camera uniforms uniform mat4 cameramatrix; uniform mat4 projectioncameramatrix; uniform vec2 camerarange; uniform float camerazoom; uniform mat4 camerainversematrix; uniform mat3 cameranormalmatrix; uniform vec3 cameraposition; //My uniforms #define BUMPINESS 0.01 //Inputs in vec2 ex_texcoords0; in vec4 ex_color; in float ex_selectionstate; in vec3 ex_VertexCameraPosition; in vec4 ex_vertexposition; in vec3 ex_normal; in vec3 ex_tangent; in vec3 ex_binormal; in float clipdistance0; out vec4 fragData0; out vec4 fragData1; out vec4 fragData2; out vec4 fragData3; float DepthToZPosition(in float depth) { return camerarange.x / (camerarange.y - depth * (camerarange.y - camerarange.x)) * camerarange.y; } void main(void) { //Clip plane discard if (clipdistance0>0.0) discard; vec4 outcolor = ex_color; vec4 color_specular = materialcolorspecular; //Normal map vec3 normal = ex_normal; normal = texture(texture1,ex_texcoords0).xyz * 2.0 - 1.0; float ao = normal.z; normal = ex_tangent*normal.x + ex_binormal*normal.y + ex_normal*normal.z; normal=normalize(normal); //Refraction //----------------------------------------------------------------- vec2 texcoord = (gl_FragCoord.xy / buffersize); if (isbackbuffer) texcoord.y = 1.0f - texcoord.y; vec3 texAdjust = vec3(texcoord.x,texcoord.y,1.0); //vec3 texAdjust = (vec3(texcoord.x*1.2,texcoord.y,1.5)+0.2 //+vec3(texcoord.x,texcoord.y+0.1,1.2) //+vec3(texcoord.x,texcoord.y/2.0,1.2)+0.5); texAdjust = normalize(texAdjust); vec4 screencolor = textureProj(texture10,texAdjust + normal.xyz*BUMPINESS); outcolor = screencolor * 0.75; //----------------------------------------------------------------- fragData0 = outcolor; #if BFN_ENABLED==1 //Best-fit normals fragData1 = texture(texture15,normalize(vec3(normal.x,-normal.y,normal.z))); fragData1.a = fragData0.a; #else //Low-res normals fragData1 = vec4(normalize(normal)*0.5+0.5,fragData0.a); #endif float specular = color_specular.r * 0.299 + color_specular.g * 0.587 + color_specular.b * 0.114; int materialflags=1; if (ex_selectionstate>0.0) materialflags += 2; if (decalmode==1) materialflags += 4;//brush if (decalmode==2) materialflags += 8;//model if (decalmode==4) materialflags += 16;//terrain if (materialroughness>=0.5) { materialflags += 32; if (materialroughness>=0.75) materialflags += 64; } else { if (materialroughness>=0.25) materialflags += 64; } fragData1.a = materialflags/255.0; fragData2 = vec4(0.0,0.0,0.0,specular); fragData3 = vec4(ex_VertexCameraPosition,1.0f); }
  14. What do you already have? I bet it's as simple as adding a timer to it.
  15. My bad. I did something else and forgot. The terrain works fine. Sorry about that lol. But is there a way to access the imported terrain in script?
  • Create New...