Jump to content

havenphillip

Members
  • Posts

    550
  • Joined

  • Last visited

Everything posted by havenphillip

  1. So what does that mean? It's slower that way? I see some places in the community you're talking about the map hook but I haven't even touched C++ yet. I can't really make sense of it. I don't know what it would look like in Lua. If you know a better way in general to help me improve this then by all means explain it, fix it, optimize it, whatever. I still consider myself a noob and I really don't know a lot of things still.
  2. Yeah this should be everything involved. bloom.zip
  3. Yeah I agree. I give Josh the benefit of the doubt, though. There's only so much one guy can do. If the demand for it was high enough I'm sure he'd put that in. There has to be a solution out there somewhere. We just got to find it ourselves.
  4. That's weird. I never noticed that. This is probably way beyond me. I don't know the terrain shaders at all. I think casting shadows has to do with materials, and you can't put materials on the terrain.
  5. Yeah that's the problem. But I seem to have gotten around it by loading the shader outside the Start() function. I thought a script would be good, otherwise for every entity you use it on in a single scene you'd need to make a whole new shader if you wanted to adjust any of the settings. Script.diffuse = "" --path "Diffuse Map" "Texture File (*tex):tex|Texture" Script.normal = "" --path "Normal Map" "Texture File (*tex):tex|Texture" Script.specular = "" --path "Specular Map" "Texture File (*tex):tex|Texture" Script.height = "" --path "Height Map" "Texture File (*tex):tex|Texture" Script.diffuseColor = Vec4(0.4,0.4,0.5,1.0) -- color "Diffuse Hue" Script.brightness = 1.0 -- float "Brightness" Script.specIntensity = 1.0 -- float "Specular Intensity" Script.parallaxSteps = 10 -- float "Parallax Steps" Script.parallaxDepth = 0.03 -- float "Parallax Depth" Script.parallaxRounding = 0.2 -- float "Parallax Rounding" Script.texSize = 1.0 -- float "Texture Size" Script.shader = Shader:Load("Parallax/parallax_economy.shader") -- here instead of in the Start() --Script.shader = Shader:Load("Parallax/parallax.shader") -- here instead of in the Start() function Script:Start() mat = Material:Create() mat:SetTexture(self.diffuse,0) mat:SetTexture(self.normal,1) mat:SetTexture(self.specular,2) mat:SetTexture(self.height,3) mat:SetShader(self.shader) self.shader:SetVec4("diffuse_hue", self.diffuseColor) self.shader:SetFloat("diffuse_brightness", self.brightness) self.shader:SetFloat("specular_intensity", self.specIntensity) self.shader:SetInt("parallax_steps", self.parallaxSteps) self.shader:SetFloat("parallax_depth", self.parallaxDepth) self.shader:SetFloat("parallax_rounding", self.parallaxRounding) self.shader:SetFloat("texture_size", self.texSize) self.entity:SetMaterial(mat) end function Script:Release() self.shader:Release() mat:Release() end
  6. What do you mean? You're not getting any shadows? Which ground shader?
  7. Mine says "NONE - opt out of all beta programs." I do have that shader, too.
  8. I don't know. How would I check that? I tried it with that other script. It got too complicated and I gave up. I couldn't manage to isolate the skybox.
  9. What do you mean? Collapse with the scene? I hadn't tried this script on more than one entity at a time and it looks like you can't do more than one. Not sure why. Adjusting the settings on one entity adjusts the settings on others. I thought each instance of the script in play would affect only the entity it was attached to. It works better I guess just to leave the lua out of it.
  10. Almost forgot that script works with these. The same as the last. I just remembered to write "uniform" in front of some things: Parallax POM.zip
  11. Here's a lua script to attach to stuff for the shader: Script.diffuse = "" --path "Diffuse Map" "Texture File (*tex):tex|Texture" Script.normal = "" --path "Normal Map" "Texture File (*tex):tex|Texture" Script.specular = "" --path "Specular Map" "Texture File (*tex):tex|Texture" Script.height = "" --path "Height Map" "Texture File (*tex):tex|Texture" Script.diffuseColor = Vec4(0.4,0.4,0.5,1.0) -- color "Diffuse Hue" Script.brightness = 2.0 -- float "Brightness" Script.specIntensity = 3.0 -- float "Specular Intensity" Script.parallaxSteps = 10 -- float "Parallax Steps" Script.parallaxDepth = 0.03 -- float "Parallax Depth" Script.parallaxRounding = 0.2 -- float "Parallax Rounding" Script.texSize = 1.5 -- float "Texture Size" function Script:Start() self.shader = Shader:Load("Parallax/parallax_economy.shader") --self.shader = Shader:Load("Parallax/parallax.shader") --surface = self.entity:GetSurface(0) -- for models surface = self.entity:GetFace(0) --for brushes mat = surface:GetMaterial() self.entity:SetMaterial(mat) mat:SetTexture(self.diffuse,0) mat:SetTexture(self.normal,1) mat:SetTexture(self.specular,2) mat:SetTexture(self.height,3) mat:SetShader(self.shader) self.shader:SetVec4("diffuse_hue", self.diffuseColor) self.shader:SetFloat("diffuse_brightness", self.brightness) self.shader:SetFloat("specular_intensity", self.specIntensity) self.shader:SetInt("parallax_steps", self.parallaxSteps) self.shader:SetFloat("parallax_depth", self.parallaxDepth) self.shader:SetFloat("parallax_rounding", self.parallaxRounding) self.shader:SetFloat("texture_size", self.texSize) end function Script:Release() self.shader:Release() mat:Release() end
  12. There's a bloom.lua and a bloom.shader in my post effects folder. I assumed those came with Leadwerks. I don't know where I got them, then. I'll see if I can make it work with the one you posted. I have that one, too, somehow. This is the one I'm using: ----------------------------- -- Simple post effect script ----------------------------- --Called once at start function Script:Start() --Load this script's shader self.shader = Shader:Load("Shaders/PostEffects/bloom.shader") self.shader_hblur = Shader:Load("Shaders/PostEffects/hblur.shader") self.shader_vblur = Shader:Load("Shaders/PostEffects/vblur.shader") self.shader_bright = Shader:Load("Shaders/PostEffects/brightpass.shader") end --Called each time the camera is rendered function Script:Render(camera,context,buffer,depth,diffuse,normals) --Create downsample buffers if they don't exist if self.buffer==nil then local w=buffer:GetWidth() local h=buffer:GetHeight() self.buffer={} self.buffer[0]=Buffer:Create(buffer:GetWidth(),buffer:GetHeight(),1,0) self.buffer[1]=Buffer:Create(w/2,h/2,1,0) self.buffer[2]=Buffer:Create(w/4,h/4,1,0) self.buffer[3]=Buffer:Create(buffer:GetWidth(),buffer:GetHeight(),1,0) end --Save for bloom pass buffer:Disable() --Brightpass self.buffer[0]:Enable() self.shader_bright:Enable() diffuse:Bind(1) context:DrawImage(diffuse,0,0,buffer:GetWidth(),buffer:GetHeight()) self.buffer[0]:Disable() --Downsample self.buffer[0]:Blit(self.buffer[1],Buffer.Color) self.buffer[1]:Blit(self.buffer[2],Buffer.Color) self.buffer[2]:Blit(self.buffer[3],Buffer.Color) --hblur self.buffer[0]:Enable() self.shader_hblur:Enable() self.buffer[3]:GetColorTexture():Bind(1) context:DrawImage(self.buffer[3]:GetColorTexture(),0,0,buffer:GetWidth(),buffer:GetHeight()) self.buffer[0]:Disable() --vblur self.buffer[3]:Enable() self.shader_vblur:Enable() self.buffer[0]:GetColorTexture():Bind(1) context:DrawImage(self.buffer[0]:GetColorTexture(),0,0,buffer:GetWidth(),buffer:GetHeight()) self.buffer[3]:Disable() --bloom buffer:Enable() self.shader:Enable() diffuse:Bind(1) tex=self.buffer[3]:GetColorTexture() tex:Bind(2) context:DrawImage(self.buffer[3]:GetColorTexture(),0,0,buffer:GetWidth(),buffer:GetHeight()) end --Called when the effect is detached or the camera is deleted function Script:Release() if self.shader then self.shader:Release() self.shader = nil end if self.shader_vblur then self.shader_vblur:Release() self.shader_vblur = nil end if self.shader_hblur then self.shader_hblur:Release() self.shader_hblur = nil end if self.shader_bright then self.shader_bright:Release() self.shader_bright = nil end --Release buffers if self.buffer~=nil then self.buffer[0]:Release() self.buffer[1]:Release() self.buffer[2]:Release() self.buffer[3]:Release() self.buffer=nil end end Then the bloom shader is : //Fragment #version 400 uniform sampler2D texture0; uniform sampler2D texture1; uniform sampler2DMS texture2; uniform bool isbackbuffer; uniform vec2 buffersize; uniform float currenttime; uniform float intensity = 4.0; out vec4 fragData0; void main(void) { vec2 coord = vec2(gl_FragCoord.xy/buffersize); if (isbackbuffer) coord.y = 1.0 - coord.y; ivec2 icoords = ivec2(coord * buffersize); vec4 blur0 = texture(texture0,coord); vec4 scene = texture(texture1, coord); // rendered scene vec4 blur2 = texelFetch(texture2, icoords, 0); //glowmap fragData0 = clamp((scene+blur2*(blur0*intensity)),0.0,0.9); } //Vertex #version 400 uniform mat4 projectionmatrix; uniform mat4 drawmatrix; uniform vec2 offset; uniform vec2 position[4]; in vec3 vertex_position; void main(void) { gl_Position = projectionmatrix * (drawmatrix * vec4(position[gl_VertexID]+offset, 0.0, 1.0)); }
  13. Did you ever solve this? I came up with one possible solution with a little adjustment to the bloom shader that I believe is the one that comes with Leadwerks. You just have to change the fragment part to this: #version 400 uniform sampler2D texture0; uniform sampler2D texture1; uniform sampler2DMS texture2; uniform bool isbackbuffer; uniform vec2 buffersize; uniform float currenttime; uniform float intensity = 4.0; out vec4 fragData0; void main(void) { vec2 coord = vec2(gl_FragCoord.xy/buffersize); if (isbackbuffer) coord.y = 1.0 - coord.y; ivec2 icoords = ivec2(coord * buffersize); vec4 blur0 = texture(texture0,coord); vec4 scene = texture(texture1, coord); // rendered scene vec4 blur2 = texelFetch(texture2, icoords, 0); //glowmap fragData0 = clamp((scene+blur2*(blur0*intensity)),0.0,0.9); } /* //original shader #version 400 uniform sampler2D texture1; uniform sampler2D texture2; uniform bool isbackbuffer; uniform vec2 buffersize; uniform float currenttime; uniform float intensity = 2.0; out vec4 fragData0; void main(void) { vec2 icoord = vec2(gl_FragCoord.xy/buffersize); if (isbackbuffer) icoord.y = 1.0 - icoord.y; vec4 scene = texture(texture1, icoord); // rendered scene vec4 blur = texture(texture2, icoord); // glowmap fragData0 = clamp(scene + (blur*intensity), 0.0, 1.0); }*/
  14. Ok last one all nice and tidy so you can delete all the above if you prefer. I put in the regular and economy versions and two textures to mess with just as examples. I left out the cobblestone texture, though. The regular parallax has the edge texture in it uncommented in case you want to check it out. It looks good but it cuts the FPS in half. The economy version is an attempt to get max speed without making it look too bad, and it really doesn't look too bad at all unless you compare it to the other one, but it's clearly the more workable option. Parallax.zip
  15. I just figured out how to get even more speed. So now I'm going to backtrack from the parallax_economy shader and see how much I can put back into it without losing that speed. I'll post the final shader either today or tomorrow.
  16. Honestly I'm just learning that as I go. But as Josh mentioned, this shader is technically "parallax occlusion" (POM), or maybe "steep parallax." Pretty much all I know is it requires an extra matrix-to-eye calculation and the way I understand it it uses the z coordinate of the "eye" to produce a perception of depth like a raycast.
  17. Here's another version I built for speed. I took out a lot of the bells and whistles. I was also doing a bunch of pointless calculations in the matrix. It's a little faster but unfortunately it requires sacrifices. Would be nice if Josh could find us a few FPS points somewhere so stuff like this could be used more widely. LE would look amazing. parallax_economy.zip
  18. I use Materialize. It's free. 3 tutorials you should have it mastered. http://boundingboxsoftware.com/materialize/downloads.php http://boundingboxsoftware.com/materialize/tutorials.php I used a slightly different diffuse texture when I made the normal map (protuberance), which I doctored in GIMP to exaggerate the contrast and then discarded. So it makes sense that the LE normal map wouldn't work the same. See how this one is brighter?
  19. Check out this updated one with the edge texture Parallax.zip
  20. Added an edge texture which I made in GIMP. It looks remarkably good in-game even with texture settings set to low and standing right up to it. I'm working right now on fixing the color change to offset the loss of brightness by adding the map. It was pretty easy to make. In GIMP I opened the diffuse texture, then went to Filters/Distorts/Emboss, and set the elevation to 90 so the edges were evenly dispersed. easy to code, too. You just mix it with the diffuse: ... vec4 edge = texture(texture4,texcoords0.xy); edge = mix(edge,outcolor,1.0-edge_amount); ... //Output fragData0 = outcolor; fragData0 *= edge; ... Zoom in on this I'm fining it ridiculous how close I can get to this texture without it looking like a pixelated mess. Might be worth it to include an edge texture generator in LE5.
  21. That decal looks like it's working. So far so good. Hadn't seen you in a while, Yue, I was worried. I've heard of AMD but I'm not sure what that means, exactly. It's parallax, though. It shouldn't be too expensive to run.
  22. Thanks dude it's a magical world of bewilderment. I dig this stuff up piecemeal but I'm going to go back and find some more tutorials to see if I can make better sense of it.
  23. Super easy to use. You just slap it on a material and slap that material on an object. You gotta have a heightmap. I make mine on Materialize, which is free. Makes simple, wimpy flat planes look more complex than they are. Haven't tested it for any FPS drop or with decals or anything. Should be fun to mess with, though. Parallax.zip
  24. 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; } //-------------------------------------------------------------------
×
×
  • Create New...