Glass shaders
by Tom Spilman · in Torque Game Engine Advanced · 12/31/2004 (12:13 am) · 3 replies
I'm not much of a shader expert, so i'd appreciate some help with this one. I'm trying to implement a simple glass shader with simple cube environment map on it. It applies the cubemap, but my glass looses it's transparency and i can no longer look out my windows. Here are two screenshots with a texture to illustrate the issue. The first one here is without the cubemap:

You can see the opaque, the 50% transparency, and the 100% transparency parts of the window working correctly.
This next one is the same except i added the cubemap to the material block:

You can see that the 50% transparency bits from the first screenshot go opaque. Here is my material datablock:
I looked thru the shaders and if i understand correctly it seems that the shader is multiplying the cubemap by the diffuse texture alpha... but that doesn't seem to be what's happening.
Anyone else try to make good looking glass with TSE?

You can see the opaque, the 50% transparency, and the 100% transparency parts of the window working correctly.
This next one is the same except i added the cubemap to the material block:

You can see that the 50% transparency bits from the first screenshot go opaque. Here is my material datablock:
datablock Material(glass)
{
baseTex[0] = "~/data/interiors/ship/glass";
translucent = true;
translucentBlendOp = LerpAlpha;
cubemap = SpaceCubeMap;
};I looked thru the shaders and if i understand correctly it seems that the shader is multiplying the cubemap by the diffuse texture alpha... but that doesn't seem to be what's happening.
Anyone else try to make good looking glass with TSE?
About the author
Tom is a programmer and co-owner of Sickhead Games, LLC.
#2
I think what's happening here is that the cubemap color is added to the base texture and maxing out the color value thus making it opaque. Try lowering both the alpha of the original texture and darkening your cubemap and see what the result is.
TIP:
If you comment out #define GEN_NEW_SHADERS in shaderGen.cpp, it will compile the shaders already generated in the shaders dir. From there you can modify the procedural shaders by hand which can help identify which exact shader is being used. Then you can play around with the shader, or copy it, modify it, and make it a custom shader.
At some point in the future I'd like to put a list of all the materials using a particular shader in the output code. It's not set up well for that though unfortunately. Maybe outputting a log file would be better, hmm.
01/05/2005 (4:55 pm)
Glass is a good candidate for custom shaders.I think what's happening here is that the cubemap color is added to the base texture and maxing out the color value thus making it opaque. Try lowering both the alpha of the original texture and darkening your cubemap and see what the result is.
TIP:
If you comment out #define GEN_NEW_SHADERS in shaderGen.cpp, it will compile the shaders already generated in the shaders dir. From there you can modify the procedural shaders by hand which can help identify which exact shader is being used. Then you can play around with the shader, or copy it, modify it, and make it a custom shader.
At some point in the future I'd like to put a list of all the materials using a particular shader in the output code. It's not set up well for that though unfortunately. Maybe outputting a log file would be better, hmm.
#3
01/06/2005 (6:20 am)
The way I found it which shader a metial is using, is commented out all the mat definitions except the one oyur working with. Then that will be the only HLSL file generated.
Torque Owner Westy