Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / I cant get c++ shaders to work

Author
Message
3d point in space
14
Years of Service
User Offline
Joined: 30th Jun 2009
Location: Idaho
Posted: 1st Mar 2015 00:42 Edited at: 1st Mar 2015 00:48
This is a modified version of baxslash's code from a while back that I translated to c++, but it does not work, and I don't know why.

the light header file

template.cpp

globals


shader



Developer of Space Chips, pianobasic, zipzapzoom, and vet pinball apps. Developed the tiled map engine seen on the showcase. Veteran for the military.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 1st Mar 2015 09:24
Nice to see someone trying to use it. I'm afraid my C++ is not so good though...


Using AppGameKit V2 Tier 1
3d point in space
14
Years of Service
User Offline
Joined: 30th Jun 2009
Location: Idaho
Posted: 2nd Mar 2015 03:53
I got one of the shaders to work in c++ but I still have a hard time with them.

Developer of Space Chips, pianobasic, zipzapzoom, and vet pinball apps. Developed the tiled map engine seen on the showcase. Veteran for the military.
3d point in space
14
Years of Service
User Offline
Joined: 30th Jun 2009
Location: Idaho
Posted: 2nd Mar 2015 21:48 Edited at: 2nd Mar 2015 21:51
I got this shader to work after I tweaked it around a bit. I think it was an earlier post but I cant find it. I kept on getting float to into errors but I corrected the pixel shader and it worked

vertex shader

this is the pixel shader


c++ code


Developer of Space Chips, pianobasic, zipzapzoom, and vet pinball apps. Developed the tiled map engine seen on the showcase. Veteran for the military.
3d point in space
14
Years of Service
User Offline
Joined: 30th Jun 2009
Location: Idaho
Posted: 2nd Mar 2015 21:52 Edited at: 2nd Mar 2015 21:58
oh I forgot some of the c++ code. The max function in and some int to floats made the other shader not work that I was using.

I modified this shader to make it work
http://forum.thegamecreators.com/?m=forum_view&t=211491&b=41

Developer of Space Chips, pianobasic, zipzapzoom, and vet pinball apps. Developed the tiled map engine seen on the showcase. Veteran for the military.
3d point in space
14
Years of Service
User Offline
Joined: 30th Jun 2009
Location: Idaho
Posted: 2nd Mar 2015 22:12
this is a light that turns around with the mouse


Developer of Space Chips, pianobasic, zipzapzoom, and vet pinball apps. Developed the tiled map engine seen on the showcase. Veteran for the military.
3d point in space
14
Years of Service
User Offline
Joined: 30th Jun 2009
Location: Idaho
Posted: 2nd Mar 2015 22:31 Edited at: 2nd Mar 2015 23:06
I got to explain some of the shader code

agk::SetShaderConstantByName(shader, "spotLightCol1", 100, 100, 100, 0);

this will set the red, green, blue value of the spotlightcol1 in the pixel shader. In the previous case it sets it to white

spotColor1 = spotLightCol1.rgb * atten * falloff;


vec3 color4 = PLightCol4.rgb * atten;

can also change the colar of the forth point light in the pixel shader to this can be seen by changing the setshaderconstantbyname
agk::SetShaderConstantByName(shader, "PLightCol4", 255, 0, 0, 0); or the rgb values of the shader.

agk::SetShaderConstantByName(shader, "spotLightPos1", torchX, torchY, 0, 0);
modifies the xy cords in the shader as follows

it places the shader spotlightPos1 at the cords 640,340 and rotates the spot light around those cords.

in the shader code it calls

spotLightPos1.xy and than rotates the light according to mouse placement on screen.

Developer of Space Chips, pianobasic, zipzapzoom, and vet pinball apps. Developed the tiled map engine seen on the showcase. Veteran for the military.
3d point in space
14
Years of Service
User Offline
Joined: 30th Jun 2009
Location: Idaho
Posted: 2nd Mar 2015 23:55 Edited at: 3rd Mar 2015 00:00
know lets look at how to move the light
change control torch function to this a and d turn the light w and s move the light.

this assumes that 1 is the velocity of the light.


Developer of Space Chips, pianobasic, zipzapzoom, and vet pinball apps. Developed the tiled map engine seen on the showcase. Veteran for the military.

Attachments

Login to view attachments
3d point in space
14
Years of Service
User Offline
Joined: 30th Jun 2009
Location: Idaho
Posted: 9th Mar 2015 21:09 Edited at: 9th Mar 2015 21:10
Shader Multiple sprites



Developer of Space Chips, pianobasic, zipzapzoom, and vet pinball apps. Developed the tiled map engine seen on the showcase. Veteran for the military.

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-04-25 06:46:45
Your offset time is: 2024-04-25 06:46:45