Hi everyone,
This is my first post on the forums.
![:) :)](https://polycount.com/plugins/emojiextender/emoji/twitter/smile.png)
Since a week I started with shader programming (HLSL), but allready I ran into a stopping problem.
I followed this
tutorial, a tutorial to write a simple ambient shader.
If I apply my shader to a model in Max 2013, or in FX Composer the model just dissapears. :shifty:
This is my shader code:
//===================================================
// Realtime game shader
// Bob Adriaenssen (CookieBE)
// 31/05/2012
// Version 0.1
// Copyright 2012. All rights reserved.
//===================================================
//===================================================
// Variables
//===================================================
float4x4 WorldMatrix;
float4x4 ViewMatrix;
float4x4 ProjectionMatrix;
float4 AmbientColor = float4( 1.0, 1.0, 1.0, 1.0);
float AmbientIntensity = 0.1;
//Tweakable parameters//
string UIName = "Test";
//===================================================
// Data structures
//===================================================
struct VertexShaderInput
{
float4 Position : POSITION0;
};
struct VertexShaderOutput
{
float4 Position : POSITION0;
};
//===================================================
// Vertex shaders
//===================================================
VertexShaderOutput VertexShaderFunction(VertexShaderInput input)
{
VertexShaderOutput output;
float4 worldPosition = mul(input.Position, WorldMatrix);
float4 viewPosition = mul(worldPosition, ViewMatrix);
output.Position = mul(viewPosition, ProjectionMatrix);
return output;
}
//===================================================
// Pixel shaders
//===================================================
float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
{
return AmbientColor * AmbientIntensity;
}
//===================================================
// Techniques
//===================================================
technique Flat
{
pass Pass0
{
CullMode = None;
VertexShader = compile vs_2_0 VertexShaderFunction();
PixelShader = compile ps_2_0 PixelShaderFunction();
}
}
I hope someone can help me with this problem.
Replies
My only experience is with GLSL but I'm guessing multiplying the ambient of 1 1 1 1 with 0.1 makes 0.1 0.1 0.1 0.1 - a very low alpha value. I'm not sure how you'd do it under HLSL cleanly but set the alpha component to 1 or remove the intensity multiplier and see what happens.
I removed the intensity component, but the problem remains unfortunately.
These are the definitions from my shader that work, you don't need all of them for the basics:
Also, you really want to use this line at the very top for 3DS Max:
string ParamID = "0x003"; //use DXSAS compiler
It tells it to use the improved DXSAS compiler. You shouldn't use anything else.
Everyone thanks for the replies.