Jump to content

havenphillip

Members
  • Posts

    550
  • Joined

  • Last visited

Everything posted by havenphillip

  1. 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.
  2. 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.
  3. Would it be difficult to do this for regular Leadwerks as well? It just looks really cool. It
  4. 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.
  5. 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.
  6. 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);
  7. Cool, man. I had fun trying to solve that one.
  8. 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
  9. 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
  10. 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
  11. You could try Math:Clamp(number to clamp, minimum zoom, maximum zoom) https://www.leadwerks.com/learn?page=API-Reference_Object_Math_Clamp
  12. 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); }
  13. What do you already have? I bet it's as simple as adding a timer to it.
  14. 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?
  15. Wet and rainy environment. I haven't quite worked out all the kinks but this is pretty good. An improved wet terrain from my last one, an object "wettener" shader and a rain shader. Included a map showing it all together in Wet Environment/Maps. Also the mud material and skybox I used in the map. Create a pivot and attach the wet.lua script. Drag a material to your terrain platform and attach wetterrain.lua script. Put rain.lua in the PostEffects box under the root in the Scene tab. Credits to Shadmar, Ma-Shell, and a few things from Shadertoy somewhere I don't even know. Wet Environment.zip
  16. I have this wettening effect I'm working on but as soon as I create terrain everything vanishes. So I want to know how to tell it not to count the .raw.
  17. Oh, duh. I was telling it to go nil for k,v in pairs (self.modelTable) do for i = 0, self.modelTable[k]:CountSurfaces()-1, 1 do surface = self.modelTable[k]:GetSurface(i) mat = surface:GetMaterial() mat:SetShader(shader) shader:SetVec4("ex_color",self.color) mat:SetColor(self.color) self.modelTable[k] = nil -- derp end end
  18. Ah man now I'm getting "attempt to index nil value" error when I add a crawler to the scene. What's that about? Do I need to do some kind of CountChildren() cycle? for k,v in pairs (self.modelTable) do for i = 0, self.modelTable[k]:CountSurfaces()-1, 1 do surface = self.modelTable[k]:GetSurface(i) <- giving me an error on this line mat = surface:GetMaterial() mat:SetShader(shader) shader:SetVec4("ex_color",self.color) mat:SetColor(self.color) self.modelTable[k] = nil end end
  19. Ah thanks! This seems to be working so far: for k,v in pairs (self.modelTable) do for i = 0, self.modelTable[k]:CountSurfaces()-1, 1 do surface = self.modelTable[k]:GetSurface(i) mat = surface:GetMaterial() mat:SetShader(shader) shader:SetVec4("ex_color",self.color) mat:SetColor(self.color) self.modelTable[k] = nil end end
  20. I keep getting this error. How can I fix this? I'm trying to grab everything in the scene and change the color of it with a bounding box. It works fine so long as I don't put a model in the scene that has a model childed to it. The "generator_withbutton.mdl" is an example. When I put that in the scene I get the error. for k,v in pairs (self.modelTable) do surface = self.modelTable[k]:GetSurface(0) mat = surface:GetMaterial() mat:SetShader(shader) shader:SetVec4("ex_color",self.color) mat:SetColor(self.color) self.modelTable[k] = nil end
  21. Ah ok I see. But now it's blue, even though the color is set to 1,1,1. How do I fix that?: surface = self.entity:GetSurface(0) mat = surface:GetMaterial() mat:SetColor(1,1,1) shader = Shader:Load("Gloss/wet_rock.shader"); mat:SetShader(shader) self.entity:SetMaterial(mat) shader:SetFloat("puddlesize", self.puddleSize) shader:SetFloat("puddlefade", self.puddleFade) shader:SetFloat("intensity" , self.intensity) mat:Release()
  22. Actually I see GetSurface() but I'm getting this funky looking rock which ought to look more like the second picture. Here's my code here so far: function Script:Start() --mat = Material:Load("Gloss/wet_rock.mat") mat = Material:Create() surface = self.entity:GetSurface(0) surface:SetMaterial(material) shader = Shader:Load("Gloss/wet_rock.shader"); mat:SetShader(shader) self.entity:SetMaterial(mat) shader:SetFloat("puddlesize", self.puddleSize) shader:SetFloat("puddlefade", self.puddleFade) shader:SetFloat("intensity" , self.intensity) mat:Release() end
  23. If I drag a material onto a model or brush, how can I then reference that material from a code placed on that object or brush without having to create a material then add a bunch of textures? I just want to reference the material I put on it. Something like a Material:GetCurrent() for the entity?
  24. In the above timer script you have to use "defaultFont = context:GetFont()" at the start of your PostRender() function, then you set the font to the font you want with " context:SetFont(self.font) ", then you "DrawText(...)" and after you have to set it back to the default font with " context:SetFont(defaultFont)." I'm guessing you have other scripts that use the DrawText() function? You have to use "defaultFont = context:GetFont()" and " context:SetFont(defaultFont) " in every script that uses "DrawText(...)". Basic Font script: This shouldn't change your other fonts because you're resetting the font back to the default here: Script.myFont = "" --path "Font" Script.color = Vec4(1,1,1,1) --color "Color" Script.size = 12 function Script:Start() self.myFont= Font:Load(self.myFont,self.size) end function Script:PostRender(context) defaultFont = context:GetFont() --at start of every postrender function context:SetBlendMode(1) context:SetColor(self.color) context:SetFont(self.myFont) -- changed to your font context:DrawText("My Text" ,20,20,100,100) context:SetFont(defaultFont) -- change font back to default at end of every postrender function anywhere "SetFont()" and "DrawText()" are used end
×
×
  • Create New...