Jump to content

Painting/drawing in Leadwerks?


havenphillip
 Share

Recommended Posts

6 hours ago, Yue said:

the ground must be of many triangles so that the effect is much more pleasing.

Yes I did build such a mesh but the triangles are not bound each other and it results a hole. 

You can't think - as I did :D - that the mesh will   react like a terrain forming, with each segment moving the next with itself, going up and down as you expect., building a beautiful hill.

No. Mesh is composed of lots of triangle but moving one vertex open a window in the mesh, - so practically you will have to calculate with this method the interpolated positions of all neighbor vertex to simulate properly a beautiful wave. If not your mesh will only looks messy

  • Like 1

 

 

Link to comment
Share on other sites

  • 3 weeks later...

Ok so I was able to make this simple painter using a Shadertoy shader. Just put a pivot in a new scene and attach the script to it. The problem I have is when I try to switch the shader over to a model shader, and I change the line in the shader from:

    if(length((coord*buffersize) - mouse_pos.xy) > radius) discard;

...to this:

    if(length(ex_vertexposition.xy - cameraposition.xy) > radius) discard;

...and change these updateworld lines also in the script to this:

function Script:UpdateWorld()
    mouse = self.entity:GetPosition(true) 
    self.shader:SetVec3("cameraposition", mouse)
end

...I end up with a dot that follows the camera around but it stops leaving trails.

 

I don't understand what I'm losing in the process. Why is that happening?

 

 

painter.zip

48897602_simplepaint.thumb.jpg.be2a8124f00fa4f97071109d21d83750.jpg

Link to comment
Share on other sites

Yeah you totally can. It's just a matter of changing the alpha value of the diffuse texture in the diffuse + normal decal shader. Try this shader on your decal material:

decal alpha + normal.zip

 

I changed only three lines:

    //Alpha
    fragData0.a = 0.0; //was probably 1.0
    fragData1.a = 1.0; //was fragData0.a;   ... was set to the alpha of the diffuse so when you set diffuse alpha to zero it also set normal alpha to zero
    fragData2 = vec4(vec3(0),1.0); //the alpha channel was fragData0.a

I also normalized the ex_tangent, ex_binormal, and ex_normal.

Here I just tried it with the bulletmark decal material. Only the normals show up. No diffuse:

712535140_decalalpha.thumb.jpg.01da38bf517e1e2cd347045ec1669340.jpg

 

Also I have the material set like this (not sure how much "pick mode" or "z-sort" matter):

676610048_decalsetup.thumb.jpg.e15874daddc1febfd8185a51d32133d4.jpg

 

  • Like 2
Link to comment
Share on other sites

  • 3 months later...

@havenphillip

Hi,

I tried today to get that work but sorry I'm a terrible zero with shader.

So I just did not get the traces to work as expected.

No matter if I use one or the second shader that comes with the download.

You put in the download height.tex and height2.tex, should i use one of them in the material ? Where?

Maybe you could just post a little screenshot of your material textures view, thx a lot

Edit

Got it to work, using tire_height.tex in the displacement slot and the "decal alpha + normal.shader"

the effect is really cool, will be useful for foot steps too I think! 

  • Like 2

 

 

Link to comment
Share on other sites

Yeah sorry I didn't clarify. I added a normals from heightmap part to it to get an extra boost on the groove of the tread. I think if you don't want the heightmap used you can hide this line:

    normal = mix(heightnormal,normal,0.5);

...and remove the whole "normals from heightmap" section and it should work fine if you have a dramatic normal map.

  • Like 2
  • Thanks 1
Link to comment
Share on other sites

13 minutes ago, Marcousik said:

Will you put the feature road tracer ?

Yeah, I was thinking I could create a bezier curve and turn that into a series of decals that form the road. This will come after the 1.0 release.

  • Upvote 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

On 6/17/2022 at 12:19 PM, Josh said:

Yeah, I was thinking I could create a bezier curve and turn that into a series of decals that form the road. This will come after the 1.0 release.

Yes something like a spline tool is a must.. But we should see the spline from the editor, that's the main feature I miss by Aggror Spline system

 

 

Link to comment
Share on other sites

Actually, I take that back. It should be done with meshes blended into the terrain, not decals. The way Epic is doing this is ridiculous. I thought of a method that will be much simpler and more efficient.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

  • 9 months later...

@havenphillip and @ all interested in this

On this topic on how to perform or animate traces on terrain especially water, mud or foot step, I worked on a your shader havenphilip

And here is what I obtain, playing with variables and shader equations:

 

And here is the shader

1950736501_Capturedcran(131).thumb.png.be7801a6c3c82773ca7bed34c24bbf70.png

 

Now the stuppid thing that I don't understand is :

I set the wind effect with the condition 

if (vertex_position.y > 100.1) 

I  actually used this  to stop the wind effect to be seen, but/so why  I can't just erase this wind?

Because if I erase the wind, the shader becaomes just mess ! I just don't understand why??

 

 

  • Like 1

 

 

Link to comment
Share on other sites

20 hours ago, havenphillip said:

You should be able to just erase these lines without any problem. It doesn't look like you're establishing anything here that you need to use later:

 

Yes that sounds logical.

But without those "wind" lines, the shader is not perfect, it breaks by rotating the camera, at some point, some of the mesh springs out and flickers.

Adding those lines solve the flickers 100% !

This is not a big issue but I can't understand why.

 

It is much more crazy; this is the difference by just changing a number of the wind line:

I set a 2 instead of 4, it is immediatly broken:

1978471760_Capturedcran(135).thumb.png.1b7362fd73cc8f1ccb5c3746bea4ef75.png

 

with a 4, it is perfect

850686408_Capturedcran(136).thumb.png.feab9d825659c55aa8d12b900885362e.png

INcredible, somethinng is wrong but Idk what

 

 

Link to comment
Share on other sites

I tried to reproduce it. I'm not getting the same outcome. It seems to be working correctly for me:

teapot.thumb.jpg.04a8b498e2ed37a0ae7ffa9b73203f10.jpg


When you zoom in and out on the object does it adjust itself? If it works correctly in-game then it might just be the material editor or have something to do with using the "player_pos".

Otherwise sometimes I've noticed if I restart my computer it will fix some of these weird things.

Does this work?:

 

 

#version 400
#define MAX_INSTANCES 256

//Uniforms
uniform instancematrices { mat4 matrix[MAX_INSTANCES];} entity;
uniform mat4 projectioncameramatrix;
uniform float currenttime;
float time = currenttime/1000;
uniform vec3 cameraposition;
uniform vec3 player_pos;

//Attributes
in vec3 vertex_position;
in vec2 vertex_texcoords0;
in vec3 vertex_normal;
in vec3 vertex_tangent;
in vec3 vertex_binormal;

//Outputs
out vec4 ex_vertexposition;
out vec2 ex_texcoords0;
out vec3 ex_normal;
out vec3 ex_tangent;
out vec3 ex_binormal;

void main()
{
    //entity matrix
    mat4 entitymatrix = entity.matrix[gl_InstanceID];
    mat4 entitymatrix_ = entitymatrix;
    entitymatrix_[0][3]=0.0;
    entitymatrix_[1][3]=0.0;
    entitymatrix_[2][3]=0.0;
    entitymatrix_[3][3]=1.0;
    
    //model position
    ex_vertexposition = entitymatrix_ * vec4(vertex_position,1.0);

    //Interactive
    vec3 direction = normalize(ex_vertexposition.xyz - player_pos);
    direction.y = -0.000;
    float radius = 2.0;
    float interact_power = 2.0;

    float dist = distance(player_pos,ex_vertexposition.xyz);
    float power = smoothstep(radius,0.0,dist*dist*0.3);
    direction = (vec4(direction,1.0) * entitymatrix_).xyz;
    ex_vertexposition.xyz += direction * power * 5.0 * interact_power * cos(5.0-ex_texcoords0.y)*cos(5.5-ex_texcoords0.x);

    gl_Position = projectioncameramatrix * ex_vertexposition;

    //normals
    mat3 nmat = mat3(entitymatrix_);
    ex_normal = normalize(nmat * vertex_normal);    
    ex_tangent = normalize(nmat * vertex_tangent);
    ex_binormal = normalize(nmat * vertex_binormal);

    //texture coordinates
    ex_texcoords0 = vertex_texcoords0;
}

 

 

Link to comment
Share on other sites

No it absolutely does not.  (but thx for helping)

1175672810_Capturedcran(137).thumb.png.83e02ba19fbbc3fa8883b6bb85161e5f.png

 

it only works if I add this absurd Wind lines

Quote

//Wind
    float time = currenttime/currenttime;
    if (vertex_position.y > 100.1) {
        ex_vertexposition.x += 0.25*cos(1.0*ex_vertexposition.y/2 + 1) * sin(1.0*ex_vertexposition.y/4 + 1); //must go //between these other two lines
        }

As I said it is not a big problem, only annoying because not really to understand.

Here is a WIP showcase  Part 2 for mud shader:

 

 

  • Like 1

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...