Gamestudio Links
Zorro Links
Newest Posts
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,454 guests, and 9 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19058 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
light position #407238
09/10/12 04:51
09/10/12 04:51
Joined: Apr 2008
Posts: 245
GameScore Offline OP
Member
GameScore  Offline OP
Member

Joined: Apr 2008
Posts: 245
i used the specular shader from the workshop
and as light sourec is the sun declared
how can i declare my own light source
which i can adjust by skills

Code:
// Calculate the ambient term: 
  float4 Ambient = AmbientIntensity * vecAmbient; 
// Calculate the diffuse term: 
  InNormal = normalize(InNormal); 
  float4 Diffuse = DiffuseIntensity * SunColor * saturate(dot(-vecSunDir, InNormal)); 
// Fetch the pixel color from the color map: 
  float4 Color = tex2D(ColorMapSampler, InTex); 
// Calculate the reflection vector: 
  float3 R = normalize(2 * dot(InNormal, -[b]vecSunDir[/b]) * InNormal + vecSunDir); 
// Calculate the speculate component: 
  float Specular = pow(saturate(dot(R, normalize(InViewDir))), SpecularPower) * SpecularIntensity; 
// Calculate final color: 
  return (Ambient + Diffuse + Specular) * Color; 
}


Last edited by GameScore; 09/10/12 04:52.
Re: light position [Re: GameScore] #407263
09/10/12 13:59
09/10/12 13:59
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Is it this variable you're looking for?

http://www.conitec.net/beta/Shader-vecLightPos.htm


Always learn from history, to be sure you make the same mistakes again...
Re: light position [Re: Uhrwerk] #407272
09/10/12 15:00
09/10/12 15:00
Joined: Apr 2008
Posts: 245
GameScore Offline OP
Member
GameScore  Offline OP
Member

Joined: Apr 2008
Posts: 245
yeah, i know this but i dont understand how to use it
i want to adjust the light position by material skills in the script.c
did you can show me a example?

Re: light position [Re: GameScore] #407275
09/10/12 17:27
09/10/12 17:27
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
I'm not exactly sure what you're up to.

The easiest way to use dynamic lights is tu just place dynamic lights in your lite-c script via the entities' lightrange and red green and blue parameters. You can then use vecLightPos and vecLightColor in your shader. Thats even the way the shaders of Gamestudio work.

In order to have a lightsource per material you can set the material's skills and then access these in the shader via the vecSkill1 .. vecSkill17 variables. It would work out very similarly for a per entity solution.

Given your code above you just had to replace vecSunDir with the variable you wanted to use instead. Don't forget to declare them in shader as well. Sorry if that is too obvious to you, I don't know you shader skill level... ;-)


Always learn from history, to be sure you make the same mistakes again...
Re: light position [Re: Uhrwerk] #407277
09/10/12 18:32
09/10/12 18:32
Joined: Apr 2008
Posts: 245
GameScore Offline OP
Member
GameScore  Offline OP
Member

Joined: Apr 2008
Posts: 245
yeah your 2nd idea is what i wanna do, i was try to do but withou succes

here u can see how i was try to do

Code:
float redskill = vecSkill1.x;
float greenskill = vecSkill1.y;
float blueskill = vecSkill1.z;
float alphaskill = vecSkill1.w;

float4 dynlight = {redskill, greenskill, blueskill, alphaskill};
float4 Diffuse = DiffuseIntensity * saturate(dot(-dynlight, InNormal)); 
// Fetch the pixel color from the color map: 
float4 Color = tex2D(ColorMapSampler, InTex); 
// Calculate the reflection vector: 
float3 R = normalize(2 * dot(InNormal, -dynlight) * InNormal + dynlight);



but the result is not very nice

Re: light position [Re: GameScore] #407280
09/10/12 20:29
09/10/12 20:29
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Some thoughts:

Did you remember to use the float conversion with floatv?

As you use a texture lookup this is most likely a pixel shader. Hence InNormal is already in viewspace. Is that also true for vecSkill1? You have most likely set it in world space, didn't you?

You don't need the detour via redskill etc. and dynlight. You can use vecSkill1 directly as a vector afaik.


Always learn from history, to be sure you make the same mistakes again...

Moderated by  Blink, Hummel, Superku 

Gamestudio download | chip programmers | 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