Horde3D

Next-Generation Graphics Engine
It is currently 28.04.2024, 13:21

All times are UTC + 1 hour




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Simple shader
PostPosted: 31.10.2009, 13:48 
Offline

Joined: 31.10.2009, 13:38
Posts: 2
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: Simple shader
PostPosted: 31.10.2009, 23:26 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: Simple shader
PostPosted: 02.11.2009, 10:22 
Offline

Joined: 31.10.2009, 13:38
Posts: 2
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: Simple shader
PostPosted: 10.11.2009, 09:16 
Offline

Joined: 16.05.2009, 12:43
Posts: 207
Glad you found it useful.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group