Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Programming and Scripting
Shader HLSL - Position Light

cmaiia
Registered User
Quote
2024-01-19 22:45:16

i need to know how to get the position of the light to write a shader in hlsls.

the documentation only shows these variables:


mWorldViewProj: transformation matrix to transform position to clip space (World * View * Projection)
mInvWorld: inverted world matrix, for transforming normals
mTransWorld: transformed world matrix, for tranforming position into world coordinates



does anyone know how to get the position of the light?


cmaiia
Registered User
Quote
2024-01-19 23:02:08

@niko - help pls.


Tyko
Guest
Quote
2024-01-19 23:13:26

Infer from this example:

// Define the variable for light position
float4 lightPosition : POSITION0;

// Vertex shader
float4x4 WorldViewProj;
struct VS_INPUT
{
float4 Position : POSITION;
// Other input elements
};
struct VS_OUTPUT
{
float4 Position : POSITION0;
// Other output elements
};
VS_OUTPUT VSMain(VS_INPUT input)
{
VS_OUTPUT output;
// Transform vertex position to clip space
output.Position = mul(WorldViewProj, input.Position);
// Other vertex transformations
return output;
}

// Pixel shader
float4 PSMain(VS_OUTPUT input) : COLOR
{
// Use light position in pixel shader calculations
float3 lightDir = normalize(lightPosition - input.Position);
// Other lighting calculations
return finalColor;
}


cmaiia
Registered User
Quote
2024-01-19 23:48:40

if i set it will it work? because i need an internal variable as well as the others he provided in the documentation how will the engine know it's direct light? @Tyko


just_in_case
Moderator
Quote
2024-01-20 07:06:31

You need to pass the light data as a shader constant, checkout the free version of the light shader available on neophyte website at this adress.

http://vazahat.github.io

I beleive it will be helpful to you .


cmaiia
Registered User
Quote
2024-01-21 23:24:38

wrote:
You need to pass the light data as a shader constant, checkout the free version of the light shader available on neophyte website at this adress.

http://vazahat.github.io

I beleive it will be helpful to you .


Thanks a lot @just_in_case.
I'll take a look.
I'm going to make a mini map version of mine available soon. can you put it on your site? it'll be free.

i was going to use render to texture for the map but i realized that i lost performance so i made a new behavior.
I haven't finished it yet.

I went to the page but the plugin isn't free, at least I couldn't find where.


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Internat?onal" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact