Jump to content

havenphillip

Members
  • Posts

    550
  • Joined

  • Last visited

Posts posted by havenphillip

  1. Here's the post where he shows the script. I copied it down:

     

     

    window = Window:Create("terrain example",0,0,800,600,Window.Titlebar+Window.Center)
    context = Context:Create(window)
    world = World:Create()
    camera = Camera:Create()
    camera:SetPosition(0,5,-5)
    camera:SetMultisampleMode(8)
    skybox = Texture:Load("Materials/Sky/skybox_texture.tex")
    camera:SetSkybox(skybox)
    light = DirectionalLight:Create()
    light:SetRotation(35,35,0)
    
    terrain = Terrain:Create(64,true)
    terrain:SetLayerTexture(0, Texture:Load("Materials/Developer/Bluegrid.tex"), 0)
    terrain:SetScale(1,100,1)
    
    ball = Model:Sphere(32)
    ballmat = Material:Load("Materials/Developer/Orangegrid.mat")
    ball:SetMaterial(ballmat)
    ball:SetScale(4,4,4)
    shape = Shape:Sphere(0,0,0, 0,0,0, 1,1,1)
    ball:SetShape(shape)
    shape:Release()
    ball:SetCollisionType(Collision.Prop)
    ball:SetSweptCollisionMode(true)
    ball:SetPosition(24,6,0)
    ball:SetMass(1)
    
    camera:Point(ball)
    
    while window:KeyDown(Key.Escape)==false do
    	if window:Closed() then break end
    	
    	pos = ball:GetPosition(true)
    	camera:SetPosition(pos.x,6,pos.z-10)
    	camera:Point(ball)
    	
    	if terrain~=nil then
    		for x = 0, 64  do
    			local y = Time:Millisecs()/600
    			for z = 0, 64 do
    				local height = math.sin(y+x) / 40
    				terrain:SetHeight(x,z,height)
    			end
    		end
    		terrain:UpdateNormals()
    	end
     
    	Time:Update()
    	world:Update()
    	world:Render()
    	
    	context:Sync(true)
    end
    • Thanks 2
  2. Ok I got it working. No script needed. Just slap it on an object. Works with posteffects now and no crazy watermode acrobatics. It's a repurpose of the Leadwerks soft particle shader.

    I set the material settings to blend mode:Alpha, uncheck cast shadows, check two-sided, check depth test, uncheck depth mask, check z-sort, check pick mode.

     

    ff.jpg

    forcefield.zip

    • Like 5
  3. Yeah I'm just stockpiling right now. I have a bunch of shaders I'll put out in a while. I don't think it will matter that much since I think everyone's moved on from LE4. I get the benefit of having put in the effort, though.

  4. That's ok, man. I got the soft particle thing and the forcefield working using this method. The problem I was having was because I had other shaders in my scene using texture4 for something other than depth. They work perfectly now. I don't know why Josh wouldn't just set up a "depth mode" as  a permanent thing so that people could use depth buffers for cool stuff.  Leadwerks' aversion to shaders is self-defeating, imo.

    • Like 1
  5. I made this forcefield shader using the watermode depth buffer which works great. I replaced the Leadwerks water shader with this dummy shader:

    //fragment

    #version 400

    //Uniforms
    uniform sampler2D texture4;// depth

    void main(void)
    {    
        float depth = textureProj(texture4,vec3(1)).r;
    }

    //vertex

    #version 400
    #define MAX_INSTANCES 256

    void main()
    {

    }

    ... and I used this script to turn on watermode and set the waterplane height:

    function Script:Start()
        world = World:GetCurrent()
        world:SetWaterMode(true)
        world:SetWaterQuality(1)
    end

    function Script:UpdatePhysics()
        world:SetWaterHeight(3.0)
    end

     

    ... everything works great and the shader works with post effects, which is something I couldn't get accomplished before, AND I'm getting excellent FPS. The problem is I lose the effect as soon as the water plane goes off camera. So I'm thinking if there is a way to create a "depth mode" which keeps the (invisible) water plane on camera at all times that would open up a nice little corner for using the depth buffer for things like a forcefield, water foam, water fog, ground fog, and soft particle falloff effects such as seen here:
    http://blog.wolfire.com/2010/04/Soft-Particles




     

    water in view.jpg

    waterout of view.jpg

    • Like 2
  6. That's ok. I"m not a shader expert either.  I appreciate you taking a stab at it. It would be nice to solve it just because it irritates me to find this apparent limitation. I'm hoping someone will read this and be able to tell me at least why it happens.

    It seems if I set the player (camera) in the scene then create the depth buffer object I can get away with putting the camera variable in the Start() function. But when I turn the player's head the depth buffer wobbles around in odd ways. If I remove the player and put him back in the scene, the depth buffer stops moving around but I then have to grab the camera in the UpdateWorld() function. I don't know if that has to do with the problem and might offer a clue, or if it's just a whole other problem.

     

  7. I don't know what it was. I went in offline mode on Steam and I closed Rainmeter. It told me the .werk file for my project was missing. That happens sometimes. Started a new project and now it seems to be working just fine.  I'm not tech savvy so if you highly suspect Rainmeter it's probably that, as far as I'm concerned.

  8. So this works but it eats up the FPS constantly loading and deleting the shader. Bloom effect brought me all the way down to a constant 7 FPS. Not sure exactly why this works but there's got to be a better way. Anyone?

     

    function Script:UpdateWorld()
        self.world = World:GetCurrent()
        if self.camera==nil then
            for i=0,self.world:CountEntities()-1 do
                if self.world:GetEntity(i):GetClass()==Object.CameraClass then
                    self.camera=self.world:GetEntity(i)
                    tolua.cast(self.camera,"Camera")
                    return
                end
            end
        end
        depthbuffer:Clear()
        depthbuffer:Enable()
        self.camera:ClearPostEffects()  <---
        world:Render()
        depthbuffer:Disable()
        self.camera:AddPostEffect("Shaders/PostEffects/bloom.lua")  <---
        Context:SetCurrent(context)
    end

  9. That's what I did. I loaded your null shader. Same results as other posteffect shaders. No line. It's the depth from the Leadwerks water shader, which works while there are posteffects running from what I can tell. So it seems to me there is something that is enabled or present somewhere in water mode that I'm not aware of .

  10. Ok I restarted my computer, went into offline mode on Steam, closed Rainmeter. Started Leadwerks. It said the project file .werk was missing. Started a new project and now it seems to be working. Didn't see any recent updates but then again I'm not entirely sure what I'm looking for. So it must be one of those things.

  11. Another thing that's happening is when I run the game the output says "Executing C:\Users\Owner\...." but nothing else. No warnings or errors occur. The game runs. And then when I go to shut the script editor it tells me an external process is still running and asks if I want to terminate it. All this is new.

  12. When I run the game the output says Executing...exe and then nothing. I can run it but something is off. If I close the Script Editor it says "An external process is still running. Do you want to terminate it? Seems like I started putting the perspective view in realtime render then moving it around and then like the next day all this.

×
×
  • Create New...