Horde3D http://horde3d.org/forums/ |
|
Simple shader http://horde3d.org/forums/viewtopic.php?f=1&t=999 |
Page 1 of 1 |
Author: | mathusalem [ 31.10.2009, 13:48 ] |
Post subject: | Simple shader |
Good afternoon, I'm trying to implement a very simple render pipeline. A shader is used for texturing meshes without any lighting rendering technique. Here's what i've got so far: Code: [[FX]] // Samplers sampler albedoMap; // Samplers sampler albedoMap = sampler_state { Address = Clamp; Filter = Bilinear; MaxAnisotropy = 1; }; context ATTRIBPASS { VertexShader = compile GLSL VS_GENERAL; PixelShader = compile GLSL FS_ATTRIBPASS; } [[VS_GENERAL]] // ================================================================================================= #include "shaders/utilityLib/vertCommon.glsl" attribute vec2 texCoords0; varying vec4 pos; varying vec2 texCoords; void main() { pos = calcWorldPos( gl_Vertex ); texCoords = texCoords0; gl_Position = gl_ModelViewProjectionMatrix * pos; } [[FS_ATTRIBPASS]] // ================================================================================================= #include "shaders/utilityLib/fragDeferredWrite.glsl" uniform sampler2D albedoMap; varying vec4 pos; varying vec2 texCoords; void main() { vec3 newCoords = vec3(texCoords, 0); newCoords.t *= -1.0; vec4 albedo = texture2D( albedoMap, newCoords.st ); vec3 newPos = pos.xyz; setMatID( 1.0 ); setPos( newPos ); setAlbedo( albedo.rgb ); } I'm very new to shader (and Horde3D), and something is certainly missing in this code because meshes doesn't appear at all. This code is inspired from the "model.shader" file. When i'm working with colour only (no texturing), it's working. I'm assuming that is comes from the texturing process. Any directions ? Thanks. |
Author: | marciano [ 31.10.2009, 23:26 ] |
Post subject: | Re: Simple shader |
The problem that you run into is unfortunately not very obvious. It is the texture address mode. Since the v-coordinate is negated due to usage of the d3d convention (for dds), 'Clamp' does not work here (it will cut the negative value). You have to use 'Wrap' instead. |
Author: | mathusalem [ 02.11.2009, 10:22 ] |
Post subject: | Re: Simple shader |
marciano, I didn't try your method, but instead i've found another shader for lightmaping in the forum which perfectly fit my needs. Author is zoombapup, here's the link: viewtopic.php?f=4&t=925&hilit=lightmap Thanks. |
Author: | zoombapup [ 10.11.2009, 09:16 ] |
Post subject: | Re: Simple shader |
Glad you found it useful. |
Page 1 of 1 | All times are UTC + 1 hour |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |