Kronos Posted January 5, 2010 Share Posted January 5, 2010 Hi, I have finally started looking at shaders. I have made this little thing as a start based on something I found on the internet. This should take four textures, multiply them with alpha textures(red) and then add the results together. The sort of thing one might use for terrain texturing for instance. uniform sampler2D texture0; uniform sampler2D texture1; uniform sampler2D texture2; uniform sampler2D texture3; uniform sampler2D texture4; uniform sampler2D texture5; uniform sampler2D texture6; uniform sampler2D texture7; varying vec4 texCoord; void main() { vec4 alpha1 = texture2D( texture0, texCoord.xy); vec4 alpha2 = texture2D( texture1, texCoord.xy); vec4 alpha3 = texture2D( texture2, texCoord.xy); vec4 alpha4 = texture2D( texture3, texCoord.xy); vec4 tex1 = texture2D( texture4, texCoord.xy * 100.0 ); vec4 tex2 = texture2D( texture5, texCoord.xy * 100.0 ); vec4 tex3 = texture2D( texture6, texCoord.xy * 100.0 ); vec4 tex4 = texture2D( texture7, texCoord.xy * 100.0 ); tex1 *= alpha1.r; tex2 *= alpha2.r; tex3 *= alpha3.r; tex4 *= alpha4.r; vec4 outcolor = tex1+tex2+tex3+tex4; gl_FragColor = outcolor; } My question is what vertex shader (if any) should I use with this. Any other tips would be welcome. Quote intel i5 2500k, ram 16gb, nvidia Geforce GTX570, asus xonar sound card. Windows 7 64 bit Link to comment Share on other sites More sharing options...
Paul Thomas Posted January 5, 2010 Share Posted January 5, 2010 Quickly guessing and depends on what you plan on using it for; Rename "varying vec4 texCoord;" to "varying vec2 texcoord0;" and use mesh.vert. Quote Link to comment Share on other sites More sharing options...
Kronos Posted January 9, 2010 Author Share Posted January 9, 2010 Hmm that didnt really work. Just get an overall greenish colour on the surface and nothing else. The best I have got so far is using sprite.vert. I can see the texture(s) using that but there is some weird light error going on. it may be unrelated to the shader but when the camera turns in certain direction everything goes white on the surface of the mesh. I am just using a large squashed cube for testing purposes at the moment. Quote intel i5 2500k, ram 16gb, nvidia Geforce GTX570, asus xonar sound card. Windows 7 64 bit 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.