My shader Expects float4 for camera position.

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
The_Glitch
Competition winner
Posts: 523
Joined: Tue Jan 15, 2013 6:36 pm

My shader Expects float4 for camera position.

Post by The_Glitch »

In my shader callback I can get the cameras position but it only return a 3d vector but my shader also uses the .w for the last floating point so float4 instead of float3.

Code: Select all

 
 
            core::vector3df pos = device->getSceneManager()->
            getActiveCamera()->getAbsolutePosition(); // returns float3
               
           f32 camera[4] = { pos.X, pos.Y, pos.Z, 1.0f };
        services->setVertexShaderConstant(EYE, reinterpret_cast<f32*>(&camera), 4);
 
 
Does this seem okay?
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: My shader Expects float4 for camera position.

Post by mongoose7 »

No. Drop the cast and the '&'. In 'C', the name of an array is a pointer.
The_Glitch
Competition winner
Posts: 523
Joined: Tue Jan 15, 2013 6:36 pm

Re: My shader Expects float4 for camera position.

Post by The_Glitch »

I'm using shader-pipeline so I believe shader callback is different.

Do you mean

Code: Select all

&camera
???
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: My shader Expects float4 for camera position.

Post by mongoose7 »

services->setVertexShaderConstant(EYE, camera, 4);
The_Glitch
Competition winner
Posts: 523
Joined: Tue Jan 15, 2013 6:36 pm

Re: My shader Expects float4 for camera position.

Post by The_Glitch »

Okay I see what you mean thanks mongoose7.
Post Reply