Search Home Members Contacts
About Us
Products
Downloads
Community
Support
Pages: 1 2 3 [4] 5
  Print  
Author Topic: Shader FAQ  (Read 13600 times)
BlindSide
Customers
Community Member
*****
Posts: 759


WWW
« Reply #60 on: September 26, 2006, 06:12:36 PM »

Thanks Zak - I wasn't sure if it would be of interest to anyone else, but it does help me flesh out ideas. I actually intended itso that I could post dev. info on the demo I'm working on, but I figured I might as well use it for general R&D as well.

That said, I was wondering if I could include some of your shader tut's from the wiki in my site, full credit of course, for anyone who stumbles by =)
Logged

Blind's Dev Blog - www.smithbower.com/devblog/

Irc.Desolation.Org :: #TV3DLicensed :: Moderated IRC channel for all your TV3D needs :: Non-Licensed users welcome.
Zaknafein
Customers
Community Member
*****
Posts: 2670


WWW
« Reply #61 on: September 26, 2006, 11:48:40 PM »

Sure, if you want. But honestly I'd prefer if you linked the wiki article itself, it's simpler for you when I update it and it gives good publicity to the wiki... Smiley
Logged

zaknafein.
>> the instruction limit : my blog & samples repository! <<
Waterman
Customers
Community Member
*****
Posts: 1141


« Reply #62 on: September 27, 2006, 08:22:11 AM »

Quote from: "Zaknafein"
Sorry for arguing, but how is that a contradiction? Isn't a vector in 3D space a 3D vector?

Thanks though, you and Blind. And heck, that's an interesting blog you got there Blind.


I see you good intention but these are really fundamental conventions when describing data. Not a big deal, but:

Singleton: Data that has no dimensions.
Vector: One dimensional data, always a sequence of numbers (can be more or less than 3).
Matrix: Data with two or more dimensions, typically a table if 2 dimensions, e.g. OLAP cubes if 3 or more. Think of it: A 2-dimensional matrix actually describes data in 3D space, so by that concept we should call it a 3 dimensional matrix!

That's why a "3 dimensional vector" is a contradiction; it has always 1 dimension only. But what it describes, that's another thing.

I think that a "3D vector" sounds different, and even "3 dimension vector" (without the "al") although that's at the fuzzy border. A 3D vector it is :-).
Logged

Things should be described as simply as possible - but not simpler [A. Einstein]
Zaknafein
Customers
Community Member
*****
Posts: 2670


WWW
« Reply #63 on: September 27, 2006, 10:50:27 AM »

Aaah I see, thanks for the insight. It does make sense now. Smiley
Hm, you say "singleton" for single values... I'm used to say "scalar" because the french equivalent is "scalaire", are those two synonyms? "Singleton" sounds like the OOP concept to me Tongue
Logged

zaknafein.
>> the instruction limit : my blog & samples repository! <<
phether
Customers
Community Member
*****
Posts: 420


« Reply #64 on: September 27, 2006, 12:19:29 PM »

call it a singularity  :twisted:
Logged

Birds of a phether...
Code with pride not ego!
Waterman
Customers
Community Member
*****
Posts: 1141


« Reply #65 on: September 27, 2006, 01:29:24 PM »

Quote from: "Zaknafein"
Aaah I see, thanks for the insight. It does make sense now. Smiley
Hm, you say "singleton" for single values... I'm used to say "scalar" because the french equivalent is "scalaire", are those two synonyms? "Singleton" sounds like the OOP concept to me Tongue


Not quite, although scalar is commonly used (and that's what we want, that people understand).

A singleton is a set with exactly one element and a set is a singleton if and only if its cardinality is 1, while a scalar is a number as opposed to a character, vector, function,  object etc. But a set may also hold for example text data (or other non-numeric data) and a set may have any shape (including multidimensional), thus a singleton is a more precise definition to cover it all.

But... scalar is all ok :-). It's one number.
Logged

Things should be described as simply as possible - but not simpler [A. Einstein]
CSharpDavid
Customers
Community Member
*****
Posts: 51


« Reply #66 on: September 29, 2006, 02:18:08 PM »

From a physics point of view

A Scalar value is one which has magnitude, but no direction

A vector is one which has both magnitude, and direction.

a vector can be described in any number of dimensions so to describe a 3D vector is both legal and descriptive.
Logged

David
Dan
Customers
Community Member
*****
Posts: 707


WWW
« Reply #67 on: October 24, 2006, 06:04:34 PM »

Quick question. What is the correct method for cleanly removing a shader from a mesh. I am currently destroying the mesh and reapply the required non shader settings. This works for me but just wondered if an alternative exists?
Logged
Waterman
Customers
Community Member
*****
Posts: 1141


« Reply #68 on: October 25, 2006, 01:59:27 AM »

