Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
2 registered members (OptimusPrime, AndrewAMD), 14,580 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Matts normal mapping shader? #183331
02/11/08 15:46
02/11/08 15:46
Joined: Jan 2008
Posts: 49
Sweden
K
Kenchu Offline OP
Newbie
Kenchu  Offline OP
Newbie
K

Joined: Jan 2008
Posts: 49
Sweden
Im trying to get Matt's normalmapping shader to work.


I just changed normaldemo.c from the shader workshop by using a "test.fx" file (code from wiki) for the effect property. That, however, doesnt work. Any ideas?

Code:

////////////////////////////////////////////////////////
// Copyright 2006 by Taco Cohen. All rights reserved
// 2007 adapted to A7 / lite-C by jcl
////////////////////////////////////////////////////////
#include <acknex.h>
#include <default.c>

MATERIAL* mtlNormal =
{
ambient_red = 40; // The ambient color - a dark grey.
ambient_green = 40;
ambient_blue = 40;
effect = "test.fx"; // The effect file containing the vertex shader, pixel shader and technique.
// flags = AUTORELOAD; // allows to edit the shader at runtime
}

function main()
{
// Load an empty level, and create a model :
level_load("");
wait(2);
ENTITY* ent = ent_create("blob.mdl",vector(50,0,0),NULL);
ent.material = mtlNormal;
while(1)
{
sun_angle.pan += 1.25 * time_step;
ent.pan -= 2.25 * time_step;
ent.tilt -= 1.1 * time_step;
wait(1);
}
}



Last edited by Kenchu; 02/11/08 15:47.
Re: Matts normal mapping shader? [Re: Kenchu] #183332
02/11/08 16:14
02/11/08 16:14
Joined: Jan 2004
Posts: 2,013
The Netherlands
E
Excessus Offline
Expert
Excessus  Offline
Expert
E

Joined: Jan 2004
Posts: 2,013
The Netherlands
Matt's shader uses dynamic lights, my shader uses the sun. So you'll have to place some dynamic lights (by code).

Maybe you'll also have to set the materials' TANGENT flag.

Re: Matts normal mapping shader? [Re: Excessus] #183333
02/11/08 18:16
02/11/08 18:16
Joined: Jan 2008
Posts: 49
Sweden
K
Kenchu Offline OP
Newbie
Kenchu  Offline OP
Newbie
K

Joined: Jan 2008
Posts: 49
Sweden
I suspected something like that. I cant find how to create lights by code in the manual though. Tried adding lights in the editor and checking the box "dynamic", but that didnt seem to work. The flag TANGENT is applied. How do I create dynamic lights by code?

Last edited by Kenchu; 02/11/08 18:16.
Re: Matts normal mapping shader? [Re: Kenchu] #183334
02/11/08 18:54
02/11/08 18:54
Joined: Jan 2004
Posts: 2,013
The Netherlands
E
Excessus Offline
Expert
Excessus  Offline
Expert
E

Joined: Jan 2004
Posts: 2,013
The Netherlands
I think it's just a matter of ent_creating an entity and setting its lightrange > 0 (big enough so that it is within range of the object you want lit).

Re: Matts normal mapping shader? [Re: Excessus] #183335
02/11/08 20:03
02/11/08 20:03
Joined: Jan 2008
Posts: 49
Sweden
K
Kenchu Offline OP
Newbie
Kenchu  Offline OP
Newbie
K

Joined: Jan 2008
Posts: 49
Sweden
This really isnt going well at all. Currently I have this:

Code:

////////////////////////////////////////////////////////
// Copyright 2006 by Taco Cohen. All rights reserved
// 2007 adapted to A7 / lite-C by jcl
////////////////////////////////////////////////////////

#include <acknex.h>
#include <default.c>

MATERIAL* mtlNormal =
{
ambient_red = 0; // The ambient color - a dark grey.
ambient_green = 0;
ambient_blue = 0;
effect = "test.fx"; // The effect file containing the vertex shader, pixel shader and technique.
// flags = TANGENT;
// flags = AUTORELOAD; // allows to edit the shader at runtime
}

