Jump to content

shadmar

Members
  • Posts

    3,618
  • Joined

  • Last visited

Posts posted by shadmar

  1. You can use this unless you're doing randoms before rendering starts. There will be tiny variations in rendering speed.

    first 5 will always be the same since GetSpeed is then 0 after first frame you will have randoms.

     

    function Script:UpdateWorld()
       math.randomseed(Time:GetSpeed()*43758.5453)
       for x=0,4,1
       do
           System:Print(math.random())
       end
       System:Print(" ---- ")
    end

  2. Just add this line at the bottom of the shader to burn red.

     

    if (NoiseV<InvAlpha+0.025) fragData2 = vec4(1.0,0.0,0.0,specular);

     

    0.025 is the width of the burn, 1.0,0.0,0.0,0.0 is the color.

     

    EDIT: it's already in there in the zips above, however after the decal update, materialflags were moved.

    • Upvote 1
  3. This generates clouds in the DayNight.shader

    if you change ctime to -ctime they go the opposite way.

     

    vec3 cloud2(float cloudheight,float scale)
    {
       vec2 p=vec2(vp.zx/(vp.y))*cloudheight;
       vec3 c = vec3(.0, .0, .2);
       c.rgb += vec3(.6, .6, .8) * cloud(p*.3+ctime*.0002,scale)*.5;
       c.gbr += vec3(.8, .8, 1.) * cloud(p*.2+ctime*.0002,scale)*.1;
       c.grb += vec3(1., 1., 1.) * cloud(p*.1+ctime*.0002,scale)*1.;
       return c.rrr;
    }

  4. Here is a nice cull script I've used alot

     

        --optimize scene place objects in viewrange based on their aabb radius.
       for i=0,world:CountEntities()-1 do
        if world:GetEntity(i):GetClass()==Object.ModelClass then
    		    local aabb=world:GetEntity(i):GetAABB(Entity.GlobalAABB)
                   if         aabb and aabb.radius < .1 then world:GetEntity(i):SetViewRange(0)
                   elseif     aabb and aabb.radius < 1 then world:GetEntity(i):SetViewRange(1)
                   elseif     aabb and aabb.radius < 10 then world:GetEntity(i):SetViewRange(2)
                   elseif     aabb and aabb.radius < 20 then world:GetEntity(i):SetViewRange(3)
                   else     world:GetEntity(i):SetViewRange(4) end
        end
       end

    • Upvote 1
  5. Realtime reflections using dual parabolic env shader (2 extra cameras with the new render to texture)

     

     

    But there is a caveat..., since I can't hide the reflection object before the render to texture, I have to place the cameras inside the sphere.

    So.. it will only work for spheres. Arbitrary geometry would self reflect.

    • Upvote 5
  6. You can recalculate normals with a geometry shader as flat like this: (will override all mesh smoothing)

     

    vec3 edge1 = vertex_position[1].xyz-vertex_position[0].xyz;
    vec3 edge2 = vertex_position[2].xyz-vertex_position[0].xyz;
    mat4 nm=transpose((cameramatrix));
    vec3 faceNorm = mat3(nm) * normalize(cross(edge2,edge1));
    

×
×
  • Create New...