Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
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? |
||||
|
@niko - help pls. |
||||
|
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; } |
||||
|
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 |
||||
|
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 . |
||||
|
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. |
|