function main()
{
// Load an empty level, and create a model :
fps_max = 90;
vec_set(sun_color, vector(0,255,0));

level_load("test.wmb");
wait(2);
ENTITY* ent = ent_create("blob.mdl",vector(0,0,0),NULL);
ENTITY* light = ent_create(NULL, vector(10,0,0), NULL);
light.lightrange = 100;
ent.material = mtlNormal;
while(1)
{
// sun_angle.pan += 1.25 * time_step;
ent.pan -= 2.25 * time_step;
ent.tilt -= 1.1 * time_step;
wait(1);
}
}



My map "test.wmb" has got a room. If I do not add a light (thorugh the editor), then the sunlight is visible and everything is more or less magically illuminated. If I however add a light, then the sunlight is gone for some reason. Adding a dynamic light by code doesnt seem to do anything. When not having a light (from editor) in the scene, everything is illuminated by sunlight or something, so I cant see if the code-created light is really there. When adding a light (from editor) somewhere, then everything is dark (except where i added the editor-light), so I guess the code-light really doesnt work.

I also noticed that the ambient lightning of objects wearing test.fx seem to not care about the ambient lightning set in lite-c. Even though all at 0, the model is bright.

So... These are my questions now :

Why does sunlight disappear when adding in a light?
How can I have both sunlight and "local" lights?
Why doesn't your shader care about sun_color? How can I make it aware of it? (Something I noticed...)
How do I make Matt's shader aware of the ambient lightning set in lite-c?

And I still need help with getting Matt's shader to work obviously...

Last edited by Kenchu; 02/11/08 21:20.
Re: Matts normal mapping shader? [Re: Kenchu] #183336
02/12/08 03:57
02/12/08 03:57
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
Look for my normal mapping shader. It does sun & Dyn lights, plus includes a dynamic light action. Of course, all are optional. D3D converted it to Lite-C not too long ago. Check the Lite-C Contributions...


xXxGuitar511
- Programmer
Re: Matts normal mapping shader? [Re: xXxGuitar511] #183337
02/12/08 15:46
02/12/08 15:46
Joined: Jan 2008
Posts: 49
Sweden
K
Kenchu Offline OP
Newbie
Kenchu  Offline OP
Newbie
K

Joined: Jan 2008
Posts: 49
Sweden
I downloaded the file youre linking to in your signature, and ran your wdl-script with the nm.fx. No changes made. And everything is just black. Same result on two computers. Also tried using your shader in the above program. But it doesnt work. Well, it does something, since the object isnt being shaded (as it is by default), but it sure isnt normalmapped.

I also tried running the workshop scripts again, but now with the newest version of A7. smoothdemo.c doesnt work - everything is black, except the background which is blue. But both the object and the ground are black. Actually, none of the scripts after normaldemo.c work properly.

I've tried these scripts at a Intel C2D, GF8800GT and a P4 with some Intel gfx. The scripts dont work on any of them.

Last edited by Kenchu; 02/12/08 20:21.
Re: Matts normal mapping shader? [Re: Kenchu] #183338
02/13/08 04:22
02/13/08 04:22
Joined: Apr 2006
Posts: 1,551
Netherlands
D3D Offline
Serious User
D3D  Offline
Serious User

Joined: Apr 2006
Posts: 1,551
Netherlands
Try this for Lite-C normalmap


smile
Re: Matts normal mapping shader? [Re: D3D] #183339
02/14/08 13:27
02/14/08 13:27
Joined: Jan 2008
Posts: 49
Sweden
K
Kenchu Offline OP
Newbie
Kenchu  Offline OP
Newbie
K

Joined: Jan 2008
Posts: 49
Sweden
Thanks, now I got it to work. Still wondering about those questions I asked in my previous post.

I also noticed that the sunlight only illuminates objects wearing NM.fx if they have specular colors set. Why is that?


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1