Roland Posted June 19, 2012 Share Posted June 19, 2012 Programmers making art ... yeah.. I know ... Anyway. I making some stone walls and had an idea of using two texture layers. One layer that is tiled and another that is not. The tiled layer is the base diffuse color (and normal map) while the non-tiled layer would be some dirt and grime added. My idea was to get a high detail on the base color and then add some flavor to that using the second layer. But how is this done? Or is it even possible to do. I have seen that its possible to have two UV-maps on the models and use different textures for each of them. Is that how to do it? And if so. Can Leadwerks handle two uv-maps with different textures? Have you guys any suggestions? Quote Roland Strålberg Website: https://rstralberg.com Link to comment Share on other sites More sharing options...
Furbolg Posted June 19, 2012 Share Posted June 19, 2012 You meaning detail maps ? http://www.cafu.de/wiki/textures:perfect_detail_maps If yes then i think its just a second textures which is blended multiplytive above the first one. Quote Link to comment Share on other sites More sharing options...
shadmar Posted June 19, 2012 Share Posted June 19, 2012 You can do that in a shader using to 2 texcoords for diffuse if you do the tiling in the shader you can keep the other stretched. Simply multiply them to blend even. Maybe the existing shaders support it, haven't checked. Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
Pixel Perfect Posted June 19, 2012 Share Posted June 19, 2012 I've seen someone do this before in Leadwerks using vertex color for the dirt Quote Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++ Link to comment Share on other sites More sharing options...
Naughty Alien Posted June 19, 2012 Share Posted June 19, 2012 ..something like this, should work.. varying vec3 lightDir,normal; uniform sampler2D MyDifuseTexture,MyTextureOverDifuse; void main() { vec3 ct,cf,c; vec4 texel; float intensity,at,af,a; intensity = max(dot(lightDir,normalize(normal)),0.0); cf = intensity * (gl_FrontMaterial.diffuse).rgb + gl_FrontMaterial.ambient.rgb; af = gl_FrontMaterial.diffuse.a; texel = texture2D(MyDifuseTexture,gl_TexCoord[0].st); ct = texel.rgb; at = texel.a; c = cf * ct; a = af * at; float coef = smoothstep(1.0,0.2,intensity); c += coef * vec3(texture2D(MyTextureOverDifuse,gl_TexCoord[0].st)); gl_FragColor = vec4(c, a); } Quote Link to comment Share on other sites More sharing options...
Roland Posted June 19, 2012 Author Share Posted June 19, 2012 You guys are just so awesome Can't wait until I get home a test Quote Roland Strålberg Website: https://rstralberg.com Link to comment Share on other sites More sharing options...
Roland Posted June 19, 2012 Author Share Posted June 19, 2012 You meaning detail maps ? http://www.cafu.de/w...ect_detail_maps If yes then i think its just a second textures which is blended multiplytive above the first one. Not quite. Grrrr .. my lack of English. Let's illustrate then Lets say I have this tile (256x256) and an oyerlay (512x512) Then I want to add the tile to plane (tile 4 times = 512x512) and the place the overlay on the same plane, like this or without the red tile markers and of course I want to place the overlay in code (or bye mat-file) so I can use different overlays. Quote Roland Strålberg Website: https://rstralberg.com Link to comment Share on other sites More sharing options...
shadmar Posted June 19, 2012 Share Posted June 19, 2012 You can do this with 2 uv sets.. UV1 has 4 tiles UV2 has 1 tile... ..and a small shader change (2-3 lines or so in the mesh.frag) Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
shadmar Posted June 19, 2012 Share Posted June 19, 2012 shader change for this test was : Before main() add uniform sampler2D texture8; Find diffuse *= texture2D(LW_DIFFUSE,texcoord0);//*fOcclusionShadow Add below this line : diffuse *= texture2D(texture8,texcoord1); //texcoord1 reads UV channel 2 or use + to add it on top, use black as background. Add texture8= to your mat file and use any diffuse shader. Might be useful to use glsl preprocessor directives so it doesn't apply to everything. Just create a mesh_diffuse_whateverelse_2uvmaps.frag and use #declare dualUV 1 Then in mesh.frag test if this is true and apply the example above. This way you can apply 2 UV sets using any shader, bump specular, glow or what not. good luck Let me know if it works or just ask, Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
Roland Posted June 19, 2012 Author Share Posted June 19, 2012 @Shadmar I'm probably doing something wrong. With those changes my MaterialEditor and Editor crashes. I have attached my files. Quote Roland Strålberg Website: https://rstralberg.com Link to comment Share on other sites More sharing options...
shadmar Posted June 19, 2012 Share Posted June 19, 2012 @Shadmar I'm probably doing something wrong. With those changes my MaterialEditor and Editor crashes. I have attached my files. Ah.. You missed the directive around diffuse *= texture2D(texture8,texcoord1); //texcoord1 reads UV channel 2 And #declare should be #define. And The diffuse should also go in the 2uv.frag file #define LW_DIFFUSE texture0 Looks good! This is what I got : Here are the shader files fixed : frags.zip 1 Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
Roland Posted June 19, 2012 Author Share Posted June 19, 2012 Wow. Thanks thanks thanks. Shadmar Now I can get good details using tiles and at the same get dirt there with good resolution. That was really kind of you to take the time for this. Much appreciated. Hope this of some usage for others also Quote Roland Strålberg Website: https://rstralberg.com Link to comment Share on other sites More sharing options...
shadmar Posted June 20, 2012 Share Posted June 20, 2012 Don't worry, I'm having fun doing shaderstuff Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
Recommended Posts
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.