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 / AGK 2.0.17 SetObjecShader() Error

Author
Message
Zigi
15
Years of Service
User Offline
Joined: 5th Jul 2009
Location:
Posted: 24th Feb 2016 16:03 Edited at: 24th Feb 2016 16:06
Hi,

I have just updated to v2.0.17 and when I try to set object shader back to internal shader using SetObjectShader(objID,0) I get the following error message:

Pixel shader failed to compile: 0(18) : error C7011: Implicit cast from "int" to "float"

I don't have this problem in v2.0.16 but v2.0.17

Thank you.
Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 24th Feb 2016 16:54
Usually this means there is an integer literal like vec4(1,1,1,1) whilst some devices will only accept float literals, like vec4(1.0,1.0,1.0,1.0). I recommend always using float literals for maximum compatibility.
Zigi
15
Years of Service
User Offline
Joined: 5th Jul 2009
Location:
Posted: 24th Feb 2016 18:01 Edited at: 24th Feb 2016 18:07
Thanks I have tried what you sad but it did not solved the problem
I don't know anything about shaders so I'm not sure what am I doing, but this is the only integer literal in the Pixel shader I'm using and I have changed

from vec4(0.5,0.5,0.5,1) to vec4(0.5,0.5,0.5,1.0)

but it didn't help, I get the same error message.

I have also tried on Ubuntu and this is the error message on Ubuntu:

Pixel shader failed to compile: 0:18(22): error: could not implicity convert operands to arithmetic operator
0:18(22): error: operands to arithmetic operators must be numeric
0:18(22): error: type mismatch

In previous version of AppGameKit did work on both Windows and Linux and I get the error message when I try to switch back to the internal shader.
Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 24th Feb 2016 22:09
Can you post the shader code you are trying to load?

Quote: "I get the error message when I try to switch back to the internal shader"

Can you post the tier 1 code so I can try to replicate this?
Zigi
15
Years of Service
User Offline
Joined: 5th Jul 2009
Location:
Posted: 24th Feb 2016 23:10 Edited at: 24th Feb 2016 23:29

Okay, this is a bit complex and messy but I try to explain.
what I'm trying to do is load an FPS Creator level in to my project with no light maps at first. And I decided to create a function to load the light maps only when I need it. I have no problem with that. The FPS Creator level load fine and the light map with the custom shader as well. I have problem when I try to sort of remove the light map and reload the level with no light map again. I'm not deleting the objects, but simply reload all the textures and apply them without light map using the internal shader again.

This is the code I'm using to load the FPSC Level converted by Wizzkid's FPSC-2-AGK tool and apply the internal shader



And this is the code I'm using to load the light map and apply the custom shader



So the idea is, when you load the FPSC Level for the first time, it is going to load all the objects and textures but not the light map. If you load the FPSC Level the second time after the light map is loaded, it is going to only reload the textures and apply the internal shader to remove the light map and this is the point when I get the error message.
The only way to avoid the error if I delete the whole Level and reload it but I would like to avoid reloading the whole level every time I want to remove the light maps because it slow.

In theory, you can use the functions as is to to load an FPSC Level and light map converted using FPSC-2-AGK, only need to declare some globals. I think this is the ones you need:

global fpscmap_loaded_withlightmap as integer = 0
global fpscmap_loaded_nolightmap as integer = 0
global fpscObjMeshStartID as integer = 1600
global fpscObjTextureStartID as integer = 2000

The shader code:

Pixel shader:


Vertex shader:

I hope it helps.
Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 25th Feb 2016 01:01
Ok, your shaders look fine, but I found a bug in the internal shader when both texture stage 0 and 1 are in use. I can't see anywhere that you are calling SetObjectImage(objID, 0, 1) to clear out the lightmap when you reload the object, this would avoid the error as then only texture stage 0 would be in use and the internal shader should work. I'll get this fixed for the next version.
Zigi
15
Years of Service
User Offline
Joined: 5th Jul 2009
Location:
Posted: 25th Feb 2016 10:41
Quote: "I can't see anywhere that you are calling SetObjectImage(objID, 0, 1)...this would avoid the error"


Thanks Paul, it worked

Login to post a reply

Server time is: 2024-11-25 09:24:54
Your offset time is: 2024-11-25 09:24:54