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!
I'm working on a vertex shader-based terrain scene node. It uses vertex texture fetch to read a heightmap in video memory and adjust vertices accordingly. Only one problem; my shader is not getting the texture.
When I've written pixel shaders I've always been able to get textures by using this syntax (HLSL):
This doesn't seem to be working for vertex shaders though. I've checked around for similar problems (like the threads about loading multiple textures in GLSL shaders) but those solutions haven't helped.
Any thoughts would be appreciated.
Frosty Topaz
=========
It isn't easy being ice-encrusted aluminum silicate fluoride hydroxide...
You can't load textures in the vertex shader unfortunately, only in the pixel shader, in HLSL I think. Pass your vertex shader's color output to the pixel then multiply with the texture loaded.
1. It only works on NVidia cards.
2. It requires an obscure texture format, something like "ATI_LUMINANCE", so you have to implement this into Irrlicht. (I dont know why an NVidia only technique requires a texture format prefixed with ATI, don't ask me.)
<--- This is why you're not recieving a texture.
3. Its slow, averaging at 30 mil tris per second compared to other techniques such as "Copy to Pbuffer" which can do 60. (And ATI's R2VB can do 90 mil tris per second.)
Cheers
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
1. I only have an NVidia card.
2. Thank you, I'll look into it.
3. It's gotta be faster than passing 64K or so vertices from the CPU to the vertex buffer every frame. I'll look into Copy to Pbuffer. And if I had an ATI card I'd do R2VB. When I'm finished if you'd like to give it a try I can send you my code and you can add the ATI support.
Overall thanks for the reply.
Frosty Topaz
=========
It isn't easy being ice-encrusted aluminum silicate fluoride hydroxide...
Seems the texture must be a 32 bit floating point texture. I suspect I can shoehorn that into Irrlicht without tooooo much difficulty since I don't need to handle rendering them, just storing them. That said I've never dug into the video drivers and material renderers so it may be more work than I anticipate. I'll report back this weekend when I've had a chance to play with it a bit.
Frosty Topaz
=========
It isn't easy being ice-encrusted aluminum silicate fluoride hydroxide...
OK I've looked into it a bit more. It seems that DirectX wants vertex textures in particular slots (257 and higher). I modified SMaterial to load textures in those slots but I've still had no luck. If anyone has any ideas let me know I'll keep looking at it when I can.
Frosty Topaz
=========
It isn't easy being ice-encrusted aluminum silicate fluoride hydroxide...
Sadly using that just gives me an error saying that the material only has 4 slots. Oddly enough slots 0 through 4 (so a total of 5) generate no error. I think there may be some way to set that number of texture slots which I'm not doing or which is happening somewhere in Irrlicht where I haven't seen it.
Assuming that's true I'll dig a bit more and see if I can find it.
Frosty Topaz
=========
It isn't easy being ice-encrusted aluminum silicate fluoride hydroxide...