Mesh.SetShader [null, nothing, nil, whatever you name it]

Also works for Landscape.SetShader (i've verified) and probably everywhere as expected.
Logged

Things should be described as simply as possible - but not simpler [A. Einstein]
osmcvl
Customers
Community Member
*****
Posts: 15


« Reply #69 on: November 19, 2006, 08:21:56 AM »

please help me, this result color WHITE, i want this result color is RED. When this error  :oops:

    Teste := Scene.CreateMeshBuilder('teste');
    Teste.CreateSphere(10,10,10);
    TesteShd := Scene.CreateShader('TesteShader');
    Testeshd.SetTechnique('TSM3');
    TesteShd.CreateFromEffectFile('c:\agua\shaders\Teste.fx');
    Teste.SetShader(TesteShd);

// teste.fx
float4x4 matViewProjection : ViewProjection;
struct VS_OUTPUT
{
   float4 Pos:     POSITION;
};
VS_OUTPUT vs_main( float4 inPos: POSITION )
{
   VS_OUTPUT Out;
   Out.Pos = mul(inPos, matViewProjection);
   return Out;
}
float4 ps_main( float4 inDiffuse: COLOR0 ) : COLOR0
{
   float4 color;
   color[0] = color[3] = 1.0;
   color[1] = color[2] = 0.0;
   return color;
}
technique TSM2 {
    pass P0 {
        VertexShader = compile vs_2_0 vs_main();
        PixelShader  = compile ps_2_0 ps_main();
    }
}
technique TSM3{
    pass P0 {
        VertexShader = compile vs_3_0 vs_main();
        PixelShader  = compile ps_3_0 ps_main();
    }
}


//DEGUG.TXT
11-19-2006 11:09:51 | DEVICE INFO : Vertex Shaders 3.0 supported in hardware.
11-19-2006 11:09:51 | DEVICE INFO : Pixel Shaders 3.0 supported in hardware.
SHADER MANAGER : Shader 'TesteShader' successfully created.
Logged
Zarkow
Customers
Community Member
*****
Posts: 342


WWW
« Reply #70 on: May 09, 2007, 06:07:04 PM »

Quote from: "bruffner"

------------------------------------------------------------------------------
Is there an example of a full screen shader?

Thanks to Sylvain, yes there is:

http://www.shelter7.com/FullscreenShader.fx


Quote

05-10-2007 05:50:05 | SHADER MANAGER : Error : error X3507: 'VS_Main': function must return a value
D:\[removed]\data\shaders\FullscreenShader.fx(76): ID3DXEffectCompiler::CompileEffect: There was an error compiling expression
ID3DXEffectCompiler: Compilation failed
Logged
Zaknafein
Customers
Community Member
*****
Posts: 2670


WWW
« Reply #71 on: May 09, 2007, 06:27:14 PM »

It's a no-brainer... just add "return output;" to the vertex shader.
Logged

zaknafein.
>> the instruction limit : my blog & samples repository! <<
Zarkow
Customers
Community Member
*****
Posts: 342


WWW
« Reply #72 on: May 09, 2007, 06:35:06 PM »

Yeah, I know and I did when I looked at it, but the file should be updated. Cheesy

Unless the error was added as a training-step.
Logged
Craigomatic
Customers
Community Member
*****
Posts: 78


« Reply #73 on: August 05, 2007, 08:54:04 PM »

How is a shader include loaded up?

A number of the shaders in the FX Composer library have this include:
Code:
#include <include\\Quad.fxh>


Logged
GD
Customers
Community Member
*****
Posts: 364


« Reply #74 on: August 06, 2007, 02:27:49 AM »

Quad.fxh is just a set of few defines that make shader writing easier.
You could also make your own file with functions and defines that you want to share with your shaders.
It's best to put includes in the same path as .fx's and use #include "Quad.fxh".
Logged

tvsm.co.cc - TVSceneManager
Craigomatic
Customers
Community Member
*****
Posts: 78


« Reply #75 on: August 06, 2007, 04:58:43 PM »

Thanks for the reply GD, what I'm mainly wanting to do is support shaders from as many different places as possible, ie: the NVIDIA shader lib.

Without going into too much detail, the shaders are all being loaded from memory via something similar to:

Code:
tvshader.CreateFromEffectString(shaderString)

So I have everything coming in as strings, including the includes. Is there a way to load the include up into the shader first? Or combine the strings (include with the shader) and put it straight into CreateFromEffectString?
Logged
sybixsus
Customers
Community Member
*****
Posts: 1088


WWW
« Reply #76 on: August 06, 2007, 07:24:30 PM »

Thanks for the reply GD, what I'm mainly wanting to do is support shaders from as many different places as possible, ie: the NVIDIA shader lib.

Without going into too much detail, the shaders are all being loaded from memory via something similar to:

Code:
tvshader.CreateFromEffectString(shaderString)

So I have everything coming in as strings, including the includes. Is there a way to load the include up into the shader first? Or combine the strings (include with the shader) and put it straight into CreateFromEffectString?

Write a mini-parser which parses includes, finds their location on disk, loads them and includes them into the string.
Logged
Insomnia
Community Member
*
Posts: 23


WWW
« Reply #77 on: February 07, 2008, 10:27:09 AM »

Hi there, I have trouble initializing a shader. I'm working with VB6, and when I call Scene.CreateShader it just sais "property or method unknown" for this line, though CreateShader is in the functions list of TVScene.
What's the problem here? (Same for Scene.CreateParticleSystem by the way)

Thanks for any help Smiley
Logged

macrosii
Customers
Community Member
*****
Posts: 48


« Reply #78 on: March 03, 2008, 05:03:49 PM »

For those that are interested some of the Bugs of Rendermonkey are fixed.  A simple shader will now run unmodded.  You must sellect the default packing order so that the matrix packing is the same as directX expects.

Regards
Macrosii
Logged
GosikII
Community Member
*
Posts: 13


« Reply #79 on: October 07, 2008, 12:43:03 PM »

How to modify "wind.shade" from "Windy Grass" sample for work with TVMesh. It works only with minimesh.  What difference between these classes (Minimesh, Tvmesh).  Huh

Code:
//------------------------------------------------------------------------------
// SHADE.
//----------------
// Wind Shader.
// Written By Geoff Wilson.
//---------------------------------
        float4x4 Wrld           : WORLD;
        float4x4 ViewProj       : VIEWPROJECTION;
        float4x3 WorldIT        : MINIMESH_WORLDINVERSETRANSPOSE;
        float4x3 World[52]      : MINIMESH_WORLD;
        float4   Colour[52]     : MINIMESH_COLOR;
       
        float3   Light          = float3(280, 450, 280);
        float3   LightColour    = float3(1, 0.8, 0.8);
        float    LightRange     = 75;
       
        float    Tick           : TIME;

        texture  Diffuse        : TEXTURE0;
       
        float    WindSpeed      = 2;
        float    WindPower      = 0.09;

//------------------------------
// Samplers.
//-------

        sampler2D DiffuseSampler = sampler_state
        {
                Texture          = (Diffuse);
                MIPFILTER        = LINEAR;
                MAGFILTER        = LINEAR;
                MINFILTER        = LINEAR;
        };

//------------------------------
// Structs.
//-------

        struct a2v //App->Vertex.
        {
                float4 Position : POSITION0;
                float3 Normal   : NORMAL;
                float2 UV       : TEXCOORD0;
                float2 Index    : TEXCOORD1;
        };

        struct v2p //Vertex->Pixel.
        {
                float4 Position : POSITION0;
                float2 UV       : TEXCOORD0;
                float4 Colour   : TEXCOORD1;
        };

        struct p2s //Pixel->Screen.
        {
                float4 Colour   : COLOR0;
        };

//------------------------------
// Programs.
//-------

        void vp( in a2v IN, out v2p OUT )
        {
                float4x3 cMatrix  = World[IN.Index.x];
               
                float3   Weight   = float3(IN.Position.x, 0, IN.Position.z);
                IN.Position.z    += (sin(WindSpeed * Tick) * WindPower) * distance(Weight.y, IN.Position.y);
                IN.Position.x    += (sin(WindSpeed * Tick) * WindPower) * distance(Weight.y, IN.Position.y);
               
                float3   WorldPos = mul(IN.Position, cMatrix);
               
                OUT.Position      = mul(float4(WorldPos, 1), ViewProj);
               
//Start test lighting.
                float  Att        = (Light.xyz - WorldPos.xyz);
                float3 L          = normalize(Light - WorldPos);
                float3 N          = normalize(mul(IN.Normal, (float3x3)(cMatrix)));
                float  D0         = saturate(dot(L, N)) * clamp(1 - length(Att) / LightRange, 0, 1);
                D0               += 0.15;
               
                float4 Ec         = float4(D0, D0, D0, 1);
//End test lighting.
               
                OUT.UV            = IN.UV;
               
                OUT.Colour        = Colour[IN.Index.x] * Ec;
        }

        void fp( in v2p IN, out p2s OUT )
        {
                OUT.Colour        = IN.Colour * tex2D(DiffuseSampler, IN.UV);
        }

        technique render
        {
                pass pass0
                {
                        vertexshader = compile vs_2_0 vp();
                        pixelshader  = compile ps_2_0 fp();
                }
        }

   
Logged
Pages: 1 2 3 [4] 5
  Print  
 
Jump to:  

Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks