Implementing dynamic shadow in OpenGL ES 2.0 - ios

I am working on implementing Dynamic shadow(for a moving truck) in OpenGL ES 2.0 on iOS platform. I need idea regarding shaders used for implementing shadows & illustration code for dynamic shadows.

Related

OpenGL ES deprecated in iOS 12 and SKShader

I am very new to the concept and use of shaders in SpriteKit.
I found this tutorial on how to render a Mandelbrot fractal with a custom shader file - Fractal.fsh - attached to a Color Sprite's Custom Shader property.
https://www.weheartswift.com/fractals-Xcode-6/
It works fine and I thought to my self that learning about OpenGL ES and custom shaders in SpriteKit would be a fun exercise.
According to Apple though, OpenGL ES is deprecated as of iOS 12.
https://developer.apple.com/library/archive/documentation/3DDrawing/Conceptual/OpenGLES_ProgrammingGuide/BestPracticesforShaders/BestPracticesforShaders.html
My question is this:
Does this mean that custom shaders for use in SpriteKit should be written in Metal as of now?
I have tried to figure out how to rewrite the fractal.fsh shader code, referred to in the first link, in Metal but I have not - yet - been able to find any resources on how to convert existing custom SKShader's from OpenGL ES to Metal. However, I am NOT looking for someone to rewrite that code to use Metal, only a pointer in the right direction.
UPDATE:
Based on the answer from #Knight0fDragon I will try to clarify my question:
The documentation on the SKShader class states that:
"An SKShader object holds a custom OpenGL ES fragment shader."
https://developer.apple.com/documentation/spritekit/skshader
So if a SKShader object holds a custom OpenGL ES fragment shader, what will it hold after the support for OpenGL ES is deprecated?
How would one go on about creating a custom fragment shader to use in SpriteKit if one cannot use OpenGL ES as of iOS 12?
First I thought that the *.fsh file containing the GLSL code could be replaced with a *.metal file containing equivalent metal code but that assessment was clearly too naive (because I tried and I couldn't assign the *.metal file to the Color Sprite's Custom Shader property)
From the documentation on "Executing Shaders in Metal and OpenGL
":
On devices that support it, the GLSL code you provide to SKShader is automatically converted to Metal shading language and run on a Metal renderer.
So, from my understanding, SpriteKit will use Metal as a backend where it is available and convert your shaders for you when compiling them. I did not find an option to directly write the shaders in Metal.
According to Apple (see near bottom of the page at this link)...
Apps built using OpenGL ES will continue to run in iOS 12, but OpenGL
ES is deprecated in iOS 12. Games and graphics-intensive apps that
previously used OpenGL ES should now adopt Metal [emphasis added].
If you are starting from scratch, I suggest you write shaders in Metal.

OpenGL deprecated in IOS 12, how to safely continue to use openGL on ios 12+ device?

Apple says that apps built using OpenGL ES will continue to run in iOS 12, but Open GL ES is deprecated in iOS 12. Games and graphics-intensive apps that previously used OpenGL ES should now adopt Metal.
But I don't want to migrate my app from OpenGL to Metal because it's the same code for Android and I don't want to create two separate branches, so what can I do to continue to use OpenGL in future iOS releases?
You more or less do not.
Apple has made it abundantly clear that they are not interested in supporting OpenGL ES further on any platform they control. In the future, you will use Metal or you will not have accelerated 3D graphics. Those will be your options.
There are projects that expose OpenGL ES on such platforms by implementing an ES layer on top of Metal. MoltenGL, for example, but that one isn't free apparently.
I use MetalANGLE, which is free and open-source with a non-viral license, in my commercial product, as an (almost) drop-in replacement for GLKit. I have had to make no changes at all to the part of my code that uses OpenGL ES, and only minor changes to the way my View and ViewController classes were initialised.
It is now six months since I moved from GLKit to MetalANGLE and the only problem that arose was one of scaling, which was really a bug in my app: in MetalANGLE I needed to retrieve the UI scale from the View's contentScaleFactor rather than [[UIScreen mainScreen] scale].
There have been no display glitches, crashes, slowdowns, or any problems whatever with the graphics rendering.
I can therefore see no reason to pay for MoltenGL instead of using the free MetalANGLE.
I recommend that OpenGL and Metal are developed together on iOS, and new features are used with Metal.

All my objects are white when I build for IOS

I recently started building a game for iOS using my iPhone 5s for testing.
However, recently I have decided to try my iPhone SE to see how it looks; all of the materials on all of the objects appear to be missing, but the color of the trails for the particle effects and the line renderers still have their color.
It could be a shader issue or a problem with the graphics API Unity is using. If you're not using the standard shader then make sure that you're shader is compatible with mobile devices. Also make sure that it's included in the project by creating a folder named Resources and moving your shader into that.
If you're using one of the standard shaders that comes with Unity then the issue is likely not a shader one but the Graphics API selected. It's likely using Metal which is causing that issue. Use OpenGL ES instead of Metal.
Disable Auto Graphics API then change iOS Graphics API to OpenGLES2 or OpenGLES3 in Unity's Player Settings.

Isnt clipping planes work in kivy opengl?

Im trying to make render to texture for reflection and refration texture for water shader... but glClipPlane is not defined in kivy opengl.. Here are some ScreenShots
Test with PyOpengl
Test with kivy Opengl
From Clipping-planes in OpenGL ES 2.0, it looks like this wasn't part of OpenGL ES 2.0, which Kivy nominally targets. If you do want to use it, you probably can, but it isn't part of Kivy's exposed API (these low level opengl calls are usually considered internal to Kivy).

Equivalent for GL_POLYGON_OFFSET_FILL in Metal

My app currently uses OpenGL and i set polygon offset using glPolygonOffset and GL_POLYGON_OFFSET_FILL. I am in the process of transforming my code to Metal and looking for the equivalent methods in Metal. What are they?
MTLRenderCommandEncoder setDepthBias:slopeScale:clamp:

Resources